partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
ReplLockManager.tryAcquire
Attempt to acquire lock. :param lockID: unique lock identifier. :type lockID: str :param sync: True - to wait until lock is acquired or failed to acquire. :type sync: bool :param callback: if sync is False - callback will be called with operation result. :type callback: ...
pysyncobj/batteries.py
def tryAcquire(self, lockID, callback=None, sync=False, timeout=None): """Attempt to acquire lock. :param lockID: unique lock identifier. :type lockID: str :param sync: True - to wait until lock is acquired or failed to acquire. :type sync: bool :param callback: if sync ...
def tryAcquire(self, lockID, callback=None, sync=False, timeout=None): """Attempt to acquire lock. :param lockID: unique lock identifier. :type lockID: str :param sync: True - to wait until lock is acquired or failed to acquire. :type sync: bool :param callback: if sync ...
[ "Attempt", "to", "acquire", "lock", "." ]
bakwc/PySyncObj
python
https://github.com/bakwc/PySyncObj/blob/be3b0aaa932d5156f5df140c23c962430f51b7b8/pysyncobj/batteries.py#L496-L509
[ "def", "tryAcquire", "(", "self", ",", "lockID", ",", "callback", "=", "None", ",", "sync", "=", "False", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "__lockImpl", ".", "acquire", "(", "lockID", ",", "self", ".", "__selfID", ",", "t...
be3b0aaa932d5156f5df140c23c962430f51b7b8
test
ReplLockManager.isAcquired
Check if lock is acquired by ourselves. :param lockID: unique lock identifier. :type lockID: str :return True if lock is acquired by ourselves.
pysyncobj/batteries.py
def isAcquired(self, lockID): """Check if lock is acquired by ourselves. :param lockID: unique lock identifier. :type lockID: str :return True if lock is acquired by ourselves. """ return self.__lockImpl.isAcquired(lockID, self.__selfID, time.time())
def isAcquired(self, lockID): """Check if lock is acquired by ourselves. :param lockID: unique lock identifier. :type lockID: str :return True if lock is acquired by ourselves. """ return self.__lockImpl.isAcquired(lockID, self.__selfID, time.time())
[ "Check", "if", "lock", "is", "acquired", "by", "ourselves", "." ]
bakwc/PySyncObj
python
https://github.com/bakwc/PySyncObj/blob/be3b0aaa932d5156f5df140c23c962430f51b7b8/pysyncobj/batteries.py#L511-L518
[ "def", "isAcquired", "(", "self", ",", "lockID", ")", ":", "return", "self", ".", "__lockImpl", ".", "isAcquired", "(", "lockID", ",", "self", ".", "__selfID", ",", "time", ".", "time", "(", ")", ")" ]
be3b0aaa932d5156f5df140c23c962430f51b7b8
test
ReplLockManager.release
Release previously-acquired lock. :param lockID: unique lock identifier. :type lockID: str :param sync: True - to wait until lock is released or failed to release. :type sync: bool :param callback: if sync is False - callback will be called with operation result. :type ...
pysyncobj/batteries.py
def release(self, lockID, callback=None, sync=False, timeout=None): """ Release previously-acquired lock. :param lockID: unique lock identifier. :type lockID: str :param sync: True - to wait until lock is released or failed to release. :type sync: bool :param ca...
def release(self, lockID, callback=None, sync=False, timeout=None): """ Release previously-acquired lock. :param lockID: unique lock identifier. :type lockID: str :param sync: True - to wait until lock is released or failed to release. :type sync: bool :param ca...
[ "Release", "previously", "-", "acquired", "lock", "." ]
bakwc/PySyncObj
python
https://github.com/bakwc/PySyncObj/blob/be3b0aaa932d5156f5df140c23c962430f51b7b8/pysyncobj/batteries.py#L520-L533
[ "def", "release", "(", "self", ",", "lockID", ",", "callback", "=", "None", ",", "sync", "=", "False", ",", "timeout", "=", "None", ")", ":", "self", ".", "__lockImpl", ".", "release", "(", "lockID", ",", "self", ".", "__selfID", ",", "callback", "="...
be3b0aaa932d5156f5df140c23c962430f51b7b8
test
check
Decorator which wraps checks and returns an error response on failure.
watchman/decorators.py
def check(func): """ Decorator which wraps checks and returns an error response on failure. """ def wrapped(*args, **kwargs): check_name = func.__name__ arg_name = None if args: arg_name = args[0] try: if arg_name: logger.debug("Che...
def check(func): """ Decorator which wraps checks and returns an error response on failure. """ def wrapped(*args, **kwargs): check_name = func.__name__ arg_name = None if args: arg_name = args[0] try: if arg_name: logger.debug("Che...
[ "Decorator", "which", "wraps", "checks", "and", "returns", "an", "error", "response", "on", "failure", "." ]
mwarkentin/django-watchman
python
https://github.com/mwarkentin/django-watchman/blob/6ef98ba54dc52f27e7b42d42028b59dc67550268/watchman/decorators.py#L14-L54
[ "def", "check", "(", "func", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "check_name", "=", "func", ".", "__name__", "arg_name", "=", "None", "if", "args", ":", "arg_name", "=", "args", "[", "0", "]", "try", "...
6ef98ba54dc52f27e7b42d42028b59dc67550268
test
token_required
Decorator which ensures that one of the WATCHMAN_TOKENS is provided if set. WATCHMAN_TOKEN_NAME can also be set if the token GET parameter must be customized.
watchman/decorators.py
def token_required(view_func): """ Decorator which ensures that one of the WATCHMAN_TOKENS is provided if set. WATCHMAN_TOKEN_NAME can also be set if the token GET parameter must be customized. """ def _parse_auth_header(auth_header): """ Parse the `Authorization` header ...
def token_required(view_func): """ Decorator which ensures that one of the WATCHMAN_TOKENS is provided if set. WATCHMAN_TOKEN_NAME can also be set if the token GET parameter must be customized. """ def _parse_auth_header(auth_header): """ Parse the `Authorization` header ...
[ "Decorator", "which", "ensures", "that", "one", "of", "the", "WATCHMAN_TOKENS", "is", "provided", "if", "set", "." ]
mwarkentin/django-watchman
python
https://github.com/mwarkentin/django-watchman/blob/6ef98ba54dc52f27e7b42d42028b59dc67550268/watchman/decorators.py#L57-L111
[ "def", "token_required", "(", "view_func", ")", ":", "def", "_parse_auth_header", "(", "auth_header", ")", ":", "\"\"\"\n Parse the `Authorization` header\n\n Expected format: `WATCHMAN-TOKEN Token=\"ABC123\"`\n \"\"\"", "# TODO: Figure out full set of allowed characte...
6ef98ba54dc52f27e7b42d42028b59dc67550268
test
set_hosts
Sets the Elasticsearch hosts to use Args: hosts (str): A single hostname or URL, or list of hostnames or URLs use_ssl (bool): Use a HTTPS connection to the server ssl_cert_path (str): Path to the certificate chain
parsedmarc/elastic.py
def set_hosts(hosts, use_ssl=False, ssl_cert_path=None): """ Sets the Elasticsearch hosts to use Args: hosts (str): A single hostname or URL, or list of hostnames or URLs use_ssl (bool): Use a HTTPS connection to the server ssl_cert_path (str): Path to the certificate chain """ ...
def set_hosts(hosts, use_ssl=False, ssl_cert_path=None): """ Sets the Elasticsearch hosts to use Args: hosts (str): A single hostname or URL, or list of hostnames or URLs use_ssl (bool): Use a HTTPS connection to the server ssl_cert_path (str): Path to the certificate chain """ ...
[ "Sets", "the", "Elasticsearch", "hosts", "to", "use" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/elastic.py#L172-L194
[ "def", "set_hosts", "(", "hosts", ",", "use_ssl", "=", "False", ",", "ssl_cert_path", "=", "None", ")", ":", "if", "type", "(", "hosts", ")", "!=", "list", ":", "hosts", "=", "[", "hosts", "]", "conn_params", "=", "{", "\"hosts\"", ":", "hosts", ",",...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
create_indexes
Create Elasticsearch indexes Args: names (list): A list of index names settings (dict): Index settings
parsedmarc/elastic.py
def create_indexes(names, settings=None): """ Create Elasticsearch indexes Args: names (list): A list of index names settings (dict): Index settings """ for name in names: index = Index(name) try: if not index.exists(): logger.debug("Crea...
def create_indexes(names, settings=None): """ Create Elasticsearch indexes Args: names (list): A list of index names settings (dict): Index settings """ for name in names: index = Index(name) try: if not index.exists(): logger.debug("Crea...
[ "Create", "Elasticsearch", "indexes" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/elastic.py#L197-L219
[ "def", "create_indexes", "(", "names", ",", "settings", "=", "None", ")", ":", "for", "name", "in", "names", ":", "index", "=", "Index", "(", "name", ")", "try", ":", "if", "not", "index", ".", "exists", "(", ")", ":", "logger", ".", "debug", "(", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
migrate_indexes
Updates index mappings Args: aggregate_indexes (list): A list of aggregate index names forensic_indexes (list): A list of forensic index names
parsedmarc/elastic.py
def migrate_indexes(aggregate_indexes=None, forensic_indexes=None): """ Updates index mappings Args: aggregate_indexes (list): A list of aggregate index names forensic_indexes (list): A list of forensic index names """ version = 2 if aggregate_indexes is None: aggregate_...
def migrate_indexes(aggregate_indexes=None, forensic_indexes=None): """ Updates index mappings Args: aggregate_indexes (list): A list of aggregate index names forensic_indexes (list): A list of forensic index names """ version = 2 if aggregate_indexes is None: aggregate_...
[ "Updates", "index", "mappings" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/elastic.py#L222-L269
[ "def", "migrate_indexes", "(", "aggregate_indexes", "=", "None", ",", "forensic_indexes", "=", "None", ")", ":", "version", "=", "2", "if", "aggregate_indexes", "is", "None", ":", "aggregate_indexes", "=", "[", "]", "if", "forensic_indexes", "is", "None", ":",...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
save_aggregate_report_to_elasticsearch
Saves a parsed DMARC aggregate report to ElasticSearch Args: aggregate_report (OrderedDict): A parsed forensic report index_suffix (str): The suffix of the name of the index to save to monthly_indexes (bool): Use monthly indexes instead of daily indexes Raises: AlreadySaved
parsedmarc/elastic.py
def save_aggregate_report_to_elasticsearch(aggregate_report, index_suffix=None, monthly_indexes=False): """ Saves a parsed DMARC aggregate report to ElasticSearch Args: aggregate_report (OrderedDict): A parsed for...
def save_aggregate_report_to_elasticsearch(aggregate_report, index_suffix=None, monthly_indexes=False): """ Saves a parsed DMARC aggregate report to ElasticSearch Args: aggregate_report (OrderedDict): A parsed for...
[ "Saves", "a", "parsed", "DMARC", "aggregate", "report", "to", "ElasticSearch" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/elastic.py#L272-L384
[ "def", "save_aggregate_report_to_elasticsearch", "(", "aggregate_report", ",", "index_suffix", "=", "None", ",", "monthly_indexes", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Saving aggregate report to Elasticsearch\"", ")", "aggregate_report", "=", "aggregat...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
save_forensic_report_to_elasticsearch
Saves a parsed DMARC forensic report to ElasticSearch Args: forensic_report (OrderedDict): A parsed forensic report index_suffix (str): The suffix of the name of the index to save to monthly_indexes (bool): Use monthly indexes instead of daily ...
parsedmarc/elastic.py
def save_forensic_report_to_elasticsearch(forensic_report, index_suffix=None, monthly_indexes=False): """ Saves a parsed DMARC forensic report to ElasticSearch Args: forensic_report (OrderedDict): A pars...
def save_forensic_report_to_elasticsearch(forensic_report, index_suffix=None, monthly_indexes=False): """ Saves a parsed DMARC forensic report to ElasticSearch Args: forensic_report (OrderedDict): A pars...
[ "Saves", "a", "parsed", "DMARC", "forensic", "report", "to", "ElasticSearch" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/elastic.py#L387-L517
[ "def", "save_forensic_report_to_elasticsearch", "(", "forensic_report", ",", "index_suffix", "=", "None", ",", "monthly_indexes", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Saving forensic report to Elasticsearch\"", ")", "forensic_report", "=", "forensic_rep...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
KafkaClient.strip_metadata
Duplicates org_name, org_email and report_id into JSON root and removes report_metadata key to bring it more inline with Elastic output.
parsedmarc/kafkaclient.py
def strip_metadata(report): """ Duplicates org_name, org_email and report_id into JSON root and removes report_metadata key to bring it more inline with Elastic output. """ report['org_name'] = report['report_metadata']['org_name'] report['org_email'] = repo...
def strip_metadata(report): """ Duplicates org_name, org_email and report_id into JSON root and removes report_metadata key to bring it more inline with Elastic output. """ report['org_name'] = report['report_metadata']['org_name'] report['org_email'] = repo...
[ "Duplicates", "org_name", "org_email", "and", "report_id", "into", "JSON", "root", "and", "removes", "report_metadata", "key", "to", "bring", "it", "more", "inline", "with", "Elastic", "output", "." ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/kafkaclient.py#L58-L69
[ "def", "strip_metadata", "(", "report", ")", ":", "report", "[", "'org_name'", "]", "=", "report", "[", "'report_metadata'", "]", "[", "'org_name'", "]", "report", "[", "'org_email'", "]", "=", "report", "[", "'report_metadata'", "]", "[", "'org_email'", "]"...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
KafkaClient.generate_daterange
Creates a date_range timestamp with format YYYY-MM-DD-T-HH:MM:SS based on begin and end dates for easier parsing in Kibana. Move to utils to avoid duplication w/ elastic?
parsedmarc/kafkaclient.py
def generate_daterange(report): """ Creates a date_range timestamp with format YYYY-MM-DD-T-HH:MM:SS based on begin and end dates for easier parsing in Kibana. Move to utils to avoid duplication w/ elastic? """ metadata = report["report_metadata"] begin_date = h...
def generate_daterange(report): """ Creates a date_range timestamp with format YYYY-MM-DD-T-HH:MM:SS based on begin and end dates for easier parsing in Kibana. Move to utils to avoid duplication w/ elastic? """ metadata = report["report_metadata"] begin_date = h...
[ "Creates", "a", "date_range", "timestamp", "with", "format", "YYYY", "-", "MM", "-", "DD", "-", "T", "-", "HH", ":", "MM", ":", "SS", "based", "on", "begin", "and", "end", "dates", "for", "easier", "parsing", "in", "Kibana", "." ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/kafkaclient.py#L72-L88
[ "def", "generate_daterange", "(", "report", ")", ":", "metadata", "=", "report", "[", "\"report_metadata\"", "]", "begin_date", "=", "human_timestamp_to_datetime", "(", "metadata", "[", "\"begin_date\"", "]", ")", "end_date", "=", "human_timestamp_to_datetime", "(", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
KafkaClient.save_aggregate_reports_to_kafka
Saves aggregate DMARC reports to Kafka Args: aggregate_reports (list): A list of aggregate report dictionaries to save to Kafka aggregate_topic (str): The name of the Kafka topic
parsedmarc/kafkaclient.py
def save_aggregate_reports_to_kafka(self, aggregate_reports, aggregate_topic): """ Saves aggregate DMARC reports to Kafka Args: aggregate_reports (list): A list of aggregate report dictionaries to save to Kafka aggrega...
def save_aggregate_reports_to_kafka(self, aggregate_reports, aggregate_topic): """ Saves aggregate DMARC reports to Kafka Args: aggregate_reports (list): A list of aggregate report dictionaries to save to Kafka aggrega...
[ "Saves", "aggregate", "DMARC", "reports", "to", "Kafka" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/kafkaclient.py#L90-L132
[ "def", "save_aggregate_reports_to_kafka", "(", "self", ",", "aggregate_reports", ",", "aggregate_topic", ")", ":", "if", "(", "type", "(", "aggregate_reports", ")", "==", "dict", "or", "type", "(", "aggregate_reports", ")", "==", "OrderedDict", ")", ":", "aggreg...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
KafkaClient.save_forensic_reports_to_kafka
Saves forensic DMARC reports to Kafka, sends individual records (slices) since Kafka requires messages to be <= 1MB by default. Args: forensic_reports (list): A list of forensic report dicts to save to Kafka forensic_topic (str): The name of the Kafka topic
parsedmarc/kafkaclient.py
def save_forensic_reports_to_kafka(self, forensic_reports, forensic_topic): """ Saves forensic DMARC reports to Kafka, sends individual records (slices) since Kafka requires messages to be <= 1MB by default. Args: forensic_reports (list): A list of forensic report d...
def save_forensic_reports_to_kafka(self, forensic_reports, forensic_topic): """ Saves forensic DMARC reports to Kafka, sends individual records (slices) since Kafka requires messages to be <= 1MB by default. Args: forensic_reports (list): A list of forensic report d...
[ "Saves", "forensic", "DMARC", "reports", "to", "Kafka", "sends", "individual", "records", "(", "slices", ")", "since", "Kafka", "requires", "messages", "to", "be", "<", "=", "1MB", "by", "default", "." ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/kafkaclient.py#L134-L165
[ "def", "save_forensic_reports_to_kafka", "(", "self", ",", "forensic_reports", ",", "forensic_topic", ")", ":", "if", "type", "(", "forensic_reports", ")", "==", "dict", ":", "forensic_reports", "=", "[", "forensic_reports", "]", "if", "len", "(", "forensic_report...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
_parse_report_record
Converts a record from a DMARC aggregate report into a more consistent format Args: record (OrderedDict): The record to convert nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) dns_timeout (float): Sets the DNS timeout i...
parsedmarc/__init__.py
def _parse_report_record(record, nameservers=None, dns_timeout=2.0, parallel=False): """ Converts a record from a DMARC aggregate report into a more consistent format Args: record (OrderedDict): The record to convert nameservers (list): A list of one or more nam...
def _parse_report_record(record, nameservers=None, dns_timeout=2.0, parallel=False): """ Converts a record from a DMARC aggregate report into a more consistent format Args: record (OrderedDict): The record to convert nameservers (list): A list of one or more nam...
[ "Converts", "a", "record", "from", "a", "DMARC", "aggregate", "report", "into", "a", "more", "consistent", "format" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L86-L208
[ "def", "_parse_report_record", "(", "record", ",", "nameservers", "=", "None", ",", "dns_timeout", "=", "2.0", ",", "parallel", "=", "False", ")", ":", "if", "nameservers", "is", "None", ":", "nameservers", "=", "[", "\"1.1.1.1\"", ",", "\"1.0.0.1\"", ",", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parse_aggregate_report_xml
Parses a DMARC XML report string and returns a consistent OrderedDict Args: xml (str): A string of DMARC aggregate report XML nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) timeout (float): Sets the DNS timeout in seconds ...
parsedmarc/__init__.py
def parse_aggregate_report_xml(xml, nameservers=None, timeout=2.0, parallel=False): """Parses a DMARC XML report string and returns a consistent OrderedDict Args: xml (str): A string of DMARC aggregate report XML nameservers (list): A list of one or more nameserve...
def parse_aggregate_report_xml(xml, nameservers=None, timeout=2.0, parallel=False): """Parses a DMARC XML report string and returns a consistent OrderedDict Args: xml (str): A string of DMARC aggregate report XML nameservers (list): A list of one or more nameserve...
[ "Parses", "a", "DMARC", "XML", "report", "string", "and", "returns", "a", "consistent", "OrderedDict" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L211-L339
[ "def", "parse_aggregate_report_xml", "(", "xml", ",", "nameservers", "=", "None", ",", "timeout", "=", "2.0", ",", "parallel", "=", "False", ")", ":", "errors", "=", "[", "]", "try", ":", "xmltodict", ".", "parse", "(", "xml", ")", "[", "\"feedback\"", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
extract_xml
Extracts xml from a zip or gzip file at the given path, file-like object, or bytes. Args: input_: A path to a file, a file like object, or bytes Returns: str: The extracted XML
parsedmarc/__init__.py
def extract_xml(input_): """ Extracts xml from a zip or gzip file at the given path, file-like object, or bytes. Args: input_: A path to a file, a file like object, or bytes Returns: str: The extracted XML """ if type(input_) == str: file_object = open(input_, "rb"...
def extract_xml(input_): """ Extracts xml from a zip or gzip file at the given path, file-like object, or bytes. Args: input_: A path to a file, a file like object, or bytes Returns: str: The extracted XML """ if type(input_) == str: file_object = open(input_, "rb"...
[ "Extracts", "xml", "from", "a", "zip", "or", "gzip", "file", "at", "the", "given", "path", "file", "-", "like", "object", "or", "bytes", "." ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L342-L383
[ "def", "extract_xml", "(", "input_", ")", ":", "if", "type", "(", "input_", ")", "==", "str", ":", "file_object", "=", "open", "(", "input_", ",", "\"rb\"", ")", "elif", "type", "(", "input_", ")", "==", "bytes", ":", "file_object", "=", "BytesIO", "...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parse_aggregate_report_file
Parses a file at the given path, a file-like object. or bytes as a aggregate DMARC report Args: _input: A path to a file, a file like object, or bytes nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) dns_timeout (float):...
parsedmarc/__init__.py
def parse_aggregate_report_file(_input, nameservers=None, dns_timeout=2.0, parallel=False): """Parses a file at the given path, a file-like object. or bytes as a aggregate DMARC report Args: _input: A path to a file, a file like object, or bytes nameservers (...
def parse_aggregate_report_file(_input, nameservers=None, dns_timeout=2.0, parallel=False): """Parses a file at the given path, a file-like object. or bytes as a aggregate DMARC report Args: _input: A path to a file, a file like object, or bytes nameservers (...
[ "Parses", "a", "file", "at", "the", "given", "path", "a", "file", "-", "like", "object", ".", "or", "bytes", "as", "a", "aggregate", "DMARC", "report" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L386-L406
[ "def", "parse_aggregate_report_file", "(", "_input", ",", "nameservers", "=", "None", ",", "dns_timeout", "=", "2.0", ",", "parallel", "=", "False", ")", ":", "xml", "=", "extract_xml", "(", "_input", ")", "return", "parse_aggregate_report_xml", "(", "xml", ",...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parsed_aggregate_reports_to_csv
Converts one or more parsed aggregate reports to flat CSV format, including headers Args: reports: A parsed aggregate report or list of parsed aggregate reports Returns: str: Parsed aggregate report data in flat CSV format, including headers
parsedmarc/__init__.py
def parsed_aggregate_reports_to_csv(reports): """ Converts one or more parsed aggregate reports to flat CSV format, including headers Args: reports: A parsed aggregate report or list of parsed aggregate reports Returns: str: Parsed aggregate report data in flat CSV format, includin...
def parsed_aggregate_reports_to_csv(reports): """ Converts one or more parsed aggregate reports to flat CSV format, including headers Args: reports: A parsed aggregate report or list of parsed aggregate reports Returns: str: Parsed aggregate report data in flat CSV format, includin...
[ "Converts", "one", "or", "more", "parsed", "aggregate", "reports", "to", "flat", "CSV", "format", "including", "headers" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L409-L516
[ "def", "parsed_aggregate_reports_to_csv", "(", "reports", ")", ":", "def", "to_str", "(", "obj", ")", ":", "return", "str", "(", "obj", ")", ".", "lower", "(", ")", "fields", "=", "[", "\"xml_schema\"", ",", "\"org_name\"", ",", "\"org_email\"", ",", "\"or...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parse_forensic_report
Converts a DMARC forensic report and sample to a ``OrderedDict`` Args: feedback_report (str): A message's feedback report as a string sample (str): The RFC 822 headers or RFC 822 message sample msg_date (str): The message's date header nameservers (list): A list of one or more names...
parsedmarc/__init__.py
def parse_forensic_report(feedback_report, sample, msg_date, nameservers=None, dns_timeout=2.0, strip_attachment_payloads=False, parallel=False): """ Converts a DMARC forensic report and sample to a ``OrderedDict`` Args: ...
def parse_forensic_report(feedback_report, sample, msg_date, nameservers=None, dns_timeout=2.0, strip_attachment_payloads=False, parallel=False): """ Converts a DMARC forensic report and sample to a ``OrderedDict`` Args: ...
[ "Converts", "a", "DMARC", "forensic", "report", "and", "sample", "to", "a", "OrderedDict" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L519-L633
[ "def", "parse_forensic_report", "(", "feedback_report", ",", "sample", ",", "msg_date", ",", "nameservers", "=", "None", ",", "dns_timeout", "=", "2.0", ",", "strip_attachment_payloads", "=", "False", ",", "parallel", "=", "False", ")", ":", "delivery_results", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parsed_forensic_reports_to_csv
Converts one or more parsed forensic reports to flat CSV format, including headers Args: reports: A parsed forensic report or list of parsed forensic reports Returns: str: Parsed forensic report data in flat CSV format, including headers
parsedmarc/__init__.py
def parsed_forensic_reports_to_csv(reports): """ Converts one or more parsed forensic reports to flat CSV format, including headers Args: reports: A parsed forensic report or list of parsed forensic reports Returns: str: Parsed forensic report data in flat CSV format, including hea...
def parsed_forensic_reports_to_csv(reports): """ Converts one or more parsed forensic reports to flat CSV format, including headers Args: reports: A parsed forensic report or list of parsed forensic reports Returns: str: Parsed forensic report data in flat CSV format, including hea...
[ "Converts", "one", "or", "more", "parsed", "forensic", "reports", "to", "flat", "CSV", "format", "including", "headers" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L636-L676
[ "def", "parsed_forensic_reports_to_csv", "(", "reports", ")", ":", "fields", "=", "[", "\"feedback_type\"", ",", "\"user_agent\"", ",", "\"version\"", ",", "\"original_envelope_id\"", ",", "\"original_mail_from\"", ",", "\"original_rcpt_to\"", ",", "\"arrival_date\"", ","...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parse_report_email
Parses a DMARC report from an email Args: input_: An emailed DMARC report in RFC 822 format, as bytes or a string nameservers (list): A list of one or more nameservers to use dns_timeout (float): Sets the DNS timeout in seconds strip_attachment_payloads (bool): Remove attachment pay...
parsedmarc/__init__.py
def parse_report_email(input_, nameservers=None, dns_timeout=2.0, strip_attachment_payloads=False, parallel=False): """ Parses a DMARC report from an email Args: input_: An emailed DMARC report in RFC 822 format, as bytes or a string nameservers (list): A list of one ...
def parse_report_email(input_, nameservers=None, dns_timeout=2.0, strip_attachment_payloads=False, parallel=False): """ Parses a DMARC report from an email Args: input_: An emailed DMARC report in RFC 822 format, as bytes or a string nameservers (list): A list of one ...
[ "Parses", "a", "DMARC", "report", "from", "an", "email" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L679-L797
[ "def", "parse_report_email", "(", "input_", ",", "nameservers", "=", "None", ",", "dns_timeout", "=", "2.0", ",", "strip_attachment_payloads", "=", "False", ",", "parallel", "=", "False", ")", ":", "result", "=", "None", "try", ":", "if", "is_outlook_msg", "...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parse_report_file
Parses a DMARC aggregate or forensic file at the given path, a file-like object. or bytes Args: input_: A path to a file, a file like object, or bytes nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) dns_timeout (float):...
parsedmarc/__init__.py
def parse_report_file(input_, nameservers=None, dns_timeout=2.0, strip_attachment_payloads=False, parallel=False): """Parses a DMARC aggregate or forensic file at the given path, a file-like object. or bytes Args: input_: A path to a file, a file like object, or bytes ...
def parse_report_file(input_, nameservers=None, dns_timeout=2.0, strip_attachment_payloads=False, parallel=False): """Parses a DMARC aggregate or forensic file at the given path, a file-like object. or bytes Args: input_: A path to a file, a file like object, or bytes ...
[ "Parses", "a", "DMARC", "aggregate", "or", "forensic", "file", "at", "the", "given", "path", "a", "file", "-", "like", "object", ".", "or", "bytes" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L800-L842
[ "def", "parse_report_file", "(", "input_", ",", "nameservers", "=", "None", ",", "dns_timeout", "=", "2.0", ",", "strip_attachment_payloads", "=", "False", ",", "parallel", "=", "False", ")", ":", "if", "type", "(", "input_", ")", "==", "str", ":", "file_o...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_imap_capabilities
Returns a list of an IMAP server's capabilities Args: server (imapclient.IMAPClient): An instance of imapclient.IMAPClient Returns (list): A list of capabilities
parsedmarc/__init__.py
def get_imap_capabilities(server): """ Returns a list of an IMAP server's capabilities Args: server (imapclient.IMAPClient): An instance of imapclient.IMAPClient Returns (list): A list of capabilities """ capabilities = list(map(str, list(server.capabilities()))) for i in range(le...
def get_imap_capabilities(server): """ Returns a list of an IMAP server's capabilities Args: server (imapclient.IMAPClient): An instance of imapclient.IMAPClient Returns (list): A list of capabilities """ capabilities = list(map(str, list(server.capabilities()))) for i in range(le...
[ "Returns", "a", "list", "of", "an", "IMAP", "server", "s", "capabilities" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L845-L862
[ "def", "get_imap_capabilities", "(", "server", ")", ":", "capabilities", "=", "list", "(", "map", "(", "str", ",", "list", "(", "server", ".", "capabilities", "(", ")", ")", ")", ")", "for", "i", "in", "range", "(", "len", "(", "capabilities", ")", "...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_dmarc_reports_from_inbox
Fetches and parses DMARC reports from sn inbox Args: host: The mail server hostname or IP address user: The mail server user password: The mail server password connection: An IMAPCLient connection to reuse port: The mail server port ssl (bool): Use SSL/TLS ss...
parsedmarc/__init__.py
def get_dmarc_reports_from_inbox(host=None, user=None, password=None, connection=None, port=None, ssl=True, ssl_context=No...
def get_dmarc_reports_from_inbox(host=None, user=None, password=None, connection=None, port=None, ssl=True, ssl_context=No...
[ "Fetches", "and", "parses", "DMARC", "reports", "from", "sn", "inbox" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L865-L1304
[ "def", "get_dmarc_reports_from_inbox", "(", "host", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "connection", "=", "None", ",", "port", "=", "None", ",", "ssl", "=", "True", ",", "ssl_context", "=", "None", ",", "move_suppor...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
save_output
Save report data in the given directory Args: results (OrderedDict): Parsing results output_directory: The patch to the directory to save in
parsedmarc/__init__.py
def save_output(results, output_directory="output"): """ Save report data in the given directory Args: results (OrderedDict): Parsing results output_directory: The patch to the directory to save in """ aggregate_reports = results["aggregate_reports"] forensic_reports = results[...
def save_output(results, output_directory="output"): """ Save report data in the given directory Args: results (OrderedDict): Parsing results output_directory: The patch to the directory to save in """ aggregate_reports = results["aggregate_reports"] forensic_reports = results[...
[ "Save", "report", "data", "in", "the", "given", "directory" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L1307-L1366
[ "def", "save_output", "(", "results", ",", "output_directory", "=", "\"output\"", ")", ":", "aggregate_reports", "=", "results", "[", "\"aggregate_reports\"", "]", "forensic_reports", "=", "results", "[", "\"forensic_reports\"", "]", "if", "os", ".", "path", ".", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_report_zip
Creates a zip file of parsed report output Args: results (OrderedDict): The parsed results Returns: bytes: zip file bytes
parsedmarc/__init__.py
def get_report_zip(results): """ Creates a zip file of parsed report output Args: results (OrderedDict): The parsed results Returns: bytes: zip file bytes """ def add_subdir(root_path, subdir): subdir_path = os.path.join(root_path, subdir) for subdir_root, subdi...
def get_report_zip(results): """ Creates a zip file of parsed report output Args: results (OrderedDict): The parsed results Returns: bytes: zip file bytes """ def add_subdir(root_path, subdir): subdir_path = os.path.join(root_path, subdir) for subdir_root, subdi...
[ "Creates", "a", "zip", "file", "of", "parsed", "report", "output" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L1369-L1411
[ "def", "get_report_zip", "(", "results", ")", ":", "def", "add_subdir", "(", "root_path", ",", "subdir", ")", ":", "subdir_path", "=", "os", ".", "path", ".", "join", "(", "root_path", ",", "subdir", ")", "for", "subdir_root", ",", "subdir_dirs", ",", "s...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
email_results
Emails parsing results as a zip file Args: results (OrderedDict): Parsing results host: Mail server hostname or IP address mail_from: The value of the message from header mail_to : A list of addresses to mail to port (int): Port to use ssl (bool): Require a SSL conne...
parsedmarc/__init__.py
def email_results(results, host, mail_from, mail_to, port=0, ssl=False, user=None, password=None, subject=None, attachment_filename=None, message=None, ssl_context=None): """ Emails parsing results as a zip file Args: results (OrderedDict): Parsing results ...
def email_results(results, host, mail_from, mail_to, port=0, ssl=False, user=None, password=None, subject=None, attachment_filename=None, message=None, ssl_context=None): """ Emails parsing results as a zip file Args: results (OrderedDict): Parsing results ...
[ "Emails", "parsing", "results", "as", "a", "zip", "file" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L1414-L1496
[ "def", "email_results", "(", "results", ",", "host", ",", "mail_from", ",", "mail_to", ",", "port", "=", "0", ",", "ssl", "=", "False", ",", "user", "=", "None", ",", "password", "=", "None", ",", "subject", "=", "None", ",", "attachment_filename", "="...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
watch_inbox
Use an IDLE IMAP connection to parse incoming emails, and pass the results to a callback function Args: host: The mail server hostname or IP address username: The mail server username password: The mail server password callback: The callback function to receive the parsing resul...
parsedmarc/__init__.py
def watch_inbox(host, username, password, callback, port=None, ssl=True, ssl_context=None, reports_folder="INBOX", archive_folder="Archive", delete=False, test=False, wait=30, nameservers=None, dns_timeout=6.0, strip_attachment_payloads=False): """ ...
def watch_inbox(host, username, password, callback, port=None, ssl=True, ssl_context=None, reports_folder="INBOX", archive_folder="Archive", delete=False, test=False, wait=30, nameservers=None, dns_timeout=6.0, strip_attachment_payloads=False): """ ...
[ "Use", "an", "IDLE", "IMAP", "connection", "to", "parse", "incoming", "emails", "and", "pass", "the", "results", "to", "a", "callback", "function" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/__init__.py#L1499-L1818
[ "def", "watch_inbox", "(", "host", ",", "username", ",", "password", ",", "callback", ",", "port", "=", "None", ",", "ssl", "=", "True", ",", "ssl_context", "=", "None", ",", "reports_folder", "=", "\"INBOX\"", ",", "archive_folder", "=", "\"Archive\"", ",...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
HECClient.save_aggregate_reports_to_splunk
Saves aggregate DMARC reports to Splunk Args: aggregate_reports: A list of aggregate report dictionaries to save in Splunk
parsedmarc/splunk.py
def save_aggregate_reports_to_splunk(self, aggregate_reports): """ Saves aggregate DMARC reports to Splunk Args: aggregate_reports: A list of aggregate report dictionaries to save in Splunk """ logger.debug("Saving aggregate reports to Splunk") i...
def save_aggregate_reports_to_splunk(self, aggregate_reports): """ Saves aggregate DMARC reports to Splunk Args: aggregate_reports: A list of aggregate report dictionaries to save in Splunk """ logger.debug("Saving aggregate reports to Splunk") i...
[ "Saves", "aggregate", "DMARC", "reports", "to", "Splunk" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/splunk.py#L58-L123
[ "def", "save_aggregate_reports_to_splunk", "(", "self", ",", "aggregate_reports", ")", ":", "logger", ".", "debug", "(", "\"Saving aggregate reports to Splunk\"", ")", "if", "type", "(", "aggregate_reports", ")", "==", "dict", ":", "aggregate_reports", "=", "[", "ag...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
HECClient.save_forensic_reports_to_splunk
Saves forensic DMARC reports to Splunk Args: forensic_reports (list): A list of forensic report dictionaries to save in Splunk
parsedmarc/splunk.py
def save_forensic_reports_to_splunk(self, forensic_reports): """ Saves forensic DMARC reports to Splunk Args: forensic_reports (list): A list of forensic report dictionaries to save in Splunk """ logger.debug("Saving forensic reports to Splunk") ...
def save_forensic_reports_to_splunk(self, forensic_reports): """ Saves forensic DMARC reports to Splunk Args: forensic_reports (list): A list of forensic report dictionaries to save in Splunk """ logger.debug("Saving forensic reports to Splunk") ...
[ "Saves", "forensic", "DMARC", "reports", "to", "Splunk" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/splunk.py#L125-L159
[ "def", "save_forensic_reports_to_splunk", "(", "self", ",", "forensic_reports", ")", ":", "logger", ".", "debug", "(", "\"Saving forensic reports to Splunk\"", ")", "if", "type", "(", "forensic_reports", ")", "==", "dict", ":", "forensic_reports", "=", "[", "forensi...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
decode_base64
Decodes a base64 string, with padding being optional Args: data: A base64 encoded string Returns: bytes: The decoded bytes
parsedmarc/utils.py
def decode_base64(data): """ Decodes a base64 string, with padding being optional Args: data: A base64 encoded string Returns: bytes: The decoded bytes """ data = bytes(data, encoding="ascii") missing_padding = len(data) % 4 if missing_padding != 0: data += b'=...
def decode_base64(data): """ Decodes a base64 string, with padding being optional Args: data: A base64 encoded string Returns: bytes: The decoded bytes """ data = bytes(data, encoding="ascii") missing_padding = len(data) % 4 if missing_padding != 0: data += b'=...
[ "Decodes", "a", "base64", "string", "with", "padding", "being", "optional" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L54-L69
[ "def", "decode_base64", "(", "data", ")", ":", "data", "=", "bytes", "(", "data", ",", "encoding", "=", "\"ascii\"", ")", "missing_padding", "=", "len", "(", "data", ")", "%", "4", "if", "missing_padding", "!=", "0", ":", "data", "+=", "b'='", "*", "...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_base_domain
Gets the base domain name for the given domain .. note:: Results are based on a list of public domain suffixes at https://publicsuffix.org/list/public_suffix_list.dat. Args: domain (str): A domain or subdomain use_fresh_psl (bool): Download a fresh Public Suffix List Retur...
parsedmarc/utils.py
def get_base_domain(domain, use_fresh_psl=False): """ Gets the base domain name for the given domain .. note:: Results are based on a list of public domain suffixes at https://publicsuffix.org/list/public_suffix_list.dat. Args: domain (str): A domain or subdomain use_fr...
def get_base_domain(domain, use_fresh_psl=False): """ Gets the base domain name for the given domain .. note:: Results are based on a list of public domain suffixes at https://publicsuffix.org/list/public_suffix_list.dat. Args: domain (str): A domain or subdomain use_fr...
[ "Gets", "the", "base", "domain", "name", "for", "the", "given", "domain" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L72-L115
[ "def", "get_base_domain", "(", "domain", ",", "use_fresh_psl", "=", "False", ")", ":", "psl_path", "=", "os", ".", "path", ".", "join", "(", "tempdir", ",", "\"public_suffix_list.dat\"", ")", "def", "download_psl", "(", ")", ":", "url", "=", "\"https://publi...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
query_dns
Queries DNS Args: domain (str): The domain or subdomain to query about record_type (str): The record type to query for cache (ExpiringDict): Cache storage nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) time...
parsedmarc/utils.py
def query_dns(domain, record_type, cache=None, nameservers=None, timeout=2.0): """ Queries DNS Args: domain (str): The domain or subdomain to query about record_type (str): The record type to query for cache (ExpiringDict): Cache storage nameservers (list): A list of one or ...
def query_dns(domain, record_type, cache=None, nameservers=None, timeout=2.0): """ Queries DNS Args: domain (str): The domain or subdomain to query about record_type (str): The record type to query for cache (ExpiringDict): Cache storage nameservers (list): A list of one or ...
[ "Queries", "DNS" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L118-L165
[ "def", "query_dns", "(", "domain", ",", "record_type", ",", "cache", "=", "None", ",", "nameservers", "=", "None", ",", "timeout", "=", "2.0", ")", ":", "domain", "=", "str", "(", "domain", ")", ".", "lower", "(", ")", "record_type", "=", "record_type"...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_reverse_dns
Resolves an IP address to a hostname using a reverse DNS query Args: ip_address (str): The IP address to resolve cache (ExpiringDict): Cache storage nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) timeout (float): S...
parsedmarc/utils.py
def get_reverse_dns(ip_address, cache=None, nameservers=None, timeout=2.0): """ Resolves an IP address to a hostname using a reverse DNS query Args: ip_address (str): The IP address to resolve cache (ExpiringDict): Cache storage nameservers (list): A list of one or more nameservers ...
def get_reverse_dns(ip_address, cache=None, nameservers=None, timeout=2.0): """ Resolves an IP address to a hostname using a reverse DNS query Args: ip_address (str): The IP address to resolve cache (ExpiringDict): Cache storage nameservers (list): A list of one or more nameservers ...
[ "Resolves", "an", "IP", "address", "to", "a", "hostname", "using", "a", "reverse", "DNS", "query" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L168-L192
[ "def", "get_reverse_dns", "(", "ip_address", ",", "cache", "=", "None", ",", "nameservers", "=", "None", ",", "timeout", "=", "2.0", ")", ":", "hostname", "=", "None", "try", ":", "address", "=", "dns", ".", "reversename", ".", "from_address", "(", "ip_a...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
human_timestamp_to_datetime
Converts a human-readable timestamp into a Python ``DateTime`` object Args: human_timestamp (str): A timestamp string to_utc (bool): Convert the timestamp to UTC Returns: DateTime: The converted timestamp
parsedmarc/utils.py
def human_timestamp_to_datetime(human_timestamp, to_utc=False): """ Converts a human-readable timestamp into a Python ``DateTime`` object Args: human_timestamp (str): A timestamp string to_utc (bool): Convert the timestamp to UTC Returns: DateTime: The converted timestamp "...
def human_timestamp_to_datetime(human_timestamp, to_utc=False): """ Converts a human-readable timestamp into a Python ``DateTime`` object Args: human_timestamp (str): A timestamp string to_utc (bool): Convert the timestamp to UTC Returns: DateTime: The converted timestamp "...
[ "Converts", "a", "human", "-", "readable", "timestamp", "into", "a", "Python", "DateTime", "object" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L221-L238
[ "def", "human_timestamp_to_datetime", "(", "human_timestamp", ",", "to_utc", "=", "False", ")", ":", "settings", "=", "{", "}", "if", "to_utc", ":", "settings", "=", "{", "\"TO_TIMEZONE\"", ":", "\"UTC\"", "}", "return", "dateparser", ".", "parse", "(", "hum...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_ip_address_country
Uses the MaxMind Geolite2 Country database to return the ISO code for the country associated with the given IPv4 or IPv6 address Args: ip_address (str): The IP address to query for parallel (bool): Parallel processing Returns: str: And ISO country code associated with the given IP ...
parsedmarc/utils.py
def get_ip_address_country(ip_address, parallel=False): """ Uses the MaxMind Geolite2 Country database to return the ISO code for the country associated with the given IPv4 or IPv6 address Args: ip_address (str): The IP address to query for parallel (bool): Parallel processing Retu...
def get_ip_address_country(ip_address, parallel=False): """ Uses the MaxMind Geolite2 Country database to return the ISO code for the country associated with the given IPv4 or IPv6 address Args: ip_address (str): The IP address to query for parallel (bool): Parallel processing Retu...
[ "Uses", "the", "MaxMind", "Geolite2", "Country", "database", "to", "return", "the", "ISO", "code", "for", "the", "country", "associated", "with", "the", "given", "IPv4", "or", "IPv6", "address" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L255-L333
[ "def", "get_ip_address_country", "(", "ip_address", ",", "parallel", "=", "False", ")", ":", "def", "download_country_database", "(", "location", "=", "\"GeoLite2-Country.mmdb\"", ")", ":", "\"\"\"Downloads the MaxMind Geolite2 Country database\n\n Args:\n locat...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_ip_address_info
Returns reverse DNS and country information for the given IP address Args: ip_address (str): The IP address to check cache (ExpiringDict): Cache storage nameservers (list): A list of one or more nameservers to use (Cloudflare's public DNS resolvers by default) timeout (float...
parsedmarc/utils.py
def get_ip_address_info(ip_address, cache=None, nameservers=None, timeout=2.0, parallel=False): """ Returns reverse DNS and country information for the given IP address Args: ip_address (str): The IP address to check cache (ExpiringDict): Cache storage namese...
def get_ip_address_info(ip_address, cache=None, nameservers=None, timeout=2.0, parallel=False): """ Returns reverse DNS and country information for the given IP address Args: ip_address (str): The IP address to check cache (ExpiringDict): Cache storage namese...
[ "Returns", "reverse", "DNS", "and", "country", "information", "for", "the", "given", "IP", "address" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L336-L371
[ "def", "get_ip_address_info", "(", "ip_address", ",", "cache", "=", "None", ",", "nameservers", "=", "None", ",", "timeout", "=", "2.0", ",", "parallel", "=", "False", ")", ":", "ip_address", "=", "ip_address", ".", "lower", "(", ")", "if", "cache", ":",...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
get_filename_safe_string
Converts a string to a string that is safe for a filename Args: string (str): A string to make safe for a filename Returns: str: A string safe for a filename
parsedmarc/utils.py
def get_filename_safe_string(string): """ Converts a string to a string that is safe for a filename Args: string (str): A string to make safe for a filename Returns: str: A string safe for a filename """ invalid_filename_chars = ['\\', '/', ':', '"', '*', '?', '|', '\n', ...
def get_filename_safe_string(string): """ Converts a string to a string that is safe for a filename Args: string (str): A string to make safe for a filename Returns: str: A string safe for a filename """ invalid_filename_chars = ['\\', '/', ':', '"', '*', '?', '|', '\n', ...
[ "Converts", "a", "string", "to", "a", "string", "that", "is", "safe", "for", "a", "filename", "Args", ":", "string", "(", "str", ")", ":", "A", "string", "to", "make", "safe", "for", "a", "filename" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L393-L410
[ "def", "get_filename_safe_string", "(", "string", ")", ":", "invalid_filename_chars", "=", "[", "'\\\\'", ",", "'/'", ",", "':'", ",", "'\"'", ",", "'*'", ",", "'?'", ",", "'|'", ",", "'\\n'", ",", "'\\r'", "]", "if", "string", "is", "None", ":", "stri...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
convert_outlook_msg
Uses the ``msgconvert`` Perl utility to convert an Outlook MS file to standard RFC 822 format Args: msg_bytes (bytes): the content of the .msg file Returns: A RFC 822 string
parsedmarc/utils.py
def convert_outlook_msg(msg_bytes): """ Uses the ``msgconvert`` Perl utility to convert an Outlook MS file to standard RFC 822 format Args: msg_bytes (bytes): the content of the .msg file Returns: A RFC 822 string """ if not is_outlook_msg(msg_bytes): raise ValueErr...
def convert_outlook_msg(msg_bytes): """ Uses the ``msgconvert`` Perl utility to convert an Outlook MS file to standard RFC 822 format Args: msg_bytes (bytes): the content of the .msg file Returns: A RFC 822 string """ if not is_outlook_msg(msg_bytes): raise ValueErr...
[ "Uses", "the", "msgconvert", "Perl", "utility", "to", "convert", "an", "Outlook", "MS", "file", "to", "standard", "RFC", "822", "format" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L427-L458
[ "def", "convert_outlook_msg", "(", "msg_bytes", ")", ":", "if", "not", "is_outlook_msg", "(", "msg_bytes", ")", ":", "raise", "ValueError", "(", "\"The supplied bytes are not an Outlook MSG file\"", ")", "orig_dir", "=", "os", ".", "getcwd", "(", ")", "tmp_dir", "...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
parse_email
A simplified email parser Args: data: The RFC 822 message string, or MSG binary strip_attachment_payloads (bool): Remove attachment payloads Returns (dict): Parsed email data
parsedmarc/utils.py
def parse_email(data, strip_attachment_payloads=False): """ A simplified email parser Args: data: The RFC 822 message string, or MSG binary strip_attachment_payloads (bool): Remove attachment payloads Returns (dict): Parsed email data """ if type(data) == bytes: if is_...
def parse_email(data, strip_attachment_payloads=False): """ A simplified email parser Args: data: The RFC 822 message string, or MSG binary strip_attachment_payloads (bool): Remove attachment payloads Returns (dict): Parsed email data """ if type(data) == bytes: if is_...
[ "A", "simplified", "email", "parser" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/utils.py#L461-L564
[ "def", "parse_email", "(", "data", ",", "strip_attachment_payloads", "=", "False", ")", ":", "if", "type", "(", "data", ")", "==", "bytes", ":", "if", "is_outlook_msg", "(", "data", ")", ":", "data", "=", "convert_outlook_msg", "(", "data", ")", "data", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
_str_to_list
Converts a comma separated string to a list
parsedmarc/cli.py
def _str_to_list(s): """Converts a comma separated string to a list""" _list = s.split(",") return list(map(lambda i: i.lstrip(), _list))
def _str_to_list(s): """Converts a comma separated string to a list""" _list = s.split(",") return list(map(lambda i: i.lstrip(), _list))
[ "Converts", "a", "comma", "separated", "string", "to", "a", "list" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/cli.py#L27-L30
[ "def", "_str_to_list", "(", "s", ")", ":", "_list", "=", "s", ".", "split", "(", "\",\"", ")", "return", "list", "(", "map", "(", "lambda", "i", ":", "i", ".", "lstrip", "(", ")", ",", "_list", ")", ")" ]
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
cli_parse
Separated this function for multiprocessing
parsedmarc/cli.py
def cli_parse(file_path, sa, nameservers, dns_timeout, parallel=False): """Separated this function for multiprocessing""" try: file_results = parse_report_file(file_path, nameservers=nameservers, dns_timeout=dns_timeout, ...
def cli_parse(file_path, sa, nameservers, dns_timeout, parallel=False): """Separated this function for multiprocessing""" try: file_results = parse_report_file(file_path, nameservers=nameservers, dns_timeout=dns_timeout, ...
[ "Separated", "this", "function", "for", "multiprocessing" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/cli.py#L33-L47
[ "def", "cli_parse", "(", "file_path", ",", "sa", ",", "nameservers", ",", "dns_timeout", ",", "parallel", "=", "False", ")", ":", "try", ":", "file_results", "=", "parse_report_file", "(", "file_path", ",", "nameservers", "=", "nameservers", ",", "dns_timeout"...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
_main
Called when the module is executed
parsedmarc/cli.py
def _main(): """Called when the module is executed""" def process_reports(reports_): output_str = "{0}\n".format(json.dumps(reports_, ensure_ascii=False, indent=2)) if not opts.silent: print...
def _main(): """Called when the module is executed""" def process_reports(reports_): output_str = "{0}\n".format(json.dumps(reports_, ensure_ascii=False, indent=2)) if not opts.silent: print...
[ "Called", "when", "the", "module", "is", "executed" ]
domainaware/parsedmarc
python
https://github.com/domainaware/parsedmarc/blob/ecc9fd434c23d896ccd1f35795ccc047f946ed05/parsedmarc/cli.py#L55-L599
[ "def", "_main", "(", ")", ":", "def", "process_reports", "(", "reports_", ")", ":", "output_str", "=", "\"{0}\\n\"", ".", "format", "(", "json", ".", "dumps", "(", "reports_", ",", "ensure_ascii", "=", "False", ",", "indent", "=", "2", ")", ")", "if", ...
ecc9fd434c23d896ccd1f35795ccc047f946ed05
test
Client.drain
Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the `closed_cb' o...
nats/aio/client.py
def drain(self, sid=None): """ Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connectio...
def drain(self, sid=None): """ Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connectio...
[ "Drain", "will", "put", "a", "connection", "into", "a", "drain", "state", ".", "All", "subscriptions", "will", "immediately", "be", "put", "into", "a", "drain", "state", ".", "Upon", "completion", "the", "publishers", "will", "be", "drained", "and", "can", ...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L338-L380
[ "def", "drain", "(", "self", ",", "sid", "=", "None", ")", ":", "if", "self", ".", "is_draining", ":", "return", "if", "self", ".", "is_closed", ":", "raise", "ErrConnectionClosed", "if", "self", ".", "is_connecting", "or", "self", ".", "is_reconnecting", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.publish
Sends a PUB command to the server on the specified subject. ->> PUB hello 5 ->> MSG_PAYLOAD: world <<- MSG hello 2 5
nats/aio/client.py
def publish(self, subject, payload): """ Sends a PUB command to the server on the specified subject. ->> PUB hello 5 ->> MSG_PAYLOAD: world <<- MSG hello 2 5 """ if self.is_closed: raise ErrConnectionClosed if self.is_draining_pubs: ...
def publish(self, subject, payload): """ Sends a PUB command to the server on the specified subject. ->> PUB hello 5 ->> MSG_PAYLOAD: world <<- MSG hello 2 5 """ if self.is_closed: raise ErrConnectionClosed if self.is_draining_pubs: ...
[ "Sends", "a", "PUB", "command", "to", "the", "server", "on", "the", "specified", "subject", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L419-L436
[ "def", "publish", "(", "self", ",", "subject", ",", "payload", ")", ":", "if", "self", ".", "is_closed", ":", "raise", "ErrConnectionClosed", "if", "self", ".", "is_draining_pubs", ":", "raise", "ErrConnectionDraining", "payload_size", "=", "len", "(", "payloa...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.publish_request
Publishes a message tagging it with a reply subscription which can be used by those receiving the message to respond. ->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5 ->> MSG_PAYLOAD: world <<- MSG hello 2 _INBOX.2007314fe0fcb2cdc2a2914c1 5
nats/aio/client.py
def publish_request(self, subject, reply, payload): """ Publishes a message tagging it with a reply subscription which can be used by those receiving the message to respond. ->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5 ->> MSG_PAYLOAD: world <<- MSG hello ...
def publish_request(self, subject, reply, payload): """ Publishes a message tagging it with a reply subscription which can be used by those receiving the message to respond. ->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5 ->> MSG_PAYLOAD: world <<- MSG hello ...
[ "Publishes", "a", "message", "tagging", "it", "with", "a", "reply", "subscription", "which", "can", "be", "used", "by", "those", "receiving", "the", "message", "to", "respond", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L439-L457
[ "def", "publish_request", "(", "self", ",", "subject", ",", "reply", ",", "payload", ")", ":", "if", "self", ".", "is_closed", ":", "raise", "ErrConnectionClosed", "if", "self", ".", "is_draining_pubs", ":", "raise", "ErrConnectionDraining", "payload_size", "=",...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._publish
Sends PUB command to the NATS server.
nats/aio/client.py
def _publish(self, subject, reply, payload, payload_size): """ Sends PUB command to the NATS server. """ if subject == "": # Avoid sending messages with empty replies. raise ErrBadSubject payload_size_bytes = ("%d" % payload_size).encode() pub_cmd...
def _publish(self, subject, reply, payload, payload_size): """ Sends PUB command to the NATS server. """ if subject == "": # Avoid sending messages with empty replies. raise ErrBadSubject payload_size_bytes = ("%d" % payload_size).encode() pub_cmd...
[ "Sends", "PUB", "command", "to", "the", "NATS", "server", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L460-L475
[ "def", "_publish", "(", "self", ",", "subject", ",", "reply", ",", "payload", ",", "payload_size", ")", ":", "if", "subject", "==", "\"\"", ":", "# Avoid sending messages with empty replies.", "raise", "ErrBadSubject", "payload_size_bytes", "=", "(", "\"%d\"", "%"...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.subscribe
Takes a subject string and optional queue string to send a SUB cmd, and a callback which to which messages (Msg) will be dispatched to be processed sequentially by default.
nats/aio/client.py
def subscribe(self, subject, queue="", cb=None, future=None, max_msgs=0, is_async=False, pending_msgs_limit=DEFAULT_SUB_PENDING_MSGS_LIMIT, pending_bytes_limit=DEFAULT_SUB_PENDING_BYTES_LIMIT, ...
def subscribe(self, subject, queue="", cb=None, future=None, max_msgs=0, is_async=False, pending_msgs_limit=DEFAULT_SUB_PENDING_MSGS_LIMIT, pending_bytes_limit=DEFAULT_SUB_PENDING_BYTES_LIMIT, ...
[ "Takes", "a", "subject", "string", "and", "optional", "queue", "string", "to", "send", "a", "SUB", "cmd", "and", "a", "callback", "which", "to", "which", "messages", "(", "Msg", ")", "will", "be", "dispatched", "to", "be", "processed", "sequentially", "by"...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L478-L585
[ "def", "subscribe", "(", "self", ",", "subject", ",", "queue", "=", "\"\"", ",", "cb", "=", "None", ",", "future", "=", "None", ",", "max_msgs", "=", "0", ",", "is_async", "=", "False", ",", "pending_msgs_limit", "=", "DEFAULT_SUB_PENDING_MSGS_LIMIT", ",",...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.subscribe_async
Sets the subcription to use a task per message to be processed. ..deprecated:: 7.0 Will be removed 9.0.
nats/aio/client.py
def subscribe_async(self, subject, **kwargs): """ Sets the subcription to use a task per message to be processed. ..deprecated:: 7.0 Will be removed 9.0. """ kwargs["is_async"] = True sid = yield from self.subscribe(subject, **kwargs) return sid
def subscribe_async(self, subject, **kwargs): """ Sets the subcription to use a task per message to be processed. ..deprecated:: 7.0 Will be removed 9.0. """ kwargs["is_async"] = True sid = yield from self.subscribe(subject, **kwargs) return sid
[ "Sets", "the", "subcription", "to", "use", "a", "task", "per", "message", "to", "be", "processed", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L588-L597
[ "def", "subscribe_async", "(", "self", ",", "subject", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"is_async\"", "]", "=", "True", "sid", "=", "yield", "from", "self", ".", "subscribe", "(", "subject", ",", "*", "*", "kwargs", ")", "return", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.unsubscribe
Takes a subscription sequence id and removes the subscription from the client, optionally after receiving more than max_msgs.
nats/aio/client.py
def unsubscribe(self, ssid, max_msgs=0): """ Takes a subscription sequence id and removes the subscription from the client, optionally after receiving more than max_msgs. """ if self.is_closed: raise ErrConnectionClosed if self.is_draining: raise E...
def unsubscribe(self, ssid, max_msgs=0): """ Takes a subscription sequence id and removes the subscription from the client, optionally after receiving more than max_msgs. """ if self.is_closed: raise ErrConnectionClosed if self.is_draining: raise E...
[ "Takes", "a", "subscription", "sequence", "id", "and", "removes", "the", "subscription", "from", "the", "client", "optionally", "after", "receiving", "more", "than", "max_msgs", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L600-L615
[ "def", "unsubscribe", "(", "self", ",", "ssid", ",", "max_msgs", "=", "0", ")", ":", "if", "self", ".", "is_closed", ":", "raise", "ErrConnectionClosed", "if", "self", ".", "is_draining", ":", "raise", "ErrConnectionDraining", "self", ".", "_remove_sub", "("...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.request
Implements the request/response pattern via pub/sub using a single wildcard subscription that handles the responses.
nats/aio/client.py
def request(self, subject, payload, timeout=0.5, expected=1, cb=None): """ Implements the request/response pattern via pub/sub using a single wildcard subscription that handles the responses. """ if self.is_draining_pubs: raise ErrConnectionDraining ...
def request(self, subject, payload, timeout=0.5, expected=1, cb=None): """ Implements the request/response pattern via pub/sub using a single wildcard subscription that handles the responses. """ if self.is_draining_pubs: raise ErrConnectionDraining ...
[ "Implements", "the", "request", "/", "response", "pattern", "via", "pub", "/", "sub", "using", "a", "single", "wildcard", "subscription", "that", "handles", "the", "responses", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L643-L732
[ "def", "request", "(", "self", ",", "subject", ",", "payload", ",", "timeout", "=", "0.5", ",", "expected", "=", "1", ",", "cb", "=", "None", ")", ":", "if", "self", ".", "is_draining_pubs", ":", "raise", "ErrConnectionDraining", "# If callback given then co...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.timed_request
Implements the request/response pattern via pub/sub using an ephemeral subscription which will be published with a limited interest of 1 reply returning the response or raising a Timeout error. ->> SUB _INBOX.2007314fe0fcb2cdc2a2914c1 90 ->> UNSUB 90 1 ->> PUB hell...
nats/aio/client.py
def timed_request(self, subject, payload, timeout=0.5): """ Implements the request/response pattern via pub/sub using an ephemeral subscription which will be published with a limited interest of 1 reply returning the response or raising a Timeout error. ->> SUB _INBOX....
def timed_request(self, subject, payload, timeout=0.5): """ Implements the request/response pattern via pub/sub using an ephemeral subscription which will be published with a limited interest of 1 reply returning the response or raising a Timeout error. ->> SUB _INBOX....
[ "Implements", "the", "request", "/", "response", "pattern", "via", "pub", "/", "sub", "using", "an", "ephemeral", "subscription", "which", "will", "be", "published", "with", "a", "limited", "interest", "of", "1", "reply", "returning", "the", "response", "or", ...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L735-L763
[ "def", "timed_request", "(", "self", ",", "subject", ",", "payload", ",", "timeout", "=", "0.5", ")", ":", "next_inbox", "=", "INBOX_PREFIX", "[", ":", "]", "next_inbox", ".", "extend", "(", "self", ".", "_nuid", ".", "next", "(", ")", ")", "inbox", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client.flush
Sends a ping to the server expecting a pong back ensuring what we have written so far has made it to the server and also enabling measuring of roundtrip time. In case a pong is not returned within the allowed timeout, then it will raise ErrTimeout.
nats/aio/client.py
def flush(self, timeout=60): """ Sends a ping to the server expecting a pong back ensuring what we have written so far has made it to the server and also enabling measuring of roundtrip time. In case a pong is not returned within the allowed timeout, then it will raise Er...
def flush(self, timeout=60): """ Sends a ping to the server expecting a pong back ensuring what we have written so far has made it to the server and also enabling measuring of roundtrip time. In case a pong is not returned within the allowed timeout, then it will raise Er...
[ "Sends", "a", "ping", "to", "the", "server", "expecting", "a", "pong", "back", "ensuring", "what", "we", "have", "written", "so", "far", "has", "made", "it", "to", "the", "server", "and", "also", "enabling", "measuring", "of", "roundtrip", "time", ".", "...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L787-L807
[ "def", "flush", "(", "self", ",", "timeout", "=", "60", ")", ":", "if", "timeout", "<=", "0", ":", "raise", "ErrBadTimeout", "if", "self", ".", "is_closed", ":", "raise", "ErrConnectionClosed", "future", "=", "asyncio", ".", "Future", "(", "loop", "=", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._select_next_server
Looks up in the server pool for an available server and attempts to connect.
nats/aio/client.py
def _select_next_server(self): """ Looks up in the server pool for an available server and attempts to connect. """ while True: if len(self._server_pool) == 0: self._current_server = None raise ErrNoServers now = time.mono...
def _select_next_server(self): """ Looks up in the server pool for an available server and attempts to connect. """ while True: if len(self._server_pool) == 0: self._current_server = None raise ErrNoServers now = time.mono...
[ "Looks", "up", "in", "the", "server", "pool", "for", "an", "available", "server", "and", "attempts", "to", "connect", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L932-L982
[ "def", "_select_next_server", "(", "self", ")", ":", "while", "True", ":", "if", "len", "(", "self", ".", "_server_pool", ")", "==", "0", ":", "self", ".", "_current_server", "=", "None", "raise", "ErrNoServers", "now", "=", "time", ".", "monotonic", "("...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._process_err
Processes the raw error message sent by the server and close connection with current server.
nats/aio/client.py
def _process_err(self, err_msg): """ Processes the raw error message sent by the server and close connection with current server. """ if STALE_CONNECTION in err_msg: yield from self._process_op_err(ErrStaleConnection) return if AUTHORIZATION_VIOLA...
def _process_err(self, err_msg): """ Processes the raw error message sent by the server and close connection with current server. """ if STALE_CONNECTION in err_msg: yield from self._process_op_err(ErrStaleConnection) return if AUTHORIZATION_VIOLA...
[ "Processes", "the", "raw", "error", "message", "sent", "by", "the", "server", "and", "close", "connection", "with", "current", "server", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L985-L1007
[ "def", "_process_err", "(", "self", ",", "err_msg", ")", ":", "if", "STALE_CONNECTION", "in", "err_msg", ":", "yield", "from", "self", ".", "_process_op_err", "(", "ErrStaleConnection", ")", "return", "if", "AUTHORIZATION_VIOLATION", "in", "err_msg", ":", "self"...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._process_op_err
Process errors which occured while reading or parsing the protocol. If allow_reconnect is enabled it will try to switch the server to which it is currently connected otherwise it will disconnect.
nats/aio/client.py
def _process_op_err(self, e): """ Process errors which occured while reading or parsing the protocol. If allow_reconnect is enabled it will try to switch the server to which it is currently connected otherwise it will disconnect. """ if self.is_connecting or self....
def _process_op_err(self, e): """ Process errors which occured while reading or parsing the protocol. If allow_reconnect is enabled it will try to switch the server to which it is currently connected otherwise it will disconnect. """ if self.is_connecting or self....
[ "Process", "errors", "which", "occured", "while", "reading", "or", "parsing", "the", "protocol", ".", "If", "allow_reconnect", "is", "enabled", "it", "will", "try", "to", "switch", "the", "server", "to", "which", "it", "is", "currently", "connected", "otherwis...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1010-L1032
[ "def", "_process_op_err", "(", "self", ",", "e", ")", ":", "if", "self", ".", "is_connecting", "or", "self", ".", "is_closed", "or", "self", ".", "is_reconnecting", ":", "return", "if", "self", ".", "options", "[", "\"allow_reconnect\"", "]", "and", "self"...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._connect_command
Generates a JSON string with the params to be used when sending CONNECT to the server. ->> CONNECT {"lang": "python3"}
nats/aio/client.py
def _connect_command(self): ''' Generates a JSON string with the params to be used when sending CONNECT to the server. ->> CONNECT {"lang": "python3"} ''' options = { "verbose": self.options["verbose"], "pedantic": self.options["pedantic"], ...
def _connect_command(self): ''' Generates a JSON string with the params to be used when sending CONNECT to the server. ->> CONNECT {"lang": "python3"} ''' options = { "verbose": self.options["verbose"], "pedantic": self.options["pedantic"], ...
[ "Generates", "a", "JSON", "string", "with", "the", "params", "to", "be", "used", "when", "sending", "CONNECT", "to", "the", "server", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1111-L1146
[ "def", "_connect_command", "(", "self", ")", ":", "options", "=", "{", "\"verbose\"", ":", "self", ".", "options", "[", "\"verbose\"", "]", ",", "\"pedantic\"", ":", "self", ".", "options", "[", "\"pedantic\"", "]", ",", "\"lang\"", ":", "__lang__", ",", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._process_pong
Process PONG sent by server.
nats/aio/client.py
def _process_pong(self): """ Process PONG sent by server. """ if len(self._pongs) > 0: future = self._pongs.pop(0) future.set_result(True) self._pongs_received += 1 self._pings_outstanding -= 1
def _process_pong(self): """ Process PONG sent by server. """ if len(self._pongs) > 0: future = self._pongs.pop(0) future.set_result(True) self._pongs_received += 1 self._pings_outstanding -= 1
[ "Process", "PONG", "sent", "by", "server", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1157-L1165
[ "def", "_process_pong", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_pongs", ")", ">", "0", ":", "future", "=", "self", ".", "_pongs", ".", "pop", "(", "0", ")", "future", ".", "set_result", "(", "True", ")", "self", ".", "_pongs_receive...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._process_msg
Process MSG sent by server.
nats/aio/client.py
def _process_msg(self, sid, subject, reply, data): """ Process MSG sent by server. """ payload_size = len(data) self.stats['in_msgs'] += 1 self.stats['in_bytes'] += payload_size sub = self._subs.get(sid) if sub is None: # Skip in case no subsc...
def _process_msg(self, sid, subject, reply, data): """ Process MSG sent by server. """ payload_size = len(data) self.stats['in_msgs'] += 1 self.stats['in_bytes'] += payload_size sub = self._subs.get(sid) if sub is None: # Skip in case no subsc...
[ "Process", "MSG", "sent", "by", "server", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1168-L1213
[ "def", "_process_msg", "(", "self", ",", "sid", ",", "subject", ",", "reply", ",", "data", ")", ":", "payload_size", "=", "len", "(", "data", ")", "self", ".", "stats", "[", "'in_msgs'", "]", "+=", "1", "self", ".", "stats", "[", "'in_bytes'", "]", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._process_info
Process INFO lines sent by the server to reconfigure client with latest updates from cluster to enable server discovery.
nats/aio/client.py
def _process_info(self, info): """ Process INFO lines sent by the server to reconfigure client with latest updates from cluster to enable server discovery. """ if 'connect_urls' in info: if info['connect_urls']: connect_urls = [] for co...
def _process_info(self, info): """ Process INFO lines sent by the server to reconfigure client with latest updates from cluster to enable server discovery. """ if 'connect_urls' in info: if info['connect_urls']: connect_urls = [] for co...
[ "Process", "INFO", "lines", "sent", "by", "the", "server", "to", "reconfigure", "client", "with", "latest", "updates", "from", "cluster", "to", "enable", "server", "discovery", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1226-L1250
[ "def", "_process_info", "(", "self", ",", "info", ")", ":", "if", "'connect_urls'", "in", "info", ":", "if", "info", "[", "'connect_urls'", "]", ":", "connect_urls", "=", "[", "]", "for", "connect_url", "in", "info", "[", "'connect_urls'", "]", ":", "uri...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._process_connect_init
Process INFO received from the server and CONNECT to the server with authentication. It is also responsible of setting up the reading and ping interval tasks from the client.
nats/aio/client.py
def _process_connect_init(self): """ Process INFO received from the server and CONNECT to the server with authentication. It is also responsible of setting up the reading and ping interval tasks from the client. """ self._status = Client.CONNECTING connection_co...
def _process_connect_init(self): """ Process INFO received from the server and CONNECT to the server with authentication. It is also responsible of setting up the reading and ping interval tasks from the client. """ self._status = Client.CONNECTING connection_co...
[ "Process", "INFO", "received", "from", "the", "server", "and", "CONNECT", "to", "the", "server", "with", "authentication", ".", "It", "is", "also", "responsible", "of", "setting", "up", "the", "reading", "and", "ping", "interval", "tasks", "from", "the", "cl...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1253-L1337
[ "def", "_process_connect_init", "(", "self", ")", ":", "self", ".", "_status", "=", "Client", ".", "CONNECTING", "connection_completed", "=", "self", ".", "_io_reader", ".", "readline", "(", ")", "info_line", "=", "yield", "from", "asyncio", ".", "wait_for", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._flusher
Coroutine which continuously tries to consume pending commands and then flushes them to the socket.
nats/aio/client.py
def _flusher(self): """ Coroutine which continuously tries to consume pending commands and then flushes them to the socket. """ while True: if not self.is_connected or self.is_connecting: break try: yield from self._flush_q...
def _flusher(self): """ Coroutine which continuously tries to consume pending commands and then flushes them to the socket. """ while True: if not self.is_connected or self.is_connecting: break try: yield from self._flush_q...
[ "Coroutine", "which", "continuously", "tries", "to", "consume", "pending", "commands", "and", "then", "flushes", "them", "to", "the", "socket", "." ]
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1348-L1371
[ "def", "_flusher", "(", "self", ")", ":", "while", "True", ":", "if", "not", "self", ".", "is_connected", "or", "self", ".", "is_connecting", ":", "break", "try", ":", "yield", "from", "self", ".", "_flush_queue", ".", "get", "(", ")", "if", "self", ...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
Client._read_loop
Coroutine which gathers bytes sent by the server and feeds them to the protocol parser. In case of error while reading, it will stop running and its task has to be rescheduled.
nats/aio/client.py
def _read_loop(self): """ Coroutine which gathers bytes sent by the server and feeds them to the protocol parser. In case of error while reading, it will stop running and its task has to be rescheduled. """ while True: try: should_bail ...
def _read_loop(self): """ Coroutine which gathers bytes sent by the server and feeds them to the protocol parser. In case of error while reading, it will stop running and its task has to be rescheduled. """ while True: try: should_bail ...
[ "Coroutine", "which", "gathers", "bytes", "sent", "by", "the", "server", "and", "feeds", "them", "to", "the", "protocol", "parser", ".", "In", "case", "of", "error", "while", "reading", "it", "will", "stop", "running", "and", "its", "task", "has", "to", ...
nats-io/asyncio-nats
python
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1392-L1419
[ "def", "_read_loop", "(", "self", ")", ":", "while", "True", ":", "try", ":", "should_bail", "=", "self", ".", "is_closed", "or", "self", ".", "is_reconnecting", "if", "should_bail", "or", "self", ".", "_io_reader", "is", "None", ":", "break", "if", "sel...
39e840be0b12ce326edac0bba69aeb1be930dcb8
test
coactivation
Compute and save coactivation map given input image as seed. This is essentially just a wrapper for a meta-analysis defined by the contrast between those studies that activate within the seed and those that don't. Args: dataset: a Dataset instance containing study and activation data. seed...
neurosynth/analysis/network.py
def coactivation(dataset, seed, threshold=0.0, output_dir='.', prefix='', r=6): """ Compute and save coactivation map given input image as seed. This is essentially just a wrapper for a meta-analysis defined by the contrast between those studies that activate within the seed and those that don't. ...
def coactivation(dataset, seed, threshold=0.0, output_dir='.', prefix='', r=6): """ Compute and save coactivation map given input image as seed. This is essentially just a wrapper for a meta-analysis defined by the contrast between those studies that activate within the seed and those that don't. ...
[ "Compute", "and", "save", "coactivation", "map", "given", "input", "image", "as", "seed", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/network.py#L7-L40
[ "def", "coactivation", "(", "dataset", ",", "seed", ",", "threshold", "=", "0.0", ",", "output_dir", "=", "'.'", ",", "prefix", "=", "''", ",", "r", "=", "6", ")", ":", "if", "isinstance", "(", "seed", ",", "string_types", ")", ":", "ids", "=", "da...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder.decode
Decodes a set of images. Args: images: The images to decode. Can be: - A single String specifying the filename of the image to decode - A list of filenames - A single NumPy array containing the image data save: Optional filename to save results to. If Non...
neurosynth/analysis/decode.py
def decode(self, images, save=None, round=4, names=None, **kwargs): """ Decodes a set of images. Args: images: The images to decode. Can be: - A single String specifying the filename of the image to decode - A list of filenames - A single NumPy array contai...
def decode(self, images, save=None, round=4, names=None, **kwargs): """ Decodes a set of images. Args: images: The images to decode. Can be: - A single String specifying the filename of the image to decode - A list of filenames - A single NumPy array contai...
[ "Decodes", "a", "set", "of", "images", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L64-L117
[ "def", "decode", "(", "self", ",", "images", ",", "save", "=", "None", ",", "round", "=", "4", ",", "names", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "images", ",", "string_types", ")", ":", "images", "=", "[", "im...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder.load_features
Load features from current Dataset instance or a list of files. Args: features: List containing paths to, or names of, features to extract. Each element in the list must be a string containing either a path to an image, or the name of a feature (as named ...
neurosynth/analysis/decode.py
def load_features(self, features, image_type=None, from_array=False, threshold=0.001): """ Load features from current Dataset instance or a list of files. Args: features: List containing paths to, or names of, features to extract. Each element in the lis...
def load_features(self, features, image_type=None, from_array=False, threshold=0.001): """ Load features from current Dataset instance or a list of files. Args: features: List containing paths to, or names of, features to extract. Each element in the lis...
[ "Load", "features", "from", "current", "Dataset", "instance", "or", "a", "list", "of", "files", ".", "Args", ":", "features", ":", "List", "containing", "paths", "to", "or", "names", "of", "features", "to", "extract", ".", "Each", "element", "in", "the", ...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L123-L152
[ "def", "load_features", "(", "self", ",", "features", ",", "image_type", "=", "None", ",", "from_array", "=", "False", ",", "threshold", "=", "0.001", ")", ":", "if", "from_array", ":", "if", "isinstance", "(", "features", ",", "list", ")", ":", "feature...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder._load_features_from_array
Load feature data from a 2D ndarray on disk.
neurosynth/analysis/decode.py
def _load_features_from_array(self, features): """ Load feature data from a 2D ndarray on disk. """ self.feature_images = np.load(features) self.feature_names = range(self.feature_images.shape[1])
def _load_features_from_array(self, features): """ Load feature data from a 2D ndarray on disk. """ self.feature_images = np.load(features) self.feature_names = range(self.feature_images.shape[1])
[ "Load", "feature", "data", "from", "a", "2D", "ndarray", "on", "disk", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L154-L157
[ "def", "_load_features_from_array", "(", "self", ",", "features", ")", ":", "self", ".", "feature_images", "=", "np", ".", "load", "(", "features", ")", "self", ".", "feature_names", "=", "range", "(", "self", ".", "feature_images", ".", "shape", "[", "1",...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder._load_features_from_dataset
Load feature image data from the current Dataset instance. See load_features() for documentation.
neurosynth/analysis/decode.py
def _load_features_from_dataset(self, features=None, image_type=None, threshold=0.001): """ Load feature image data from the current Dataset instance. See load_features() for documentation. """ self.feature_names = self.dataset.feature_table.feature_na...
def _load_features_from_dataset(self, features=None, image_type=None, threshold=0.001): """ Load feature image data from the current Dataset instance. See load_features() for documentation. """ self.feature_names = self.dataset.feature_table.feature_na...
[ "Load", "feature", "image", "data", "from", "the", "current", "Dataset", "instance", ".", "See", "load_features", "()", "for", "documentation", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L159-L175
[ "def", "_load_features_from_dataset", "(", "self", ",", "features", "=", "None", ",", "image_type", "=", "None", ",", "threshold", "=", "0.001", ")", ":", "self", ".", "feature_names", "=", "self", ".", "dataset", ".", "feature_table", ".", "feature_names", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder._load_features_from_images
Load feature image data from image files. Args: images: A list of image filenames. names: An optional list of strings to use as the feature names. Must be in the same order as the images.
neurosynth/analysis/decode.py
def _load_features_from_images(self, images, names=None): """ Load feature image data from image files. Args: images: A list of image filenames. names: An optional list of strings to use as the feature names. Must be in the same order as the images. """ i...
def _load_features_from_images(self, images, names=None): """ Load feature image data from image files. Args: images: A list of image filenames. names: An optional list of strings to use as the feature names. Must be in the same order as the images. """ i...
[ "Load", "feature", "image", "data", "from", "image", "files", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L177-L189
[ "def", "_load_features_from_images", "(", "self", ",", "images", ",", "names", "=", "None", ")", ":", "if", "names", "is", "not", "None", "and", "len", "(", "names", ")", "!=", "len", "(", "images", ")", ":", "raise", "Exception", "(", "\"Lists of featur...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder._pearson_correlation
Decode images using Pearson's r. Computes the correlation between each input image and each feature image across voxels. Args: imgs_to_decode: An ndarray of images to decode, with voxels in rows and images in columns. Returns: An n_features x n_...
neurosynth/analysis/decode.py
def _pearson_correlation(self, imgs_to_decode): """ Decode images using Pearson's r. Computes the correlation between each input image and each feature image across voxels. Args: imgs_to_decode: An ndarray of images to decode, with voxels in rows and images ...
def _pearson_correlation(self, imgs_to_decode): """ Decode images using Pearson's r. Computes the correlation between each input image and each feature image across voxels. Args: imgs_to_decode: An ndarray of images to decode, with voxels in rows and images ...
[ "Decode", "images", "using", "Pearson", "s", "r", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L198-L214
[ "def", "_pearson_correlation", "(", "self", ",", "imgs_to_decode", ")", ":", "x", ",", "y", "=", "imgs_to_decode", ".", "astype", "(", "float", ")", ",", "self", ".", "feature_images", ".", "astype", "(", "float", ")", "return", "self", ".", "_xy_corr", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder._dot_product
Decoding using the dot product.
neurosynth/analysis/decode.py
def _dot_product(self, imgs_to_decode): """ Decoding using the dot product. """ return np.dot(imgs_to_decode.T, self.feature_images).T
def _dot_product(self, imgs_to_decode): """ Decoding using the dot product. """ return np.dot(imgs_to_decode.T, self.feature_images).T
[ "Decoding", "using", "the", "dot", "product", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L216-L219
[ "def", "_dot_product", "(", "self", ",", "imgs_to_decode", ")", ":", "return", "np", ".", "dot", "(", "imgs_to_decode", ".", "T", ",", "self", ".", "feature_images", ")", ".", "T" ]
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Decoder._roi_association
Computes the strength of association between activation in a mask and presence/absence of a semantic feature. This is essentially a generalization of the voxel-wise reverse inference z-score to the multivoxel case.
neurosynth/analysis/decode.py
def _roi_association(self, imgs_to_decode, value='z', binarize=None): """ Computes the strength of association between activation in a mask and presence/absence of a semantic feature. This is essentially a generalization of the voxel-wise reverse inference z-score to the multivoxel case....
def _roi_association(self, imgs_to_decode, value='z', binarize=None): """ Computes the strength of association between activation in a mask and presence/absence of a semantic feature. This is essentially a generalization of the voxel-wise reverse inference z-score to the multivoxel case....
[ "Computes", "the", "strength", "of", "association", "between", "activation", "in", "a", "mask", "and", "presence", "/", "absence", "of", "a", "semantic", "feature", ".", "This", "is", "essentially", "a", "generalization", "of", "the", "voxel", "-", "wise", "...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L221-L238
[ "def", "_roi_association", "(", "self", ",", "imgs_to_decode", ",", "value", "=", "'z'", ",", "binarize", "=", "None", ")", ":", "imgs_to_decode", "=", "imgs_to_decode", ".", "squeeze", "(", ")", "x", "=", "average_within_regions", "(", "self", ".", "dataset...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
feature_selection
Implements various kinds of feature selection
neurosynth/analysis/classify.py
def feature_selection(feat_select, X, y): """" Implements various kinds of feature selection """ # K-best if re.match('.*-best', feat_select) is not None: n = int(feat_select.split('-')[0]) selector = SelectKBest(k=n) import warnings with warnings.catch_warnings(): ...
def feature_selection(feat_select, X, y): """" Implements various kinds of feature selection """ # K-best if re.match('.*-best', feat_select) is not None: n = int(feat_select.split('-')[0]) selector = SelectKBest(k=n) import warnings with warnings.catch_warnings(): ...
[ "Implements", "various", "kinds", "of", "feature", "selection" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L10-L33
[ "def", "feature_selection", "(", "feat_select", ",", "X", ",", "y", ")", ":", "# K-best", "if", "re", ".", "match", "(", "'.*-best'", ",", "feat_select", ")", "is", "not", "None", ":", "n", "=", "int", "(", "feat_select", ".", "split", "(", "'-'", ")...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
get_studies_by_regions
Set up data for a classification task given a set of masks Given a set of masks, this function retrieves studies associated with each mask at the specified threshold, optionally removes overlap and filters by studies and features, and returns studies by feature matrix (X) and class labe...
neurosynth/analysis/classify.py
def get_studies_by_regions(dataset, masks, threshold=0.08, remove_overlap=True, studies=None, features=None, regularization="scale"): """ Set up data for a classification task given a set of masks Given a set of masks, this function retrieves studies as...
def get_studies_by_regions(dataset, masks, threshold=0.08, remove_overlap=True, studies=None, features=None, regularization="scale"): """ Set up data for a classification task given a set of masks Given a set of masks, this function retrieves studies as...
[ "Set", "up", "data", "for", "a", "classification", "task", "given", "a", "set", "of", "masks" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L64-L137
[ "def", "get_studies_by_regions", "(", "dataset", ",", "masks", ",", "threshold", "=", "0.08", ",", "remove_overlap", "=", "True", ",", "studies", "=", "None", ",", "features", "=", "None", ",", "regularization", "=", "\"scale\"", ")", ":", "import", "nibabel...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
get_feature_order
Returns a list with the order that features requested appear in dataset
neurosynth/analysis/classify.py
def get_feature_order(dataset, features): """ Returns a list with the order that features requested appear in dataset """ all_features = dataset.get_feature_names() i = [all_features.index(f) for f in features] return i
def get_feature_order(dataset, features): """ Returns a list with the order that features requested appear in dataset """ all_features = dataset.get_feature_names() i = [all_features.index(f) for f in features] return i
[ "Returns", "a", "list", "with", "the", "order", "that", "features", "requested", "appear", "in", "dataset" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L140-L147
[ "def", "get_feature_order", "(", "dataset", ",", "features", ")", ":", "all_features", "=", "dataset", ".", "get_feature_names", "(", ")", "i", "=", "[", "all_features", ".", "index", "(", "f", ")", "for", "f", "in", "features", "]", "return", "i" ]
948ce7edce15d7df693446e76834e0c23bfe8f11
test
classify_regions
Perform classification on specified regions Given a set of masks, this function retrieves studies associated with each mask at the specified threshold, optionally removes overlap and filters by studies and features. Then it trains an algorithm to classify studies based on features and t...
neurosynth/analysis/classify.py
def classify_regions(dataset, masks, method='ERF', threshold=0.08, remove_overlap=True, regularization='scale', output='summary', studies=None, features=None, class_weight='auto', classifier=None, cross_val='4-Fold', param_grid=None, sc...
def classify_regions(dataset, masks, method='ERF', threshold=0.08, remove_overlap=True, regularization='scale', output='summary', studies=None, features=None, class_weight='auto', classifier=None, cross_val='4-Fold', param_grid=None, sc...
[ "Perform", "classification", "on", "specified", "regions" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L150-L209
[ "def", "classify_regions", "(", "dataset", ",", "masks", ",", "method", "=", "'ERF'", ",", "threshold", "=", "0.08", ",", "remove_overlap", "=", "True", ",", "regularization", "=", "'scale'", ",", "output", "=", "'summary'", ",", "studies", "=", "None", ",...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
classify
Wrapper for scikit-learn classification functions Imlements various types of classification and cross validation
neurosynth/analysis/classify.py
def classify(X, y, clf_method='ERF', classifier=None, output='summary_clf', cross_val=None, class_weight=None, regularization=None, param_grid=None, scoring='accuracy', refit_all=True, feat_select=None): """ Wrapper for scikit-learn classification functions Imlements vario...
def classify(X, y, clf_method='ERF', classifier=None, output='summary_clf', cross_val=None, class_weight=None, regularization=None, param_grid=None, scoring='accuracy', refit_all=True, feat_select=None): """ Wrapper for scikit-learn classification functions Imlements vario...
[ "Wrapper", "for", "scikit", "-", "learn", "classification", "functions", "Imlements", "various", "types", "of", "classification", "and", "cross", "validation" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L212-L248
[ "def", "classify", "(", "X", ",", "y", ",", "clf_method", "=", "'ERF'", ",", "classifier", "=", "None", ",", "output", "=", "'summary_clf'", ",", "cross_val", "=", "None", ",", "class_weight", "=", "None", ",", "regularization", "=", "None", ",", "param_...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Classifier.fit
Fits X to outcomes y, using clf
neurosynth/analysis/classify.py
def fit(self, X, y, cv=None, class_weight='auto'): """ Fits X to outcomes y, using clf """ # Incorporate error checking such as : # if isinstance(self.classifier, ScikitClassifier): # do one thingNone # otherwiseNone. self.X = X self.y = y self.set_...
def fit(self, X, y, cv=None, class_weight='auto'): """ Fits X to outcomes y, using clf """ # Incorporate error checking such as : # if isinstance(self.classifier, ScikitClassifier): # do one thingNone # otherwiseNone. self.X = X self.y = y self.set_...
[ "Fits", "X", "to", "outcomes", "y", "using", "clf" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L291-L306
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "cv", "=", "None", ",", "class_weight", "=", "'auto'", ")", ":", "# Incorporate error checking such as :", "# if isinstance(self.classifier, ScikitClassifier):", "# do one thingNone", "# otherwiseNone.", "self", "....
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Classifier.set_class_weight
Sets the class_weight of the classifier to match y
neurosynth/analysis/classify.py
def set_class_weight(self, class_weight='auto', y=None): """ Sets the class_weight of the classifier to match y """ if class_weight is None: cw = None try: self.clf.set_params(class_weight=cw) except ValueError: pass elif cla...
def set_class_weight(self, class_weight='auto', y=None): """ Sets the class_weight of the classifier to match y """ if class_weight is None: cw = None try: self.clf.set_params(class_weight=cw) except ValueError: pass elif cla...
[ "Sets", "the", "class_weight", "of", "the", "classifier", "to", "match", "y" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L308-L331
[ "def", "set_class_weight", "(", "self", ",", "class_weight", "=", "'auto'", ",", "y", "=", "None", ")", ":", "if", "class_weight", "is", "None", ":", "cw", "=", "None", "try", ":", "self", ".", "clf", ".", "set_params", "(", "class_weight", "=", "cw", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Classifier.cross_val_fit
Fits X to outcomes y, using clf and cv_method
neurosynth/analysis/classify.py
def cross_val_fit(self, X, y, cross_val='4-Fold', scoring='accuracy', feat_select=None, class_weight='auto'): """ Fits X to outcomes y, using clf and cv_method """ from sklearn import cross_validation self.X = X self.y = y self.set_class_weight(class_weig...
def cross_val_fit(self, X, y, cross_val='4-Fold', scoring='accuracy', feat_select=None, class_weight='auto'): """ Fits X to outcomes y, using clf and cv_method """ from sklearn import cross_validation self.X = X self.y = y self.set_class_weight(class_weig...
[ "Fits", "X", "to", "outcomes", "y", "using", "clf", "and", "cv_method" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L333-L386
[ "def", "cross_val_fit", "(", "self", ",", "X", ",", "y", ",", "cross_val", "=", "'4-Fold'", ",", "scoring", "=", "'accuracy'", ",", "feat_select", "=", "None", ",", "class_weight", "=", "'auto'", ")", ":", "from", "sklearn", "import", "cross_validation", "...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Classifier.feat_select_cvs
Returns cross validated scores (just like cross_val_score), but includes feature selection as part of the cross validation loop
neurosynth/analysis/classify.py
def feat_select_cvs(self, scoring=None, feat_select=None): """ Returns cross validated scores (just like cross_val_score), but includes feature selection as part of the cross validation loop """ scores = [] self.predictions = [] for train, test in self.cver: X_train...
def feat_select_cvs(self, scoring=None, feat_select=None): """ Returns cross validated scores (just like cross_val_score), but includes feature selection as part of the cross validation loop """ scores = [] self.predictions = [] for train, test in self.cver: X_train...
[ "Returns", "cross", "validated", "scores", "(", "just", "like", "cross_val_score", ")", "but", "includes", "feature", "selection", "as", "part", "of", "the", "cross", "validation", "loop" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L388-L422
[ "def", "feat_select_cvs", "(", "self", ",", "scoring", "=", "None", ",", "feat_select", "=", "None", ")", ":", "scores", "=", "[", "]", "self", ".", "predictions", "=", "[", "]", "for", "train", ",", "test", "in", "self", ".", "cver", ":", "X_train",...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Classifier.fit_dataset
Given a dataset, fits either features or voxels to y
neurosynth/analysis/classify.py
def fit_dataset(self, dataset, y, features=None, feature_type='features'): """ Given a dataset, fits either features or voxels to y """ # Get data from dataset if feature_type == 'features': X = np.rot90(dataset.feature_table.data.toarray()) elif feature...
def fit_dataset(self, dataset, y, features=None, feature_type='features'): """ Given a dataset, fits either features or voxels to y """ # Get data from dataset if feature_type == 'features': X = np.rot90(dataset.feature_table.data.toarray()) elif feature...
[ "Given", "a", "dataset", "fits", "either", "features", "or", "voxels", "to", "y" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L424-L435
[ "def", "fit_dataset", "(", "self", ",", "dataset", ",", "y", ",", "features", "=", "None", ",", "feature_type", "=", "'features'", ")", ":", "# Get data from dataset", "if", "feature_type", "==", "'features'", ":", "X", "=", "np", ".", "rot90", "(", "datas...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Parser.p_list_andnot
list : list ANDNOT list
neurosynth/base/lexparser.py
def p_list_andnot(self, p): 'list : list ANDNOT list' p[0] = p[1].loc[set(p[1].index) - set(p[3].index)]
def p_list_andnot(self, p): 'list : list ANDNOT list' p[0] = p[1].loc[set(p[1].index) - set(p[3].index)]
[ "list", ":", "list", "ANDNOT", "list" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/lexparser.py#L66-L68
[ "def", "p_list_andnot", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "p", "[", "1", "]", ".", "loc", "[", "set", "(", "p", "[", "1", "]", ".", "index", ")", "-", "set", "(", "p", "[", "3", "]", ".", "index", ")", "]" ]
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Parser.p_list_and
list : list AND list
neurosynth/base/lexparser.py
def p_list_and(self, p): 'list : list AND list' p[0] = pd.concat( [p[1], p[3]], axis=1).dropna().apply(self.func, axis=1)
def p_list_and(self, p): 'list : list AND list' p[0] = pd.concat( [p[1], p[3]], axis=1).dropna().apply(self.func, axis=1)
[ "list", ":", "list", "AND", "list" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/lexparser.py#L70-L73
[ "def", "p_list_and", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "pd", ".", "concat", "(", "[", "p", "[", "1", "]", ",", "p", "[", "3", "]", "]", ",", "axis", "=", "1", ")", ".", "dropna", "(", ")", ".", "apply", "(", "sel...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Parser.p_list_or
list : list OR list
neurosynth/base/lexparser.py
def p_list_or(self, p): 'list : list OR list' p[0] = pd.concat( [p[1], p[3]], axis=1).fillna(0.0).apply(self.func, axis=1)
def p_list_or(self, p): 'list : list OR list' p[0] = pd.concat( [p[1], p[3]], axis=1).fillna(0.0).apply(self.func, axis=1)
[ "list", ":", "list", "OR", "list" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/lexparser.py#L75-L78
[ "def", "p_list_or", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "pd", ".", "concat", "(", "[", "p", "[", "1", "]", ",", "p", "[", "3", "]", "]", ",", "axis", "=", "1", ")", ".", "fillna", "(", "0.0", ")", ".", "apply", "("...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Parser.p_list_feature
list : feature | WORD
neurosynth/base/lexparser.py
def p_list_feature(self, p): '''list : feature | WORD ''' p[0] = self.dataset.get_studies( features=p[1], frequency_threshold=self.threshold, func=self.func, return_type='weights')
def p_list_feature(self, p): '''list : feature | WORD ''' p[0] = self.dataset.get_studies( features=p[1], frequency_threshold=self.threshold, func=self.func, return_type='weights')
[ "list", ":", "feature", "|", "WORD" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/lexparser.py#L93-L98
[ "def", "p_list_feature", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "self", ".", "dataset", ".", "get_studies", "(", "features", "=", "p", "[", "1", "]", ",", "frequency_threshold", "=", "self", ".", "threshold", ",", "func", "=", "s...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
average_within_regions
Aggregates over all voxels within each ROI in the input image. Takes a Dataset and a Nifti image that defines distinct regions, and returns a numpy matrix of ROIs x mappables, where the value at each ROI is the proportion of active voxels in that ROI. Each distinct ROI must have a unique value in the ...
neurosynth/analysis/reduce.py
def average_within_regions(dataset, regions, masker=None, threshold=None, remove_zero=True): """ Aggregates over all voxels within each ROI in the input image. Takes a Dataset and a Nifti image that defines distinct regions, and returns a numpy matrix of ROIs x mappables, where ...
def average_within_regions(dataset, regions, masker=None, threshold=None, remove_zero=True): """ Aggregates over all voxels within each ROI in the input image. Takes a Dataset and a Nifti image that defines distinct regions, and returns a numpy matrix of ROIs x mappables, where ...
[ "Aggregates", "over", "all", "voxels", "within", "each", "ROI", "in", "the", "input", "image", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/reduce.py#L17-L111
[ "def", "average_within_regions", "(", "dataset", ",", "regions", ",", "masker", "=", "None", ",", "threshold", "=", "None", ",", "remove_zero", "=", "True", ")", ":", "if", "masker", "is", "not", "None", ":", "masker", "=", "masker", "else", ":", "if", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
apply_grid
Imposes a 3D grid on the brain volume and averages across all voxels that fall within each cell. Args: dataset: Data to apply grid to. Either a Dataset instance, or a numpy array with voxels in rows and features in columns. masker: Optional Masker instance used to map between the cre...
neurosynth/analysis/reduce.py
def apply_grid(dataset, masker=None, scale=5, threshold=None): """ Imposes a 3D grid on the brain volume and averages across all voxels that fall within each cell. Args: dataset: Data to apply grid to. Either a Dataset instance, or a numpy array with voxels in rows and features in column...
def apply_grid(dataset, masker=None, scale=5, threshold=None): """ Imposes a 3D grid on the brain volume and averages across all voxels that fall within each cell. Args: dataset: Data to apply grid to. Either a Dataset instance, or a numpy array with voxels in rows and features in column...
[ "Imposes", "a", "3D", "grid", "on", "the", "brain", "volume", "and", "averages", "across", "all", "voxels", "that", "fall", "within", "each", "cell", ".", "Args", ":", "dataset", ":", "Data", "to", "apply", "grid", "to", ".", "Either", "a", "Dataset", ...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/reduce.py#L114-L142
[ "def", "apply_grid", "(", "dataset", ",", "masker", "=", "None", ",", "scale", "=", "5", ",", "threshold", "=", "None", ")", ":", "if", "masker", "is", "None", ":", "if", "isinstance", "(", "dataset", ",", "Dataset", ")", ":", "masker", "=", "dataset...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
get_random_voxels
Returns mappable data for a random subset of voxels. May be useful as a baseline in predictive analyses--e.g., to compare performance of a more principled feature selection method with simple random selection. Args: dataset: A Dataset instance n_voxels: An integer specifying the number...
neurosynth/analysis/reduce.py
def get_random_voxels(dataset, n_voxels): """ Returns mappable data for a random subset of voxels. May be useful as a baseline in predictive analyses--e.g., to compare performance of a more principled feature selection method with simple random selection. Args: dataset: A Dataset instance ...
def get_random_voxels(dataset, n_voxels): """ Returns mappable data for a random subset of voxels. May be useful as a baseline in predictive analyses--e.g., to compare performance of a more principled feature selection method with simple random selection. Args: dataset: A Dataset instance ...
[ "Returns", "mappable", "data", "for", "a", "random", "subset", "of", "voxels", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/reduce.py#L145-L163
[ "def", "get_random_voxels", "(", "dataset", ",", "n_voxels", ")", ":", "voxels", "=", "np", ".", "arange", "(", "dataset", ".", "masker", ".", "n_vox_in_vol", ")", "np", ".", "random", ".", "shuffle", "(", "voxels", ")", "selected", "=", "voxels", "[", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
_get_top_words
Return top forty words from each topic in trained topic model.
neurosynth/analysis/reduce.py
def _get_top_words(model, feature_names, n_top_words=40): """ Return top forty words from each topic in trained topic model. """ topic_words = [] for topic in model.components_: top_words = [feature_names[i] for i in topic.argsort()[:-n_top_words-1:-1]] topic_words += [top_words] ret...
def _get_top_words(model, feature_names, n_top_words=40): """ Return top forty words from each topic in trained topic model. """ topic_words = [] for topic in model.components_: top_words = [feature_names[i] for i in topic.argsort()[:-n_top_words-1:-1]] topic_words += [top_words] ret...
[ "Return", "top", "forty", "words", "from", "each", "topic", "in", "trained", "topic", "model", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/reduce.py#L166-L173
[ "def", "_get_top_words", "(", "model", ",", "feature_names", ",", "n_top_words", "=", "40", ")", ":", "topic_words", "=", "[", "]", "for", "topic", "in", "model", ".", "components_", ":", "top_words", "=", "[", "feature_names", "[", "i", "]", "for", "i",...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
run_lda
Perform topic modeling using Latent Dirichlet Allocation with the Java toolbox MALLET. Args: abstracts: A pandas DataFrame with two columns ('pmid' and 'abstract') containing article abstracts. n_topics: Number of topics to generate. Default=50. n_words: Number...
neurosynth/analysis/reduce.py
def run_lda(abstracts, n_topics=50, n_words=31, n_iters=1000, alpha=None, beta=0.001): """ Perform topic modeling using Latent Dirichlet Allocation with the Java toolbox MALLET. Args: abstracts: A pandas DataFrame with two columns ('pmid' and 'abstract') containing ...
def run_lda(abstracts, n_topics=50, n_words=31, n_iters=1000, alpha=None, beta=0.001): """ Perform topic modeling using Latent Dirichlet Allocation with the Java toolbox MALLET. Args: abstracts: A pandas DataFrame with two columns ('pmid' and 'abstract') containing ...
[ "Perform", "topic", "modeling", "using", "Latent", "Dirichlet", "Allocation", "with", "the", "Java", "toolbox", "MALLET", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/reduce.py#L176-L323
[ "def", "run_lda", "(", "abstracts", ",", "n_topics", "=", "50", ",", "n_words", "=", "31", ",", "n_iters", "=", "1000", ",", "alpha", "=", "None", ",", "beta", "=", "0.001", ")", ":", "if", "abstracts", ".", "index", ".", "name", "!=", "'pmid'", ":...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
pearson
Correlates row vector x with each row vector in 2D array y.
neurosynth/analysis/stats.py
def pearson(x, y): """ Correlates row vector x with each row vector in 2D array y. """ data = np.vstack((x, y)) ms = data.mean(axis=1)[(slice(None, None, None), None)] datam = data - ms datass = np.sqrt(np.sum(datam**2, axis=1)) temp = np.dot(datam[1:], datam[0].T) rs = temp / (datass[1:] * ...
def pearson(x, y): """ Correlates row vector x with each row vector in 2D array y. """ data = np.vstack((x, y)) ms = data.mean(axis=1)[(slice(None, None, None), None)] datam = data - ms datass = np.sqrt(np.sum(datam**2, axis=1)) temp = np.dot(datam[1:], datam[0].T) rs = temp / (datass[1:] * ...
[ "Correlates", "row", "vector", "x", "with", "each", "row", "vector", "in", "2D", "array", "y", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/stats.py#L8-L16
[ "def", "pearson", "(", "x", ",", "y", ")", ":", "data", "=", "np", ".", "vstack", "(", "(", "x", ",", "y", ")", ")", "ms", "=", "data", ".", "mean", "(", "axis", "=", "1", ")", "[", "(", "slice", "(", "None", ",", "None", ",", "None", ")"...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
two_way
Two-way chi-square test of independence. Takes a 3D array as input: N(voxels) x 2 x 2, where the last two dimensions are the contingency table for each of N voxels. Returns an array of p-values.
neurosynth/analysis/stats.py
def two_way(cells): """ Two-way chi-square test of independence. Takes a 3D array as input: N(voxels) x 2 x 2, where the last two dimensions are the contingency table for each of N voxels. Returns an array of p-values. """ # Mute divide-by-zero warning for bad voxels since we account for that ...
def two_way(cells): """ Two-way chi-square test of independence. Takes a 3D array as input: N(voxels) x 2 x 2, where the last two dimensions are the contingency table for each of N voxels. Returns an array of p-values. """ # Mute divide-by-zero warning for bad voxels since we account for that ...
[ "Two", "-", "way", "chi", "-", "square", "test", "of", "independence", ".", "Takes", "a", "3D", "array", "as", "input", ":", "N", "(", "voxels", ")", "x", "2", "x", "2", "where", "the", "last", "two", "dimensions", "are", "the", "contingency", "table...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/stats.py#L19-L40
[ "def", "two_way", "(", "cells", ")", ":", "# Mute divide-by-zero warning for bad voxels since we account for that", "# later", "warnings", ".", "simplefilter", "(", "\"ignore\"", ",", "RuntimeWarning", ")", "cells", "=", "cells", ".", "astype", "(", "'float64'", ")", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
one_way
One-way chi-square test of independence. Takes a 1D array as input and compares activation at each voxel to proportion expected under a uniform distribution throughout the array. Note that if you're testing activation with this, make sure that only valid voxels (e.g., in-mask gray matter voxels) are inc...
neurosynth/analysis/stats.py
def one_way(data, n): """ One-way chi-square test of independence. Takes a 1D array as input and compares activation at each voxel to proportion expected under a uniform distribution throughout the array. Note that if you're testing activation with this, make sure that only valid voxels (e.g., in-ma...
def one_way(data, n): """ One-way chi-square test of independence. Takes a 1D array as input and compares activation at each voxel to proportion expected under a uniform distribution throughout the array. Note that if you're testing activation with this, make sure that only valid voxels (e.g., in-ma...
[ "One", "-", "way", "chi", "-", "square", "test", "of", "independence", ".", "Takes", "a", "1D", "array", "as", "input", "and", "compares", "activation", "at", "each", "voxel", "to", "proportion", "expected", "under", "a", "uniform", "distribution", "througho...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/stats.py#L43-L59
[ "def", "one_way", "(", "data", ",", "n", ")", ":", "term", "=", "data", ".", "astype", "(", "'float64'", ")", "no_term", "=", "n", "-", "term", "t_exp", "=", "np", ".", "mean", "(", "term", ",", "0", ")", "t_exp", "=", "np", ".", "array", "(", ...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
fdr
Determine FDR threshold given a p value array and desired false discovery rate q.
neurosynth/analysis/stats.py
def fdr(p, q=.05): """ Determine FDR threshold given a p value array and desired false discovery rate q. """ s = np.sort(p) nvox = p.shape[0] null = np.array(range(1, nvox + 1), dtype='float') * q / nvox below = np.where(s <= null)[0] return s[max(below)] if len(below) else -1
def fdr(p, q=.05): """ Determine FDR threshold given a p value array and desired false discovery rate q. """ s = np.sort(p) nvox = p.shape[0] null = np.array(range(1, nvox + 1), dtype='float') * q / nvox below = np.where(s <= null)[0] return s[max(below)] if len(below) else -1
[ "Determine", "FDR", "threshold", "given", "a", "p", "value", "array", "and", "desired", "false", "discovery", "rate", "q", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/stats.py#L62-L69
[ "def", "fdr", "(", "p", ",", "q", "=", ".05", ")", ":", "s", "=", "np", ".", "sort", "(", "p", ")", "nvox", "=", "p", ".", "shape", "[", "0", "]", "null", "=", "np", ".", "array", "(", "range", "(", "1", ",", "nvox", "+", "1", ")", ",",...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
download
Download the latest data files. Args: path (str): Location to save the retrieved data files. Defaults to current directory. unpack (bool): If True, unzips the data file post-download.
neurosynth/base/dataset.py
def download(path='.', url=None, unpack=False): """ Download the latest data files. Args: path (str): Location to save the retrieved data files. Defaults to current directory. unpack (bool): If True, unzips the data file post-download. """ if url is None: url = 'http...
def download(path='.', url=None, unpack=False): """ Download the latest data files. Args: path (str): Location to save the retrieved data files. Defaults to current directory. unpack (bool): If True, unzips the data file post-download. """ if url is None: url = 'http...
[ "Download", "the", "latest", "data", "files", ".", "Args", ":", "path", "(", "str", ")", ":", "Location", "to", "save", "the", "retrieved", "data", "files", ".", "Defaults", "to", "current", "directory", ".", "unpack", "(", "bool", ")", ":", "If", "Tru...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/dataset.py#L29-L69
[ "def", "download", "(", "path", "=", "'.'", ",", "url", "=", "None", ",", "unpack", "=", "False", ")", ":", "if", "url", "is", "None", ":", "url", "=", "'https://github.com/neurosynth/neurosynth-data/blob/master/current_data.tar.gz?raw=true'", "if", "os", ".", "...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
download_abstracts
Download the abstracts for a dataset/list of pmids
neurosynth/base/dataset.py
def download_abstracts(dataset, path='.', email=None, out_file=None): """ Download the abstracts for a dataset/list of pmids """ try: from Bio import Entrez, Medline except: raise Exception( 'Module biopython is required for downloading abstracts from PubMed.') if email ...
def download_abstracts(dataset, path='.', email=None, out_file=None): """ Download the abstracts for a dataset/list of pmids """ try: from Bio import Entrez, Medline except: raise Exception( 'Module biopython is required for downloading abstracts from PubMed.') if email ...
[ "Download", "the", "abstracts", "for", "a", "dataset", "/", "list", "of", "pmids" ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/dataset.py#L72-L107
[ "def", "download_abstracts", "(", "dataset", ",", "path", "=", "'.'", ",", "email", "=", "None", ",", "out_file", "=", "None", ")", ":", "try", ":", "from", "Bio", "import", "Entrez", ",", "Medline", "except", ":", "raise", "Exception", "(", "'Module bio...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Dataset._load_activations
Load activation data from a text file. Args: filename (str): a string pointing to the location of the txt file to read from.
neurosynth/base/dataset.py
def _load_activations(self, filename): """ Load activation data from a text file. Args: filename (str): a string pointing to the location of the txt file to read from. """ logger.info("Loading activation data from %s..." % filename) activations = pd....
def _load_activations(self, filename): """ Load activation data from a text file. Args: filename (str): a string pointing to the location of the txt file to read from. """ logger.info("Loading activation data from %s..." % filename) activations = pd....
[ "Load", "activation", "data", "from", "a", "text", "file", "." ]
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/dataset.py#L189-L223
[ "def", "_load_activations", "(", "self", ",", "filename", ")", ":", "logger", ".", "info", "(", "\"Loading activation data from %s...\"", "%", "filename", ")", "activations", "=", "pd", ".", "read_csv", "(", "filename", ",", "sep", "=", "'\\t'", ")", "activati...
948ce7edce15d7df693446e76834e0c23bfe8f11
test
Dataset.create_image_table
Create and store a new ImageTable instance based on the current Dataset. Will generally be called privately, but may be useful as a convenience method in cases where the user wants to re-generate the table with a new smoothing kernel of different radius. Args: r (int): An op...
neurosynth/base/dataset.py
def create_image_table(self, r=None): """ Create and store a new ImageTable instance based on the current Dataset. Will generally be called privately, but may be useful as a convenience method in cases where the user wants to re-generate the table with a new smoothing kernel of different...
def create_image_table(self, r=None): """ Create and store a new ImageTable instance based on the current Dataset. Will generally be called privately, but may be useful as a convenience method in cases where the user wants to re-generate the table with a new smoothing kernel of different...
[ "Create", "and", "store", "a", "new", "ImageTable", "instance", "based", "on", "the", "current", "Dataset", ".", "Will", "generally", "be", "called", "privately", "but", "may", "be", "useful", "as", "a", "convenience", "method", "in", "cases", "where", "the"...
neurosynth/neurosynth
python
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/dataset.py#L225-L239
[ "def", "create_image_table", "(", "self", ",", "r", "=", "None", ")", ":", "logger", ".", "info", "(", "\"Creating image table...\"", ")", "if", "r", "is", "not", "None", ":", "self", ".", "r", "=", "r", "self", ".", "image_table", "=", "ImageTable", "...
948ce7edce15d7df693446e76834e0c23bfe8f11