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
valid
read_temple_config
Reads the temple YAML configuration file in the repository
temple/utils.py
def read_temple_config(): """Reads the temple YAML configuration file in the repository""" with open(temple.constants.TEMPLE_CONFIG_FILE) as temple_config_file: return yaml.load(temple_config_file, Loader=yaml.SafeLoader)
def read_temple_config(): """Reads the temple YAML configuration file in the repository""" with open(temple.constants.TEMPLE_CONFIG_FILE) as temple_config_file: return yaml.load(temple_config_file, Loader=yaml.SafeLoader)
[ "Reads", "the", "temple", "YAML", "configuration", "file", "in", "the", "repository" ]
CloverHealth/temple
python
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/utils.py#L42-L45
[ "def", "read_temple_config", "(", ")", ":", "with", "open", "(", "temple", ".", "constants", ".", "TEMPLE_CONFIG_FILE", ")", "as", "temple_config_file", ":", "return", "yaml", ".", "load", "(", "temple_config_file", ",", "Loader", "=", "yaml", ".", "SafeLoader...
d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd
valid
write_temple_config
Writes the temple YAML configuration
temple/utils.py
def write_temple_config(temple_config, template, version): """Writes the temple YAML configuration""" with open(temple.constants.TEMPLE_CONFIG_FILE, 'w') as temple_config_file: versioned_config = { **temple_config, **{'_version': version, '_template': template}, } ...
def write_temple_config(temple_config, template, version): """Writes the temple YAML configuration""" with open(temple.constants.TEMPLE_CONFIG_FILE, 'w') as temple_config_file: versioned_config = { **temple_config, **{'_version': version, '_template': template}, } ...
[ "Writes", "the", "temple", "YAML", "configuration" ]
CloverHealth/temple
python
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/utils.py#L48-L55
[ "def", "write_temple_config", "(", "temple_config", ",", "template", ",", "version", ")", ":", "with", "open", "(", "temple", ".", "constants", ".", "TEMPLE_CONFIG_FILE", ",", "'w'", ")", "as", "temple_config_file", ":", "versioned_config", "=", "{", "*", "*",...
d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd
valid
get_cookiecutter_config
Obtains the configuration used for cookiecutter templating Args: template: Path to the template default_config (dict, optional): The default configuration version (str, optional): The git SHA or branch to use when checking out template. Defaults to latest version Returns: ...
temple/utils.py
def get_cookiecutter_config(template, default_config=None, version=None): """Obtains the configuration used for cookiecutter templating Args: template: Path to the template default_config (dict, optional): The default configuration version (str, optional): The git SHA or branch to use w...
def get_cookiecutter_config(template, default_config=None, version=None): """Obtains the configuration used for cookiecutter templating Args: template: Path to the template default_config (dict, optional): The default configuration version (str, optional): The git SHA or branch to use w...
[ "Obtains", "the", "configuration", "used", "for", "cookiecutter", "templating" ]
CloverHealth/temple
python
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/utils.py#L58-L82
[ "def", "get_cookiecutter_config", "(", "template", ",", "default_config", "=", "None", ",", "version", "=", "None", ")", ":", "default_config", "=", "default_config", "or", "{", "}", "config_dict", "=", "cc_config", ".", "get_user_config", "(", ")", "repo_dir", ...
d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd
valid
set_cmd_env_var
Decorator that sets the temple command env var to value
temple/utils.py
def set_cmd_env_var(value): """Decorator that sets the temple command env var to value""" def func_decorator(function): @functools.wraps(function) def wrapper(*args, **kwargs): previous_cmd_env_var = os.getenv(temple.constants.TEMPLE_ENV_VAR) os.environ[temple.constants.T...
def set_cmd_env_var(value): """Decorator that sets the temple command env var to value""" def func_decorator(function): @functools.wraps(function) def wrapper(*args, **kwargs): previous_cmd_env_var = os.getenv(temple.constants.TEMPLE_ENV_VAR) os.environ[temple.constants.T...
[ "Decorator", "that", "sets", "the", "temple", "command", "env", "var", "to", "value" ]
CloverHealth/temple
python
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/utils.py#L85-L102
[ "def", "set_cmd_env_var", "(", "value", ")", ":", "def", "func_decorator", "(", "function", ")", ":", "@", "functools", ".", "wraps", "(", "function", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_cmd_env_var", "="...
d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd
valid
GithubClient._call_api
Perform a github API call Args: verb (str): Can be "post", "put", or "get" url (str): The base URL with a leading slash for Github API (v3) auth (str or HTTPBasicAuth): A Github API token or a HTTPBasicAuth object
temple/utils.py
def _call_api(self, verb, url, **request_kwargs): """Perform a github API call Args: verb (str): Can be "post", "put", or "get" url (str): The base URL with a leading slash for Github API (v3) auth (str or HTTPBasicAuth): A Github API token or a HTTPBasicAuth object ...
def _call_api(self, verb, url, **request_kwargs): """Perform a github API call Args: verb (str): Can be "post", "put", or "get" url (str): The base URL with a leading slash for Github API (v3) auth (str or HTTPBasicAuth): A Github API token or a HTTPBasicAuth object ...
[ "Perform", "a", "github", "API", "call" ]
CloverHealth/temple
python
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/utils.py#L113-L124
[ "def", "_call_api", "(", "self", ",", "verb", ",", "url", ",", "*", "*", "request_kwargs", ")", ":", "api", "=", "'https://api.github.com{}'", ".", "format", "(", "url", ")", "auth_headers", "=", "{", "'Authorization'", ":", "'token {}'", ".", "format", "(...
d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd
valid
deploy
Deploys the package and documentation. Proceeds in the following steps: 1. Ensures proper environment variables are set and checks that we are on Circle CI 2. Tags the repository with the new version 3. Creates a standard distribution and a wheel 4. Updates version.py to have the proper version ...
deploy.py
def deploy(target): """Deploys the package and documentation. Proceeds in the following steps: 1. Ensures proper environment variables are set and checks that we are on Circle CI 2. Tags the repository with the new version 3. Creates a standard distribution and a wheel 4. Updates version.py to...
def deploy(target): """Deploys the package and documentation. Proceeds in the following steps: 1. Ensures proper environment variables are set and checks that we are on Circle CI 2. Tags the repository with the new version 3. Creates a standard distribution and a wheel 4. Updates version.py to...
[ "Deploys", "the", "package", "and", "documentation", "." ]
CloverHealth/temple
python
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/deploy.py#L43-L128
[ "def", "deploy", "(", "target", ")", ":", "# Ensure proper environment", "if", "not", "os", ".", "getenv", "(", "CIRCLECI_ENV_VAR", ")", ":", "# pragma: no cover", "raise", "EnvironmentError", "(", "'Must be on CircleCI to run this script'", ")", "current_branch", "=", ...
d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd
valid
report
Decorator for method run. This method will be execute before the execution from the method with this decorator.
atomshields/reports/base.py
def report(func): """ Decorator for method run. This method will be execute before the execution from the method with this decorator. """ def execute(self, *args, **kwargs): try: print "[>] Executing {n} report. . . ".format(n=self.__class__.NAME) if hasattr(self, 'test'): if self.test(): return f...
def report(func): """ Decorator for method run. This method will be execute before the execution from the method with this decorator. """ def execute(self, *args, **kwargs): try: print "[>] Executing {n} report. . . ".format(n=self.__class__.NAME) if hasattr(self, 'test'): if self.test(): return f...
[ "Decorator", "for", "method", "run", ".", "This", "method", "will", "be", "execute", "before", "the", "execution", "from", "the", "method", "with", "this", "decorator", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/reports/base.py#L88-L107
[ "def", "report", "(", "func", ")", ":", "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "print", "\"[>] Executing {n} report. . . \"", ".", "format", "(", "n", "=", "self", ".", "__class__", ".", "NAME", ...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
DSStoreChecker.run
Finds .DS_Store files into path
atomshields/checkers/dsstore.py
def run(self): """ Finds .DS_Store files into path """ filename = ".DS_Store" command = "find {path} -type f -name \"{filename}\" ".format(path = self.path, filename = filename) cmd = CommandHelper(command) cmd.execute() files = cmd.output.split("\n") for f in files: if not f.endswith(filename): ...
def run(self): """ Finds .DS_Store files into path """ filename = ".DS_Store" command = "find {path} -type f -name \"{filename}\" ".format(path = self.path, filename = filename) cmd = CommandHelper(command) cmd.execute() files = cmd.output.split("\n") for f in files: if not f.endswith(filename): ...
[ "Finds", ".", "DS_Store", "files", "into", "path" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/checkers/dsstore.py#L22-L48
[ "def", "run", "(", "self", ")", ":", "filename", "=", "\".DS_Store\"", "command", "=", "\"find {path} -type f -name \\\"{filename}\\\" \"", ".", "format", "(", "path", "=", "self", ".", "path", ",", "filename", "=", "filename", ")", "cmd", "=", "CommandHelper", ...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
HttpReport.run
Method executed dynamically by framework. This method will do a http request to endpoint setted into config file with the issues and other data.
atomshields/reports/http.py
def run(self): """ Method executed dynamically by framework. This method will do a http request to endpoint setted into config file with the issues and other data. """ options = {} if bool(self.config['use_proxy']): options['proxies'] = {"http": self.config['proxy'], "https": self.config['proxy']} opt...
def run(self): """ Method executed dynamically by framework. This method will do a http request to endpoint setted into config file with the issues and other data. """ options = {} if bool(self.config['use_proxy']): options['proxies'] = {"http": self.config['proxy'], "https": self.config['proxy']} opt...
[ "Method", "executed", "dynamically", "by", "framework", ".", "This", "method", "will", "do", "a", "http", "request", "to", "endpoint", "setted", "into", "config", "file", "with", "the", "issues", "and", "other", "data", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/reports/http.py#L33-L48
[ "def", "run", "(", "self", ")", ":", "options", "=", "{", "}", "if", "bool", "(", "self", ".", "config", "[", "'use_proxy'", "]", ")", ":", "options", "[", "'proxies'", "]", "=", "{", "\"http\"", ":", "self", ".", "config", "[", "'proxy'", "]", "...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
GenericChecker.path
Setter for 'path' property Args: value (str): Absolute path to scan
atomshields/checkers/base.py
def path(self, value): """ Setter for 'path' property Args: value (str): Absolute path to scan """ if not value.endswith('/'): self._path = '{v}/'.format(v=value) else: self._path = value
def path(self, value): """ Setter for 'path' property Args: value (str): Absolute path to scan """ if not value.endswith('/'): self._path = '{v}/'.format(v=value) else: self._path = value
[ "Setter", "for", "path", "property" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/checkers/base.py#L51-L62
[ "def", "path", "(", "self", ",", "value", ")", ":", "if", "not", "value", ".", "endswith", "(", "'/'", ")", ":", "self", ".", "_path", "=", "'{v}/'", ".", "format", "(", "v", "=", "value", ")", "else", ":", "self", ".", "_path", "=", "value" ]
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
GenericChecker.parseConfig
Parse the config values Args: value (dict): Dictionary which contains the checker config Returns: dict: The checker config with parsed values
atomshields/checkers/base.py
def parseConfig(cls, value): """ Parse the config values Args: value (dict): Dictionary which contains the checker config Returns: dict: The checker config with parsed values """ if 'enabled' in value: value['enabled'] = bool(value['enabled']) if 'exclude_paths' in value: value['exclude_pat...
def parseConfig(cls, value): """ Parse the config values Args: value (dict): Dictionary which contains the checker config Returns: dict: The checker config with parsed values """ if 'enabled' in value: value['enabled'] = bool(value['enabled']) if 'exclude_paths' in value: value['exclude_pat...
[ "Parse", "the", "config", "values" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/checkers/base.py#L161-L177
[ "def", "parseConfig", "(", "cls", ",", "value", ")", ":", "if", "'enabled'", "in", "value", ":", "value", "[", "'enabled'", "]", "=", "bool", "(", "value", "[", "'enabled'", "]", ")", "if", "'exclude_paths'", "in", "value", ":", "value", "[", "'exclude...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
GenericChecker.isInstalled
Check if a software is installed into machine. Args: value (str): Software's name Returns: bool: True if the software is installed. False else
atomshields/checkers/base.py
def isInstalled(value): """ Check if a software is installed into machine. Args: value (str): Software's name Returns: bool: True if the software is installed. False else """ function = """ function is_installed { local return_=1; type $1 >/dev/null 2>&1 || { local return_=0; }; echo ...
def isInstalled(value): """ Check if a software is installed into machine. Args: value (str): Software's name Returns: bool: True if the software is installed. False else """ function = """ function is_installed { local return_=1; type $1 >/dev/null 2>&1 || { local return_=0; }; echo ...
[ "Check", "if", "a", "software", "is", "installed", "into", "machine", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/checkers/base.py#L180-L201
[ "def", "isInstalled", "(", "value", ")", ":", "function", "=", "\"\"\"\n\t\tfunction is_installed {\n\t\t local return_=1;\n\t\t type $1 >/dev/null 2>&1 || { local return_=0; };\n\t\t echo \"$return_\";\n\t\t}\"\"\"", "command", "=", "\"\"\"bash -c '{f}; echo $(is_installed \\\"{arg}\\\")'\...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
CommandHelper.getOSName
Get the OS name. If OS is linux, returns the Linux distribution name Returns: str: OS name
atomshields/helpers.py
def getOSName(self): """ Get the OS name. If OS is linux, returns the Linux distribution name Returns: str: OS name """ _system = platform.system() if _system in [self.__class__.OS_WINDOWS, self.__class__.OS_MAC, self.__class__.OS_LINUX]: if _system == self.__class__.OS_LINUX: _dist = platform.li...
def getOSName(self): """ Get the OS name. If OS is linux, returns the Linux distribution name Returns: str: OS name """ _system = platform.system() if _system in [self.__class__.OS_WINDOWS, self.__class__.OS_MAC, self.__class__.OS_LINUX]: if _system == self.__class__.OS_LINUX: _dist = platform.li...
[ "Get", "the", "OS", "name", ".", "If", "OS", "is", "linux", "returns", "the", "Linux", "distribution", "name" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/helpers.py#L96-L119
[ "def", "getOSName", "(", "self", ")", ":", "_system", "=", "platform", ".", "system", "(", ")", "if", "_system", "in", "[", "self", ".", "__class__", ".", "OS_WINDOWS", ",", "self", ".", "__class__", ".", "OS_MAC", ",", "self", ".", "__class__", ".", ...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
CommandHelper.execute
Executes the command setted into class Args: shell (boolean): Set True if command is a shell command. Default: True
atomshields/helpers.py
def execute(self, shell = True): """ Executes the command setted into class Args: shell (boolean): Set True if command is a shell command. Default: True """ process = Popen(self.command, stdout=PIPE, stderr=PIPE, shell=shell) self.output, self.errors = process.communicate()
def execute(self, shell = True): """ Executes the command setted into class Args: shell (boolean): Set True if command is a shell command. Default: True """ process = Popen(self.command, stdout=PIPE, stderr=PIPE, shell=shell) self.output, self.errors = process.communicate()
[ "Executes", "the", "command", "setted", "into", "class" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/helpers.py#L152-L160
[ "def", "execute", "(", "self", ",", "shell", "=", "True", ")", ":", "process", "=", "Popen", "(", "self", ".", "command", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "PIPE", ",", "shell", "=", "shell", ")", "self", ".", "output", ",", "self", ...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner._debug
Print a message if the class attribute 'verbose' is enabled Args: message (str): Message to print
atomshields/scanner.py
def _debug(message, color=None, attrs=None): """ Print a message if the class attribute 'verbose' is enabled Args: message (str): Message to print """ if attrs is None: attrs = [] if color is not None: print colored(message, color, attrs=attrs) else: if len(attrs) > 0: print colored(messa...
def _debug(message, color=None, attrs=None): """ Print a message if the class attribute 'verbose' is enabled Args: message (str): Message to print """ if attrs is None: attrs = [] if color is not None: print colored(message, color, attrs=attrs) else: if len(attrs) > 0: print colored(messa...
[ "Print", "a", "message", "if", "the", "class", "attribute", "verbose", "is", "enabled" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L43-L58
[ "def", "_debug", "(", "message", ",", "color", "=", "None", ",", "attrs", "=", "None", ")", ":", "if", "attrs", "is", "None", ":", "attrs", "=", "[", "]", "if", "color", "is", "not", "None", ":", "print", "colored", "(", "message", ",", "color", ...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner.setup
Creates required directories and copy checkers and reports.
atomshields/scanner.py
def setup(): """ Creates required directories and copy checkers and reports. """ # # Check if dir is writable # if not os.access(AtomShieldsScanner.HOME, os.W_OK): # AtomShieldsScanner.HOME = os.path.expanduser("~/.atomshields") # AtomShieldsScanner.CHECKERS_DIR = os.path.join(AtomShieldsScanner.HOME...
def setup(): """ Creates required directories and copy checkers and reports. """ # # Check if dir is writable # if not os.access(AtomShieldsScanner.HOME, os.W_OK): # AtomShieldsScanner.HOME = os.path.expanduser("~/.atomshields") # AtomShieldsScanner.CHECKERS_DIR = os.path.join(AtomShieldsScanner.HOME...
[ "Creates", "required", "directories", "and", "copy", "checkers", "and", "reports", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L175-L206
[ "def", "setup", "(", ")", ":", "# # Check if dir is writable", "# if not os.access(AtomShieldsScanner.HOME, os.W_OK):", "# \tAtomShieldsScanner.HOME = os.path.expanduser(\"~/.atomshields\")", "# \tAtomShieldsScanner.CHECKERS_DIR = os.path.join(AtomShieldsScanner.HOME, \"checkers\")", "# \tAtomShie...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner._addConfig
Writes a section for a plugin. Args: instance (object): Class instance for plugin config (object): Object (ConfigParser) which the current config parent_section (str): Parent section for plugin. Usually 'checkers' or 'reports'
atomshields/scanner.py
def _addConfig(instance, config, parent_section): """ Writes a section for a plugin. Args: instance (object): Class instance for plugin config (object): Object (ConfigParser) which the current config parent_section (str): Parent section for plugin. Usually 'checkers' or 'reports' """ try: section...
def _addConfig(instance, config, parent_section): """ Writes a section for a plugin. Args: instance (object): Class instance for plugin config (object): Object (ConfigParser) which the current config parent_section (str): Parent section for plugin. Usually 'checkers' or 'reports' """ try: section...
[ "Writes", "a", "section", "for", "a", "plugin", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L294-L309
[ "def", "_addConfig", "(", "instance", ",", "config", ",", "parent_section", ")", ":", "try", ":", "section_name", "=", "\"{p}/{n}\"", ".", "format", "(", "p", "=", "parent_section", ",", "n", "=", "instance", ".", "NAME", ".", "lower", "(", ")", ")", "...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner.getConfig
Returns a dictionary which contains the current config. If a section is setted, only will returns the section config Args: section (str): (Optional) Section name. Returns: dict: Representation of current config
atomshields/scanner.py
def getConfig(self, section = None): """ Returns a dictionary which contains the current config. If a section is setted, only will returns the section config Args: section (str): (Optional) Section name. Returns: dict: Representation of current config """ data = {} if section is None: for s i...
def getConfig(self, section = None): """ Returns a dictionary which contains the current config. If a section is setted, only will returns the section config Args: section (str): (Optional) Section name. Returns: dict: Representation of current config """ data = {} if section is None: for s i...
[ "Returns", "a", "dictionary", "which", "contains", "the", "current", "config", ".", "If", "a", "section", "is", "setted", "only", "will", "returns", "the", "section", "config" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L364-L387
[ "def", "getConfig", "(", "self", ",", "section", "=", "None", ")", ":", "data", "=", "{", "}", "if", "section", "is", "None", ":", "for", "s", "in", "self", ".", "config", ".", "sections", "(", ")", ":", "if", "'/'", "in", "s", ":", "# Subsection...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner._getClassInstance
Returns a class instance from a .py file. Args: path (str): Absolute path to .py file args (dict): Arguments passed via class constructor Returns: object: Class instance or None
atomshields/scanner.py
def _getClassInstance(path, args=None): """ Returns a class instance from a .py file. Args: path (str): Absolute path to .py file args (dict): Arguments passed via class constructor Returns: object: Class instance or None """ if not path.endswith(".py"): return None if args is None: args...
def _getClassInstance(path, args=None): """ Returns a class instance from a .py file. Args: path (str): Absolute path to .py file args (dict): Arguments passed via class constructor Returns: object: Class instance or None """ if not path.endswith(".py"): return None if args is None: args...
[ "Returns", "a", "class", "instance", "from", "a", ".", "py", "file", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L419-L448
[ "def", "_getClassInstance", "(", "path", ",", "args", "=", "None", ")", ":", "if", "not", "path", ".", "endswith", "(", "\".py\"", ")", ":", "return", "None", "if", "args", "is", "None", ":", "args", "=", "{", "}", "classname", "=", "AtomShieldsScanner...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner._executeMassiveMethod
Execute an specific method for each class instance located in path Args: path (str): Absolute path which contains the .py files method (str): Method to execute into class instance Returns: dict: Dictionary which contains the response for every class instance. The dictionary keys are the value of 'N...
atomshields/scanner.py
def _executeMassiveMethod(path, method, args=None, classArgs = None): """ Execute an specific method for each class instance located in path Args: path (str): Absolute path which contains the .py files method (str): Method to execute into class instance Returns: dict: Dictionary which contains the re...
def _executeMassiveMethod(path, method, args=None, classArgs = None): """ Execute an specific method for each class instance located in path Args: path (str): Absolute path which contains the .py files method (str): Method to execute into class instance Returns: dict: Dictionary which contains the re...
[ "Execute", "an", "specific", "method", "for", "each", "class", "instance", "located", "in", "path" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L451-L491
[ "def", "_executeMassiveMethod", "(", "path", ",", "method", ",", "args", "=", "None", ",", "classArgs", "=", "None", ")", ":", "response", "=", "{", "}", "if", "args", "is", "None", ":", "args", "=", "{", "}", "if", "classArgs", "is", "None", ":", ...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
AtomShieldsScanner.run
Run a scan in the path setted.
atomshields/scanner.py
def run(self): """ Run a scan in the path setted. """ self.checkProperties() self.debug("[*] Iniciando escaneo de AtomShields con las siguientes propiedades. . . ") self.showScanProperties() self.loadConfig() # Init time counter init_ts = datetime.now() # Execute plugins cwd = os.getcwd() ...
def run(self): """ Run a scan in the path setted. """ self.checkProperties() self.debug("[*] Iniciando escaneo de AtomShields con las siguientes propiedades. . . ") self.showScanProperties() self.loadConfig() # Init time counter init_ts = datetime.now() # Execute plugins cwd = os.getcwd() ...
[ "Run", "a", "scan", "in", "the", "path", "setted", "." ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L571-L620
[ "def", "run", "(", "self", ")", ":", "self", ".", "checkProperties", "(", ")", "self", ".", "debug", "(", "\"[*] Iniciando escaneo de AtomShields con las siguientes propiedades. . . \"", ")", "self", ".", "showScanProperties", "(", ")", "self", ".", "loadConfig", "(...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
RetireJSChecker.install
Install all the dependences
atomshields/checkers/retirejs.py
def install(): """ Install all the dependences """ cmd = CommandHelper() cmd.install("npm") cmd = CommandHelper() cmd.install("nodejs-legacy") # Install retre with npm cmd = CommandHelper() cmd.command = "npm install -g retire" cmd.execute() if cmd.errors: from termcolor import colored ...
def install(): """ Install all the dependences """ cmd = CommandHelper() cmd.install("npm") cmd = CommandHelper() cmd.install("nodejs-legacy") # Install retre with npm cmd = CommandHelper() cmd.command = "npm install -g retire" cmd.execute() if cmd.errors: from termcolor import colored ...
[ "Install", "all", "the", "dependences" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/checkers/retirejs.py#L170-L189
[ "def", "install", "(", ")", ":", "cmd", "=", "CommandHelper", "(", ")", "cmd", ".", "install", "(", "\"npm\"", ")", "cmd", "=", "CommandHelper", "(", ")", "cmd", ".", "install", "(", "\"nodejs-legacy\"", ")", "# Install retre with npm", "cmd", "=", "Comman...
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
Issue.potential
Setter for 'potential' property Args: value (bool): True if a potential is required. False else
atomshields/models/issue.py
def potential(self, value): """ Setter for 'potential' property Args: value (bool): True if a potential is required. False else """ if value: self._potential = True else: self._potential = False
def potential(self, value): """ Setter for 'potential' property Args: value (bool): True if a potential is required. False else """ if value: self._potential = True else: self._potential = False
[ "Setter", "for", "potential", "property" ]
ElevenPaths/AtomShields
python
https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/models/issue.py#L125-L136
[ "def", "potential", "(", "self", ",", "value", ")", ":", "if", "value", ":", "self", ".", "_potential", "=", "True", "else", ":", "self", ".", "_potential", "=", "False" ]
e75f25393b4a7a315ec96bf9b8e654cb2200866a
valid
get
Shortcut method for getting a setting value. :param str name: Setting key name. :param default: Default value of setting if it's not explicitly set. Defaults to `None` :param bool allow_default: If true, use the parameter default as default if the...
pyconfig/__init__.py
def get(name, default=None, allow_default=True): """ Shortcut method for getting a setting value. :param str name: Setting key name. :param default: Default value of setting if it's not explicitly set. Defaults to `None` :param bool allow_default: If true, use the pa...
def get(name, default=None, allow_default=True): """ Shortcut method for getting a setting value. :param str name: Setting key name. :param default: Default value of setting if it's not explicitly set. Defaults to `None` :param bool allow_default: If true, use the pa...
[ "Shortcut", "method", "for", "getting", "a", "setting", "value", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L245-L257
[ "def", "get", "(", "name", ",", "default", "=", "None", ",", "allow_default", "=", "True", ")", ":", "return", "Config", "(", ")", ".", "get", "(", "name", ",", "default", ",", "allow_default", "=", "allow_default", ")" ]
000cb127db51e03cb4070aae6943e956193cbad5
valid
env
Helper to try to get a setting from the environment, or pyconfig, or finally use a provided default.
pyconfig/__init__.py
def env(key, default): """ Helper to try to get a setting from the environment, or pyconfig, or finally use a provided default. """ value = os.environ.get(key, None) if value is not None: log.info(' %s = %r', key.lower().replace('_', '.'), value) return value key = key.l...
def env(key, default): """ Helper to try to get a setting from the environment, or pyconfig, or finally use a provided default. """ value = os.environ.get(key, None) if value is not None: log.info(' %s = %r', key.lower().replace('_', '.'), value) return value key = key.l...
[ "Helper", "to", "try", "to", "get", "a", "setting", "from", "the", "environment", "or", "pyconfig", "or", "finally", "use", "a", "provided", "default", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L603-L619
[ "def", "env", "(", "key", ",", "default", ")", ":", "value", "=", "os", ".", "environ", ".", "get", "(", "key", ",", "None", ")", "if", "value", "is", "not", "None", ":", "log", ".", "info", "(", "' %s = %r'", ",", "key", ".", "lower", "(", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
env_key
Try to get `key` from the environment. This mutates `key` to replace dots with underscores and makes it all uppercase. my.database.host => MY_DATABASE_HOST
pyconfig/__init__.py
def env_key(key, default): """ Try to get `key` from the environment. This mutates `key` to replace dots with underscores and makes it all uppercase. my.database.host => MY_DATABASE_HOST """ env = key.upper().replace('.', '_') return os.environ.get(env, default)
def env_key(key, default): """ Try to get `key` from the environment. This mutates `key` to replace dots with underscores and makes it all uppercase. my.database.host => MY_DATABASE_HOST """ env = key.upper().replace('.', '_') return os.environ.get(env, default)
[ "Try", "to", "get", "key", "from", "the", "environment", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L622-L633
[ "def", "env_key", "(", "key", ",", "default", ")", ":", "env", "=", "key", ".", "upper", "(", ")", ".", "replace", "(", "'.'", ",", "'_'", ")", "return", "os", ".", "environ", ".", "get", "(", "env", ",", "default", ")" ]
000cb127db51e03cb4070aae6943e956193cbad5
valid
Config.set
Changes a setting value. This implements a locking mechanism to ensure some level of thread safety. :param str name: Setting key name. :param value: Setting value.
pyconfig/__init__.py
def set(self, name, value): """ Changes a setting value. This implements a locking mechanism to ensure some level of thread safety. :param str name: Setting key name. :param value: Setting value. """ if not self.settings.get('pyconfig.case_sensi...
def set(self, name, value): """ Changes a setting value. This implements a locking mechanism to ensure some level of thread safety. :param str name: Setting key name. :param value: Setting value. """ if not self.settings.get('pyconfig.case_sensi...
[ "Changes", "a", "setting", "value", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L69-L85
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "if", "not", "self", ".", "settings", ".", "get", "(", "'pyconfig.case_sensitive'", ",", "False", ")", ":", "name", "=", "name", ".", "lower", "(", ")", "log", ".", "info", "(", "\" ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
Config._update
Updates the current configuration with the values in `conf_dict`. :param dict conf_dict: Dictionary of key value settings. :param str base_name: Base namespace for setting keys.
pyconfig/__init__.py
def _update(self, conf_dict, base_name=None): """ Updates the current configuration with the values in `conf_dict`. :param dict conf_dict: Dictionary of key value settings. :param str base_name: Base namespace for setting keys. """ for name in conf_dict: # S...
def _update(self, conf_dict, base_name=None): """ Updates the current configuration with the values in `conf_dict`. :param dict conf_dict: Dictionary of key value settings. :param str base_name: Base namespace for setting keys. """ for name in conf_dict: # S...
[ "Updates", "the", "current", "configuration", "with", "the", "values", "in", "conf_dict", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L87-L115
[ "def", "_update", "(", "self", ",", "conf_dict", ",", "base_name", "=", "None", ")", ":", "for", "name", "in", "conf_dict", ":", "# Skip private names", "if", "name", ".", "startswith", "(", "'_'", ")", ":", "continue", "value", "=", "conf_dict", "[", "n...
000cb127db51e03cb4070aae6943e956193cbad5
valid
Config.load
Loads all the config plugin modules to build a working configuration. If there is a ``localconfig`` module on the python path, it will be loaded last, overriding other settings. :param bool clear: Clear out the previous settings before loading
pyconfig/__init__.py
def load(self, clear=False): """ Loads all the config plugin modules to build a working configuration. If there is a ``localconfig`` module on the python path, it will be loaded last, overriding other settings. :param bool clear: Clear out the previous settings before loading ...
def load(self, clear=False): """ Loads all the config plugin modules to build a working configuration. If there is a ``localconfig`` module on the python path, it will be loaded last, overriding other settings. :param bool clear: Clear out the previous settings before loading ...
[ "Loads", "all", "the", "config", "plugin", "modules", "to", "build", "a", "working", "configuration", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L117-L187
[ "def", "load", "(", "self", ",", "clear", "=", "False", ")", ":", "if", "clear", ":", "self", ".", "settings", "=", "{", "}", "defer", "=", "[", "]", "# Load all config plugins", "for", "conf", "in", "pkg_resources", ".", "iter_entry_points", "(", "'pyco...
000cb127db51e03cb4070aae6943e956193cbad5
valid
Config.get
Return a setting value. :param str name: Setting key name. :param default: Default value of setting if it's not explicitly set. :param bool allow_default: If true, use the parameter default as default if the key is not set, els...
pyconfig/__init__.py
def get(self, name, default, allow_default=True): """ Return a setting value. :param str name: Setting key name. :param default: Default value of setting if it's not explicitly set. :param bool allow_default: If true, use the parameter default as ...
def get(self, name, default, allow_default=True): """ Return a setting value. :param str name: Setting key name. :param default: Default value of setting if it's not explicitly set. :param bool allow_default: If true, use the parameter default as ...
[ "Return", "a", "setting", "value", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L195-L213
[ "def", "get", "(", "self", ",", "name", ",", "default", ",", "allow_default", "=", "True", ")", ":", "if", "not", "self", ".", "settings", ".", "get", "(", "'pyconfig.case_sensitive'", ",", "False", ")", ":", "name", "=", "name", ".", "lower", "(", "...
000cb127db51e03cb4070aae6943e956193cbad5
valid
etcd.init
Handle creating the new etcd client instance and other business. :param hosts: Host string or list of hosts (default: `'127.0.0.1:2379'`) :param cacert: CA cert filename (optional) :param client_cert: Client cert filename (optional) :param client_key: Client key filename (optional) ...
pyconfig/__init__.py
def init(self, hosts=None, cacert=None, client_cert=None, client_key=None): """ Handle creating the new etcd client instance and other business. :param hosts: Host string or list of hosts (default: `'127.0.0.1:2379'`) :param cacert: CA cert filename (optional) :param client_cert...
def init(self, hosts=None, cacert=None, client_cert=None, client_key=None): """ Handle creating the new etcd client instance and other business. :param hosts: Host string or list of hosts (default: `'127.0.0.1:2379'`) :param cacert: CA cert filename (optional) :param client_cert...
[ "Handle", "creating", "the", "new", "etcd", "client", "instance", "and", "other", "business", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L339-L412
[ "def", "init", "(", "self", ",", "hosts", "=", "None", ",", "cacert", "=", "None", ",", "client_cert", "=", "None", ",", "client_key", "=", "None", ")", ":", "# Try to get the etcd module", "try", ":", "import", "etcd", "self", ".", "module", "=", "etcd"...
000cb127db51e03cb4070aae6943e956193cbad5
valid
etcd.load
Return a dictionary of settings loaded from etcd.
pyconfig/__init__.py
def load(self, prefix=None, depth=None): """ Return a dictionary of settings loaded from etcd. """ prefix = prefix or self.prefix prefix = '/' + prefix.strip('/') + '/' if depth is None: depth = self.inherit_depth if not self.configured: ...
def load(self, prefix=None, depth=None): """ Return a dictionary of settings loaded from etcd. """ prefix = prefix or self.prefix prefix = '/' + prefix.strip('/') + '/' if depth is None: depth = self.inherit_depth if not self.configured: ...
[ "Return", "a", "dictionary", "of", "settings", "loaded", "from", "etcd", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L414-L472
[ "def", "load", "(", "self", ",", "prefix", "=", "None", ",", "depth", "=", "None", ")", ":", "prefix", "=", "prefix", "or", "self", ".", "prefix", "prefix", "=", "'/'", "+", "prefix", ".", "strip", "(", "'/'", ")", "+", "'/'", "if", "depth", "is"...
000cb127db51e03cb4070aae6943e956193cbad5
valid
etcd.get_watcher
Return a etcd watching generator which yields events as they happen.
pyconfig/__init__.py
def get_watcher(self): """ Return a etcd watching generator which yields events as they happen. """ if not self.watching: raise StopIteration() return self.client.eternal_watch(self.prefix, recursive=True)
def get_watcher(self): """ Return a etcd watching generator which yields events as they happen. """ if not self.watching: raise StopIteration() return self.client.eternal_watch(self.prefix, recursive=True)
[ "Return", "a", "etcd", "watching", "generator", "which", "yields", "events", "as", "they", "happen", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L474-L481
[ "def", "get_watcher", "(", "self", ")", ":", "if", "not", "self", ".", "watching", ":", "raise", "StopIteration", "(", ")", "return", "self", ".", "client", ".", "eternal_watch", "(", "self", ".", "prefix", ",", "recursive", "=", "True", ")" ]
000cb127db51e03cb4070aae6943e956193cbad5
valid
etcd.start_watching
Begins watching etcd for changes.
pyconfig/__init__.py
def start_watching(self): """ Begins watching etcd for changes. """ # Don't create a new watcher thread if we already have one running if self.watcher and self.watcher.is_alive(): return # Create a new watcher thread and start it self.watcher = Watcher() self...
def start_watching(self): """ Begins watching etcd for changes. """ # Don't create a new watcher thread if we already have one running if self.watcher and self.watcher.is_alive(): return # Create a new watcher thread and start it self.watcher = Watcher() self...
[ "Begins", "watching", "etcd", "for", "changes", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L483-L491
[ "def", "start_watching", "(", "self", ")", ":", "# Don't create a new watcher thread if we already have one running", "if", "self", ".", "watcher", "and", "self", ".", "watcher", ".", "is_alive", "(", ")", ":", "return", "# Create a new watcher thread and start it", "self...
000cb127db51e03cb4070aae6943e956193cbad5
valid
etcd._parse_hosts
Return hosts parsed into a tuple of tuples. :param hosts: String or list of hosts
pyconfig/__init__.py
def _parse_hosts(self, hosts): """ Return hosts parsed into a tuple of tuples. :param hosts: String or list of hosts """ # Default host if hosts is None: return # If it's a string, we allow comma separated strings if isinstance(hosts, six.st...
def _parse_hosts(self, hosts): """ Return hosts parsed into a tuple of tuples. :param hosts: String or list of hosts """ # Default host if hosts is None: return # If it's a string, we allow comma separated strings if isinstance(hosts, six.st...
[ "Return", "hosts", "parsed", "into", "a", "tuple", "of", "tuples", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L493-L514
[ "def", "_parse_hosts", "(", "self", ",", "hosts", ")", ":", "# Default host", "if", "hosts", "is", "None", ":", "return", "# If it's a string, we allow comma separated strings", "if", "isinstance", "(", "hosts", ",", "six", ".", "string_types", ")", ":", "# Split ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
etcd._parse_jetconfig
Undocumented cross-compatability functionality with jetconfig (https://github.com/shakefu/jetconfig) that is very sloppy.
pyconfig/__init__.py
def _parse_jetconfig(self): """ Undocumented cross-compatability functionality with jetconfig (https://github.com/shakefu/jetconfig) that is very sloppy. """ conf = env('JETCONFIG_ETCD', None) if not conf: return import urlparse auth = None...
def _parse_jetconfig(self): """ Undocumented cross-compatability functionality with jetconfig (https://github.com/shakefu/jetconfig) that is very sloppy. """ conf = env('JETCONFIG_ETCD', None) if not conf: return import urlparse auth = None...
[ "Undocumented", "cross", "-", "compatability", "functionality", "with", "jetconfig", "(", "https", ":", "//", "github", ".", "com", "/", "shakefu", "/", "jetconfig", ")", "that", "is", "very", "sloppy", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/__init__.py#L516-L555
[ "def", "_parse_jetconfig", "(", "self", ")", ":", "conf", "=", "env", "(", "'JETCONFIG_ETCD'", ",", "None", ")", "if", "not", "conf", ":", "return", "import", "urlparse", "auth", "=", "None", "port", "=", "None", "conf", "=", "conf", ".", "split", "(",...
000cb127db51e03cb4070aae6943e956193cbad5
valid
main
Main script for `pyconfig` command.
pyconfig/scripts.py
def main(): """ Main script for `pyconfig` command. """ parser = argparse.ArgumentParser(description="Helper for working with " "pyconfigs") target_group = parser.add_mutually_exclusive_group() target_group.add_argument('-f', '--filename', help="parse an individual file ...
def main(): """ Main script for `pyconfig` command. """ parser = argparse.ArgumentParser(description="Helper for working with " "pyconfigs") target_group = parser.add_mutually_exclusive_group() target_group.add_argument('-f', '--filename', help="parse an individual file ...
[ "Main", "script", "for", "pyconfig", "command", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L21-L68
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Helper for working with \"", "\"pyconfigs\"", ")", "target_group", "=", "parser", ".", "add_mutually_exclusive_group", "(", ")", "target_group", ".", "add_arg...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_handle_module
Handles the -m argument.
pyconfig/scripts.py
def _handle_module(args): """ Handles the -m argument. """ module = _get_module_filename(args.module) if not module: _error("Could not load module or package: %r", args.module) elif isinstance(module, Unparseable): _error("Could not determine module source: %r", args.module) ...
def _handle_module(args): """ Handles the -m argument. """ module = _get_module_filename(args.module) if not module: _error("Could not load module or package: %r", args.module) elif isinstance(module, Unparseable): _error("Could not determine module source: %r", args.module) ...
[ "Handles", "the", "-", "m", "argument", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L224-L235
[ "def", "_handle_module", "(", "args", ")", ":", "module", "=", "_get_module_filename", "(", "args", ".", "module", ")", "if", "not", "module", ":", "_error", "(", "\"Could not load module or package: %r\"", ",", "args", ".", "module", ")", "elif", "isinstance", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_error
Print an error message and exit. :param msg: A message to print :type msg: str
pyconfig/scripts.py
def _error(msg, *args): """ Print an error message and exit. :param msg: A message to print :type msg: str """ print(msg % args, file=sys.stderr) sys.exit(1)
def _error(msg, *args): """ Print an error message and exit. :param msg: A message to print :type msg: str """ print(msg % args, file=sys.stderr) sys.exit(1)
[ "Print", "an", "error", "message", "and", "exit", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L247-L256
[ "def", "_error", "(", "msg", ",", "*", "args", ")", ":", "print", "(", "msg", "%", "args", ",", "file", "=", "sys", ".", "stderr", ")", "sys", ".", "exit", "(", "1", ")" ]
000cb127db51e03cb4070aae6943e956193cbad5
valid
_get_module_filename
Return the filename of `module` if it can be imported. If `module` is a package, its directory will be returned. If it cannot be imported ``None`` is returned. If the ``__file__`` attribute is missing, or the module or package is a compiled egg, then an :class:`Unparseable` instance is returned, sinc...
pyconfig/scripts.py
def _get_module_filename(module): """ Return the filename of `module` if it can be imported. If `module` is a package, its directory will be returned. If it cannot be imported ``None`` is returned. If the ``__file__`` attribute is missing, or the module or package is a compiled egg, then an :...
def _get_module_filename(module): """ Return the filename of `module` if it can be imported. If `module` is a package, its directory will be returned. If it cannot be imported ``None`` is returned. If the ``__file__`` attribute is missing, or the module or package is a compiled egg, then an :...
[ "Return", "the", "filename", "of", "module", "if", "it", "can", "be", "imported", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L259-L311
[ "def", "_get_module_filename", "(", "module", ")", ":", "# Split up the module and its containing package, if it has one", "module", "=", "module", ".", "split", "(", "'.'", ")", "package", "=", "'.'", ".", "join", "(", "module", "[", ":", "-", "1", "]", ")", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_parse_and_output
Parse `filename` appropriately and then output calls according to the `args` specified. :param filename: A file or directory :param args: Command arguments :type filename: str
pyconfig/scripts.py
def _parse_and_output(filename, args): """ Parse `filename` appropriately and then output calls according to the `args` specified. :param filename: A file or directory :param args: Command arguments :type filename: str """ relpath = os.path.dirname(filename) if os.path.isfile(filen...
def _parse_and_output(filename, args): """ Parse `filename` appropriately and then output calls according to the `args` specified. :param filename: A file or directory :param args: Command arguments :type filename: str """ relpath = os.path.dirname(filename) if os.path.isfile(filen...
[ "Parse", "filename", "appropriately", "and", "then", "output", "calls", "according", "to", "the", "args", "specified", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L314-L353
[ "def", "_parse_and_output", "(", "filename", ",", "args", ")", ":", "relpath", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "calls", "=", "_parse_file", "(", "filename"...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_output
Outputs `calls`. :param calls: List of :class:`_PyconfigCall` instances :param args: :class:`~argparse.ArgumentParser` instance :type calls: list :type args: argparse.ArgumentParser
pyconfig/scripts.py
def _output(calls, args): """ Outputs `calls`. :param calls: List of :class:`_PyconfigCall` instances :param args: :class:`~argparse.ArgumentParser` instance :type calls: list :type args: argparse.ArgumentParser """ # Sort the keys appropriately if args.natural_sort or args.source:...
def _output(calls, args): """ Outputs `calls`. :param calls: List of :class:`_PyconfigCall` instances :param args: :class:`~argparse.ArgumentParser` instance :type calls: list :type args: argparse.ArgumentParser """ # Sort the keys appropriately if args.natural_sort or args.source:...
[ "Outputs", "calls", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L356-L406
[ "def", "_output", "(", "calls", ",", "args", ")", ":", "# Sort the keys appropriately", "if", "args", ".", "natural_sort", "or", "args", ".", "source", ":", "calls", "=", "sorted", "(", "calls", ",", "key", "=", "lambda", "c", ":", "(", "c", ".", "file...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_format_call
Return `call` formatted appropriately for `args`. :param call: A pyconfig call object :param args: Arguments from the command :type call: :class:`_PyconfigCall`
pyconfig/scripts.py
def _format_call(call, args): """ Return `call` formatted appropriately for `args`. :param call: A pyconfig call object :param args: Arguments from the command :type call: :class:`_PyconfigCall` """ out = '' if args.source: out += call.annotation() + '\n' if args.only_keys...
def _format_call(call, args): """ Return `call` formatted appropriately for `args`. :param call: A pyconfig call object :param args: Arguments from the command :type call: :class:`_PyconfigCall` """ out = '' if args.source: out += call.annotation() + '\n' if args.only_keys...
[ "Return", "call", "formatted", "appropriately", "for", "args", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L409-L433
[ "def", "_format_call", "(", "call", ",", "args", ")", ":", "out", "=", "''", "if", "args", ".", "source", ":", "out", "+=", "call", ".", "annotation", "(", ")", "+", "'\\n'", "if", "args", ".", "only_keys", ":", "out", "+=", "call", ".", "get_key",...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_colorize
Return `output` colorized with Pygments, if available.
pyconfig/scripts.py
def _colorize(output): """ Return `output` colorized with Pygments, if available. """ if not pygments: return output # Available styles # ['monokai', 'manni', 'rrt', 'perldoc', 'borland', 'colorful', 'default', # 'murphy', 'vs', 'trac', 'tango', 'fruity', 'autumn', 'bw', 'emacs', ...
def _colorize(output): """ Return `output` colorized with Pygments, if available. """ if not pygments: return output # Available styles # ['monokai', 'manni', 'rrt', 'perldoc', 'borland', 'colorful', 'default', # 'murphy', 'vs', 'trac', 'tango', 'fruity', 'autumn', 'bw', 'emacs', ...
[ "Return", "output", "colorized", "with", "Pygments", "if", "available", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L436-L449
[ "def", "_colorize", "(", "output", ")", ":", "if", "not", "pygments", ":", "return", "output", "# Available styles", "# ['monokai', 'manni', 'rrt', 'perldoc', 'borland', 'colorful', 'default',", "# 'murphy', 'vs', 'trac', 'tango', 'fruity', 'autumn', 'bw', 'emacs',", "# 'vim', 'pastie'...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_parse_dir
Return a list of :class:`_PyconfigCall` from recursively parsing `directory`. :param directory: Directory to walk looking for python files :param relpath: Path to make filenames relative to :type directory: str :type relpath: str
pyconfig/scripts.py
def _parse_dir(directory, relpath): """ Return a list of :class:`_PyconfigCall` from recursively parsing `directory`. :param directory: Directory to walk looking for python files :param relpath: Path to make filenames relative to :type directory: str :type relpath: str """ relpath ...
def _parse_dir(directory, relpath): """ Return a list of :class:`_PyconfigCall` from recursively parsing `directory`. :param directory: Directory to walk looking for python files :param relpath: Path to make filenames relative to :type directory: str :type relpath: str """ relpath ...
[ "Return", "a", "list", "of", ":", "class", ":", "_PyconfigCall", "from", "recursively", "parsing", "directory", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L452-L472
[ "def", "_parse_dir", "(", "directory", ",", "relpath", ")", ":", "relpath", "=", "os", ".", "path", ".", "dirname", "(", "relpath", ")", "pyconfig_calls", "=", "[", "]", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "directo...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_parse_file
Return a list of :class:`_PyconfigCall` from parsing `filename`. :param filename: A file to parse :param relpath: Relative directory to strip (optional) :type filename: str :type relpath: str
pyconfig/scripts.py
def _parse_file(filename, relpath=None): """ Return a list of :class:`_PyconfigCall` from parsing `filename`. :param filename: A file to parse :param relpath: Relative directory to strip (optional) :type filename: str :type relpath: str """ with open(filename, 'r') as source: s...
def _parse_file(filename, relpath=None): """ Return a list of :class:`_PyconfigCall` from parsing `filename`. :param filename: A file to parse :param relpath: Relative directory to strip (optional) :type filename: str :type relpath: str """ with open(filename, 'r') as source: s...
[ "Return", "a", "list", "of", ":", "class", ":", "_PyconfigCall", "from", "parsing", "filename", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L475-L553
[ "def", "_parse_file", "(", "filename", ",", "relpath", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "source", ":", "source", "=", "source", ".", "read", "(", ")", "pyconfig_calls", "=", "[", "]", "try", ":", "nodes",...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_map_arg
Return `arg` appropriately parsed or mapped to a usable value.
pyconfig/scripts.py
def _map_arg(arg): """ Return `arg` appropriately parsed or mapped to a usable value. """ # Grab the easy to parse values if isinstance(arg, _ast.Str): return repr(arg.s) elif isinstance(arg, _ast.Num): return arg.n elif isinstance(arg, _ast.Name): name = arg.id ...
def _map_arg(arg): """ Return `arg` appropriately parsed or mapped to a usable value. """ # Grab the easy to parse values if isinstance(arg, _ast.Str): return repr(arg.s) elif isinstance(arg, _ast.Num): return arg.n elif isinstance(arg, _ast.Name): name = arg.id ...
[ "Return", "arg", "appropriately", "parsed", "or", "mapped", "to", "a", "usable", "value", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L556-L577
[ "def", "_map_arg", "(", "arg", ")", ":", "# Grab the easy to parse values", "if", "isinstance", "(", "arg", ",", "_ast", ".", "Str", ")", ":", "return", "repr", "(", "arg", ".", "s", ")", "elif", "isinstance", "(", "arg", ",", "_ast", ".", "Num", ")", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_PyconfigCall.as_namespace
Return this call as if it were being assigned in a pyconfig namespace. If `namespace` is specified and matches the top level of this call's :attr:`key`, then that section of the key will be removed.
pyconfig/scripts.py
def as_namespace(self, namespace=None): """ Return this call as if it were being assigned in a pyconfig namespace. If `namespace` is specified and matches the top level of this call's :attr:`key`, then that section of the key will be removed. """ key = self.key ...
def as_namespace(self, namespace=None): """ Return this call as if it were being assigned in a pyconfig namespace. If `namespace` is specified and matches the top level of this call's :attr:`key`, then that section of the key will be removed. """ key = self.key ...
[ "Return", "this", "call", "as", "if", "it", "were", "being", "assigned", "in", "a", "pyconfig", "namespace", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L110-L122
[ "def", "as_namespace", "(", "self", ",", "namespace", "=", "None", ")", ":", "key", "=", "self", ".", "key", "if", "namespace", "and", "key", ".", "startswith", "(", "namespace", ")", ":", "key", "=", "key", "[", "len", "(", "namespace", ")", "+", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_PyconfigCall.as_live
Return this call as if it were being assigned in a pyconfig namespace, but load the actual value currently available in pyconfig.
pyconfig/scripts.py
def as_live(self): """ Return this call as if it were being assigned in a pyconfig namespace, but load the actual value currently available in pyconfig. """ key = self.get_key() default = pyconfig.get(key) if default: default = repr(default) e...
def as_live(self): """ Return this call as if it were being assigned in a pyconfig namespace, but load the actual value currently available in pyconfig. """ key = self.get_key() default = pyconfig.get(key) if default: default = repr(default) e...
[ "Return", "this", "call", "as", "if", "it", "were", "being", "assigned", "in", "a", "pyconfig", "namespace", "but", "load", "the", "actual", "value", "currently", "available", "in", "pyconfig", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L124-L136
[ "def", "as_live", "(", "self", ")", ":", "key", "=", "self", ".", "get_key", "(", ")", "default", "=", "pyconfig", ".", "get", "(", "key", ")", "if", "default", ":", "default", "=", "repr", "(", "default", ")", "else", ":", "default", "=", "self", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_PyconfigCall.as_call
Return this call as it is called in its source.
pyconfig/scripts.py
def as_call(self): """ Return this call as it is called in its source. """ default = self._default() default = ', ' + default if default else '' return "pyconfig.%s(%r%s)" % (self.method, self.get_key(), default)
def as_call(self): """ Return this call as it is called in its source. """ default = self._default() default = ', ' + default if default else '' return "pyconfig.%s(%r%s)" % (self.method, self.get_key(), default)
[ "Return", "this", "call", "as", "it", "is", "called", "in", "its", "source", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L138-L145
[ "def", "as_call", "(", "self", ")", ":", "default", "=", "self", ".", "_default", "(", ")", "default", "=", "', '", "+", "default", "if", "default", "else", "''", "return", "\"pyconfig.%s(%r%s)\"", "%", "(", "self", ".", "method", ",", "self", ".", "ge...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_PyconfigCall.get_key
Return the call key, even if it has to be parsed from the source.
pyconfig/scripts.py
def get_key(self): """ Return the call key, even if it has to be parsed from the source. """ if not isinstance(self.key, Unparseable): return self.key line = self.source[self.col_offset:] regex = re.compile('''pyconfig\.[eginst]+\(([^,]+).*?\)''') ma...
def get_key(self): """ Return the call key, even if it has to be parsed from the source. """ if not isinstance(self.key, Unparseable): return self.key line = self.source[self.col_offset:] regex = re.compile('''pyconfig\.[eginst]+\(([^,]+).*?\)''') ma...
[ "Return", "the", "call", "key", "even", "if", "it", "has", "to", "be", "parsed", "from", "the", "source", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L156-L170
[ "def", "get_key", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "key", ",", "Unparseable", ")", ":", "return", "self", ".", "key", "line", "=", "self", ".", "source", "[", "self", ".", "col_offset", ":", "]", "regex", "=", "re...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_PyconfigCall._default_value_only
Return only the default value, if there is one.
pyconfig/scripts.py
def _default_value_only(self): """ Return only the default value, if there is one. """ line = self.source[self.col_offset:] regex = re.compile('''pyconfig\.[eginst]+\(['"][^)]+?['"], ?(.*?)\)''') match = regex.match(line) if not match: return '' ...
def _default_value_only(self): """ Return only the default value, if there is one. """ line = self.source[self.col_offset:] regex = re.compile('''pyconfig\.[eginst]+\(['"][^)]+?['"], ?(.*?)\)''') match = regex.match(line) if not match: return '' ...
[ "Return", "only", "the", "default", "value", "if", "there", "is", "one", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L186-L197
[ "def", "_default_value_only", "(", "self", ")", ":", "line", "=", "self", ".", "source", "[", "self", ".", "col_offset", ":", "]", "regex", "=", "re", ".", "compile", "(", "'''pyconfig\\.[eginst]+\\(['\"][^)]+?['\"], ?(.*?)\\)'''", ")", "match", "=", "regex", ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
_PyconfigCall._default
Return the default argument, formatted nicely.
pyconfig/scripts.py
def _default(self): """ Return the default argument, formatted nicely. """ try: # Check if it's iterable iter(self.default) except TypeError: return repr(self.default) # This is to look for unparsable values, and if we find one, we tr...
def _default(self): """ Return the default argument, formatted nicely. """ try: # Check if it's iterable iter(self.default) except TypeError: return repr(self.default) # This is to look for unparsable values, and if we find one, we tr...
[ "Return", "the", "default", "argument", "formatted", "nicely", "." ]
shakefu/pyconfig
python
https://github.com/shakefu/pyconfig/blob/000cb127db51e03cb4070aae6943e956193cbad5/pyconfig/scripts.py#L199-L218
[ "def", "_default", "(", "self", ")", ":", "try", ":", "# Check if it's iterable", "iter", "(", "self", ".", "default", ")", "except", "TypeError", ":", "return", "repr", "(", "self", ".", "default", ")", "# This is to look for unparsable values, and if we find one, ...
000cb127db51e03cb4070aae6943e956193cbad5
valid
Pylearn2Estimator._get_param_names
Get mappable parameters from YAML.
osprey/plugins/plugin_pylearn2.py
def _get_param_names(self): """ Get mappable parameters from YAML. """ template = Template(self.yaml_string) names = ['yaml_string'] # always include the template for match in re.finditer(template.pattern, template.template): name = match.group('named') or ma...
def _get_param_names(self): """ Get mappable parameters from YAML. """ template = Template(self.yaml_string) names = ['yaml_string'] # always include the template for match in re.finditer(template.pattern, template.template): name = match.group('named') or ma...
[ "Get", "mappable", "parameters", "from", "YAML", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L31-L41
[ "def", "_get_param_names", "(", "self", ")", ":", "template", "=", "Template", "(", "self", ".", "yaml_string", ")", "names", "=", "[", "'yaml_string'", "]", "# always include the template", "for", "match", "in", "re", ".", "finditer", "(", "template", ".", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Pylearn2Estimator._get_dataset
Construct a pylearn2 dataset. Parameters ---------- X : array_like Training examples. y : array_like, optional Labels.
osprey/plugins/plugin_pylearn2.py
def _get_dataset(self, X, y=None): """ Construct a pylearn2 dataset. Parameters ---------- X : array_like Training examples. y : array_like, optional Labels. """ from pylearn2.datasets import DenseDesignMatrix X = np.asarr...
def _get_dataset(self, X, y=None): """ Construct a pylearn2 dataset. Parameters ---------- X : array_like Training examples. y : array_like, optional Labels. """ from pylearn2.datasets import DenseDesignMatrix X = np.asarr...
[ "Construct", "a", "pylearn2", "dataset", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L43-L62
[ "def", "_get_dataset", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "from", "pylearn2", ".", "datasets", "import", "DenseDesignMatrix", "X", "=", "np", ".", "asarray", "(", "X", ")", "assert", "X", ".", "ndim", ">", "1", "if", "y", "is",...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Pylearn2Estimator._get_labels
Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels.
osprey/plugins/plugin_pylearn2.py
def _get_labels(self, y): """ Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels. """ y = np.asarray(y) if y.ndim == 1: return y.reshape((y.size, 1)) assert y.ndim == 2 return y
def _get_labels(self, y): """ Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels. """ y = np.asarray(y) if y.ndim == 1: return y.reshape((y.size, 1)) assert y.ndim == 2 return y
[ "Construct", "pylearn2", "dataset", "labels", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L64-L77
[ "def", "_get_labels", "(", "self", ",", "y", ")", ":", "y", "=", "np", ".", "asarray", "(", "y", ")", "if", "y", ".", "ndim", "==", "1", ":", "return", "y", ".", "reshape", "(", "(", "y", ".", "size", ",", "1", ")", ")", "assert", "y", ".",...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Pylearn2Estimator.fit
Build a trainer and run main_loop. Parameters ---------- X : array_like Training examples. y : array_like, optional Labels.
osprey/plugins/plugin_pylearn2.py
def fit(self, X, y=None): """ Build a trainer and run main_loop. Parameters ---------- X : array_like Training examples. y : array_like, optional Labels. """ from pylearn2.config import yaml_parse from pylearn2.train import...
def fit(self, X, y=None): """ Build a trainer and run main_loop. Parameters ---------- X : array_like Training examples. y : array_like, optional Labels. """ from pylearn2.config import yaml_parse from pylearn2.train import...
[ "Build", "a", "trainer", "and", "run", "main_loop", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L79-L116
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "from", "pylearn2", ".", "config", "import", "yaml_parse", "from", "pylearn2", ".", "train", "import", "Train", "# build trainer", "params", "=", "self", ".", "get_params", "(", ")", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Pylearn2Estimator._predict
Get model predictions. See pylearn2.scripts.mlp.predict_csv and http://fastml.com/how-to-get-predictions-from-pylearn2/. Parameters ---------- X : array_like Test dataset. method : str Model method to call for prediction.
osprey/plugins/plugin_pylearn2.py
def _predict(self, X, method='fprop'): """ Get model predictions. See pylearn2.scripts.mlp.predict_csv and http://fastml.com/how-to-get-predictions-from-pylearn2/. Parameters ---------- X : array_like Test dataset. method : str Mo...
def _predict(self, X, method='fprop'): """ Get model predictions. See pylearn2.scripts.mlp.predict_csv and http://fastml.com/how-to-get-predictions-from-pylearn2/. Parameters ---------- X : array_like Test dataset. method : str Mo...
[ "Get", "model", "predictions", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L129-L148
[ "def", "_predict", "(", "self", ",", "X", ",", "method", "=", "'fprop'", ")", ":", "import", "theano", "X_sym", "=", "self", ".", "trainer", ".", "model", ".", "get_input_space", "(", ")", ".", "make_theano_batch", "(", ")", "y_sym", "=", "getattr", "(...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Pylearn2Classifier._get_labels
Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels.
osprey/plugins/plugin_pylearn2.py
def _get_labels(self, y): """ Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels. """ y = np.asarray(y) assert y.ndim == 1 # convert to one-hot labels = np.unique(y).tolist() oh = n...
def _get_labels(self, y): """ Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels. """ y = np.asarray(y) assert y.ndim == 1 # convert to one-hot labels = np.unique(y).tolist() oh = n...
[ "Construct", "pylearn2", "dataset", "labels", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L168-L184
[ "def", "_get_labels", "(", "self", ",", "y", ")", ":", "y", "=", "np", ".", "asarray", "(", "y", ")", "assert", "y", ".", "ndim", "==", "1", "# convert to one-hot", "labels", "=", "np", ".", "unique", "(", "y", ")", ".", "tolist", "(", ")", "oh",...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Pylearn2DatasetLoader.load
Load the dataset using pylearn2.config.yaml_parse.
osprey/plugins/plugin_pylearn2.py
def load(self): """ Load the dataset using pylearn2.config.yaml_parse. """ from pylearn2.config import yaml_parse from pylearn2.datasets import Dataset dataset = yaml_parse.load(self.yaml_string) assert isinstance(dataset, Dataset) data = dataset.iterator...
def load(self): """ Load the dataset using pylearn2.config.yaml_parse. """ from pylearn2.config import yaml_parse from pylearn2.datasets import Dataset dataset = yaml_parse.load(self.yaml_string) assert isinstance(dataset, Dataset) data = dataset.iterator...
[ "Load", "the", "dataset", "using", "pylearn2", ".", "config", ".", "yaml_parse", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plugins/plugin_pylearn2.py#L278-L298
[ "def", "load", "(", "self", ")", ":", "from", "pylearn2", ".", "config", "import", "yaml_parse", "from", "pylearn2", ".", "datasets", "import", "Dataset", "dataset", "=", "yaml_parse", ".", "load", "(", "self", ".", "yaml_string", ")", "assert", "isinstance"...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
MaximumLikelihoodGaussianProcess.fit
Fits the model with random restarts. :return:
osprey/surrogate_models.py
def fit(self): """ Fits the model with random restarts. :return: """ self.model.optimize_restarts(num_restarts=self.num_restarts, verbose=False)
def fit(self): """ Fits the model with random restarts. :return: """ self.model.optimize_restarts(num_restarts=self.num_restarts, verbose=False)
[ "Fits", "the", "model", "with", "random", "restarts", ".", ":", "return", ":" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/surrogate_models.py#L45-L50
[ "def", "fit", "(", "self", ")", ":", "self", ".", "model", ".", "optimize_restarts", "(", "num_restarts", "=", "self", ".", "num_restarts", ",", "verbose", "=", "False", ")" ]
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
GaussianProcessKernel._create_kernel
creates an additive kernel
osprey/surrogate_models.py
def _create_kernel(self): """ creates an additive kernel """ # Check kernels kernels = self.kernel_params if not isinstance(kernels, list): raise RuntimeError('Must provide enumeration of kernels') for kernel in kernels: if sorted(list(kern...
def _create_kernel(self): """ creates an additive kernel """ # Check kernels kernels = self.kernel_params if not isinstance(kernels, list): raise RuntimeError('Must provide enumeration of kernels') for kernel in kernels: if sorted(list(kern...
[ "creates", "an", "additive", "kernel" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/surrogate_models.py#L67-L99
[ "def", "_create_kernel", "(", "self", ")", ":", "# Check kernels", "kernels", "=", "self", ".", "kernel_params", "if", "not", "isinstance", "(", "kernels", ",", "list", ")", ":", "raise", "RuntimeError", "(", "'Must provide enumeration of kernels'", ")", "for", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
fit_and_score_estimator
Fit and score an estimator with cross-validation This function is basically a copy of sklearn's model_selection._BaseSearchCV._fit(), which is the core of the GridSearchCV fit() method. Unfortunately, that class does _not_ return the training set scores, which we want to save in the database, and becau...
osprey/fit_estimator.py
def fit_and_score_estimator(estimator, parameters, cv, X, y=None, scoring=None, iid=True, n_jobs=1, verbose=1, pre_dispatch='2*n_jobs'): """Fit and score an estimator with cross-validation This function is basically a copy of sklearn's model_selection...
def fit_and_score_estimator(estimator, parameters, cv, X, y=None, scoring=None, iid=True, n_jobs=1, verbose=1, pre_dispatch='2*n_jobs'): """Fit and score an estimator with cross-validation This function is basically a copy of sklearn's model_selection...
[ "Fit", "and", "score", "an", "estimator", "with", "cross", "-", "validation" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/fit_estimator.py#L22-L93
[ "def", "fit_and_score_estimator", "(", "estimator", ",", "parameters", ",", "cv", ",", "X", ",", "y", "=", "None", ",", "scoring", "=", "None", ",", "iid", "=", "True", ",", "n_jobs", "=", "1", ",", "verbose", "=", "1", ",", "pre_dispatch", "=", "'2*...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
init_subclass_by_name
Find the subclass, `kls` of baseclass with class attribute `short_name` that matches the supplied `short_name`, and then instantiate and return that class with: return kls(**params) This function also tries its best to catch any possible TypeErrors due to binding of the arguments, and rethrows...
osprey/subclass_factory.py
def init_subclass_by_name(baseclass, short_name, params): """ Find the subclass, `kls` of baseclass with class attribute `short_name` that matches the supplied `short_name`, and then instantiate and return that class with: return kls(**params) This function also tries its best to catch any...
def init_subclass_by_name(baseclass, short_name, params): """ Find the subclass, `kls` of baseclass with class attribute `short_name` that matches the supplied `short_name`, and then instantiate and return that class with: return kls(**params) This function also tries its best to catch any...
[ "Find", "the", "subclass", "kls", "of", "baseclass", "with", "class", "attribute", "short_name", "that", "matches", "the", "supplied", "short_name", "and", "then", "instantiate", "and", "return", "that", "class", "with", ":" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/subclass_factory.py#L10-L58
[ "def", "init_subclass_by_name", "(", "baseclass", ",", "short_name", ",", "params", ")", ":", "sc", "=", "baseclass", ".", "__subclasses__", "(", ")", "for", "kls", "in", "sc", ":", "if", "kls", ".", "short_name", "==", "short_name", "or", "(", "_is_collec...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
dict_merge
Recursively merge two dictionaries, with the elements from `top` taking precedence over elements from `top`. Returns ------- out : dict A new dict, containing the merged records.
osprey/utils.py
def dict_merge(base, top): """Recursively merge two dictionaries, with the elements from `top` taking precedence over elements from `top`. Returns ------- out : dict A new dict, containing the merged records. """ out = dict(top) for key in base: if key in top: ...
def dict_merge(base, top): """Recursively merge two dictionaries, with the elements from `top` taking precedence over elements from `top`. Returns ------- out : dict A new dict, containing the merged records. """ out = dict(top) for key in base: if key in top: ...
[ "Recursively", "merge", "two", "dictionaries", "with", "the", "elements", "from", "top", "taking", "precedence", "over", "elements", "from", "top", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L38-L54
[ "def", "dict_merge", "(", "base", ",", "top", ")", ":", "out", "=", "dict", "(", "top", ")", "for", "key", "in", "base", ":", "if", "key", "in", "top", ":", "if", "isinstance", "(", "base", "[", "key", "]", ",", "dict", ")", "and", "isinstance", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
in_directory
Context manager (with statement) that changes the current directory during the context.
osprey/utils.py
def in_directory(path): """Context manager (with statement) that changes the current directory during the context. """ curdir = os.path.abspath(os.curdir) os.chdir(path) yield os.chdir(curdir)
def in_directory(path): """Context manager (with statement) that changes the current directory during the context. """ curdir = os.path.abspath(os.curdir) os.chdir(path) yield os.chdir(curdir)
[ "Context", "manager", "(", "with", "statement", ")", "that", "changes", "the", "current", "directory", "during", "the", "context", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L58-L65
[ "def", "in_directory", "(", "path", ")", ":", "curdir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "curdir", ")", "os", ".", "chdir", "(", "path", ")", "yield", "os", ".", "chdir", "(", "curdir", ")" ]
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
format_timedelta
Format a timedelta object for display to users Returns ------- str
osprey/utils.py
def format_timedelta(td_object): """Format a timedelta object for display to users Returns ------- str """ def get_total_seconds(td): # timedelta.total_seconds not in py2.6 return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 1e6) / 1e6 seconds = i...
def format_timedelta(td_object): """Format a timedelta object for display to users Returns ------- str """ def get_total_seconds(td): # timedelta.total_seconds not in py2.6 return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 1e6) / 1e6 seconds = i...
[ "Format", "a", "timedelta", "object", "for", "display", "to", "users" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L91-L120
[ "def", "format_timedelta", "(", "td_object", ")", ":", "def", "get_total_seconds", "(", "td", ")", ":", "# timedelta.total_seconds not in py2.6", "return", "(", "td", ".", "microseconds", "+", "(", "td", ".", "seconds", "+", "td", ".", "days", "*", "24", "*"...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
_assert_all_finite
Like assert_all_finite, but only for ndarray.
osprey/utils.py
def _assert_all_finite(X): """Like assert_all_finite, but only for ndarray.""" X = np.asanyarray(X) # First try an O(n) time, O(1) space solution for the common case that # everything is finite; fall back to O(n) space np.isfinite to prevent # false positives from overflow in sum method if (X.dt...
def _assert_all_finite(X): """Like assert_all_finite, but only for ndarray.""" X = np.asanyarray(X) # First try an O(n) time, O(1) space solution for the common case that # everything is finite; fall back to O(n) space np.isfinite to prevent # false positives from overflow in sum method if (X.dt...
[ "Like", "assert_all_finite", "but", "only", "for", "ndarray", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L183-L192
[ "def", "_assert_all_finite", "(", "X", ")", ":", "X", "=", "np", ".", "asanyarray", "(", "X", ")", "# First try an O(n) time, O(1) space solution for the common case that", "# everything is finite; fall back to O(n) space np.isfinite to prevent", "# false positives from overflow in s...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
_warn_if_not_finite
UserWarning if array contains non-finite elements
osprey/utils.py
def _warn_if_not_finite(X): """UserWarning if array contains non-finite elements""" X = np.asanyarray(X) # First try an O(n) time, O(1) space solution for the common case that # everything is finite; fall back to O(n) space np.isfinite to prevent # false positives from overflow in sum method if ...
def _warn_if_not_finite(X): """UserWarning if array contains non-finite elements""" X = np.asanyarray(X) # First try an O(n) time, O(1) space solution for the common case that # everything is finite; fall back to O(n) space np.isfinite to prevent # false positives from overflow in sum method if ...
[ "UserWarning", "if", "array", "contains", "non", "-", "finite", "elements" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L195-L205
[ "def", "_warn_if_not_finite", "(", "X", ")", ":", "X", "=", "np", ".", "asanyarray", "(", "X", ")", "# First try an O(n) time, O(1) space solution for the common case that", "# everything is finite; fall back to O(n) space np.isfinite to prevent", "# false positives from overflow in ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
num_samples
Return number of samples in array-like x.
osprey/utils.py
def num_samples(x, is_nested=False): """Return number of samples in array-like x.""" if hasattr(x, 'fit'): # Don't get num_samples from an ensembles length! raise TypeError('Expected sequence or array-like, got ' 'estimator %s' % x) if is_nested: return sum(n...
def num_samples(x, is_nested=False): """Return number of samples in array-like x.""" if hasattr(x, 'fit'): # Don't get num_samples from an ensembles length! raise TypeError('Expected sequence or array-like, got ' 'estimator %s' % x) if is_nested: return sum(n...
[ "Return", "number", "of", "samples", "in", "array", "-", "like", "x", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L208-L230
[ "def", "num_samples", "(", "x", ",", "is_nested", "=", "False", ")", ":", "if", "hasattr", "(", "x", ",", "'fit'", ")", ":", "# Don't get num_samples from an ensembles length!", "raise", "TypeError", "(", "'Expected sequence or array-like, got '", "'estimator %s'", "%...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
check_arrays
Check that all arrays have consistent first dimensions. Checks whether all objects in arrays have the same shape or length. By default lists and tuples are converted to numpy arrays. It is possible to enforce certain properties, such as dtype, continguity and sparse matrix format (if a sparse matrix i...
osprey/utils.py
def check_arrays(*arrays, **options): """Check that all arrays have consistent first dimensions. Checks whether all objects in arrays have the same shape or length. By default lists and tuples are converted to numpy arrays. It is possible to enforce certain properties, such as dtype, continguity a...
def check_arrays(*arrays, **options): """Check that all arrays have consistent first dimensions. Checks whether all objects in arrays have the same shape or length. By default lists and tuples are converted to numpy arrays. It is possible to enforce certain properties, such as dtype, continguity a...
[ "Check", "that", "all", "arrays", "have", "consistent", "first", "dimensions", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/utils.py#L233-L352
[ "def", "check_arrays", "(", "*", "arrays", ",", "*", "*", "options", ")", ":", "sparse_format", "=", "options", ".", "pop", "(", "'sparse_format'", ",", "None", ")", "if", "sparse_format", "not", "in", "(", "None", ",", "'csr'", ",", "'csc'", ",", "'de...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
BaseStrategy.is_repeated_suggestion
Parameters ---------- params : dict Trial param set history : list of 3-tuples History of past function evaluations. Each element in history should be a tuple `(params, score, status)`, where `params` is a dict mapping parameter names to values ...
osprey/strategies.py
def is_repeated_suggestion(params, history): """ Parameters ---------- params : dict Trial param set history : list of 3-tuples History of past function evaluations. Each element in history should be a tuple `(params, score, status)`, where `pa...
def is_repeated_suggestion(params, history): """ Parameters ---------- params : dict Trial param set history : list of 3-tuples History of past function evaluations. Each element in history should be a tuple `(params, score, status)`, where `pa...
[ "Parameters", "----------", "params", ":", "dict", "Trial", "param", "set", "history", ":", "list", "of", "3", "-", "tuples", "History", "of", "past", "function", "evaluations", ".", "Each", "element", "in", "history", "should", "be", "a", "tuple", "(", "p...
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/strategies.py#L48-L67
[ "def", "is_repeated_suggestion", "(", "params", ",", "history", ")", ":", "if", "any", "(", "params", "==", "hparams", "and", "hstatus", "==", "'SUCCEEDED'", "for", "hparams", ",", "hscore", ",", "hstatus", "in", "history", ")", ":", "return", "True", "els...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
HyperoptTPE.suggest
Suggest params to maximize an objective function based on the function evaluation history using a tree of Parzen estimators (TPE), as implemented in the hyperopt package. Use of this function requires that hyperopt be installed.
osprey/strategies.py
def suggest(self, history, searchspace): """ Suggest params to maximize an objective function based on the function evaluation history using a tree of Parzen estimators (TPE), as implemented in the hyperopt package. Use of this function requires that hyperopt be installed. ...
def suggest(self, history, searchspace): """ Suggest params to maximize an objective function based on the function evaluation history using a tree of Parzen estimators (TPE), as implemented in the hyperopt package. Use of this function requires that hyperopt be installed. ...
[ "Suggest", "params", "to", "maximize", "an", "objective", "function", "based", "on", "the", "function", "evaluation", "history", "using", "a", "tree", "of", "Parzen", "estimators", "(", "TPE", ")", "as", "implemented", "in", "the", "hyperopt", "package", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/strategies.py#L90-L198
[ "def", "suggest", "(", "self", ",", "history", ",", "searchspace", ")", ":", "# This function is very odd, because as far as I can tell there's", "# no real documented API for any of the internals of hyperopt. Its", "# execution model is that hyperopt calls your objective function", "# (in...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Config._merge_defaults
The config object loads its values from two sources, with the following precedence: 1. data/default_config.yaml 2. The config file itself, passed in to this object in the constructor as `path`. in case of conflict, the config file dominates.
osprey/config.py
def _merge_defaults(self, config): """The config object loads its values from two sources, with the following precedence: 1. data/default_config.yaml 2. The config file itself, passed in to this object in the constructor as `path`. in case of conflict, th...
def _merge_defaults(self, config): """The config object loads its values from two sources, with the following precedence: 1. data/default_config.yaml 2. The config file itself, passed in to this object in the constructor as `path`. in case of conflict, th...
[ "The", "config", "object", "loads", "its", "values", "from", "two", "sources", "with", "the", "following", "precedence", ":" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L74-L87
[ "def", "_merge_defaults", "(", "self", ",", "config", ")", ":", "fn", "=", "resource_filename", "(", "'osprey'", ",", "join", "(", "'data'", ",", "'default_config.yaml'", ")", ")", "with", "open", "(", "fn", ")", "as", "f", ":", "default", "=", "parse", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Config.fromdict
Create a Config object from config dict directly.
osprey/config.py
def fromdict(cls, config, check_fields=True): """Create a Config object from config dict directly.""" m = super(Config, cls).__new__(cls) m.path = '.' m.verbose = False m.config = m._merge_defaults(config) if check_fields: m._check_fields() return m
def fromdict(cls, config, check_fields=True): """Create a Config object from config dict directly.""" m = super(Config, cls).__new__(cls) m.path = '.' m.verbose = False m.config = m._merge_defaults(config) if check_fields: m._check_fields() return m
[ "Create", "a", "Config", "object", "from", "config", "dict", "directly", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L117-L125
[ "def", "fromdict", "(", "cls", ",", "config", ",", "check_fields", "=", "True", ")", ":", "m", "=", "super", "(", "Config", ",", "cls", ")", ".", "__new__", "(", "cls", ")", "m", ".", "path", "=", "'.'", "m", ".", "verbose", "=", "False", "m", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Config.get_value
Get an entry from within a section, using a '/' delimiter
osprey/config.py
def get_value(self, field, default=None): """Get an entry from within a section, using a '/' delimiter""" section, key = field.split('/') return self.get_section(section).get(key, default)
def get_value(self, field, default=None): """Get an entry from within a section, using a '/' delimiter""" section, key = field.split('/') return self.get_section(section).get(key, default)
[ "Get", "an", "entry", "from", "within", "a", "section", "using", "a", "/", "delimiter" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L131-L134
[ "def", "get_value", "(", "self", ",", "field", ",", "default", "=", "None", ")", ":", "section", ",", "key", "=", "field", ".", "split", "(", "'/'", ")", "return", "self", ".", "get_section", "(", "section", ")", ".", "get", "(", "key", ",", "defau...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Config.estimator
Get the estimator, an instance of a (subclass of) sklearn.base.BaseEstimator It can be loaded either from a pickle, from a string using eval(), or from an entry point. e.g. estimator: # only one of the following can actually be active in a given # confi...
osprey/config.py
def estimator(self): """Get the estimator, an instance of a (subclass of) sklearn.base.BaseEstimator It can be loaded either from a pickle, from a string using eval(), or from an entry point. e.g. estimator: # only one of the following can actually be activ...
def estimator(self): """Get the estimator, an instance of a (subclass of) sklearn.base.BaseEstimator It can be loaded either from a pickle, from a string using eval(), or from an entry point. e.g. estimator: # only one of the following can actually be activ...
[ "Get", "the", "estimator", "an", "instance", "of", "a", "(", "subclass", "of", ")", "sklearn", ".", "base", ".", "BaseEstimator" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L138-L227
[ "def", "estimator", "(", "self", ")", ":", "module_path", "=", "self", ".", "get_value", "(", "'estimator/module'", ")", "if", "module_path", "is", "not", "None", ":", "with", "prepend_syspath", "(", "dirname", "(", "abspath", "(", "self", ".", "path", ")"...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
Config.sha1
SHA1 hash of the config file itself.
osprey/config.py
def sha1(self): """SHA1 hash of the config file itself.""" with open(self.path, 'rb') as f: return hashlib.sha1(f.read()).hexdigest()
def sha1(self): """SHA1 hash of the config file itself.""" with open(self.path, 'rb') as f: return hashlib.sha1(f.read()).hexdigest()
[ "SHA1", "hash", "of", "the", "config", "file", "itself", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L368-L371
[ "def", "sha1", "(", "self", ")", ":", "with", "open", "(", "self", ".", "path", ",", "'rb'", ")", "as", "f", ":", "return", "hashlib", ".", "sha1", "(", "f", ".", "read", "(", ")", ")", ".", "hexdigest", "(", ")" ]
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
AcquisitionFunction.get_best_candidate
Returns ---------- best_candidate : the best candidate hyper-parameters as defined by
osprey/acquisition_functions.py
def get_best_candidate(self): """ Returns ---------- best_candidate : the best candidate hyper-parameters as defined by """ # TODO make this best mean response self.incumbent = self.surrogate.Y.max() # Objective function def z(x): # TO...
def get_best_candidate(self): """ Returns ---------- best_candidate : the best candidate hyper-parameters as defined by """ # TODO make this best mean response self.incumbent = self.surrogate.Y.max() # Objective function def z(x): # TO...
[ "Returns", "----------", "best_candidate", ":", "the", "best", "candidate", "hyper", "-", "parameters", "as", "defined", "by" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/acquisition_functions.py#L75-L109
[ "def", "get_best_candidate", "(", "self", ")", ":", "# TODO make this best mean response", "self", ".", "incumbent", "=", "self", ".", "surrogate", ".", "Y", ".", "max", "(", ")", "# Objective function", "def", "z", "(", "x", ")", ":", "# TODO make spread of poi...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
plot_1
Plot 1. All iterations (scatter plot)
osprey/plot.py
def plot_1(data, *args): """Plot 1. All iterations (scatter plot)""" df_all = pd.DataFrame(data) df_params = nonconstant_parameters(data) return build_scatter_tooltip( x=df_all['id'], y=df_all['mean_test_score'], tt=df_params, title='All Iterations')
def plot_1(data, *args): """Plot 1. All iterations (scatter plot)""" df_all = pd.DataFrame(data) df_params = nonconstant_parameters(data) return build_scatter_tooltip( x=df_all['id'], y=df_all['mean_test_score'], tt=df_params, title='All Iterations')
[ "Plot", "1", ".", "All", "iterations", "(", "scatter", "plot", ")" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plot.py#L57-L63
[ "def", "plot_1", "(", "data", ",", "*", "args", ")", ":", "df_all", "=", "pd", ".", "DataFrame", "(", "data", ")", "df_params", "=", "nonconstant_parameters", "(", "data", ")", "return", "build_scatter_tooltip", "(", "x", "=", "df_all", "[", "'id'", "]",...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
plot_2
Plot 2. Running best score (scatter plot)
osprey/plot.py
def plot_2(data, *args): """Plot 2. Running best score (scatter plot)""" df_all = pd.DataFrame(data) df_params = nonconstant_parameters(data) x = [df_all['id'][0]] y = [df_all['mean_test_score'][0]] params = [df_params.loc[0]] for i in range(len(df_all)): if df_all['mean_test_score']...
def plot_2(data, *args): """Plot 2. Running best score (scatter plot)""" df_all = pd.DataFrame(data) df_params = nonconstant_parameters(data) x = [df_all['id'][0]] y = [df_all['mean_test_score'][0]] params = [df_params.loc[0]] for i in range(len(df_all)): if df_all['mean_test_score']...
[ "Plot", "2", ".", "Running", "best", "score", "(", "scatter", "plot", ")" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plot.py#L66-L79
[ "def", "plot_2", "(", "data", ",", "*", "args", ")", ":", "df_all", "=", "pd", ".", "DataFrame", "(", "data", ")", "df_params", "=", "nonconstant_parameters", "(", "data", ")", "x", "=", "[", "df_all", "[", "'id'", "]", "[", "0", "]", "]", "y", "...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
plot_3
t-SNE embedding of the parameters, colored by score
osprey/plot.py
def plot_3(data, ss, *args): """t-SNE embedding of the parameters, colored by score """ if len(data) <= 1: warnings.warn("Only one datapoint. Could not compute t-SNE embedding.") return None scores = np.array([d['mean_test_score'] for d in data]) # maps each parameters to a vector ...
def plot_3(data, ss, *args): """t-SNE embedding of the parameters, colored by score """ if len(data) <= 1: warnings.warn("Only one datapoint. Could not compute t-SNE embedding.") return None scores = np.array([d['mean_test_score'] for d in data]) # maps each parameters to a vector ...
[ "t", "-", "SNE", "embedding", "of", "the", "parameters", "colored", "by", "score" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plot.py#L82-L122
[ "def", "plot_3", "(", "data", ",", "ss", ",", "*", "args", ")", ":", "if", "len", "(", "data", ")", "<=", "1", ":", "warnings", ".", "warn", "(", "\"Only one datapoint. Could not compute t-SNE embedding.\"", ")", "return", "None", "scores", "=", "np", ".",...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
plot_4
Scatter plot of score vs each param
osprey/plot.py
def plot_4(data, *args): """Scatter plot of score vs each param """ params = nonconstant_parameters(data) scores = np.array([d['mean_test_score'] for d in data]) order = np.argsort(scores) for key in params.keys(): if params[key].dtype == np.dtype('bool'): params[key] = para...
def plot_4(data, *args): """Scatter plot of score vs each param """ params = nonconstant_parameters(data) scores = np.array([d['mean_test_score'] for d in data]) order = np.argsort(scores) for key in params.keys(): if params[key].dtype == np.dtype('bool'): params[key] = para...
[ "Scatter", "plot", "of", "score", "vs", "each", "param" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/plot.py#L125-L149
[ "def", "plot_4", "(", "data", ",", "*", "args", ")", ":", "params", "=", "nonconstant_parameters", "(", "data", ")", "scores", "=", "np", ".", "array", "(", "[", "d", "[", "'mean_test_score'", "]", "for", "d", "in", "data", "]", ")", "order", "=", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
SearchSpace.add_jump
An integer/float-valued enumerable with `num` items, bounded between [`min`, `max`]. Note that the right endpoint of the interval includes `max`. This is a wrapper around the add_enum. `jump` can be a float or int.
osprey/search_space.py
def add_jump(self, name, min, max, num, warp=None, var_type=float): """ An integer/float-valued enumerable with `num` items, bounded between [`min`, `max`]. Note that the right endpoint of the interval includes `max`. This is a wrapper around the add_enum. `jump` can be a float or int. ...
def add_jump(self, name, min, max, num, warp=None, var_type=float): """ An integer/float-valued enumerable with `num` items, bounded between [`min`, `max`]. Note that the right endpoint of the interval includes `max`. This is a wrapper around the add_enum. `jump` can be a float or int. ...
[ "An", "integer", "/", "float", "-", "valued", "enumerable", "with", "num", "items", "bounded", "between", "[", "min", "max", "]", ".", "Note", "that", "the", "right", "endpoint", "of", "the", "interval", "includes", "max", ".", "This", "is", "a", "wrappe...
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/search_space.py#L33-L62
[ "def", "add_jump", "(", "self", ",", "name", ",", "min", ",", "max", ",", "num", ",", "warp", "=", "None", ",", "var_type", "=", "float", ")", ":", "if", "not", "isinstance", "(", "var_type", ",", "type", ")", ":", "if", "var_type", "==", "'int'", ...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
SearchSpace.add_int
An integer-valued dimension bounded between `min` <= x <= `max`. Note that the right endpoint of the interval includes `max`. When `warp` is None, the base measure associated with this dimension is a categorical distribution with each weight on each of the integers in [min, max]. With `...
osprey/search_space.py
def add_int(self, name, min, max, warp=None): """An integer-valued dimension bounded between `min` <= x <= `max`. Note that the right endpoint of the interval includes `max`. When `warp` is None, the base measure associated with this dimension is a categorical distribution with each wei...
def add_int(self, name, min, max, warp=None): """An integer-valued dimension bounded between `min` <= x <= `max`. Note that the right endpoint of the interval includes `max`. When `warp` is None, the base measure associated with this dimension is a categorical distribution with each wei...
[ "An", "integer", "-", "valued", "dimension", "bounded", "between", "min", "<", "=", "x", "<", "=", "max", ".", "Note", "that", "the", "right", "endpoint", "of", "the", "interval", "includes", "max", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/search_space.py#L64-L86
[ "def", "add_int", "(", "self", ",", "name", ",", "min", ",", "max", ",", "warp", "=", "None", ")", ":", "min", ",", "max", "=", "map", "(", "int", ",", "(", "min", ",", "max", ")", ")", "if", "max", "<", "min", ":", "raise", "ValueError", "("...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
SearchSpace.add_float
A floating point-valued dimension bounded `min` <= x < `max` When `warp` is None, the base measure associated with this dimension is a uniform distribution on [min, max). With `warp == 'log'`, the base measure is a uniform distribution on the log of the variable, with bounds at `log(min...
osprey/search_space.py
def add_float(self, name, min, max, warp=None): """A floating point-valued dimension bounded `min` <= x < `max` When `warp` is None, the base measure associated with this dimension is a uniform distribution on [min, max). With `warp == 'log'`, the base measure is a uniform distribution ...
def add_float(self, name, min, max, warp=None): """A floating point-valued dimension bounded `min` <= x < `max` When `warp` is None, the base measure associated with this dimension is a uniform distribution on [min, max). With `warp == 'log'`, the base measure is a uniform distribution ...
[ "A", "floating", "point", "-", "valued", "dimension", "bounded", "min", "<", "=", "x", "<", "max" ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/search_space.py#L88-L107
[ "def", "add_float", "(", "self", ",", "name", ",", "min", ",", "max", ",", "warp", "=", "None", ")", ":", "min", ",", "max", "=", "map", "(", "float", ",", "(", "min", ",", "max", ")", ")", "if", "not", "min", "<", "max", ":", "raise", "Value...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
SearchSpace.add_enum
An enumeration-valued dimension. The base measure associated with this dimension is a categorical distribution with equal weight on each element in `choices`.
osprey/search_space.py
def add_enum(self, name, choices): """An enumeration-valued dimension. The base measure associated with this dimension is a categorical distribution with equal weight on each element in `choices`. """ if not isinstance(choices, Iterable): raise ValueError('variable %...
def add_enum(self, name, choices): """An enumeration-valued dimension. The base measure associated with this dimension is a categorical distribution with equal weight on each element in `choices`. """ if not isinstance(choices, Iterable): raise ValueError('variable %...
[ "An", "enumeration", "-", "valued", "dimension", "." ]
msmbuilder/osprey
python
https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/search_space.py#L109-L117
[ "def", "add_enum", "(", "self", ",", "name", ",", "choices", ")", ":", "if", "not", "isinstance", "(", "choices", ",", "Iterable", ")", ":", "raise", "ValueError", "(", "'variable %s: choices must be iterable'", "%", "name", ")", "self", ".", "variables", "[...
ea09da24e45820e1300e24a52fefa6c849f7a986
valid
bresenham
Yield integer coordinates on the line from (x0, y0) to (x1, y1). Input coordinates should be integers. The result will contain both the start and the end point.
bresenham.py
def bresenham(x0, y0, x1, y1): """Yield integer coordinates on the line from (x0, y0) to (x1, y1). Input coordinates should be integers. The result will contain both the start and the end point. """ dx = x1 - x0 dy = y1 - y0 xsign = 1 if dx > 0 else -1 ysign = 1 if dy > 0 else -1 ...
def bresenham(x0, y0, x1, y1): """Yield integer coordinates on the line from (x0, y0) to (x1, y1). Input coordinates should be integers. The result will contain both the start and the end point. """ dx = x1 - x0 dy = y1 - y0 xsign = 1 if dx > 0 else -1 ysign = 1 if dy > 0 else -1 ...
[ "Yield", "integer", "coordinates", "on", "the", "line", "from", "(", "x0", "y0", ")", "to", "(", "x1", "y1", ")", "." ]
encukou/bresenham
python
https://github.com/encukou/bresenham/blob/d18fe31725122b53a61a597b0fe36b22bf75b375/bresenham.py#L7-L37
[ "def", "bresenham", "(", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "dx", "=", "x1", "-", "x0", "dy", "=", "y1", "-", "y0", "xsign", "=", "1", "if", "dx", ">", "0", "else", "-", "1", "ysign", "=", "1", "if", "dy", ">", "0", "else", ...
d18fe31725122b53a61a597b0fe36b22bf75b375
valid
log_callback
Decorator that produces DEBUG level log messages before and after calling a parser method. If a callback raises an IgnoredMatchException the log will show 'IGNORED' instead to indicate that the parser will not create any objects from the matched string. Example: DEBUG:poyo.parser:parse_sim...
poyo/parser.py
def log_callback(wrapped_function): """Decorator that produces DEBUG level log messages before and after calling a parser method. If a callback raises an IgnoredMatchException the log will show 'IGNORED' instead to indicate that the parser will not create any objects from the matched string. E...
def log_callback(wrapped_function): """Decorator that produces DEBUG level log messages before and after calling a parser method. If a callback raises an IgnoredMatchException the log will show 'IGNORED' instead to indicate that the parser will not create any objects from the matched string. E...
[ "Decorator", "that", "produces", "DEBUG", "level", "log", "messages", "before", "and", "after", "calling", "a", "parser", "method", "." ]
hackebrot/poyo
python
https://github.com/hackebrot/poyo/blob/4c7338a87c692c317b3b5bc726d731dd96689298/poyo/parser.py#L20-L62
[ "def", "log_callback", "(", "wrapped_function", ")", ":", "def", "debug_log", "(", "message", ")", ":", "\"\"\"Helper to log an escaped version of the given message to DEBUG\"\"\"", "logger", ".", "debug", "(", "message", ".", "encode", "(", "'unicode_escape'", ")", "."...
4c7338a87c692c317b3b5bc726d731dd96689298
valid
_Parser.find_match
Try to find a pattern that matches the source and calll a parser method to create Python objects. A callback that raises an IgnoredMatchException indicates that the given string data is ignored by the parser and no objects are created. If none of the pattern match a NoMatchException is...
poyo/parser.py
def find_match(self): """Try to find a pattern that matches the source and calll a parser method to create Python objects. A callback that raises an IgnoredMatchException indicates that the given string data is ignored by the parser and no objects are created. If none of the pa...
def find_match(self): """Try to find a pattern that matches the source and calll a parser method to create Python objects. A callback that raises an IgnoredMatchException indicates that the given string data is ignored by the parser and no objects are created. If none of the pa...
[ "Try", "to", "find", "a", "pattern", "that", "matches", "the", "source", "and", "calll", "a", "parser", "method", "to", "create", "Python", "objects", "." ]
hackebrot/poyo
python
https://github.com/hackebrot/poyo/blob/4c7338a87c692c317b3b5bc726d731dd96689298/poyo/parser.py#L198-L225
[ "def", "find_match", "(", "self", ")", ":", "for", "pattern", ",", "callback", "in", "self", ".", "rules", ":", "match", "=", "pattern", ".", "match", "(", "self", ".", "source", ",", "pos", "=", "self", ".", "pos", ")", "if", "not", "match", ":", ...
4c7338a87c692c317b3b5bc726d731dd96689298
valid
ContainerMixin.add_child
If the given object is an instance of Child add it to self and register self as a parent.
poyo/_nodes.py
def add_child(self, child): """If the given object is an instance of Child add it to self and register self as a parent. """ if not isinstance(child, ChildMixin): raise TypeError( 'Requires instance of TreeElement. ' 'Got {}'.format(type(child)...
def add_child(self, child): """If the given object is an instance of Child add it to self and register self as a parent. """ if not isinstance(child, ChildMixin): raise TypeError( 'Requires instance of TreeElement. ' 'Got {}'.format(type(child)...
[ "If", "the", "given", "object", "is", "an", "instance", "of", "Child", "add", "it", "to", "self", "and", "register", "self", "as", "a", "parent", "." ]
hackebrot/poyo
python
https://github.com/hackebrot/poyo/blob/4c7338a87c692c317b3b5bc726d731dd96689298/poyo/_nodes.py#L26-L36
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "if", "not", "isinstance", "(", "child", ",", "ChildMixin", ")", ":", "raise", "TypeError", "(", "'Requires instance of TreeElement. '", "'Got {}'", ".", "format", "(", "type", "(", "child", ")", ")", ...
4c7338a87c692c317b3b5bc726d731dd96689298
valid
get_ip_packet
if client_port is 0 any client_port is good
thrift_tools/util.py
def get_ip_packet(data, client_port, server_port, is_loopback=False): """ if client_port is 0 any client_port is good """ header = _loopback if is_loopback else _ethernet try: header.unpack(data) except Exception as ex: raise ValueError('Bad header: %s' % ex) tcp_p = getattr(header...
def get_ip_packet(data, client_port, server_port, is_loopback=False): """ if client_port is 0 any client_port is good """ header = _loopback if is_loopback else _ethernet try: header.unpack(data) except Exception as ex: raise ValueError('Bad header: %s' % ex) tcp_p = getattr(header...
[ "if", "client_port", "is", "0", "any", "client_port", "is", "good" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/util.py#L34-L56
[ "def", "get_ip_packet", "(", "data", ",", "client_port", ",", "server_port", ",", "is_loopback", "=", "False", ")", ":", "header", "=", "_loopback", "if", "is_loopback", "else", "_ethernet", "try", ":", "header", ".", "unpack", "(", "data", ")", "except", ...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
listening_ports
Reads listening ports from /proc/net/tcp
examples/methods_per_port.py
def listening_ports(): """ Reads listening ports from /proc/net/tcp """ ports = [] if not os.path.exists(PROC_TCP): return ports with open(PROC_TCP) as fh: for line in fh: if '00000000:0000' not in line: continue parts = line.lstrip(' ').split(' ...
def listening_ports(): """ Reads listening ports from /proc/net/tcp """ ports = [] if not os.path.exists(PROC_TCP): return ports with open(PROC_TCP) as fh: for line in fh: if '00000000:0000' not in line: continue parts = line.lstrip(' ').split(' ...
[ "Reads", "listening", "ports", "from", "/", "proc", "/", "net", "/", "tcp" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/examples/methods_per_port.py#L37-L56
[ "def", "listening_ports", "(", ")", ":", "ports", "=", "[", "]", "if", "not", "os", ".", "path", ".", "exists", "(", "PROC_TCP", ")", ":", "return", "ports", "with", "open", "(", "PROC_TCP", ")", "as", "fh", ":", "for", "line", "in", "fh", ":", "...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
LatencyPrinter.report
get stats & show them
thrift_tools/printer.py
def report(self): """ get stats & show them """ self._output.write('\r') sort_by = 'avg' results = {} for key, latencies in self._latencies_by_method.items(): result = {} result['count'] = len(latencies) result['avg'] = sum(latencies) / len(la...
def report(self): """ get stats & show them """ self._output.write('\r') sort_by = 'avg' results = {} for key, latencies in self._latencies_by_method.items(): result = {} result['count'] = len(latencies) result['avg'] = sum(latencies) / len(la...
[ "get", "stats", "&", "show", "them" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/printer.py#L209-L239
[ "def", "report", "(", "self", ")", ":", "self", ".", "_output", ".", "write", "(", "'\\r'", ")", "sort_by", "=", "'avg'", "results", "=", "{", "}", "for", "key", ",", "latencies", "in", "self", ".", "_latencies_by_method", ".", "items", "(", ")", ":"...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
ThriftDiff.of_structs
Diff two thrift structs and return the result as a ThriftDiff instance
thrift_tools/thrift_diff.py
def of_structs(cls, a, b): """ Diff two thrift structs and return the result as a ThriftDiff instance """ t_diff = ThriftDiff(a, b) t_diff._do_diff() return t_diff
def of_structs(cls, a, b): """ Diff two thrift structs and return the result as a ThriftDiff instance """ t_diff = ThriftDiff(a, b) t_diff._do_diff() return t_diff
[ "Diff", "two", "thrift", "structs", "and", "return", "the", "result", "as", "a", "ThriftDiff", "instance" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_diff.py#L32-L38
[ "def", "of_structs", "(", "cls", ",", "a", ",", "b", ")", ":", "t_diff", "=", "ThriftDiff", "(", "a", ",", "b", ")", "t_diff", ".", "_do_diff", "(", ")", "return", "t_diff" ]
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
ThriftDiff.of_messages
Diff two thrift messages by comparing their args, raises exceptions if for some reason the messages can't be diffed. Only args of type 'struct' are compared. Returns a list of ThriftDiff results - one for each struct arg
thrift_tools/thrift_diff.py
def of_messages(cls, msg_a, msg_b): """ Diff two thrift messages by comparing their args, raises exceptions if for some reason the messages can't be diffed. Only args of type 'struct' are compared. Returns a list of ThriftDiff results - one for each struct arg """ ...
def of_messages(cls, msg_a, msg_b): """ Diff two thrift messages by comparing their args, raises exceptions if for some reason the messages can't be diffed. Only args of type 'struct' are compared. Returns a list of ThriftDiff results - one for each struct arg """ ...
[ "Diff", "two", "thrift", "messages", "by", "comparing", "their", "args", "raises", "exceptions", "if", "for", "some", "reason", "the", "messages", "can", "t", "be", "diffed", ".", "Only", "args", "of", "type", "struct", "are", "compared", "." ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_diff.py#L41-L54
[ "def", "of_messages", "(", "cls", ",", "msg_a", ",", "msg_b", ")", ":", "ok_to_diff", ",", "reason", "=", "cls", ".", "can_diff", "(", "msg_a", ",", "msg_b", ")", "if", "not", "ok_to_diff", ":", "raise", "ValueError", "(", "reason", ")", "return", "[",...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
ThriftDiff.can_diff
Check if two thrift messages are diff ready. Returns a tuple of (boolean, reason_string), i.e. (False, reason_string) if the messages can not be diffed along with the reason and (True, None) for the opposite case
thrift_tools/thrift_diff.py
def can_diff(msg_a, msg_b): """ Check if two thrift messages are diff ready. Returns a tuple of (boolean, reason_string), i.e. (False, reason_string) if the messages can not be diffed along with the reason and (True, None) for the opposite case """ if msg_a.metho...
def can_diff(msg_a, msg_b): """ Check if two thrift messages are diff ready. Returns a tuple of (boolean, reason_string), i.e. (False, reason_string) if the messages can not be diffed along with the reason and (True, None) for the opposite case """ if msg_a.metho...
[ "Check", "if", "two", "thrift", "messages", "are", "diff", "ready", "." ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_diff.py#L57-L70
[ "def", "can_diff", "(", "msg_a", ",", "msg_b", ")", ":", "if", "msg_a", ".", "method", "!=", "msg_b", ".", "method", ":", "return", "False", ",", "'method name of messages do not match'", "if", "len", "(", "msg_a", ".", "args", ")", "!=", "len", "(", "ms...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
ThriftStruct.is_isomorphic_to
Returns true if all fields of other struct are isomorphic to this struct's fields
thrift_tools/thrift_struct.py
def is_isomorphic_to(self, other): """ Returns true if all fields of other struct are isomorphic to this struct's fields """ return (isinstance(other, self.__class__) and len(self.fields) == len(other.fields) and all...
def is_isomorphic_to(self, other): """ Returns true if all fields of other struct are isomorphic to this struct's fields """ return (isinstance(other, self.__class__) and len(self.fields) == len(other.fields) and all...
[ "Returns", "true", "if", "all", "fields", "of", "other", "struct", "are", "isomorphic", "to", "this", "struct", "s", "fields" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_struct.py#L33-L43
[ "def", "is_isomorphic_to", "(", "self", ",", "other", ")", ":", "return", "(", "isinstance", "(", "other", ",", "self", ".", "__class__", ")", "and", "len", "(", "self", ".", "fields", ")", "==", "len", "(", "other", ".", "fields", ")", "and", "all",...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
ThriftField.is_isomorphic_to
Returns true if other field's meta data (everything except value) is same as this one
thrift_tools/thrift_struct.py
def is_isomorphic_to(self, other): """ Returns true if other field's meta data (everything except value) is same as this one """ return (isinstance(other, self.__class__) and self.field_type == other.field_type and self.field_id == other.field_id)
def is_isomorphic_to(self, other): """ Returns true if other field's meta data (everything except value) is same as this one """ return (isinstance(other, self.__class__) and self.field_type == other.field_type and self.field_id == other.field_id)
[ "Returns", "true", "if", "other", "field", "s", "meta", "data", "(", "everything", "except", "value", ")", "is", "same", "as", "this", "one" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_struct.py#L262-L269
[ "def", "is_isomorphic_to", "(", "self", ",", "other", ")", ":", "return", "(", "isinstance", "(", "other", ",", "self", ".", "__class__", ")", "and", "self", ".", "field_type", "==", "other", ".", "field_type", "and", "self", ".", "field_id", "==", "othe...
64e74aec89e2491c781fc62d1c45944dc15aba28
valid
ThriftMessage.read
tries to deserialize a message, might fail if data is missing
thrift_tools/thrift_message.py
def read(cls, data, protocol=None, fallback_protocol=TBinaryProtocol, finagle_thrift=False, max_fields=MAX_FIELDS, max_list_size=MAX_LIST_SIZE, max_map_size=MAX_MAP_SIZE, max_set_size=MAX_SET_SIZE, read_values=False)...
def read(cls, data, protocol=None, fallback_protocol=TBinaryProtocol, finagle_thrift=False, max_fields=MAX_FIELDS, max_list_size=MAX_LIST_SIZE, max_map_size=MAX_MAP_SIZE, max_set_size=MAX_SET_SIZE, read_values=False)...
[ "tries", "to", "deserialize", "a", "message", "might", "fail", "if", "data", "is", "missing" ]
pinterest/thrift-tools
python
https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_message.py#L82-L150
[ "def", "read", "(", "cls", ",", "data", ",", "protocol", "=", "None", ",", "fallback_protocol", "=", "TBinaryProtocol", ",", "finagle_thrift", "=", "False", ",", "max_fields", "=", "MAX_FIELDS", ",", "max_list_size", "=", "MAX_LIST_SIZE", ",", "max_map_size", ...
64e74aec89e2491c781fc62d1c45944dc15aba28