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
wmayner/pyphi
pyphi/tpm.py
marginalize_out
def marginalize_out(node_indices, tpm): """Marginalize out nodes from a TPM. Args: node_indices (list[int]): The indices of nodes to be marginalized out. tpm (np.ndarray): The TPM to marginalize the node out of. Returns: np.ndarray: A TPM with the same number of dimensions, with th...
python
def marginalize_out(node_indices, tpm): """Marginalize out nodes from a TPM. Args: node_indices (list[int]): The indices of nodes to be marginalized out. tpm (np.ndarray): The TPM to marginalize the node out of. Returns: np.ndarray: A TPM with the same number of dimensions, with th...
[ "def", "marginalize_out", "(", "node_indices", ",", "tpm", ")", ":", "return", "tpm", ".", "sum", "(", "tuple", "(", "node_indices", ")", ",", "keepdims", "=", "True", ")", "/", "(", "np", ".", "array", "(", "tpm", ".", "shape", ")", "[", "list", "...
Marginalize out nodes from a TPM. Args: node_indices (list[int]): The indices of nodes to be marginalized out. tpm (np.ndarray): The TPM to marginalize the node out of. Returns: np.ndarray: A TPM with the same number of dimensions, with the nodes marginalized out.
[ "Marginalize", "out", "nodes", "from", "a", "TPM", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/tpm.py#L57-L69
train
wmayner/pyphi
pyphi/tpm.py
infer_edge
def infer_edge(tpm, a, b, contexts): """Infer the presence or absence of an edge from node A to node B. Let |S| be the set of all nodes in a network. Let |A' = S - {A}|. We call the state of |A'| the context |C| of |A|. There is an edge from |A| to |B| if there exists any context |C(A)| such that |Pr(B...
python
def infer_edge(tpm, a, b, contexts): """Infer the presence or absence of an edge from node A to node B. Let |S| be the set of all nodes in a network. Let |A' = S - {A}|. We call the state of |A'| the context |C| of |A|. There is an edge from |A| to |B| if there exists any context |C(A)| such that |Pr(B...
[ "def", "infer_edge", "(", "tpm", ",", "a", ",", "b", ",", "contexts", ")", ":", "def", "a_in_context", "(", "context", ")", ":", "a_off", "=", "context", "[", ":", "a", "]", "+", "OFF", "+", "context", "[", "a", ":", "]", "a_on", "=", "context", ...
Infer the presence or absence of an edge from node A to node B. Let |S| be the set of all nodes in a network. Let |A' = S - {A}|. We call the state of |A'| the context |C| of |A|. There is an edge from |A| to |B| if there exists any context |C(A)| such that |Pr(B | C(A), A=0) != Pr(B | C(A), A=1)|. ...
[ "Infer", "the", "presence", "or", "absence", "of", "an", "edge", "from", "node", "A", "to", "node", "B", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/tpm.py#L72-L101
train
wmayner/pyphi
pyphi/tpm.py
infer_cm
def infer_cm(tpm): """Infer the connectivity matrix associated with a state-by-node TPM in multidimensional form. """ network_size = tpm.shape[-1] all_contexts = tuple(all_states(network_size - 1)) cm = np.empty((network_size, network_size), dtype=int) for a, b in np.ndindex(cm.shape): ...
python
def infer_cm(tpm): """Infer the connectivity matrix associated with a state-by-node TPM in multidimensional form. """ network_size = tpm.shape[-1] all_contexts = tuple(all_states(network_size - 1)) cm = np.empty((network_size, network_size), dtype=int) for a, b in np.ndindex(cm.shape): ...
[ "def", "infer_cm", "(", "tpm", ")", ":", "network_size", "=", "tpm", ".", "shape", "[", "-", "1", "]", "all_contexts", "=", "tuple", "(", "all_states", "(", "network_size", "-", "1", ")", ")", "cm", "=", "np", ".", "empty", "(", "(", "network_size", ...
Infer the connectivity matrix associated with a state-by-node TPM in multidimensional form.
[ "Infer", "the", "connectivity", "matrix", "associated", "with", "a", "state", "-", "by", "-", "node", "TPM", "in", "multidimensional", "form", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/tpm.py#L104-L113
train
wmayner/pyphi
pyphi/compute/parallel.py
get_num_processes
def get_num_processes(): """Return the number of processes to use in parallel.""" cpu_count = multiprocessing.cpu_count() if config.NUMBER_OF_CORES == 0: raise ValueError( 'Invalid NUMBER_OF_CORES; value may not be 0.') if config.NUMBER_OF_CORES > cpu_count: log.info('Reque...
python
def get_num_processes(): """Return the number of processes to use in parallel.""" cpu_count = multiprocessing.cpu_count() if config.NUMBER_OF_CORES == 0: raise ValueError( 'Invalid NUMBER_OF_CORES; value may not be 0.') if config.NUMBER_OF_CORES > cpu_count: log.info('Reque...
[ "def", "get_num_processes", "(", ")", ":", "cpu_count", "=", "multiprocessing", ".", "cpu_count", "(", ")", "if", "config", ".", "NUMBER_OF_CORES", "==", "0", ":", "raise", "ValueError", "(", "'Invalid NUMBER_OF_CORES; value may not be 0.'", ")", "if", "config", "...
Return the number of processes to use in parallel.
[ "Return", "the", "number", "of", "processes", "to", "use", "in", "parallel", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L24-L46
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.init_progress_bar
def init_progress_bar(self): """Initialize and return a progress bar.""" # Forked worker processes can't show progress bars. disable = MapReduce._forked or not config.PROGRESS_BARS # Don't materialize iterable unless we have to: huge iterables # (e.g. of `KCuts`) eat memory. ...
python
def init_progress_bar(self): """Initialize and return a progress bar.""" # Forked worker processes can't show progress bars. disable = MapReduce._forked or not config.PROGRESS_BARS # Don't materialize iterable unless we have to: huge iterables # (e.g. of `KCuts`) eat memory. ...
[ "def", "init_progress_bar", "(", "self", ")", ":", "disable", "=", "MapReduce", ".", "_forked", "or", "not", "config", ".", "PROGRESS_BARS", "if", "disable", ":", "total", "=", "None", "else", ":", "self", ".", "iterable", "=", "list", "(", "self", ".", ...
Initialize and return a progress bar.
[ "Initialize", "and", "return", "a", "progress", "bar", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L144-L158
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.worker
def worker(compute, task_queue, result_queue, log_queue, complete, *context): """A worker process, run by ``multiprocessing.Process``.""" try: MapReduce._forked = True log.debug('Worker process starting...') configure_worker_logging(log_queue) ...
python
def worker(compute, task_queue, result_queue, log_queue, complete, *context): """A worker process, run by ``multiprocessing.Process``.""" try: MapReduce._forked = True log.debug('Worker process starting...') configure_worker_logging(log_queue) ...
[ "def", "worker", "(", "compute", ",", "task_queue", ",", "result_queue", ",", "log_queue", ",", "complete", ",", "*", "context", ")", ":", "try", ":", "MapReduce", ".", "_forked", "=", "True", "log", ".", "debug", "(", "'Worker process starting...'", ")", ...
A worker process, run by ``multiprocessing.Process``.
[ "A", "worker", "process", "run", "by", "multiprocessing", ".", "Process", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L161-L183
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.start_parallel
def start_parallel(self): """Initialize all queues and start the worker processes and the log thread. """ self.num_processes = get_num_processes() self.task_queue = multiprocessing.Queue(maxsize=Q_MAX_SIZE) self.result_queue = multiprocessing.Queue() self.log_que...
python
def start_parallel(self): """Initialize all queues and start the worker processes and the log thread. """ self.num_processes = get_num_processes() self.task_queue = multiprocessing.Queue(maxsize=Q_MAX_SIZE) self.result_queue = multiprocessing.Queue() self.log_que...
[ "def", "start_parallel", "(", "self", ")", ":", "self", ".", "num_processes", "=", "get_num_processes", "(", ")", "self", ".", "task_queue", "=", "multiprocessing", ".", "Queue", "(", "maxsize", "=", "Q_MAX_SIZE", ")", "self", ".", "result_queue", "=", "mult...
Initialize all queues and start the worker processes and the log thread.
[ "Initialize", "all", "queues", "and", "start", "the", "worker", "processes", "and", "the", "log", "thread", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L185-L211
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.initialize_tasks
def initialize_tasks(self): """Load the input queue to capacity. Overfilling causes a deadlock when `queue.put` blocks when full, so further tasks are enqueued as results are returned. """ # Add a poison pill to shutdown each process. self.tasks = chain(self.iterable, [P...
python
def initialize_tasks(self): """Load the input queue to capacity. Overfilling causes a deadlock when `queue.put` blocks when full, so further tasks are enqueued as results are returned. """ # Add a poison pill to shutdown each process. self.tasks = chain(self.iterable, [P...
[ "def", "initialize_tasks", "(", "self", ")", ":", "self", ".", "tasks", "=", "chain", "(", "self", ".", "iterable", ",", "[", "POISON_PILL", "]", "*", "self", ".", "num_processes", ")", "for", "task", "in", "islice", "(", "self", ".", "tasks", ",", "...
Load the input queue to capacity. Overfilling causes a deadlock when `queue.put` blocks when full, so further tasks are enqueued as results are returned.
[ "Load", "the", "input", "queue", "to", "capacity", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L213-L223
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.maybe_put_task
def maybe_put_task(self): """Enqueue the next task, if there are any waiting.""" try: task = next(self.tasks) except StopIteration: pass else: log.debug('Putting %s on queue', task) self.task_queue.put(task)
python
def maybe_put_task(self): """Enqueue the next task, if there are any waiting.""" try: task = next(self.tasks) except StopIteration: pass else: log.debug('Putting %s on queue', task) self.task_queue.put(task)
[ "def", "maybe_put_task", "(", "self", ")", ":", "try", ":", "task", "=", "next", "(", "self", ".", "tasks", ")", "except", "StopIteration", ":", "pass", "else", ":", "log", ".", "debug", "(", "'Putting %s on queue'", ",", "task", ")", "self", ".", "tas...
Enqueue the next task, if there are any waiting.
[ "Enqueue", "the", "next", "task", "if", "there", "are", "any", "waiting", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L225-L233
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.run_parallel
def run_parallel(self): """Perform the computation in parallel, reading results from the output queue and passing them to ``process_result``. """ try: self.start_parallel() result = self.empty_result(*self.context) while self.num_processes > 0: ...
python
def run_parallel(self): """Perform the computation in parallel, reading results from the output queue and passing them to ``process_result``. """ try: self.start_parallel() result = self.empty_result(*self.context) while self.num_processes > 0: ...
[ "def", "run_parallel", "(", "self", ")", ":", "try", ":", "self", ".", "start_parallel", "(", ")", "result", "=", "self", ".", "empty_result", "(", "*", "self", ".", "context", ")", "while", "self", ".", "num_processes", ">", "0", ":", "r", "=", "sel...
Perform the computation in parallel, reading results from the output queue and passing them to ``process_result``.
[ "Perform", "the", "computation", "in", "parallel", "reading", "results", "from", "the", "output", "queue", "and", "passing", "them", "to", "process_result", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L235-L269
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.finish_parallel
def finish_parallel(self): """Orderly shutdown of workers.""" for process in self.processes: process.join() # Shutdown the log thread log.debug('Joining log thread') self.log_queue.put(POISON_PILL) self.log_thread.join() self.log_queue.close() ...
python
def finish_parallel(self): """Orderly shutdown of workers.""" for process in self.processes: process.join() # Shutdown the log thread log.debug('Joining log thread') self.log_queue.put(POISON_PILL) self.log_thread.join() self.log_queue.close() ...
[ "def", "finish_parallel", "(", "self", ")", ":", "for", "process", "in", "self", ".", "processes", ":", "process", ".", "join", "(", ")", "log", ".", "debug", "(", "'Joining log thread'", ")", "self", ".", "log_queue", ".", "put", "(", "POISON_PILL", ")"...
Orderly shutdown of workers.
[ "Orderly", "shutdown", "of", "workers", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L271-L285
train
wmayner/pyphi
pyphi/compute/parallel.py
MapReduce.run_sequential
def run_sequential(self): """Perform the computation sequentially, only holding two computed objects in memory at a time. """ try: result = self.empty_result(*self.context) for obj in self.iterable: r = self.compute(obj, *self.context) ...
python
def run_sequential(self): """Perform the computation sequentially, only holding two computed objects in memory at a time. """ try: result = self.empty_result(*self.context) for obj in self.iterable: r = self.compute(obj, *self.context) ...
[ "def", "run_sequential", "(", "self", ")", ":", "try", ":", "result", "=", "self", ".", "empty_result", "(", "*", "self", ".", "context", ")", "for", "obj", "in", "self", ".", "iterable", ":", "r", "=", "self", ".", "compute", "(", "obj", ",", "*",...
Perform the computation sequentially, only holding two computed objects in memory at a time.
[ "Perform", "the", "computation", "sequentially", "only", "holding", "two", "computed", "objects", "in", "memory", "at", "a", "time", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/parallel.py#L287-L307
train
wmayner/pyphi
pyphi/conf.py
configure_logging
def configure_logging(conf): """Reconfigure PyPhi logging based on the current configuration.""" logging.config.dictConfig({ 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s [%(name)s] %(levelname)s ' ...
python
def configure_logging(conf): """Reconfigure PyPhi logging based on the current configuration.""" logging.config.dictConfig({ 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s [%(name)s] %(levelname)s ' ...
[ "def", "configure_logging", "(", "conf", ")", ":", "logging", ".", "config", ".", "dictConfig", "(", "{", "'version'", ":", "1", ",", "'disable_existing_loggers'", ":", "False", ",", "'formatters'", ":", "{", "'standard'", ":", "{", "'format'", ":", "'%(asct...
Reconfigure PyPhi logging based on the current configuration.
[ "Reconfigure", "PyPhi", "logging", "based", "on", "the", "current", "configuration", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L328-L357
train
wmayner/pyphi
pyphi/conf.py
Option._validate
def _validate(self, value): """Validate the new value.""" if self.values and value not in self.values: raise ValueError( '{} is not a valid value for {}'.format(value, self.name))
python
def _validate(self, value): """Validate the new value.""" if self.values and value not in self.values: raise ValueError( '{} is not a valid value for {}'.format(value, self.name))
[ "def", "_validate", "(", "self", ",", "value", ")", ":", "if", "self", ".", "values", "and", "value", "not", "in", "self", ".", "values", ":", "raise", "ValueError", "(", "'{} is not a valid value for {}'", ".", "format", "(", "value", ",", "self", ".", ...
Validate the new value.
[ "Validate", "the", "new", "value", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L201-L205
train
wmayner/pyphi
pyphi/conf.py
Config.options
def options(cls): """Return a dictionary of the ``Option`` objects for this config.""" return {k: v for k, v in cls.__dict__.items() if isinstance(v, Option)}
python
def options(cls): """Return a dictionary of the ``Option`` objects for this config.""" return {k: v for k, v in cls.__dict__.items() if isinstance(v, Option)}
[ "def", "options", "(", "cls", ")", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "cls", ".", "__dict__", ".", "items", "(", ")", "if", "isinstance", "(", "v", ",", "Option", ")", "}" ]
Return a dictionary of the ``Option`` objects for this config.
[ "Return", "a", "dictionary", "of", "the", "Option", "objects", "for", "this", "config", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L262-L264
train
wmayner/pyphi
pyphi/conf.py
Config.defaults
def defaults(self): """Return the default values of this configuration.""" return {k: v.default for k, v in self.options().items()}
python
def defaults(self): """Return the default values of this configuration.""" return {k: v.default for k, v in self.options().items()}
[ "def", "defaults", "(", "self", ")", ":", "return", "{", "k", ":", "v", ".", "default", "for", "k", ",", "v", "in", "self", ".", "options", "(", ")", ".", "items", "(", ")", "}" ]
Return the default values of this configuration.
[ "Return", "the", "default", "values", "of", "this", "configuration", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L266-L268
train
wmayner/pyphi
pyphi/conf.py
Config.load_dict
def load_dict(self, dct): """Load a dictionary of configuration values.""" for k, v in dct.items(): setattr(self, k, v)
python
def load_dict(self, dct): """Load a dictionary of configuration values.""" for k, v in dct.items(): setattr(self, k, v)
[ "def", "load_dict", "(", "self", ",", "dct", ")", ":", "for", "k", ",", "v", "in", "dct", ".", "items", "(", ")", ":", "setattr", "(", "self", ",", "k", ",", "v", ")" ]
Load a dictionary of configuration values.
[ "Load", "a", "dictionary", "of", "configuration", "values", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L270-L273
train
wmayner/pyphi
pyphi/conf.py
Config.load_file
def load_file(self, filename): """Load config from a YAML file.""" filename = os.path.abspath(filename) with open(filename) as f: self.load_dict(yaml.load(f)) self._loaded_files.append(filename)
python
def load_file(self, filename): """Load config from a YAML file.""" filename = os.path.abspath(filename) with open(filename) as f: self.load_dict(yaml.load(f)) self._loaded_files.append(filename)
[ "def", "load_file", "(", "self", ",", "filename", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "with", "open", "(", "filename", ")", "as", "f", ":", "self", ".", "load_dict", "(", "yaml", ".", "load", "(", "f"...
Load config from a YAML file.
[ "Load", "config", "from", "a", "YAML", "file", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L275-L282
train
wmayner/pyphi
pyphi/conf.py
PyphiConfig.log
def log(self): """Log current settings.""" log.info('PyPhi v%s', __about__.__version__) if self._loaded_files: log.info('Loaded configuration from %s', self._loaded_files) else: log.info('Using default configuration (no configuration file ' 'p...
python
def log(self): """Log current settings.""" log.info('PyPhi v%s', __about__.__version__) if self._loaded_files: log.info('Loaded configuration from %s', self._loaded_files) else: log.info('Using default configuration (no configuration file ' 'p...
[ "def", "log", "(", "self", ")", ":", "log", ".", "info", "(", "'PyPhi v%s'", ",", "__about__", ".", "__version__", ")", "if", "self", ".", "_loaded_files", ":", "log", ".", "info", "(", "'Loaded configuration from %s'", ",", "self", ".", "_loaded_files", "...
Log current settings.
[ "Log", "current", "settings", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/conf.py#L636-L644
train
wmayner/pyphi
pyphi/convert.py
be2le_state_by_state
def be2le_state_by_state(tpm): """Convert a state-by-state TPM from big-endian to little-endian or vice versa. Args: tpm (np.ndarray): A state-by-state TPM. Returns: np.ndarray: The state-by-state TPM in the other indexing format. Example: >>> tpm = np.arange(16).reshape([...
python
def be2le_state_by_state(tpm): """Convert a state-by-state TPM from big-endian to little-endian or vice versa. Args: tpm (np.ndarray): A state-by-state TPM. Returns: np.ndarray: The state-by-state TPM in the other indexing format. Example: >>> tpm = np.arange(16).reshape([...
[ "def", "be2le_state_by_state", "(", "tpm", ")", ":", "le", "=", "np", ".", "empty", "(", "tpm", ".", "shape", ")", "N", "=", "tpm", ".", "shape", "[", "0", "]", "n", "=", "int", "(", "log2", "(", "N", ")", ")", "for", "i", "in", "range", "(",...
Convert a state-by-state TPM from big-endian to little-endian or vice versa. Args: tpm (np.ndarray): A state-by-state TPM. Returns: np.ndarray: The state-by-state TPM in the other indexing format. Example: >>> tpm = np.arange(16).reshape([4, 4]) >>> be2le_state_by_stat...
[ "Convert", "a", "state", "-", "by", "-", "state", "TPM", "from", "big", "-", "endian", "to", "little", "-", "endian", "or", "vice", "versa", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/convert.py#L147-L170
train
wmayner/pyphi
pyphi/convert.py
to_multidimensional
def to_multidimensional(tpm): """Reshape a state-by-node TPM to the multidimensional form. See documentation for the |Network| object for more information on TPM formats. """ # Cast to np.array. tpm = np.array(tpm) # Get the number of nodes. N = tpm.shape[-1] # Reshape. We use Fortr...
python
def to_multidimensional(tpm): """Reshape a state-by-node TPM to the multidimensional form. See documentation for the |Network| object for more information on TPM formats. """ # Cast to np.array. tpm = np.array(tpm) # Get the number of nodes. N = tpm.shape[-1] # Reshape. We use Fortr...
[ "def", "to_multidimensional", "(", "tpm", ")", ":", "tpm", "=", "np", ".", "array", "(", "tpm", ")", "N", "=", "tpm", ".", "shape", "[", "-", "1", "]", "return", "tpm", ".", "reshape", "(", "[", "2", "]", "*", "N", "+", "[", "N", "]", ",", ...
Reshape a state-by-node TPM to the multidimensional form. See documentation for the |Network| object for more information on TPM formats.
[ "Reshape", "a", "state", "-", "by", "-", "node", "TPM", "to", "the", "multidimensional", "form", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/convert.py#L176-L190
train
wmayner/pyphi
pyphi/convert.py
state_by_state2state_by_node
def state_by_state2state_by_node(tpm): """Convert a state-by-state TPM to a state-by-node TPM. .. danger:: Many nondeterministic state-by-state TPMs can be represented by a single a state-by-state TPM. However, the mapping can be made to be one-to-one if we assume the state-by-state TPM...
python
def state_by_state2state_by_node(tpm): """Convert a state-by-state TPM to a state-by-node TPM. .. danger:: Many nondeterministic state-by-state TPMs can be represented by a single a state-by-state TPM. However, the mapping can be made to be one-to-one if we assume the state-by-state TPM...
[ "def", "state_by_state2state_by_node", "(", "tpm", ")", ":", "tpm", "=", "np", ".", "array", "(", "tpm", ")", "S", "=", "tpm", ".", "shape", "[", "-", "1", "]", "N", "=", "int", "(", "log2", "(", "S", ")", ")", "sbn_tpm", "=", "np", ".", "zeros...
Convert a state-by-state TPM to a state-by-node TPM. .. danger:: Many nondeterministic state-by-state TPMs can be represented by a single a state-by-state TPM. However, the mapping can be made to be one-to-one if we assume the state-by-state TPM is conditionally independent, as this...
[ "Convert", "a", "state", "-", "by", "-", "state", "TPM", "to", "a", "state", "-", "by", "-", "node", "TPM", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/convert.py#L207-L264
train
wmayner/pyphi
pyphi/convert.py
state_by_node2state_by_state
def state_by_node2state_by_state(tpm): """Convert a state-by-node TPM to a state-by-state TPM. .. important:: A nondeterministic state-by-node TPM can have more than one representation as a state-by-state TPM. However, the mapping can be made to be one-to-one if we assume the TPMs to be...
python
def state_by_node2state_by_state(tpm): """Convert a state-by-node TPM to a state-by-state TPM. .. important:: A nondeterministic state-by-node TPM can have more than one representation as a state-by-state TPM. However, the mapping can be made to be one-to-one if we assume the TPMs to be...
[ "def", "state_by_node2state_by_state", "(", "tpm", ")", ":", "tpm", "=", "np", ".", "array", "(", "tpm", ")", "tpm", "=", "to_multidimensional", "(", "tpm", ")", "N", "=", "tpm", ".", "shape", "[", "-", "1", "]", "S", "=", "2", "**", "N", "sbs_tpm"...
Convert a state-by-node TPM to a state-by-state TPM. .. important:: A nondeterministic state-by-node TPM can have more than one representation as a state-by-state TPM. However, the mapping can be made to be one-to-one if we assume the TPMs to be conditionally independent. Therefore,...
[ "Convert", "a", "state", "-", "by", "-", "node", "TPM", "to", "a", "state", "-", "by", "-", "state", "TPM", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/convert.py#L270-L345
train
wmayner/pyphi
profiling/code_to_profile.py
load_json_network
def load_json_network(json_dict): """Load a network from a json file""" network = pyphi.Network.from_json(json_dict['network']) state = json_dict['state'] return (network, state)
python
def load_json_network(json_dict): """Load a network from a json file""" network = pyphi.Network.from_json(json_dict['network']) state = json_dict['state'] return (network, state)
[ "def", "load_json_network", "(", "json_dict", ")", ":", "network", "=", "pyphi", ".", "Network", ".", "from_json", "(", "json_dict", "[", "'network'", "]", ")", "state", "=", "json_dict", "[", "'state'", "]", "return", "(", "network", ",", "state", ")" ]
Load a network from a json file
[ "Load", "a", "network", "from", "a", "json", "file" ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/profiling/code_to_profile.py#L35-L39
train
wmayner/pyphi
profiling/code_to_profile.py
all_network_files
def all_network_files(): """All network files""" # TODO: list explicitly since some are missing? network_types = [ 'AND-circle', 'MAJ-specialized', 'MAJ-complete', 'iit-3.0-modular' ] network_sizes = range(5, 8) network_files = [] for n in network_sizes: ...
python
def all_network_files(): """All network files""" # TODO: list explicitly since some are missing? network_types = [ 'AND-circle', 'MAJ-specialized', 'MAJ-complete', 'iit-3.0-modular' ] network_sizes = range(5, 8) network_files = [] for n in network_sizes: ...
[ "def", "all_network_files", "(", ")", ":", "network_types", "=", "[", "'AND-circle'", ",", "'MAJ-specialized'", ",", "'MAJ-complete'", ",", "'iit-3.0-modular'", "]", "network_sizes", "=", "range", "(", "5", ",", "8", ")", "network_files", "=", "[", "]", "for",...
All network files
[ "All", "network", "files" ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/profiling/code_to_profile.py#L42-L56
train
wmayner/pyphi
profiling/code_to_profile.py
profile_network
def profile_network(filename): """Profile a network. Saves PyPhi results, pstats, and logs to respective directories. """ log = logging.getLogger(filename) logfile = os.path.join(LOGS, filename + '.log') os.makedirs(os.path.dirname(logfile), exist_ok=True) handler = logging.FileHandler(logf...
python
def profile_network(filename): """Profile a network. Saves PyPhi results, pstats, and logs to respective directories. """ log = logging.getLogger(filename) logfile = os.path.join(LOGS, filename + '.log') os.makedirs(os.path.dirname(logfile), exist_ok=True) handler = logging.FileHandler(logf...
[ "def", "profile_network", "(", "filename", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "filename", ")", "logfile", "=", "os", ".", "path", ".", "join", "(", "LOGS", ",", "filename", "+", "'.log'", ")", "os", ".", "makedirs", "(", "os", "....
Profile a network. Saves PyPhi results, pstats, and logs to respective directories.
[ "Profile", "a", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/profiling/code_to_profile.py#L59-L102
train
wmayner/pyphi
pyphi/timescale.py
run_tpm
def run_tpm(tpm, time_scale): """Iterate a TPM by the specified number of time steps. Args: tpm (np.ndarray): A state-by-node tpm. time_scale (int): The number of steps to run the tpm. Returns: np.ndarray """ sbs_tpm = convert.state_by_node2state_by_state(tpm) if sparse...
python
def run_tpm(tpm, time_scale): """Iterate a TPM by the specified number of time steps. Args: tpm (np.ndarray): A state-by-node tpm. time_scale (int): The number of steps to run the tpm. Returns: np.ndarray """ sbs_tpm = convert.state_by_node2state_by_state(tpm) if sparse...
[ "def", "run_tpm", "(", "tpm", ",", "time_scale", ")", ":", "sbs_tpm", "=", "convert", ".", "state_by_node2state_by_state", "(", "tpm", ")", "if", "sparse", "(", "tpm", ")", ":", "tpm", "=", "sparse_time", "(", "sbs_tpm", ",", "time_scale", ")", "else", "...
Iterate a TPM by the specified number of time steps. Args: tpm (np.ndarray): A state-by-node tpm. time_scale (int): The number of steps to run the tpm. Returns: np.ndarray
[ "Iterate", "a", "TPM", "by", "the", "specified", "number", "of", "time", "steps", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/timescale.py#L28-L43
train
wmayner/pyphi
pyphi/timescale.py
run_cm
def run_cm(cm, time_scale): """Iterate a connectivity matrix the specified number of steps. Args: cm (np.ndarray): A connectivity matrix. time_scale (int): The number of steps to run. Returns: np.ndarray: The connectivity matrix at the new timescale. """ cm = np.linalg.matr...
python
def run_cm(cm, time_scale): """Iterate a connectivity matrix the specified number of steps. Args: cm (np.ndarray): A connectivity matrix. time_scale (int): The number of steps to run. Returns: np.ndarray: The connectivity matrix at the new timescale. """ cm = np.linalg.matr...
[ "def", "run_cm", "(", "cm", ",", "time_scale", ")", ":", "cm", "=", "np", ".", "linalg", ".", "matrix_power", "(", "cm", ",", "time_scale", ")", "cm", "[", "cm", ">", "1", "]", "=", "1", "return", "cm" ]
Iterate a connectivity matrix the specified number of steps. Args: cm (np.ndarray): A connectivity matrix. time_scale (int): The number of steps to run. Returns: np.ndarray: The connectivity matrix at the new timescale.
[ "Iterate", "a", "connectivity", "matrix", "the", "specified", "number", "of", "steps", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/timescale.py#L46-L59
train
wmayner/pyphi
pyphi/compute/network.py
_reachable_subsystems
def _reachable_subsystems(network, indices, state): """A generator over all subsystems in a valid state.""" validate.is_network(network) # Return subsystems largest to smallest to optimize parallel # resource usage. for subset in utils.powerset(indices, nonempty=True, reverse=True): try: ...
python
def _reachable_subsystems(network, indices, state): """A generator over all subsystems in a valid state.""" validate.is_network(network) # Return subsystems largest to smallest to optimize parallel # resource usage. for subset in utils.powerset(indices, nonempty=True, reverse=True): try: ...
[ "def", "_reachable_subsystems", "(", "network", ",", "indices", ",", "state", ")", ":", "validate", ".", "is_network", "(", "network", ")", "for", "subset", "in", "utils", ".", "powerset", "(", "indices", ",", "nonempty", "=", "True", ",", "reverse", "=", ...
A generator over all subsystems in a valid state.
[ "A", "generator", "over", "all", "subsystems", "in", "a", "valid", "state", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/network.py#L21-L31
train
wmayner/pyphi
pyphi/compute/network.py
all_complexes
def all_complexes(network, state): """Return a generator for all complexes of the network. .. note:: Includes reducible, zero-|big_phi| complexes (which are not, strictly speaking, complexes at all). Args: network (Network): The |Network| of interest. state (tuple[int]): Th...
python
def all_complexes(network, state): """Return a generator for all complexes of the network. .. note:: Includes reducible, zero-|big_phi| complexes (which are not, strictly speaking, complexes at all). Args: network (Network): The |Network| of interest. state (tuple[int]): Th...
[ "def", "all_complexes", "(", "network", ",", "state", ")", ":", "engine", "=", "FindAllComplexes", "(", "subsystems", "(", "network", ",", "state", ")", ")", "return", "engine", ".", "run", "(", "config", ".", "PARALLEL_COMPLEX_EVALUATION", ")" ]
Return a generator for all complexes of the network. .. note:: Includes reducible, zero-|big_phi| complexes (which are not, strictly speaking, complexes at all). Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). ...
[ "Return", "a", "generator", "for", "all", "complexes", "of", "the", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/network.py#L93-L109
train
wmayner/pyphi
pyphi/compute/network.py
complexes
def complexes(network, state): """Return all irreducible complexes of the network. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Yields: SystemIrreducibilityAnalysis: A |SIA| for each |Subsystem| of the |N...
python
def complexes(network, state): """Return all irreducible complexes of the network. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Yields: SystemIrreducibilityAnalysis: A |SIA| for each |Subsystem| of the |N...
[ "def", "complexes", "(", "network", ",", "state", ")", ":", "engine", "=", "FindIrreducibleComplexes", "(", "possible_complexes", "(", "network", ",", "state", ")", ")", "return", "engine", ".", "run", "(", "config", ".", "PARALLEL_COMPLEX_EVALUATION", ")" ]
Return all irreducible complexes of the network. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Yields: SystemIrreducibilityAnalysis: A |SIA| for each |Subsystem| of the |Network|, excluding those with |big_phi...
[ "Return", "all", "irreducible", "complexes", "of", "the", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/network.py#L121-L133
train
wmayner/pyphi
pyphi/compute/network.py
major_complex
def major_complex(network, state): """Return the major complex of the network. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Returns: SystemIrreducibilityAnalysis: The |SIA| for the |Subsystem| with maxima...
python
def major_complex(network, state): """Return the major complex of the network. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Returns: SystemIrreducibilityAnalysis: The |SIA| for the |Subsystem| with maxima...
[ "def", "major_complex", "(", "network", ",", "state", ")", ":", "log", ".", "info", "(", "'Calculating major complex...'", ")", "result", "=", "complexes", "(", "network", ",", "state", ")", "if", "result", ":", "result", "=", "max", "(", "result", ")", ...
Return the major complex of the network. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Returns: SystemIrreducibilityAnalysis: The |SIA| for the |Subsystem| with maximal |big_phi|.
[ "Return", "the", "major", "complex", "of", "the", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/network.py#L136-L158
train
wmayner/pyphi
pyphi/compute/network.py
condensed
def condensed(network, state): """Return a list of maximal non-overlapping complexes. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Returns: list[SystemIrreducibilityAnalysis]: A list of |SIA| for non-overlapping ...
python
def condensed(network, state): """Return a list of maximal non-overlapping complexes. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Returns: list[SystemIrreducibilityAnalysis]: A list of |SIA| for non-overlapping ...
[ "def", "condensed", "(", "network", ",", "state", ")", ":", "result", "=", "[", "]", "covered_nodes", "=", "set", "(", ")", "for", "c", "in", "reversed", "(", "sorted", "(", "complexes", "(", "network", ",", "state", ")", ")", ")", ":", "if", "not"...
Return a list of maximal non-overlapping complexes. Args: network (Network): The |Network| of interest. state (tuple[int]): The state of the network (a binary tuple). Returns: list[SystemIrreducibilityAnalysis]: A list of |SIA| for non-overlapping complexes with maximal |big_ph...
[ "Return", "a", "list", "of", "maximal", "non", "-", "overlapping", "complexes", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/network.py#L161-L180
train
wmayner/pyphi
pyphi/examples.py
basic_network
def basic_network(cm=False): """A 3-node network of logic gates. Diagram:: +~~~~~~~~+ +~~~~>| A |<~~~~+ | | (OR) +~~~+ | | +~~~~~~~~+ | | | | | | v | +~+~~~~~~+ +~~~~~+~+ ...
python
def basic_network(cm=False): """A 3-node network of logic gates. Diagram:: +~~~~~~~~+ +~~~~>| A |<~~~~+ | | (OR) +~~~+ | | +~~~~~~~~+ | | | | | | v | +~+~~~~~~+ +~~~~~+~+ ...
[ "def", "basic_network", "(", "cm", "=", "False", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "0", ",", "0", ",", "0", "]", ",", "[", "0", ",", "0", ",", "1", "]", ",", "[", "1", ",", "0", ",", "1", "]", ",", "[", "1", ","...
A 3-node network of logic gates. Diagram:: +~~~~~~~~+ +~~~~>| A |<~~~~+ | | (OR) +~~~+ | | +~~~~~~~~+ | | | | | | v | +~+~~~~~~+ +~~~~~+~+ | B |<~~~~~~+ C | |...
[ "A", "3", "-", "node", "network", "of", "logic", "gates", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L24-L99
train
wmayner/pyphi
pyphi/examples.py
basic_noisy_selfloop_network
def basic_noisy_selfloop_network(): """Based on the basic_network, but with added selfloops and noisy edges. Nodes perform deterministic functions of their inputs, but those inputs may be flipped (i.e. what should be a 0 becomes a 1, and vice versa) with probability epsilon (eps = 0.1 here). Diagr...
python
def basic_noisy_selfloop_network(): """Based on the basic_network, but with added selfloops and noisy edges. Nodes perform deterministic functions of their inputs, but those inputs may be flipped (i.e. what should be a 0 becomes a 1, and vice versa) with probability epsilon (eps = 0.1 here). Diagr...
[ "def", "basic_noisy_selfloop_network", "(", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "0.271", ",", "0.19", ",", "0.244", "]", ",", "[", "0.919", ",", "0.19", ",", "0.756", "]", ",", "[", "0.919", ",", "0.91", ",", "0.756", "]", ",...
Based on the basic_network, but with added selfloops and noisy edges. Nodes perform deterministic functions of their inputs, but those inputs may be flipped (i.e. what should be a 0 becomes a 1, and vice versa) with probability epsilon (eps = 0.1 here). Diagram:: +~~+ ...
[ "Based", "on", "the", "basic_network", "but", "with", "added", "selfloops", "and", "noisy", "edges", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L116-L158
train
wmayner/pyphi
pyphi/examples.py
residue_network
def residue_network(): """The network for the residue example. Current and previous state are all nodes OFF. Diagram:: +~~~~~~~+ +~~~~~~~+ | A | | B | +~~>| (AND) | | (AND) |<~~+ | +~~~~~~~+ +~~~~~~~+ | ...
python
def residue_network(): """The network for the residue example. Current and previous state are all nodes OFF. Diagram:: +~~~~~~~+ +~~~~~~~+ | A | | B | +~~>| (AND) | | (AND) |<~~+ | +~~~~~~~+ +~~~~~~~+ | ...
[ "def", "residue_network", "(", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "int", "(", "s", ")", "for", "s", "in", "bin", "(", "x", ")", "[", "2", ":", "]", ".", "zfill", "(", "5", ")", "[", ":", ":", "-", "1", "]", "]", "f...
The network for the residue example. Current and previous state are all nodes OFF. Diagram:: +~~~~~~~+ +~~~~~~~+ | A | | B | +~~>| (AND) | | (AND) |<~~+ | +~~~~~~~+ +~~~~~~~+ | | ^ ...
[ "The", "network", "for", "the", "residue", "example", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L170-L218
train
wmayner/pyphi
pyphi/examples.py
propagation_delay_network
def propagation_delay_network(): """A version of the primary example from the IIT 3.0 paper with deterministic COPY gates on each connection. These copy gates essentially function as propagation delays on the signal between OR, AND and XOR gates from the original system. The current and previous st...
python
def propagation_delay_network(): """A version of the primary example from the IIT 3.0 paper with deterministic COPY gates on each connection. These copy gates essentially function as propagation delays on the signal between OR, AND and XOR gates from the original system. The current and previous st...
[ "def", "propagation_delay_network", "(", ")", ":", "num_nodes", "=", "9", "num_states", "=", "2", "**", "num_nodes", "tpm", "=", "np", ".", "zeros", "(", "(", "num_states", ",", "num_nodes", ")", ")", "for", "previous_state_index", ",", "previous", "in", "...
A version of the primary example from the IIT 3.0 paper with deterministic COPY gates on each connection. These copy gates essentially function as propagation delays on the signal between OR, AND and XOR gates from the original system. The current and previous states of the network are also selected to...
[ "A", "version", "of", "the", "primary", "example", "from", "the", "IIT", "3", ".", "0", "paper", "with", "deterministic", "COPY", "gates", "on", "each", "connection", ".", "These", "copy", "gates", "essentially", "function", "as", "propagation", "delays", "o...
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L395-L496
train
wmayner/pyphi
pyphi/examples.py
macro_network
def macro_network(): """A network of micro elements which has greater integrated information after coarse graining to a macro scale. """ tpm = np.array([[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 1.0, 1.0], ...
python
def macro_network(): """A network of micro elements which has greater integrated information after coarse graining to a macro scale. """ tpm = np.array([[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 1.0, 1.0], ...
[ "def", "macro_network", "(", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "0.3", ",", "0.3", ",", "0.3", ",", "0.3", "]", ",", "[", "0.3", ",", "0.3", ",", "0.3", ",", "0.3", "]", ",", "[", "0.3", ",", "0.3", ",", "0.3", ",", ...
A network of micro elements which has greater integrated information after coarse graining to a macro scale.
[ "A", "network", "of", "micro", "elements", "which", "has", "greater", "integrated", "information", "after", "coarse", "graining", "to", "a", "macro", "scale", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L499-L519
train
wmayner/pyphi
pyphi/examples.py
blackbox_network
def blackbox_network(): """A micro-network to demonstrate blackboxing. Diagram:: +----------+ +-------------------->+ A (COPY) + <---------------+ | +----------+ | | +----------+ ...
python
def blackbox_network(): """A micro-network to demonstrate blackboxing. Diagram:: +----------+ +-------------------->+ A (COPY) + <---------------+ | +----------+ | | +----------+ ...
[ "def", "blackbox_network", "(", ")", ":", "num_nodes", "=", "6", "num_states", "=", "2", "**", "num_nodes", "tpm", "=", "np", ".", "zeros", "(", "(", "num_states", ",", "num_nodes", ")", ")", "for", "index", ",", "previous_state", "in", "enumerate", "(",...
A micro-network to demonstrate blackboxing. Diagram:: +----------+ +-------------------->+ A (COPY) + <---------------+ | +----------+ | | +----------+ | | +---------...
[ "A", "micro", "-", "network", "to", "demonstrate", "blackboxing", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L531-L603
train
wmayner/pyphi
pyphi/examples.py
actual_causation
def actual_causation(): """The actual causation example network, consisting of an ``OR`` and ``AND`` gate with self-loops. """ tpm = np.array([ [1, 0, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1] ]) cm = np.array([ [1, 1], [1, 1] ]) retu...
python
def actual_causation(): """The actual causation example network, consisting of an ``OR`` and ``AND`` gate with self-loops. """ tpm = np.array([ [1, 0, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1] ]) cm = np.array([ [1, 1], [1, 1] ]) retu...
[ "def", "actual_causation", "(", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "1", ",", "0", ",", "0", ",", "0", "]", ",", "[", "0", ",", "1", ",", "0", ",", "0", "]", ",", "[", "0", ",", "1", ",", "0", ",", "0", "]", ",", ...
The actual causation example network, consisting of an ``OR`` and ``AND`` gate with self-loops.
[ "The", "actual", "causation", "example", "network", "consisting", "of", "an", "OR", "and", "AND", "gate", "with", "self", "-", "loops", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L1063-L1077
train
wmayner/pyphi
pyphi/examples.py
prevention
def prevention(): """The |Transition| for the prevention example from Actual Causation Figure 5D. """ tpm = np.array([ [0.5, 0.5, 1], [0.5, 0.5, 0], [0.5, 0.5, 1], [0.5, 0.5, 1], [0.5, 0.5, 1], [0.5, 0.5, 0], [0.5, 0.5, 1], [0.5, 0.5, 1] ...
python
def prevention(): """The |Transition| for the prevention example from Actual Causation Figure 5D. """ tpm = np.array([ [0.5, 0.5, 1], [0.5, 0.5, 0], [0.5, 0.5, 1], [0.5, 0.5, 1], [0.5, 0.5, 1], [0.5, 0.5, 0], [0.5, 0.5, 1], [0.5, 0.5, 1] ...
[ "def", "prevention", "(", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "0.5", ",", "0.5", ",", "1", "]", ",", "[", "0.5", ",", "0.5", ",", "0", "]", ",", "[", "0.5", ",", "0.5", ",", "1", "]", ",", "[", "0.5", ",", "0.5", ",...
The |Transition| for the prevention example from Actual Causation Figure 5D.
[ "The", "|Transition|", "for", "the", "prevention", "example", "from", "Actual", "Causation", "Figure", "5D", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L1113-L1136
train
wmayner/pyphi
benchmarks/benchmarks/subsystem.py
clear_subsystem_caches
def clear_subsystem_caches(subsys): """Clear subsystem caches""" try: # New-style caches subsys._repertoire_cache.clear() subsys._mice_cache.clear() except TypeError: try: # Pre cache.clear() implementation subsys._repertoire_cache.cache = {} ...
python
def clear_subsystem_caches(subsys): """Clear subsystem caches""" try: # New-style caches subsys._repertoire_cache.clear() subsys._mice_cache.clear() except TypeError: try: # Pre cache.clear() implementation subsys._repertoire_cache.cache = {} ...
[ "def", "clear_subsystem_caches", "(", "subsys", ")", ":", "try", ":", "subsys", ".", "_repertoire_cache", ".", "clear", "(", ")", "subsys", ".", "_mice_cache", ".", "clear", "(", ")", "except", "TypeError", ":", "try", ":", "subsys", ".", "_repertoire_cache"...
Clear subsystem caches
[ "Clear", "subsystem", "caches" ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/benchmarks/benchmarks/subsystem.py#L24-L39
train
wmayner/pyphi
pyphi/utils.py
all_states
def all_states(n, big_endian=False): """Return all binary states for a system. Args: n (int): The number of elements in the system. big_endian (bool): Whether to return the states in big-endian order instead of little-endian order. Yields: tuple[int]: The next state of ...
python
def all_states(n, big_endian=False): """Return all binary states for a system. Args: n (int): The number of elements in the system. big_endian (bool): Whether to return the states in big-endian order instead of little-endian order. Yields: tuple[int]: The next state of ...
[ "def", "all_states", "(", "n", ",", "big_endian", "=", "False", ")", ":", "if", "n", "==", "0", ":", "return", "for", "state", "in", "product", "(", "(", "0", ",", "1", ")", ",", "repeat", "=", "n", ")", ":", "if", "big_endian", ":", "yield", "...
Return all binary states for a system. Args: n (int): The number of elements in the system. big_endian (bool): Whether to return the states in big-endian order instead of little-endian order. Yields: tuple[int]: The next state of an ``n``-element system, in little-endian ...
[ "Return", "all", "binary", "states", "for", "a", "system", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/utils.py#L27-L46
train
wmayner/pyphi
pyphi/utils.py
np_hash
def np_hash(a): """Return a hash of a NumPy array.""" if a is None: return hash(None) # Ensure that hashes are equal whatever the ordering in memory (C or # Fortran) a = np.ascontiguousarray(a) # Compute the digest and return a decimal int return int(hashlib.sha1(a.view(a.dtype)).hex...
python
def np_hash(a): """Return a hash of a NumPy array.""" if a is None: return hash(None) # Ensure that hashes are equal whatever the ordering in memory (C or # Fortran) a = np.ascontiguousarray(a) # Compute the digest and return a decimal int return int(hashlib.sha1(a.view(a.dtype)).hex...
[ "def", "np_hash", "(", "a", ")", ":", "if", "a", "is", "None", ":", "return", "hash", "(", "None", ")", "a", "=", "np", ".", "ascontiguousarray", "(", "a", ")", "return", "int", "(", "hashlib", ".", "sha1", "(", "a", ".", "view", "(", "a", ".",...
Return a hash of a NumPy array.
[ "Return", "a", "hash", "of", "a", "NumPy", "array", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/utils.py#L55-L63
train
wmayner/pyphi
pyphi/utils.py
powerset
def powerset(iterable, nonempty=False, reverse=False): """Generate the power set of an iterable. Args: iterable (Iterable): The iterable from which to generate the power set. Keyword Args: nonempty (boolean): If True, don't include the empty set. reverse (boolean): If True, reverse...
python
def powerset(iterable, nonempty=False, reverse=False): """Generate the power set of an iterable. Args: iterable (Iterable): The iterable from which to generate the power set. Keyword Args: nonempty (boolean): If True, don't include the empty set. reverse (boolean): If True, reverse...
[ "def", "powerset", "(", "iterable", ",", "nonempty", "=", "False", ",", "reverse", "=", "False", ")", ":", "iterable", "=", "list", "(", "iterable", ")", "if", "nonempty", ":", "start", "=", "1", "else", ":", "start", "=", "0", "seq_sizes", "=", "ran...
Generate the power set of an iterable. Args: iterable (Iterable): The iterable from which to generate the power set. Keyword Args: nonempty (boolean): If True, don't include the empty set. reverse (boolean): If True, reverse the order of the powerset. Returns: Iterable: An...
[ "Generate", "the", "power", "set", "of", "an", "iterable", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/utils.py#L146-L183
train
wmayner/pyphi
pyphi/utils.py
load_data
def load_data(directory, num): """Load numpy data from the data directory. The files should stored in ``../data/<dir>`` and named ``0.npy, 1.npy, ... <num - 1>.npy``. Returns: list: A list of loaded data, such that ``list[i]`` contains the the contents of ``i.npy``. """ root = ...
python
def load_data(directory, num): """Load numpy data from the data directory. The files should stored in ``../data/<dir>`` and named ``0.npy, 1.npy, ... <num - 1>.npy``. Returns: list: A list of loaded data, such that ``list[i]`` contains the the contents of ``i.npy``. """ root = ...
[ "def", "load_data", "(", "directory", ",", "num", ")", ":", "root", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "def", "get_path", "(", "i", ")", ":", "return", "os", ".", "path", "."...
Load numpy data from the data directory. The files should stored in ``../data/<dir>`` and named ``0.npy, 1.npy, ... <num - 1>.npy``. Returns: list: A list of loaded data, such that ``list[i]`` contains the the contents of ``i.npy``.
[ "Load", "numpy", "data", "from", "the", "data", "directory", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/utils.py#L186-L201
train
wmayner/pyphi
pyphi/utils.py
time_annotated
def time_annotated(func, *args, **kwargs): """Annotate the decorated function or method with the total execution time. The result is annotated with a `time` attribute. """ start = time() result = func(*args, **kwargs) end = time() result.time = round(end - start, config.PRECISION) r...
python
def time_annotated(func, *args, **kwargs): """Annotate the decorated function or method with the total execution time. The result is annotated with a `time` attribute. """ start = time() result = func(*args, **kwargs) end = time() result.time = round(end - start, config.PRECISION) r...
[ "def", "time_annotated", "(", "func", ",", "*", "args", ",", "**", "kwargs", ")", ":", "start", "=", "time", "(", ")", "result", "=", "func", "(", "*", "args", ",", "**", "kwargs", ")", "end", "=", "time", "(", ")", "result", ".", "time", "=", ...
Annotate the decorated function or method with the total execution time. The result is annotated with a `time` attribute.
[ "Annotate", "the", "decorated", "function", "or", "method", "with", "the", "total", "execution", "time", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/utils.py#L207-L217
train
wmayner/pyphi
pyphi/models/mechanism.py
_null_ria
def _null_ria(direction, mechanism, purview, repertoire=None, phi=0.0): """The irreducibility analysis for a reducible mechanism.""" # TODO Use properties here to infer mechanism and purview from # partition yet access them with .mechanism and .partition return RepertoireIrreducibilityAnalysis( ...
python
def _null_ria(direction, mechanism, purview, repertoire=None, phi=0.0): """The irreducibility analysis for a reducible mechanism.""" # TODO Use properties here to infer mechanism and purview from # partition yet access them with .mechanism and .partition return RepertoireIrreducibilityAnalysis( ...
[ "def", "_null_ria", "(", "direction", ",", "mechanism", ",", "purview", ",", "repertoire", "=", "None", ",", "phi", "=", "0.0", ")", ":", "return", "RepertoireIrreducibilityAnalysis", "(", "direction", "=", "direction", ",", "mechanism", "=", "mechanism", ",",...
The irreducibility analysis for a reducible mechanism.
[ "The", "irreducibility", "analysis", "for", "a", "reducible", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/mechanism.py#L135-L147
train
wmayner/pyphi
pyphi/models/mechanism.py
MaximallyIrreducibleCauseOrEffect.damaged_by_cut
def damaged_by_cut(self, subsystem): """Return ``True`` if this MICE is affected by the subsystem's cut. The cut affects the MICE if it either splits the MICE's mechanism or splits the connections between the purview and mechanism. """ return (subsystem.cut.splits_mechanism(self...
python
def damaged_by_cut(self, subsystem): """Return ``True`` if this MICE is affected by the subsystem's cut. The cut affects the MICE if it either splits the MICE's mechanism or splits the connections between the purview and mechanism. """ return (subsystem.cut.splits_mechanism(self...
[ "def", "damaged_by_cut", "(", "self", ",", "subsystem", ")", ":", "return", "(", "subsystem", ".", "cut", ".", "splits_mechanism", "(", "self", ".", "mechanism", ")", "or", "np", ".", "any", "(", "self", ".", "_relevant_connections", "(", "subsystem", ")",...
Return ``True`` if this MICE is affected by the subsystem's cut. The cut affects the MICE if it either splits the MICE's mechanism or splits the connections between the purview and mechanism.
[ "Return", "True", "if", "this", "MICE", "is", "affected", "by", "the", "subsystem", "s", "cut", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/mechanism.py#L277-L285
train
wmayner/pyphi
pyphi/models/mechanism.py
Concept.eq_repertoires
def eq_repertoires(self, other): """Return whether this concept has the same repertoires as another. .. warning:: This only checks if the cause and effect repertoires are equal as arrays; mechanisms, purviews, or even the nodes that the mechanism and purview indices ...
python
def eq_repertoires(self, other): """Return whether this concept has the same repertoires as another. .. warning:: This only checks if the cause and effect repertoires are equal as arrays; mechanisms, purviews, or even the nodes that the mechanism and purview indices ...
[ "def", "eq_repertoires", "(", "self", ",", "other", ")", ":", "return", "(", "np", ".", "array_equal", "(", "self", ".", "cause_repertoire", ",", "other", ".", "cause_repertoire", ")", "and", "np", ".", "array_equal", "(", "self", ".", "effect_repertoire", ...
Return whether this concept has the same repertoires as another. .. warning:: This only checks if the cause and effect repertoires are equal as arrays; mechanisms, purviews, or even the nodes that the mechanism and purview indices refer to, might be different.
[ "Return", "whether", "this", "concept", "has", "the", "same", "repertoires", "as", "another", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/mechanism.py#L431-L441
train
wmayner/pyphi
pyphi/models/mechanism.py
Concept.emd_eq
def emd_eq(self, other): """Return whether this concept is equal to another in the context of an EMD calculation. """ return (self.phi == other.phi and self.mechanism == other.mechanism and self.eq_repertoires(other))
python
def emd_eq(self, other): """Return whether this concept is equal to another in the context of an EMD calculation. """ return (self.phi == other.phi and self.mechanism == other.mechanism and self.eq_repertoires(other))
[ "def", "emd_eq", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "phi", "==", "other", ".", "phi", "and", "self", ".", "mechanism", "==", "other", ".", "mechanism", "and", "self", ".", "eq_repertoires", "(", "other", ")", ")" ]
Return whether this concept is equal to another in the context of an EMD calculation.
[ "Return", "whether", "this", "concept", "is", "equal", "to", "another", "in", "the", "context", "of", "an", "EMD", "calculation", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/mechanism.py#L443-L449
train
wmayner/pyphi
pyphi/actual.py
directed_account
def directed_account(transition, direction, mechanisms=False, purviews=False, allow_neg=False): """Return the set of all |CausalLinks| of the specified direction.""" if mechanisms is False: mechanisms = utils.powerset(transition.mechanism_indices(direction), ...
python
def directed_account(transition, direction, mechanisms=False, purviews=False, allow_neg=False): """Return the set of all |CausalLinks| of the specified direction.""" if mechanisms is False: mechanisms = utils.powerset(transition.mechanism_indices(direction), ...
[ "def", "directed_account", "(", "transition", ",", "direction", ",", "mechanisms", "=", "False", ",", "purviews", "=", "False", ",", "allow_neg", "=", "False", ")", ":", "if", "mechanisms", "is", "False", ":", "mechanisms", "=", "utils", ".", "powerset", "...
Return the set of all |CausalLinks| of the specified direction.
[ "Return", "the", "set", "of", "all", "|CausalLinks|", "of", "the", "specified", "direction", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L440-L452
train
wmayner/pyphi
pyphi/actual.py
account
def account(transition, direction=Direction.BIDIRECTIONAL): """Return the set of all causal links for a |Transition|. Args: transition (Transition): The transition of interest. Keyword Args: direction (Direction): By default the account contains actual causes and actual effects...
python
def account(transition, direction=Direction.BIDIRECTIONAL): """Return the set of all causal links for a |Transition|. Args: transition (Transition): The transition of interest. Keyword Args: direction (Direction): By default the account contains actual causes and actual effects...
[ "def", "account", "(", "transition", ",", "direction", "=", "Direction", ".", "BIDIRECTIONAL", ")", ":", "if", "direction", "!=", "Direction", ".", "BIDIRECTIONAL", ":", "return", "directed_account", "(", "transition", ",", "direction", ")", "return", "Account",...
Return the set of all causal links for a |Transition|. Args: transition (Transition): The transition of interest. Keyword Args: direction (Direction): By default the account contains actual causes and actual effects.
[ "Return", "the", "set", "of", "all", "causal", "links", "for", "a", "|Transition|", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L455-L469
train
wmayner/pyphi
pyphi/actual.py
_evaluate_cut
def _evaluate_cut(transition, cut, unpartitioned_account, direction=Direction.BIDIRECTIONAL): """Find the |AcSystemIrreducibilityAnalysis| for a given cut.""" cut_transition = transition.apply_cut(cut) partitioned_account = account(cut_transition, direction) log.debug("Finished evalua...
python
def _evaluate_cut(transition, cut, unpartitioned_account, direction=Direction.BIDIRECTIONAL): """Find the |AcSystemIrreducibilityAnalysis| for a given cut.""" cut_transition = transition.apply_cut(cut) partitioned_account = account(cut_transition, direction) log.debug("Finished evalua...
[ "def", "_evaluate_cut", "(", "transition", ",", "cut", ",", "unpartitioned_account", ",", "direction", "=", "Direction", ".", "BIDIRECTIONAL", ")", ":", "cut_transition", "=", "transition", ".", "apply_cut", "(", "cut", ")", "partitioned_account", "=", "account", ...
Find the |AcSystemIrreducibilityAnalysis| for a given cut.
[ "Find", "the", "|AcSystemIrreducibilityAnalysis|", "for", "a", "given", "cut", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L492-L507
train
wmayner/pyphi
pyphi/actual.py
_get_cuts
def _get_cuts(transition, direction): """A list of possible cuts to a transition.""" n = transition.network.size if direction is Direction.BIDIRECTIONAL: yielded = set() for cut in chain(_get_cuts(transition, Direction.CAUSE), _get_cuts(transition, Direction.EFFECT)...
python
def _get_cuts(transition, direction): """A list of possible cuts to a transition.""" n = transition.network.size if direction is Direction.BIDIRECTIONAL: yielded = set() for cut in chain(_get_cuts(transition, Direction.CAUSE), _get_cuts(transition, Direction.EFFECT)...
[ "def", "_get_cuts", "(", "transition", ",", "direction", ")", ":", "n", "=", "transition", ".", "network", ".", "size", "if", "direction", "is", "Direction", ".", "BIDIRECTIONAL", ":", "yielded", "=", "set", "(", ")", "for", "cut", "in", "chain", "(", ...
A list of possible cuts to a transition.
[ "A", "list", "of", "possible", "cuts", "to", "a", "transition", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L511-L529
train
wmayner/pyphi
pyphi/actual.py
sia
def sia(transition, direction=Direction.BIDIRECTIONAL): """Return the minimal information partition of a transition in a specific direction. Args: transition (Transition): The candidate system. Returns: AcSystemIrreducibilityAnalysis: A nested structure containing all the data ...
python
def sia(transition, direction=Direction.BIDIRECTIONAL): """Return the minimal information partition of a transition in a specific direction. Args: transition (Transition): The candidate system. Returns: AcSystemIrreducibilityAnalysis: A nested structure containing all the data ...
[ "def", "sia", "(", "transition", ",", "direction", "=", "Direction", ".", "BIDIRECTIONAL", ")", ":", "validate", ".", "direction", "(", "direction", ",", "allow_bi", "=", "True", ")", "log", ".", "info", "(", "\"Calculating big-alpha for %s...\"", ",", "transi...
Return the minimal information partition of a transition in a specific direction. Args: transition (Transition): The candidate system. Returns: AcSystemIrreducibilityAnalysis: A nested structure containing all the data from the intermediate calculations. The top level contains the ...
[ "Return", "the", "minimal", "information", "partition", "of", "a", "transition", "in", "a", "specific", "direction", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L532-L573
train
wmayner/pyphi
pyphi/actual.py
nexus
def nexus(network, before_state, after_state, direction=Direction.BIDIRECTIONAL): """Return a tuple of all irreducible nexus of the network.""" validate.is_network(network) sias = (sia(transition, direction) for transition in transitions(network, before_state, after_state)) return...
python
def nexus(network, before_state, after_state, direction=Direction.BIDIRECTIONAL): """Return a tuple of all irreducible nexus of the network.""" validate.is_network(network) sias = (sia(transition, direction) for transition in transitions(network, before_state, after_state)) return...
[ "def", "nexus", "(", "network", ",", "before_state", ",", "after_state", ",", "direction", "=", "Direction", ".", "BIDIRECTIONAL", ")", ":", "validate", ".", "is_network", "(", "network", ")", "sias", "=", "(", "sia", "(", "transition", ",", "direction", "...
Return a tuple of all irreducible nexus of the network.
[ "Return", "a", "tuple", "of", "all", "irreducible", "nexus", "of", "the", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L626-L633
train
wmayner/pyphi
pyphi/actual.py
causal_nexus
def causal_nexus(network, before_state, after_state, direction=Direction.BIDIRECTIONAL): """Return the causal nexus of the network.""" validate.is_network(network) log.info("Calculating causal nexus...") result = nexus(network, before_state, after_state, direction) if result: ...
python
def causal_nexus(network, before_state, after_state, direction=Direction.BIDIRECTIONAL): """Return the causal nexus of the network.""" validate.is_network(network) log.info("Calculating causal nexus...") result = nexus(network, before_state, after_state, direction) if result: ...
[ "def", "causal_nexus", "(", "network", ",", "before_state", ",", "after_state", ",", "direction", "=", "Direction", ".", "BIDIRECTIONAL", ")", ":", "validate", ".", "is_network", "(", "network", ")", "log", ".", "info", "(", "\"Calculating causal nexus...\"", ")...
Return the causal nexus of the network.
[ "Return", "the", "causal", "nexus", "of", "the", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L636-L652
train
wmayner/pyphi
pyphi/actual.py
nice_true_ces
def nice_true_ces(tc): """Format a true |CauseEffectStructure|.""" cause_list = [] next_list = [] cause = '<--' effect = '-->' for event in tc: if event.direction == Direction.CAUSE: cause_list.append(["{0:.4f}".format(round(event.alpha, 4)), ev...
python
def nice_true_ces(tc): """Format a true |CauseEffectStructure|.""" cause_list = [] next_list = [] cause = '<--' effect = '-->' for event in tc: if event.direction == Direction.CAUSE: cause_list.append(["{0:.4f}".format(round(event.alpha, 4)), ev...
[ "def", "nice_true_ces", "(", "tc", ")", ":", "cause_list", "=", "[", "]", "next_list", "=", "[", "]", "cause", "=", "'<--'", "effect", "=", "'", "for", "event", "in", "tc", ":", "if", "event", ".", "direction", "==", "Direction", ".", "CAUSE", ":", ...
Format a true |CauseEffectStructure|.
[ "Format", "a", "true", "|CauseEffectStructure|", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L660-L678
train
wmayner/pyphi
pyphi/actual.py
true_ces
def true_ces(subsystem, previous_state, next_state): """Set of all sets of elements that have true causes and true effects. .. note:: Since the true |CauseEffectStructure| is always about the full system, the background conditions don't matter and the subsystem should be conditioned on ...
python
def true_ces(subsystem, previous_state, next_state): """Set of all sets of elements that have true causes and true effects. .. note:: Since the true |CauseEffectStructure| is always about the full system, the background conditions don't matter and the subsystem should be conditioned on ...
[ "def", "true_ces", "(", "subsystem", ",", "previous_state", ",", "next_state", ")", ":", "network", "=", "subsystem", ".", "network", "nodes", "=", "subsystem", ".", "node_indices", "state", "=", "subsystem", ".", "state", "_events", "=", "events", "(", "net...
Set of all sets of elements that have true causes and true effects. .. note:: Since the true |CauseEffectStructure| is always about the full system, the background conditions don't matter and the subsystem should be conditioned on the current state.
[ "Set", "of", "all", "sets", "of", "elements", "that", "have", "true", "causes", "and", "true", "effects", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L728-L751
train
wmayner/pyphi
pyphi/actual.py
true_events
def true_events(network, previous_state, current_state, next_state, indices=None, major_complex=None): """Return all mechanisms that have true causes and true effects within the complex. Args: network (Network): The network to analyze. previous_state (tuple[int]): The state ...
python
def true_events(network, previous_state, current_state, next_state, indices=None, major_complex=None): """Return all mechanisms that have true causes and true effects within the complex. Args: network (Network): The network to analyze. previous_state (tuple[int]): The state ...
[ "def", "true_events", "(", "network", ",", "previous_state", ",", "current_state", ",", "next_state", ",", "indices", "=", "None", ",", "major_complex", "=", "None", ")", ":", "if", "major_complex", ":", "nodes", "=", "major_complex", ".", "subsystem", ".", ...
Return all mechanisms that have true causes and true effects within the complex. Args: network (Network): The network to analyze. previous_state (tuple[int]): The state of the network at ``t - 1``. current_state (tuple[int]): The state of the network at ``t``. next_state (tuple[...
[ "Return", "all", "mechanisms", "that", "have", "true", "causes", "and", "true", "effects", "within", "the", "complex", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L754-L783
train
wmayner/pyphi
pyphi/actual.py
extrinsic_events
def extrinsic_events(network, previous_state, current_state, next_state, indices=None, major_complex=None): """Set of all mechanisms that are in the major complex but which have true causes and effects within the entire network. Args: network (Network): The network to analyze. ...
python
def extrinsic_events(network, previous_state, current_state, next_state, indices=None, major_complex=None): """Set of all mechanisms that are in the major complex but which have true causes and effects within the entire network. Args: network (Network): The network to analyze. ...
[ "def", "extrinsic_events", "(", "network", ",", "previous_state", ",", "current_state", ",", "next_state", ",", "indices", "=", "None", ",", "major_complex", "=", "None", ")", ":", "if", "major_complex", ":", "mc_nodes", "=", "major_complex", ".", "subsystem", ...
Set of all mechanisms that are in the major complex but which have true causes and effects within the entire network. Args: network (Network): The network to analyze. previous_state (tuple[int]): The state of the network at ``t - 1``. current_state (tuple[int]): The state of the network...
[ "Set", "of", "all", "mechanisms", "that", "are", "in", "the", "major", "complex", "but", "which", "have", "true", "causes", "and", "effects", "within", "the", "entire", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L786-L817
train
wmayner/pyphi
pyphi/actual.py
Transition.apply_cut
def apply_cut(self, cut): """Return a cut version of this transition.""" return Transition(self.network, self.before_state, self.after_state, self.cause_indices, self.effect_indices, cut)
python
def apply_cut(self, cut): """Return a cut version of this transition.""" return Transition(self.network, self.before_state, self.after_state, self.cause_indices, self.effect_indices, cut)
[ "def", "apply_cut", "(", "self", ",", "cut", ")", ":", "return", "Transition", "(", "self", ".", "network", ",", "self", ".", "before_state", ",", "self", ".", "after_state", ",", "self", ".", "cause_indices", ",", "self", ".", "effect_indices", ",", "cu...
Return a cut version of this transition.
[ "Return", "a", "cut", "version", "of", "this", "transition", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L176-L179
train
wmayner/pyphi
pyphi/actual.py
Transition.cause_repertoire
def cause_repertoire(self, mechanism, purview): """Return the cause repertoire.""" return self.repertoire(Direction.CAUSE, mechanism, purview)
python
def cause_repertoire(self, mechanism, purview): """Return the cause repertoire.""" return self.repertoire(Direction.CAUSE, mechanism, purview)
[ "def", "cause_repertoire", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "self", ".", "repertoire", "(", "Direction", ".", "CAUSE", ",", "mechanism", ",", "purview", ")" ]
Return the cause repertoire.
[ "Return", "the", "cause", "repertoire", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L181-L183
train
wmayner/pyphi
pyphi/actual.py
Transition.effect_repertoire
def effect_repertoire(self, mechanism, purview): """Return the effect repertoire.""" return self.repertoire(Direction.EFFECT, mechanism, purview)
python
def effect_repertoire(self, mechanism, purview): """Return the effect repertoire.""" return self.repertoire(Direction.EFFECT, mechanism, purview)
[ "def", "effect_repertoire", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "self", ".", "repertoire", "(", "Direction", ".", "EFFECT", ",", "mechanism", ",", "purview", ")" ]
Return the effect repertoire.
[ "Return", "the", "effect", "repertoire", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L185-L187
train
wmayner/pyphi
pyphi/actual.py
Transition.repertoire
def repertoire(self, direction, mechanism, purview): """Return the cause or effect repertoire function based on a direction. Args: direction (str): The temporal direction, specifiying the cause or effect repertoire. """ system = self.system[direction] ...
python
def repertoire(self, direction, mechanism, purview): """Return the cause or effect repertoire function based on a direction. Args: direction (str): The temporal direction, specifiying the cause or effect repertoire. """ system = self.system[direction] ...
[ "def", "repertoire", "(", "self", ",", "direction", ",", "mechanism", ",", "purview", ")", ":", "system", "=", "self", ".", "system", "[", "direction", "]", "node_labels", "=", "system", ".", "node_labels", "if", "not", "set", "(", "purview", ")", ".", ...
Return the cause or effect repertoire function based on a direction. Args: direction (str): The temporal direction, specifiying the cause or effect repertoire.
[ "Return", "the", "cause", "or", "effect", "repertoire", "function", "based", "on", "a", "direction", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L197-L215
train
wmayner/pyphi
pyphi/actual.py
Transition.state_probability
def state_probability(self, direction, repertoire, purview,): """Compute the probability of the purview in its current state given the repertoire. Collapses the dimensions of the repertoire that correspond to the purview nodes onto their state. All other dimension are already si...
python
def state_probability(self, direction, repertoire, purview,): """Compute the probability of the purview in its current state given the repertoire. Collapses the dimensions of the repertoire that correspond to the purview nodes onto their state. All other dimension are already si...
[ "def", "state_probability", "(", "self", ",", "direction", ",", "repertoire", ",", "purview", ",", ")", ":", "purview_state", "=", "self", ".", "purview_state", "(", "direction", ")", "index", "=", "tuple", "(", "node_state", "if", "node", "in", "purview", ...
Compute the probability of the purview in its current state given the repertoire. Collapses the dimensions of the repertoire that correspond to the purview nodes onto their state. All other dimension are already singular and thus receive 0 as the conditioning index. Returns: ...
[ "Compute", "the", "probability", "of", "the", "purview", "in", "its", "current", "state", "given", "the", "repertoire", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L217-L232
train
wmayner/pyphi
pyphi/actual.py
Transition.probability
def probability(self, direction, mechanism, purview): """Probability that the purview is in it's current state given the state of the mechanism. """ repertoire = self.repertoire(direction, mechanism, purview) return self.state_probability(direction, repertoire, purview)
python
def probability(self, direction, mechanism, purview): """Probability that the purview is in it's current state given the state of the mechanism. """ repertoire = self.repertoire(direction, mechanism, purview) return self.state_probability(direction, repertoire, purview)
[ "def", "probability", "(", "self", ",", "direction", ",", "mechanism", ",", "purview", ")", ":", "repertoire", "=", "self", ".", "repertoire", "(", "direction", ",", "mechanism", ",", "purview", ")", "return", "self", ".", "state_probability", "(", "directio...
Probability that the purview is in it's current state given the state of the mechanism.
[ "Probability", "that", "the", "purview", "is", "in", "it", "s", "current", "state", "given", "the", "state", "of", "the", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L234-L240
train
wmayner/pyphi
pyphi/actual.py
Transition.purview_state
def purview_state(self, direction): """The state of the purview when we are computing coefficients in ``direction``. For example, if we are computing the cause coefficient of a mechanism in ``after_state``, the direction is``CAUSE`` and the ``purview_state`` is ``before_state``....
python
def purview_state(self, direction): """The state of the purview when we are computing coefficients in ``direction``. For example, if we are computing the cause coefficient of a mechanism in ``after_state``, the direction is``CAUSE`` and the ``purview_state`` is ``before_state``....
[ "def", "purview_state", "(", "self", ",", "direction", ")", ":", "return", "{", "Direction", ".", "CAUSE", ":", "self", ".", "before_state", ",", "Direction", ".", "EFFECT", ":", "self", ".", "after_state", "}", "[", "direction", "]" ]
The state of the purview when we are computing coefficients in ``direction``. For example, if we are computing the cause coefficient of a mechanism in ``after_state``, the direction is``CAUSE`` and the ``purview_state`` is ``before_state``.
[ "The", "state", "of", "the", "purview", "when", "we", "are", "computing", "coefficients", "in", "direction", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L246-L257
train
wmayner/pyphi
pyphi/actual.py
Transition.mechanism_indices
def mechanism_indices(self, direction): """The indices of nodes in the mechanism system.""" return { Direction.CAUSE: self.effect_indices, Direction.EFFECT: self.cause_indices }[direction]
python
def mechanism_indices(self, direction): """The indices of nodes in the mechanism system.""" return { Direction.CAUSE: self.effect_indices, Direction.EFFECT: self.cause_indices }[direction]
[ "def", "mechanism_indices", "(", "self", ",", "direction", ")", ":", "return", "{", "Direction", ".", "CAUSE", ":", "self", ".", "effect_indices", ",", "Direction", ".", "EFFECT", ":", "self", ".", "cause_indices", "}", "[", "direction", "]" ]
The indices of nodes in the mechanism system.
[ "The", "indices", "of", "nodes", "in", "the", "mechanism", "system", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L265-L270
train
wmayner/pyphi
pyphi/actual.py
Transition.purview_indices
def purview_indices(self, direction): """The indices of nodes in the purview system.""" return { Direction.CAUSE: self.cause_indices, Direction.EFFECT: self.effect_indices }[direction]
python
def purview_indices(self, direction): """The indices of nodes in the purview system.""" return { Direction.CAUSE: self.cause_indices, Direction.EFFECT: self.effect_indices }[direction]
[ "def", "purview_indices", "(", "self", ",", "direction", ")", ":", "return", "{", "Direction", ".", "CAUSE", ":", "self", ".", "cause_indices", ",", "Direction", ".", "EFFECT", ":", "self", ".", "effect_indices", "}", "[", "direction", "]" ]
The indices of nodes in the purview system.
[ "The", "indices", "of", "nodes", "in", "the", "purview", "system", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L272-L277
train
wmayner/pyphi
pyphi/actual.py
Transition.cause_ratio
def cause_ratio(self, mechanism, purview): """The cause ratio of the ``purview`` given ``mechanism``.""" return self._ratio(Direction.CAUSE, mechanism, purview)
python
def cause_ratio(self, mechanism, purview): """The cause ratio of the ``purview`` given ``mechanism``.""" return self._ratio(Direction.CAUSE, mechanism, purview)
[ "def", "cause_ratio", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "self", ".", "_ratio", "(", "Direction", ".", "CAUSE", ",", "mechanism", ",", "purview", ")" ]
The cause ratio of the ``purview`` given ``mechanism``.
[ "The", "cause", "ratio", "of", "the", "purview", "given", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L283-L285
train
wmayner/pyphi
pyphi/actual.py
Transition.effect_ratio
def effect_ratio(self, mechanism, purview): """The effect ratio of the ``purview`` given ``mechanism``.""" return self._ratio(Direction.EFFECT, mechanism, purview)
python
def effect_ratio(self, mechanism, purview): """The effect ratio of the ``purview`` given ``mechanism``.""" return self._ratio(Direction.EFFECT, mechanism, purview)
[ "def", "effect_ratio", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "self", ".", "_ratio", "(", "Direction", ".", "EFFECT", ",", "mechanism", ",", "purview", ")" ]
The effect ratio of the ``purview`` given ``mechanism``.
[ "The", "effect", "ratio", "of", "the", "purview", "given", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L287-L289
train
wmayner/pyphi
pyphi/actual.py
Transition.partitioned_repertoire
def partitioned_repertoire(self, direction, partition): """Compute the repertoire over the partition in the given direction.""" system = self.system[direction] return system.partitioned_repertoire(direction, partition)
python
def partitioned_repertoire(self, direction, partition): """Compute the repertoire over the partition in the given direction.""" system = self.system[direction] return system.partitioned_repertoire(direction, partition)
[ "def", "partitioned_repertoire", "(", "self", ",", "direction", ",", "partition", ")", ":", "system", "=", "self", ".", "system", "[", "direction", "]", "return", "system", ".", "partitioned_repertoire", "(", "direction", ",", "partition", ")" ]
Compute the repertoire over the partition in the given direction.
[ "Compute", "the", "repertoire", "over", "the", "partition", "in", "the", "given", "direction", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L291-L294
train
wmayner/pyphi
pyphi/actual.py
Transition.partitioned_probability
def partitioned_probability(self, direction, partition): """Compute the probability of the mechanism over the purview in the partition. """ repertoire = self.partitioned_repertoire(direction, partition) return self.state_probability(direction, repertoire, partition.purview)
python
def partitioned_probability(self, direction, partition): """Compute the probability of the mechanism over the purview in the partition. """ repertoire = self.partitioned_repertoire(direction, partition) return self.state_probability(direction, repertoire, partition.purview)
[ "def", "partitioned_probability", "(", "self", ",", "direction", ",", "partition", ")", ":", "repertoire", "=", "self", ".", "partitioned_repertoire", "(", "direction", ",", "partition", ")", "return", "self", ".", "state_probability", "(", "direction", ",", "re...
Compute the probability of the mechanism over the purview in the partition.
[ "Compute", "the", "probability", "of", "the", "mechanism", "over", "the", "purview", "in", "the", "partition", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L296-L301
train
wmayner/pyphi
pyphi/actual.py
Transition.find_mip
def find_mip(self, direction, mechanism, purview, allow_neg=False): """Find the ratio minimum information partition for a mechanism over a purview. Args: direction (str): |CAUSE| or |EFFECT| mechanism (tuple[int]): A mechanism. purview (tuple[int]): A purview...
python
def find_mip(self, direction, mechanism, purview, allow_neg=False): """Find the ratio minimum information partition for a mechanism over a purview. Args: direction (str): |CAUSE| or |EFFECT| mechanism (tuple[int]): A mechanism. purview (tuple[int]): A purview...
[ "def", "find_mip", "(", "self", ",", "direction", ",", "mechanism", ",", "purview", ",", "allow_neg", "=", "False", ")", ":", "alpha_min", "=", "float", "(", "'inf'", ")", "probability", "=", "self", ".", "probability", "(", "direction", ",", "mechanism", ...
Find the ratio minimum information partition for a mechanism over a purview. Args: direction (str): |CAUSE| or |EFFECT| mechanism (tuple[int]): A mechanism. purview (tuple[int]): A purview. Keyword Args: allow_neg (boolean): If true, ``alpha`` is...
[ "Find", "the", "ratio", "minimum", "information", "partition", "for", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L307-L361
train
wmayner/pyphi
pyphi/actual.py
Transition.find_causal_link
def find_causal_link(self, direction, mechanism, purviews=False, allow_neg=False): """Return the maximally irreducible cause or effect ratio for a mechanism. Args: direction (str): The temporal direction, specifying cause or effect. ...
python
def find_causal_link(self, direction, mechanism, purviews=False, allow_neg=False): """Return the maximally irreducible cause or effect ratio for a mechanism. Args: direction (str): The temporal direction, specifying cause or effect. ...
[ "def", "find_causal_link", "(", "self", ",", "direction", ",", "mechanism", ",", "purviews", "=", "False", ",", "allow_neg", "=", "False", ")", ":", "purviews", "=", "self", ".", "potential_purviews", "(", "direction", ",", "mechanism", ",", "purviews", ")",...
Return the maximally irreducible cause or effect ratio for a mechanism. Args: direction (str): The temporal direction, specifying cause or effect. mechanism (tuple[int]): The mechanism to be tested for irreducibility. Keyword Args: ...
[ "Return", "the", "maximally", "irreducible", "cause", "or", "effect", "ratio", "for", "a", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L387-L420
train
wmayner/pyphi
pyphi/actual.py
Transition.find_actual_cause
def find_actual_cause(self, mechanism, purviews=False): """Return the actual cause of a mechanism.""" return self.find_causal_link(Direction.CAUSE, mechanism, purviews)
python
def find_actual_cause(self, mechanism, purviews=False): """Return the actual cause of a mechanism.""" return self.find_causal_link(Direction.CAUSE, mechanism, purviews)
[ "def", "find_actual_cause", "(", "self", ",", "mechanism", ",", "purviews", "=", "False", ")", ":", "return", "self", ".", "find_causal_link", "(", "Direction", ".", "CAUSE", ",", "mechanism", ",", "purviews", ")" ]
Return the actual cause of a mechanism.
[ "Return", "the", "actual", "cause", "of", "a", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L422-L424
train
wmayner/pyphi
pyphi/actual.py
Transition.find_actual_effect
def find_actual_effect(self, mechanism, purviews=False): """Return the actual effect of a mechanism.""" return self.find_causal_link(Direction.EFFECT, mechanism, purviews)
python
def find_actual_effect(self, mechanism, purviews=False): """Return the actual effect of a mechanism.""" return self.find_causal_link(Direction.EFFECT, mechanism, purviews)
[ "def", "find_actual_effect", "(", "self", ",", "mechanism", ",", "purviews", "=", "False", ")", ":", "return", "self", ".", "find_causal_link", "(", "Direction", ".", "EFFECT", ",", "mechanism", ",", "purviews", ")" ]
Return the actual effect of a mechanism.
[ "Return", "the", "actual", "effect", "of", "a", "mechanism", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L426-L428
train
wmayner/pyphi
pyphi/db.py
find
def find(key): """Return the value associated with a key. If there is no value with the given key, returns ``None``. """ docs = list(collection.find({KEY_FIELD: key})) # Return None if we didn't find anything. if not docs: return None pickled_value = docs[0][VALUE_FIELD] # Unpic...
python
def find(key): """Return the value associated with a key. If there is no value with the given key, returns ``None``. """ docs = list(collection.find({KEY_FIELD: key})) # Return None if we didn't find anything. if not docs: return None pickled_value = docs[0][VALUE_FIELD] # Unpic...
[ "def", "find", "(", "key", ")", ":", "docs", "=", "list", "(", "collection", ".", "find", "(", "{", "KEY_FIELD", ":", "key", "}", ")", ")", "if", "not", "docs", ":", "return", "None", "pickled_value", "=", "docs", "[", "0", "]", "[", "VALUE_FIELD",...
Return the value associated with a key. If there is no value with the given key, returns ``None``.
[ "Return", "the", "value", "associated", "with", "a", "key", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/db.py#L34-L45
train
wmayner/pyphi
pyphi/db.py
insert
def insert(key, value): """Store a value with a key. If the key is already present in the database, this does nothing. """ # Pickle the value. value = pickle.dumps(value, protocol=constants.PICKLE_PROTOCOL) # Store the value as binary data in a document. doc = { KEY_FIELD: key, ...
python
def insert(key, value): """Store a value with a key. If the key is already present in the database, this does nothing. """ # Pickle the value. value = pickle.dumps(value, protocol=constants.PICKLE_PROTOCOL) # Store the value as binary data in a document. doc = { KEY_FIELD: key, ...
[ "def", "insert", "(", "key", ",", "value", ")", ":", "value", "=", "pickle", ".", "dumps", "(", "value", ",", "protocol", "=", "constants", ".", "PICKLE_PROTOCOL", ")", "doc", "=", "{", "KEY_FIELD", ":", "key", ",", "VALUE_FIELD", ":", "Binary", "(", ...
Store a value with a key. If the key is already present in the database, this does nothing.
[ "Store", "a", "value", "with", "a", "key", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/db.py#L48-L65
train
wmayner/pyphi
pyphi/db.py
generate_key
def generate_key(filtered_args): """Get a key from some input. This function should be used whenever a key is needed, to keep keys consistent. """ # Convert the value to a (potentially singleton) tuple to be consistent # with joblib.filtered_args. if isinstance(filtered_args, Iterable): ...
python
def generate_key(filtered_args): """Get a key from some input. This function should be used whenever a key is needed, to keep keys consistent. """ # Convert the value to a (potentially singleton) tuple to be consistent # with joblib.filtered_args. if isinstance(filtered_args, Iterable): ...
[ "def", "generate_key", "(", "filtered_args", ")", ":", "if", "isinstance", "(", "filtered_args", ",", "Iterable", ")", ":", "return", "hash", "(", "tuple", "(", "filtered_args", ")", ")", "return", "hash", "(", "(", "filtered_args", ",", ")", ")" ]
Get a key from some input. This function should be used whenever a key is needed, to keep keys consistent.
[ "Get", "a", "key", "from", "some", "input", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/db.py#L69-L79
train
wmayner/pyphi
pyphi/memory.py
cache
def cache(ignore=None): """Decorator for memoizing a function using either the filesystem or a database. """ def decorator(func): # Initialize both cached versions joblib_cached = constants.joblib_memory.cache(func, ignore=ignore) db_cached = DbMemoizedFunc(func, ignore) ...
python
def cache(ignore=None): """Decorator for memoizing a function using either the filesystem or a database. """ def decorator(func): # Initialize both cached versions joblib_cached = constants.joblib_memory.cache(func, ignore=ignore) db_cached = DbMemoizedFunc(func, ignore) ...
[ "def", "cache", "(", "ignore", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "joblib_cached", "=", "constants", ".", "joblib_memory", ".", "cache", "(", "func", ",", "ignore", "=", "ignore", ")", "db_cached", "=", "DbMemoizedFunc", "(...
Decorator for memoizing a function using either the filesystem or a database.
[ "Decorator", "for", "memoizing", "a", "function", "using", "either", "the", "filesystem", "or", "a", "database", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/memory.py#L18-L39
train
wmayner/pyphi
pyphi/memory.py
DbMemoizedFunc.get_output_key
def get_output_key(self, args, kwargs): """Return the key that the output should be cached with, given arguments, keyword arguments, and a list of arguments to ignore. """ # Get a dictionary mapping argument names to argument values where # ignored arguments are omitted. ...
python
def get_output_key(self, args, kwargs): """Return the key that the output should be cached with, given arguments, keyword arguments, and a list of arguments to ignore. """ # Get a dictionary mapping argument names to argument values where # ignored arguments are omitted. ...
[ "def", "get_output_key", "(", "self", ",", "args", ",", "kwargs", ")", ":", "filtered_args", "=", "joblib", ".", "func_inspect", ".", "filter_args", "(", "self", ".", "func", ",", "self", ".", "ignore", ",", "args", ",", "kwargs", ")", "filtered_args", "...
Return the key that the output should be cached with, given arguments, keyword arguments, and a list of arguments to ignore.
[ "Return", "the", "key", "that", "the", "output", "should", "be", "cached", "with", "given", "arguments", "keyword", "arguments", "and", "a", "list", "of", "arguments", "to", "ignore", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/memory.py#L73-L84
train
wmayner/pyphi
pyphi/memory.py
DbMemoizedFunc.load_output
def load_output(self, args, kwargs): """Return cached output.""" return db.find(self.get_output_key(args, kwargs))
python
def load_output(self, args, kwargs): """Return cached output.""" return db.find(self.get_output_key(args, kwargs))
[ "def", "load_output", "(", "self", ",", "args", ",", "kwargs", ")", ":", "return", "db", ".", "find", "(", "self", ".", "get_output_key", "(", "args", ",", "kwargs", ")", ")" ]
Return cached output.
[ "Return", "cached", "output", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/memory.py#L86-L88
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.cache_info
def cache_info(self): """Report repertoire cache statistics.""" return { 'single_node_repertoire': self._single_node_repertoire_cache.info(), 'repertoire': self._repertoire_cache.info(), 'mice': self._mice_cache.info() }
python
def cache_info(self): """Report repertoire cache statistics.""" return { 'single_node_repertoire': self._single_node_repertoire_cache.info(), 'repertoire': self._repertoire_cache.info(), 'mice': self._mice_cache.info() }
[ "def", "cache_info", "(", "self", ")", ":", "return", "{", "'single_node_repertoire'", ":", "self", ".", "_single_node_repertoire_cache", ".", "info", "(", ")", ",", "'repertoire'", ":", "self", ".", "_repertoire_cache", ".", "info", "(", ")", ",", "'mice'", ...
Report repertoire cache statistics.
[ "Report", "repertoire", "cache", "statistics", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L171-L178
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.clear_caches
def clear_caches(self): """Clear the mice and repertoire caches.""" self._single_node_repertoire_cache.clear() self._repertoire_cache.clear() self._mice_cache.clear()
python
def clear_caches(self): """Clear the mice and repertoire caches.""" self._single_node_repertoire_cache.clear() self._repertoire_cache.clear() self._mice_cache.clear()
[ "def", "clear_caches", "(", "self", ")", ":", "self", ".", "_single_node_repertoire_cache", ".", "clear", "(", ")", "self", ".", "_repertoire_cache", ".", "clear", "(", ")", "self", ".", "_mice_cache", ".", "clear", "(", ")" ]
Clear the mice and repertoire caches.
[ "Clear", "the", "mice", "and", "repertoire", "caches", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L180-L184
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.apply_cut
def apply_cut(self, cut): """Return a cut version of this |Subsystem|. Args: cut (Cut): The cut to apply to this |Subsystem|. Returns: Subsystem: The cut subsystem. """ return Subsystem(self.network, self.state, self.node_indices, ...
python
def apply_cut(self, cut): """Return a cut version of this |Subsystem|. Args: cut (Cut): The cut to apply to this |Subsystem|. Returns: Subsystem: The cut subsystem. """ return Subsystem(self.network, self.state, self.node_indices, ...
[ "def", "apply_cut", "(", "self", ",", "cut", ")", ":", "return", "Subsystem", "(", "self", ".", "network", ",", "self", ".", "state", ",", "self", ".", "node_indices", ",", "cut", "=", "cut", ",", "mice_cache", "=", "self", ".", "_mice_cache", ")" ]
Return a cut version of this |Subsystem|. Args: cut (Cut): The cut to apply to this |Subsystem|. Returns: Subsystem: The cut subsystem.
[ "Return", "a", "cut", "version", "of", "this", "|Subsystem|", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L247-L257
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.indices2nodes
def indices2nodes(self, indices): """Return |Nodes| for these indices. Args: indices (tuple[int]): The indices in question. Returns: tuple[Node]: The |Node| objects corresponding to these indices. Raises: ValueError: If requested indices are not in ...
python
def indices2nodes(self, indices): """Return |Nodes| for these indices. Args: indices (tuple[int]): The indices in question. Returns: tuple[Node]: The |Node| objects corresponding to these indices. Raises: ValueError: If requested indices are not in ...
[ "def", "indices2nodes", "(", "self", ",", "indices", ")", ":", "if", "set", "(", "indices", ")", "-", "set", "(", "self", ".", "node_indices", ")", ":", "raise", "ValueError", "(", "\"`indices` must be a subset of the Subsystem's indices.\"", ")", "return", "tup...
Return |Nodes| for these indices. Args: indices (tuple[int]): The indices in question. Returns: tuple[Node]: The |Node| objects corresponding to these indices. Raises: ValueError: If requested indices are not in the subsystem.
[ "Return", "|Nodes|", "for", "these", "indices", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L259-L274
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.cause_repertoire
def cause_repertoire(self, mechanism, purview): """Return the cause repertoire of a mechanism over a purview. Args: mechanism (tuple[int]): The mechanism for which to calculate the cause repertoire. purview (tuple[int]): The purview over which to calculate the ...
python
def cause_repertoire(self, mechanism, purview): """Return the cause repertoire of a mechanism over a purview. Args: mechanism (tuple[int]): The mechanism for which to calculate the cause repertoire. purview (tuple[int]): The purview over which to calculate the ...
[ "def", "cause_repertoire", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "if", "not", "purview", ":", "return", "np", ".", "array", "(", "[", "1.0", "]", ")", "if", "not", "mechanism", ":", "return", "max_entropy_distribution", "(", "purview", ...
Return the cause repertoire of a mechanism over a purview. Args: mechanism (tuple[int]): The mechanism for which to calculate the cause repertoire. purview (tuple[int]): The purview over which to calculate the cause repertoire. Returns: ...
[ "Return", "the", "cause", "repertoire", "of", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L290-L330
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.effect_repertoire
def effect_repertoire(self, mechanism, purview): """Return the effect repertoire of a mechanism over a purview. Args: mechanism (tuple[int]): The mechanism for which to calculate the effect repertoire. purview (tuple[int]): The purview over which to calculate the...
python
def effect_repertoire(self, mechanism, purview): """Return the effect repertoire of a mechanism over a purview. Args: mechanism (tuple[int]): The mechanism for which to calculate the effect repertoire. purview (tuple[int]): The purview over which to calculate the...
[ "def", "effect_repertoire", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "if", "not", "purview", ":", "return", "np", ".", "array", "(", "[", "1.0", "]", ")", "mechanism", "=", "frozenset", "(", "mechanism", ")", "joint", "=", "np", ".", ...
Return the effect repertoire of a mechanism over a purview. Args: mechanism (tuple[int]): The mechanism for which to calculate the effect repertoire. purview (tuple[int]): The purview over which to calculate the effect repertoire. Returns: ...
[ "Return", "the", "effect", "repertoire", "of", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L348-L380
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.repertoire
def repertoire(self, direction, mechanism, purview): """Return the cause or effect repertoire based on a direction. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The mechanism for which to calculate the repertoire. purview ...
python
def repertoire(self, direction, mechanism, purview): """Return the cause or effect repertoire based on a direction. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The mechanism for which to calculate the repertoire. purview ...
[ "def", "repertoire", "(", "self", ",", "direction", ",", "mechanism", ",", "purview", ")", ":", "if", "direction", "==", "Direction", ".", "CAUSE", ":", "return", "self", ".", "cause_repertoire", "(", "mechanism", ",", "purview", ")", "elif", "direction", ...
Return the cause or effect repertoire based on a direction. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The mechanism for which to calculate the repertoire. purview (tuple[int]): The purview over which to calculate the ...
[ "Return", "the", "cause", "or", "effect", "repertoire", "based", "on", "a", "direction", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L382-L404
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.partitioned_repertoire
def partitioned_repertoire(self, direction, partition): """Compute the repertoire of a partitioned mechanism and purview.""" repertoires = [ self.repertoire(direction, part.mechanism, part.purview) for part in partition ] return functools.reduce(np.multiply, reper...
python
def partitioned_repertoire(self, direction, partition): """Compute the repertoire of a partitioned mechanism and purview.""" repertoires = [ self.repertoire(direction, part.mechanism, part.purview) for part in partition ] return functools.reduce(np.multiply, reper...
[ "def", "partitioned_repertoire", "(", "self", ",", "direction", ",", "partition", ")", ":", "repertoires", "=", "[", "self", ".", "repertoire", "(", "direction", ",", "part", ".", "mechanism", ",", "part", ".", "purview", ")", "for", "part", "in", "partiti...
Compute the repertoire of a partitioned mechanism and purview.
[ "Compute", "the", "repertoire", "of", "a", "partitioned", "mechanism", "and", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L424-L430
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.expand_repertoire
def expand_repertoire(self, direction, repertoire, new_purview=None): """Distribute an effect repertoire over a larger purview. Args: direction (Direction): |CAUSE| or |EFFECT|. repertoire (np.ndarray): The repertoire to expand. Keyword Args: new_purview (tu...
python
def expand_repertoire(self, direction, repertoire, new_purview=None): """Distribute an effect repertoire over a larger purview. Args: direction (Direction): |CAUSE| or |EFFECT|. repertoire (np.ndarray): The repertoire to expand. Keyword Args: new_purview (tu...
[ "def", "expand_repertoire", "(", "self", ",", "direction", ",", "repertoire", ",", "new_purview", "=", "None", ")", ":", "if", "repertoire", "is", "None", ":", "return", "None", "purview", "=", "distribution", ".", "purview", "(", "repertoire", ")", "if", ...
Distribute an effect repertoire over a larger purview. Args: direction (Direction): |CAUSE| or |EFFECT|. repertoire (np.ndarray): The repertoire to expand. Keyword Args: new_purview (tuple[int]): The new purview to expand the repertoire over. If ``No...
[ "Distribute", "an", "effect", "repertoire", "over", "a", "larger", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L432-L470
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.cause_info
def cause_info(self, mechanism, purview): """Return the cause information for a mechanism over a purview.""" return repertoire_distance( Direction.CAUSE, self.cause_repertoire(mechanism, purview), self.unconstrained_cause_repertoire(purview) )
python
def cause_info(self, mechanism, purview): """Return the cause information for a mechanism over a purview.""" return repertoire_distance( Direction.CAUSE, self.cause_repertoire(mechanism, purview), self.unconstrained_cause_repertoire(purview) )
[ "def", "cause_info", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "repertoire_distance", "(", "Direction", ".", "CAUSE", ",", "self", ".", "cause_repertoire", "(", "mechanism", ",", "purview", ")", ",", "self", ".", "unconstrained_cause_r...
Return the cause information for a mechanism over a purview.
[ "Return", "the", "cause", "information", "for", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L484-L490
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.effect_info
def effect_info(self, mechanism, purview): """Return the effect information for a mechanism over a purview.""" return repertoire_distance( Direction.EFFECT, self.effect_repertoire(mechanism, purview), self.unconstrained_effect_repertoire(purview) )
python
def effect_info(self, mechanism, purview): """Return the effect information for a mechanism over a purview.""" return repertoire_distance( Direction.EFFECT, self.effect_repertoire(mechanism, purview), self.unconstrained_effect_repertoire(purview) )
[ "def", "effect_info", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "repertoire_distance", "(", "Direction", ".", "EFFECT", ",", "self", ".", "effect_repertoire", "(", "mechanism", ",", "purview", ")", ",", "self", ".", "unconstrained_effe...
Return the effect information for a mechanism over a purview.
[ "Return", "the", "effect", "information", "for", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L492-L498
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.cause_effect_info
def cause_effect_info(self, mechanism, purview): """Return the cause-effect information for a mechanism over a purview. This is the minimum of the cause and effect information. """ return min(self.cause_info(mechanism, purview), self.effect_info(mechanism, purview))
python
def cause_effect_info(self, mechanism, purview): """Return the cause-effect information for a mechanism over a purview. This is the minimum of the cause and effect information. """ return min(self.cause_info(mechanism, purview), self.effect_info(mechanism, purview))
[ "def", "cause_effect_info", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "min", "(", "self", ".", "cause_info", "(", "mechanism", ",", "purview", ")", ",", "self", ".", "effect_info", "(", "mechanism", ",", "purview", ")", ")" ]
Return the cause-effect information for a mechanism over a purview. This is the minimum of the cause and effect information.
[ "Return", "the", "cause", "-", "effect", "information", "for", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L500-L506
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.evaluate_partition
def evaluate_partition(self, direction, mechanism, purview, partition, repertoire=None): """Return the |small_phi| of a mechanism over a purview for the given partition. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): ...
python
def evaluate_partition(self, direction, mechanism, purview, partition, repertoire=None): """Return the |small_phi| of a mechanism over a purview for the given partition. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): ...
[ "def", "evaluate_partition", "(", "self", ",", "direction", ",", "mechanism", ",", "purview", ",", "partition", ",", "repertoire", "=", "None", ")", ":", "if", "repertoire", "is", "None", ":", "repertoire", "=", "self", ".", "repertoire", "(", "direction", ...
Return the |small_phi| of a mechanism over a purview for the given partition. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The nodes in the mechanism. purview (tuple[int]): The nodes in the purview. partition (Bipartition): Th...
[ "Return", "the", "|small_phi|", "of", "a", "mechanism", "over", "a", "purview", "for", "the", "given", "partition", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L511-L539
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.find_mip
def find_mip(self, direction, mechanism, purview): """Return the minimum information partition for a mechanism over a purview. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The nodes in the mechanism. purview (tuple[int]): The node...
python
def find_mip(self, direction, mechanism, purview): """Return the minimum information partition for a mechanism over a purview. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The nodes in the mechanism. purview (tuple[int]): The node...
[ "def", "find_mip", "(", "self", ",", "direction", ",", "mechanism", ",", "purview", ")", ":", "if", "not", "purview", ":", "return", "_null_ria", "(", "direction", ",", "mechanism", ",", "purview", ")", "repertoire", "=", "self", ".", "repertoire", "(", ...
Return the minimum information partition for a mechanism over a purview. Args: direction (Direction): |CAUSE| or |EFFECT|. mechanism (tuple[int]): The nodes in the mechanism. purview (tuple[int]): The nodes in the purview. Returns: RepertoireIrre...
[ "Return", "the", "minimum", "information", "partition", "for", "a", "mechanism", "over", "a", "purview", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L541-L598
train
wmayner/pyphi
pyphi/subsystem.py
Subsystem.cause_mip
def cause_mip(self, mechanism, purview): """Return the irreducibility analysis for the cause MIP. Alias for |find_mip()| with ``direction`` set to |CAUSE|. """ return self.find_mip(Direction.CAUSE, mechanism, purview)
python
def cause_mip(self, mechanism, purview): """Return the irreducibility analysis for the cause MIP. Alias for |find_mip()| with ``direction`` set to |CAUSE|. """ return self.find_mip(Direction.CAUSE, mechanism, purview)
[ "def", "cause_mip", "(", "self", ",", "mechanism", ",", "purview", ")", ":", "return", "self", ".", "find_mip", "(", "Direction", ".", "CAUSE", ",", "mechanism", ",", "purview", ")" ]
Return the irreducibility analysis for the cause MIP. Alias for |find_mip()| with ``direction`` set to |CAUSE|.
[ "Return", "the", "irreducibility", "analysis", "for", "the", "cause", "MIP", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L600-L605
train