repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
calmjs/calmjs
src/calmjs/cli.py
PackageManagerDriver.pkg_manager_install
def pkg_manager_install( self, package_names=None, production=None, development=None, args=(), env={}, **kw): """ This will install all dependencies into the current working directory for the specific Python package from the selected JavaScript package...
python
def pkg_manager_install( self, package_names=None, production=None, development=None, args=(), env={}, **kw): """ This will install all dependencies into the current working directory for the specific Python package from the selected JavaScript package...
[ "def", "pkg_manager_install", "(", "self", ",", "package_names", "=", "None", ",", "production", "=", "None", ",", "development", "=", "None", ",", "args", "=", "(", ")", ",", "env", "=", "{", "}", ",", "*", "*", "kw", ")", ":", "if", "not", "packa...
This will install all dependencies into the current working directory for the specific Python package from the selected JavaScript package manager; this requires that this package manager's package definition file to be properly generated first, otherwise the process will be aborted. ...
[ "This", "will", "install", "all", "dependencies", "into", "the", "current", "working", "directory", "for", "the", "specific", "Python", "package", "from", "the", "selected", "JavaScript", "package", "manager", ";", "this", "requires", "that", "this", "package", ...
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/cli.py#L415-L505
calmjs/calmjs
src/calmjs/cli.py
PackageManagerDriver.run
def run(self, args=(), env={}): """ Calls the package manager with the arguments. Returns decoded output of stdout and stderr; decoding determine by locale. """ # the following will call self._get_exec_binary return self._exec(self.binary, args=args, env=env)
python
def run(self, args=(), env={}): """ Calls the package manager with the arguments. Returns decoded output of stdout and stderr; decoding determine by locale. """ # the following will call self._get_exec_binary return self._exec(self.binary, args=args, env=env)
[ "def", "run", "(", "self", ",", "args", "=", "(", ")", ",", "env", "=", "{", "}", ")", ":", "# the following will call self._get_exec_binary", "return", "self", ".", "_exec", "(", "self", ".", "binary", ",", "args", "=", "args", ",", "env", "=", "env",...
Calls the package manager with the arguments. Returns decoded output of stdout and stderr; decoding determine by locale.
[ "Calls", "the", "package", "manager", "with", "the", "arguments", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/cli.py#L540-L549
calmjs/calmjs
src/calmjs/base.py
_get_exec_binary
def _get_exec_binary(binary, kw): """ On win32, the subprocess module can only reliably resolve the target binary if it's actually a binary; as for a Node.js script it seems to only work iff shell=True was specified, presenting a security risk. Resolve the target manually through which will acc...
python
def _get_exec_binary(binary, kw): """ On win32, the subprocess module can only reliably resolve the target binary if it's actually a binary; as for a Node.js script it seems to only work iff shell=True was specified, presenting a security risk. Resolve the target manually through which will acc...
[ "def", "_get_exec_binary", "(", "binary", ",", "kw", ")", ":", "binary", "=", "which", "(", "binary", ",", "path", "=", "kw", ".", "get", "(", "'env'", ",", "{", "}", ")", ".", "get", "(", "'PATH'", ")", ")", "if", "binary", "is", "None", ":", ...
On win32, the subprocess module can only reliably resolve the target binary if it's actually a binary; as for a Node.js script it seems to only work iff shell=True was specified, presenting a security risk. Resolve the target manually through which will account for that. The kw argument is the key...
[ "On", "win32", "the", "subprocess", "module", "can", "only", "reliably", "resolve", "the", "target", "binary", "if", "it", "s", "actually", "a", "binary", ";", "as", "for", "a", "Node", ".", "js", "script", "it", "seems", "to", "only", "work", "iff", "...
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L59-L75
calmjs/calmjs
src/calmjs/base.py
BaseRegistry._init_entry_points
def _init_entry_points(self, entry_points): """ Default initialization loop. """ logger.debug( "registering %d entry points for registry '%s'", len(entry_points), self.registry_name, ) for entry_point in entry_points: try: ...
python
def _init_entry_points(self, entry_points): """ Default initialization loop. """ logger.debug( "registering %d entry points for registry '%s'", len(entry_points), self.registry_name, ) for entry_point in entry_points: try: ...
[ "def", "_init_entry_points", "(", "self", ",", "entry_points", ")", ":", "logger", ".", "debug", "(", "\"registering %d entry points for registry '%s'\"", ",", "len", "(", "entry_points", ")", ",", "self", ".", "registry_name", ",", ")", "for", "entry_point", "in"...
Default initialization loop.
[ "Default", "initialization", "loop", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L153-L178
calmjs/calmjs
src/calmjs/base.py
BasePkgRefRegistry.store_records_for_package
def store_records_for_package(self, entry_point, records): """ Store the records in a way that permit lookup by package """ # If provided records already exist in the module mapping list, # it likely means that a package declared multiple keys for the # same package name...
python
def store_records_for_package(self, entry_point, records): """ Store the records in a way that permit lookup by package """ # If provided records already exist in the module mapping list, # it likely means that a package declared multiple keys for the # same package name...
[ "def", "store_records_for_package", "(", "self", ",", "entry_point", ",", "records", ")", ":", "# If provided records already exist in the module mapping list,", "# it likely means that a package declared multiple keys for the", "# same package namespace; while normally this does not happen,...
Store the records in a way that permit lookup by package
[ "Store", "the", "records", "in", "a", "way", "that", "permit", "lookup", "by", "package" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L248-L259
calmjs/calmjs
src/calmjs/base.py
BaseModuleRegistry.register_entry_point
def register_entry_point(self, entry_point): """ Register a lone entry_point Will raise ImportError if the entry_point leads to an invalid import. """ module = _import_module(entry_point.module_name) self._register_entry_point_module(entry_point, module)
python
def register_entry_point(self, entry_point): """ Register a lone entry_point Will raise ImportError if the entry_point leads to an invalid import. """ module = _import_module(entry_point.module_name) self._register_entry_point_module(entry_point, module)
[ "def", "register_entry_point", "(", "self", ",", "entry_point", ")", ":", "module", "=", "_import_module", "(", "entry_point", ".", "module_name", ")", "self", ".", "_register_entry_point_module", "(", "entry_point", ",", "module", ")" ]
Register a lone entry_point Will raise ImportError if the entry_point leads to an invalid import.
[ "Register", "a", "lone", "entry_point" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L277-L286
calmjs/calmjs
src/calmjs/base.py
BaseModuleRegistry._register_entry_point_module
def _register_entry_point_module(self, entry_point, module): """ Private method that registers an entry_point with a provided module. """ records_map = self._map_entry_point_module(entry_point, module) self.store_records_for_package(entry_point, list(records_map.keys()))...
python
def _register_entry_point_module(self, entry_point, module): """ Private method that registers an entry_point with a provided module. """ records_map = self._map_entry_point_module(entry_point, module) self.store_records_for_package(entry_point, list(records_map.keys()))...
[ "def", "_register_entry_point_module", "(", "self", ",", "entry_point", ",", "module", ")", ":", "records_map", "=", "self", ".", "_map_entry_point_module", "(", "entry_point", ",", "module", ")", "self", ".", "store_records_for_package", "(", "entry_point", ",", ...
Private method that registers an entry_point with a provided module.
[ "Private", "method", "that", "registers", "an", "entry_point", "with", "a", "provided", "module", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L288-L314
calmjs/calmjs
src/calmjs/base.py
BaseModuleRegistry.get_record
def get_record(self, name): """ Get a record by name """ result = {} result.update(self.records.get(name, {})) return result
python
def get_record(self, name): """ Get a record by name """ result = {} result.update(self.records.get(name, {})) return result
[ "def", "get_record", "(", "self", ",", "name", ")", ":", "result", "=", "{", "}", "result", ".", "update", "(", "self", ".", "records", ".", "get", "(", "name", ",", "{", "}", ")", ")", "return", "result" ]
Get a record by name
[ "Get", "a", "record", "by", "name" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L326-L333
calmjs/calmjs
src/calmjs/base.py
BaseModuleRegistry.get_records_for_package
def get_records_for_package(self, package_name): """ Get all records identified by package. """ names = self.package_module_map.get(package_name, []) result = {} for name in names: result.update(self.get_record(name)) return result
python
def get_records_for_package(self, package_name): """ Get all records identified by package. """ names = self.package_module_map.get(package_name, []) result = {} for name in names: result.update(self.get_record(name)) return result
[ "def", "get_records_for_package", "(", "self", ",", "package_name", ")", ":", "names", "=", "self", ".", "package_module_map", ".", "get", "(", "package_name", ",", "[", "]", ")", "result", "=", "{", "}", "for", "name", "in", "names", ":", "result", ".",...
Get all records identified by package.
[ "Get", "all", "records", "identified", "by", "package", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L335-L344
calmjs/calmjs
src/calmjs/base.py
BaseChildModuleRegistry.resolve_parent_registry_name
def resolve_parent_registry_name(self, registry_name, suffix): """ Subclasses should override to specify the default suffix, as the invocation is done without a suffix. """ if not registry_name.endswith(suffix): raise ValueError( "child module registr...
python
def resolve_parent_registry_name(self, registry_name, suffix): """ Subclasses should override to specify the default suffix, as the invocation is done without a suffix. """ if not registry_name.endswith(suffix): raise ValueError( "child module registr...
[ "def", "resolve_parent_registry_name", "(", "self", ",", "registry_name", ",", "suffix", ")", ":", "if", "not", "registry_name", ".", "endswith", "(", "suffix", ")", ":", "raise", "ValueError", "(", "\"child module registry name defined with invalid suffix \"", "\"('%s'...
Subclasses should override to specify the default suffix, as the invocation is done without a suffix.
[ "Subclasses", "should", "override", "to", "specify", "the", "default", "suffix", "as", "the", "invocation", "is", "done", "without", "a", "suffix", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L379-L389
calmjs/calmjs
src/calmjs/base.py
BaseExternalModuleRegistry.get_record
def get_record(self, name): """ Get a record for the registered name, which will be a set of matching desired "module names" for the given path. """ return set().union(self.records.get(name, set()))
python
def get_record(self, name): """ Get a record for the registered name, which will be a set of matching desired "module names" for the given path. """ return set().union(self.records.get(name, set()))
[ "def", "get_record", "(", "self", ",", "name", ")", ":", "return", "set", "(", ")", ".", "union", "(", "self", ".", "records", ".", "get", "(", "name", ",", "set", "(", ")", ")", ")" ]
Get a record for the registered name, which will be a set of matching desired "module names" for the given path.
[ "Get", "a", "record", "for", "the", "registered", "name", "which", "will", "be", "a", "set", "of", "matching", "desired", "module", "names", "for", "the", "given", "path", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L440-L446
calmjs/calmjs
src/calmjs/base.py
BaseExternalModuleRegistry.get_records_for_package
def get_records_for_package(self, package_name): """ Get all records identified by package. """ result = [] result.extend(self.package_module_map.get(package_name)) return result
python
def get_records_for_package(self, package_name): """ Get all records identified by package. """ result = [] result.extend(self.package_module_map.get(package_name)) return result
[ "def", "get_records_for_package", "(", "self", ",", "package_name", ")", ":", "result", "=", "[", "]", "result", ".", "extend", "(", "self", ".", "package_module_map", ".", "get", "(", "package_name", ")", ")", "return", "result" ]
Get all records identified by package.
[ "Get", "all", "records", "identified", "by", "package", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L448-L455
calmjs/calmjs
src/calmjs/base.py
BaseDriver.which
def which(self): """ Figure out which binary this will execute. Returns None if the binary is not found. """ if self.binary is None: return None return which(self.binary, path=self.env_path)
python
def which(self): """ Figure out which binary this will execute. Returns None if the binary is not found. """ if self.binary is None: return None return which(self.binary, path=self.env_path)
[ "def", "which", "(", "self", ")", ":", "if", "self", ".", "binary", "is", "None", ":", "return", "None", "return", "which", "(", "self", ".", "binary", ",", "path", "=", "self", ".", "env_path", ")" ]
Figure out which binary this will execute. Returns None if the binary is not found.
[ "Figure", "out", "which", "binary", "this", "will", "execute", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L508-L518
calmjs/calmjs
src/calmjs/base.py
BaseDriver.find_node_modules_basedir
def find_node_modules_basedir(self): """ Find all node_modules directories configured to be accessible through this driver instance. This is typically used for adding the direct instance, and does not traverse the parent directories like what Node.js does. Returns a lis...
python
def find_node_modules_basedir(self): """ Find all node_modules directories configured to be accessible through this driver instance. This is typically used for adding the direct instance, and does not traverse the parent directories like what Node.js does. Returns a lis...
[ "def", "find_node_modules_basedir", "(", "self", ")", ":", "paths", "=", "[", "]", "# First do the working dir.", "local_node_path", "=", "self", ".", "join_cwd", "(", "NODE_MODULES", ")", "if", "isdir", "(", "local_node_path", ")", ":", "paths", ".", "append", ...
Find all node_modules directories configured to be accessible through this driver instance. This is typically used for adding the direct instance, and does not traverse the parent directories like what Node.js does. Returns a list of directories that contain a 'node_modules' di...
[ "Find", "all", "node_modules", "directories", "configured", "to", "be", "accessible", "through", "this", "driver", "instance", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L520-L544
calmjs/calmjs
src/calmjs/base.py
BaseDriver.which_with_node_modules
def which_with_node_modules(self): """ Which with node_path and node_modules """ if self.binary is None: return None # first, log down the pedantic things... if isdir(self.join_cwd(NODE_MODULES)): logger.debug( "'%s' instance will...
python
def which_with_node_modules(self): """ Which with node_path and node_modules """ if self.binary is None: return None # first, log down the pedantic things... if isdir(self.join_cwd(NODE_MODULES)): logger.debug( "'%s' instance will...
[ "def", "which_with_node_modules", "(", "self", ")", ":", "if", "self", ".", "binary", "is", "None", ":", "return", "None", "# first, log down the pedantic things...", "if", "isdir", "(", "self", ".", "join_cwd", "(", "NODE_MODULES", ")", ")", ":", "logger", "....
Which with node_path and node_modules
[ "Which", "with", "node_path", "and", "node_modules" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L546-L580
calmjs/calmjs
src/calmjs/base.py
BaseDriver._set_env_path_with_node_modules
def _set_env_path_with_node_modules(self): """ Attempt to locate and set the paths to the binary with the working directory defined for this instance. """ modcls_name = ':'.join(( self.__class__.__module__, self.__class__.__name__)) if self.binary is None: ...
python
def _set_env_path_with_node_modules(self): """ Attempt to locate and set the paths to the binary with the working directory defined for this instance. """ modcls_name = ':'.join(( self.__class__.__module__, self.__class__.__name__)) if self.binary is None: ...
[ "def", "_set_env_path_with_node_modules", "(", "self", ")", ":", "modcls_name", "=", "':'", ".", "join", "(", "(", "self", ".", "__class__", ".", "__module__", ",", "self", ".", "__class__", ".", "__name__", ")", ")", "if", "self", ".", "binary", "is", "...
Attempt to locate and set the paths to the binary with the working directory defined for this instance.
[ "Attempt", "to", "locate", "and", "set", "the", "paths", "to", "the", "binary", "with", "the", "working", "directory", "defined", "for", "this", "instance", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L593-L638
calmjs/calmjs
src/calmjs/base.py
BaseDriver._exec
def _exec(self, binary, stdin='', args=(), env={}): """ Executes the binary using stdin and args with environment variables. Returns a tuple of stdout, stderr. Format determined by the input text (either str or bytes), and the encoding of str will be determined by the l...
python
def _exec(self, binary, stdin='', args=(), env={}): """ Executes the binary using stdin and args with environment variables. Returns a tuple of stdout, stderr. Format determined by the input text (either str or bytes), and the encoding of str will be determined by the l...
[ "def", "_exec", "(", "self", ",", "binary", ",", "stdin", "=", "''", ",", "args", "=", "(", ")", ",", "env", "=", "{", "}", ")", ":", "call_kw", "=", "self", ".", "_gen_call_kws", "(", "*", "*", "env", ")", "call_args", "=", "[", "self", ".", ...
Executes the binary using stdin and args with environment variables. Returns a tuple of stdout, stderr. Format determined by the input text (either str or bytes), and the encoding of str will be determined by the locale this module was imported in.
[ "Executes", "the", "binary", "using", "stdin", "and", "args", "with", "environment", "variables", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L672-L685
calmjs/calmjs
src/calmjs/base.py
BaseDriver.dump
def dump(self, blob, stream): """ Call json.dump with the attributes of this instance as arguments. """ json.dump( blob, stream, indent=self.indent, sort_keys=True, separators=self.separators, )
python
def dump(self, blob, stream): """ Call json.dump with the attributes of this instance as arguments. """ json.dump( blob, stream, indent=self.indent, sort_keys=True, separators=self.separators, )
[ "def", "dump", "(", "self", ",", "blob", ",", "stream", ")", ":", "json", ".", "dump", "(", "blob", ",", "stream", ",", "indent", "=", "self", ".", "indent", ",", "sort_keys", "=", "True", ",", "separators", "=", "self", ".", "separators", ",", ")"...
Call json.dump with the attributes of this instance as arguments.
[ "Call", "json", ".", "dump", "with", "the", "attributes", "of", "this", "instance", "as", "arguments", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L691-L700
calmjs/calmjs
src/calmjs/base.py
BaseDriver.dumps
def dumps(self, blob): """ Call json.dumps with the attributes of this instance as arguments. """ return json.dumps( blob, indent=self.indent, sort_keys=True, separators=self.separators, )
python
def dumps(self, blob): """ Call json.dumps with the attributes of this instance as arguments. """ return json.dumps( blob, indent=self.indent, sort_keys=True, separators=self.separators, )
[ "def", "dumps", "(", "self", ",", "blob", ")", ":", "return", "json", ".", "dumps", "(", "blob", ",", "indent", "=", "self", ".", "indent", ",", "sort_keys", "=", "True", ",", "separators", "=", "self", ".", "separators", ",", ")" ]
Call json.dumps with the attributes of this instance as arguments.
[ "Call", "json", ".", "dumps", "with", "the", "attributes", "of", "this", "instance", "as", "arguments", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L702-L711
calmjs/calmjs
src/calmjs/base.py
BaseDriver.join_cwd
def join_cwd(self, path=None): """ Join the path with the current working directory. If it is specified for this instance of the object it will be used, otherwise rely on the global value. """ if self.working_dir: logger.debug( "'%s' instance...
python
def join_cwd(self, path=None): """ Join the path with the current working directory. If it is specified for this instance of the object it will be used, otherwise rely on the global value. """ if self.working_dir: logger.debug( "'%s' instance...
[ "def", "join_cwd", "(", "self", ",", "path", "=", "None", ")", ":", "if", "self", ".", "working_dir", ":", "logger", ".", "debug", "(", "\"'%s' instance 'working_dir' set to '%s' for join_cwd\"", ",", "type", "(", "self", ")", ".", "__name__", ",", "self", "...
Join the path with the current working directory. If it is specified for this instance of the object it will be used, otherwise rely on the global value.
[ "Join", "the", "path", "with", "the", "current", "working", "directory", ".", "If", "it", "is", "specified", "for", "this", "instance", "of", "the", "object", "it", "will", "be", "used", "otherwise", "rely", "on", "the", "global", "value", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L713-L736
calmjs/calmjs
src/calmjs/base.py
BaseLoaderPluginHandler.modname_source_to_target
def modname_source_to_target( self, toolchain, spec, modname, source): """ This is called by the Toolchain for modnames that contain a '!' as that signifies a loaderplugin syntax. This will be used by the toolchain (which will also be supplied as the first argument) ...
python
def modname_source_to_target( self, toolchain, spec, modname, source): """ This is called by the Toolchain for modnames that contain a '!' as that signifies a loaderplugin syntax. This will be used by the toolchain (which will also be supplied as the first argument) ...
[ "def", "modname_source_to_target", "(", "self", ",", "toolchain", ",", "spec", ",", "modname", ",", "source", ")", ":", "stripped_modname", "=", "self", ".", "unwrap", "(", "modname", ")", "chained", "=", "(", "self", ".", "registry", ".", "get_record", "(...
This is called by the Toolchain for modnames that contain a '!' as that signifies a loaderplugin syntax. This will be used by the toolchain (which will also be supplied as the first argument) to resolve the copy target, which must be a path relative to the spec[WORKING_DIR]. If...
[ "This", "is", "called", "by", "the", "Toolchain", "for", "modnames", "that", "contain", "a", "!", "as", "that", "signifies", "a", "loaderplugin", "syntax", ".", "This", "will", "be", "used", "by", "the", "toolchain", "(", "which", "will", "also", "be", "...
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L802-L826
calmjs/calmjs
src/calmjs/base.py
BaseLoaderPluginHandler.unwrap
def unwrap(self, value): """ A helper method for unwrapping the loaderplugin fragment out of the provided value (typically a modname) and return it. Note that the filter chaining is very implementation specific to each and every loader plugin and their specific toolchain, so ...
python
def unwrap(self, value): """ A helper method for unwrapping the loaderplugin fragment out of the provided value (typically a modname) and return it. Note that the filter chaining is very implementation specific to each and every loader plugin and their specific toolchain, so ...
[ "def", "unwrap", "(", "self", ",", "value", ")", ":", "globs", "=", "value", ".", "split", "(", "'!'", ",", "1", ")", "if", "globs", "[", "0", "]", ".", "split", "(", "'?'", ",", "1", ")", "[", "0", "]", "==", "self", ".", "name", ":", "ret...
A helper method for unwrapping the loaderplugin fragment out of the provided value (typically a modname) and return it. Note that the filter chaining is very implementation specific to each and every loader plugin and their specific toolchain, so this default implementation is not going...
[ "A", "helper", "method", "for", "unwrapping", "the", "loaderplugin", "fragment", "out", "of", "the", "provided", "value", "(", "typically", "a", "modname", ")", "and", "return", "it", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L861-L881
weso/CWR-DataApi
cwr/parser/encoder/cwrjson.py
_unicode_handler
def _unicode_handler(obj): """ Transforms an unicode string into a UTF-8 equivalent. :param obj: object to transform into it's UTF-8 equivalent :return: the UTF-8 equivalent of the string """ try: result = obj.isoformat() except AttributeError: raise TypeError("Unserializabl...
python
def _unicode_handler(obj): """ Transforms an unicode string into a UTF-8 equivalent. :param obj: object to transform into it's UTF-8 equivalent :return: the UTF-8 equivalent of the string """ try: result = obj.isoformat() except AttributeError: raise TypeError("Unserializabl...
[ "def", "_unicode_handler", "(", "obj", ")", ":", "try", ":", "result", "=", "obj", ".", "isoformat", "(", ")", "except", "AttributeError", ":", "raise", "TypeError", "(", "\"Unserializable object {} of type {}\"", ".", "format", "(", "obj", ",", "type", "(", ...
Transforms an unicode string into a UTF-8 equivalent. :param obj: object to transform into it's UTF-8 equivalent :return: the UTF-8 equivalent of the string
[ "Transforms", "an", "unicode", "string", "into", "a", "UTF", "-", "8", "equivalent", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/parser/encoder/cwrjson.py#L57-L70
weso/CWR-DataApi
cwr/parser/encoder/cwrjson.py
JSONEncoder.encode
def encode(self, entity): """ Encodes the data, creating a JSON structure from an instance from the domain model. :param entity: the instance to encode :return: a JSON structure created from the received data """ encoded = self._dict_encoder.encode(entity) ...
python
def encode(self, entity): """ Encodes the data, creating a JSON structure from an instance from the domain model. :param entity: the instance to encode :return: a JSON structure created from the received data """ encoded = self._dict_encoder.encode(entity) ...
[ "def", "encode", "(", "self", ",", "entity", ")", ":", "encoded", "=", "self", ".", "_dict_encoder", ".", "encode", "(", "entity", ")", "if", "sys", ".", "version_info", "[", "0", "]", "==", "2", ":", "result", "=", "json", ".", "dumps", "(", "enco...
Encodes the data, creating a JSON structure from an instance from the domain model. :param entity: the instance to encode :return: a JSON structure created from the received data
[ "Encodes", "the", "data", "creating", "a", "JSON", "structure", "from", "an", "instance", "from", "the", "domain", "model", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/parser/encoder/cwrjson.py#L36-L54
weso/CWR-DataApi
cwr/grammar/field/special.py
ipi_base_number
def ipi_base_number(name=None): """ IPI Base Number field. An IPI Base Number code written on a field follows the Pattern C-NNNNNNNNN-M. This being: - C: header, a character. - N: numeric value. - M: control digit. So, for example, an IPI Base Number code field can contain I-000000229-...
python
def ipi_base_number(name=None): """ IPI Base Number field. An IPI Base Number code written on a field follows the Pattern C-NNNNNNNNN-M. This being: - C: header, a character. - N: numeric value. - M: control digit. So, for example, an IPI Base Number code field can contain I-000000229-...
[ "def", "ipi_base_number", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'IPI Base Number Field'", "field", "=", "pp", ".", "Regex", "(", "'I-[0-9]{9}-[0-9]'", ")", "# Name", "field", ".", "setName", "(", "name", ")", ...
IPI Base Number field. An IPI Base Number code written on a field follows the Pattern C-NNNNNNNNN-M. This being: - C: header, a character. - N: numeric value. - M: control digit. So, for example, an IPI Base Number code field can contain I-000000229-7. :param name: name for the field ...
[ "IPI", "Base", "Number", "field", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L38-L70
weso/CWR-DataApi
cwr/grammar/field/special.py
ipi_name_number
def ipi_name_number(name=None): """ IPI Name Number field. An IPI Name Number is composed of eleven digits. So, for example, an IPI Name Number code field can contain 00014107338. :param name: name for the field :return: a parser for the IPI Name Number field """ if name is None: ...
python
def ipi_name_number(name=None): """ IPI Name Number field. An IPI Name Number is composed of eleven digits. So, for example, an IPI Name Number code field can contain 00014107338. :param name: name for the field :return: a parser for the IPI Name Number field """ if name is None: ...
[ "def", "ipi_name_number", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'IPI Name Number Field'", "field", "=", "basic", ".", "numeric", "(", "11", ")", "field", ".", "setName", "(", "name", ")", "return", "field", ...
IPI Name Number field. An IPI Name Number is composed of eleven digits. So, for example, an IPI Name Number code field can contain 00014107338. :param name: name for the field :return: a parser for the IPI Name Number field
[ "IPI", "Name", "Number", "field", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L73-L92
weso/CWR-DataApi
cwr/grammar/field/special.py
iswc
def iswc(name=None): """ ISWC field. A ISWC code written on a field follows the Pattern TNNNNNNNNNC. This being: - T: header, it is always T. - N: numeric value. - C: control digit. So, for example, an ISWC code field can contain T0345246801. :param name: name for the field :r...
python
def iswc(name=None): """ ISWC field. A ISWC code written on a field follows the Pattern TNNNNNNNNNC. This being: - T: header, it is always T. - N: numeric value. - C: control digit. So, for example, an ISWC code field can contain T0345246801. :param name: name for the field :r...
[ "def", "iswc", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'ISWC Field'", "# T followed by 10 numbers", "field", "=", "pp", ".", "Regex", "(", "'T[0-9]{10}'", ")", "# Name", "field", ".", "setName", "(", "name", ")"...
ISWC field. A ISWC code written on a field follows the Pattern TNNNNNNNNNC. This being: - T: header, it is always T. - N: numeric value. - C: control digit. So, for example, an ISWC code field can contain T0345246801. :param name: name for the field :return: a parser for the ISWC fiel...
[ "ISWC", "field", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L95-L123
weso/CWR-DataApi
cwr/grammar/field/special.py
percentage
def percentage(columns, maximum=100, name=None): """ Creates the grammar for a Numeric (N) field storing a percentage and accepting only the specified number of characters. It is possible to set the maximum allowed value. By default this is 100 (for 100%), and if modified it is expected to be reduc...
python
def percentage(columns, maximum=100, name=None): """ Creates the grammar for a Numeric (N) field storing a percentage and accepting only the specified number of characters. It is possible to set the maximum allowed value. By default this is 100 (for 100%), and if modified it is expected to be reduc...
[ "def", "percentage", "(", "columns", ",", "maximum", "=", "100", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'Percentage Field'", "if", "columns", "<", "3", ":", "message", "=", "'The values can not be lower than 3'", ...
Creates the grammar for a Numeric (N) field storing a percentage and accepting only the specified number of characters. It is possible to set the maximum allowed value. By default this is 100 (for 100%), and if modified it is expected to be reduced, not increased. The three first digits will be for th...
[ "Creates", "the", "grammar", "for", "a", "Numeric", "(", "N", ")", "field", "storing", "a", "percentage", "and", "accepting", "only", "the", "specified", "number", "of", "characters", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L126-L157
weso/CWR-DataApi
cwr/grammar/field/special.py
_assert_is_percentage
def _assert_is_percentage(value, maximum=100): """ Makes sure the received value is a percentage. Otherwise an exception is thrown. :param value: the value to check """ if value < 0 or value > maximum: message = 'The value on a percentage field should be between 0 and %s' \ ...
python
def _assert_is_percentage(value, maximum=100): """ Makes sure the received value is a percentage. Otherwise an exception is thrown. :param value: the value to check """ if value < 0 or value > maximum: message = 'The value on a percentage field should be between 0 and %s' \ ...
[ "def", "_assert_is_percentage", "(", "value", ",", "maximum", "=", "100", ")", ":", "if", "value", "<", "0", "or", "value", ">", "maximum", ":", "message", "=", "'The value on a percentage field should be between 0 and %s'", "%", "maximum", "raise", "pp", ".", "...
Makes sure the received value is a percentage. Otherwise an exception is thrown. :param value: the value to check
[ "Makes", "sure", "the", "received", "value", "is", "a", "percentage", ".", "Otherwise", "an", "exception", "is", "thrown", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L160-L171
weso/CWR-DataApi
cwr/grammar/field/special.py
ean_13
def ean_13(name=None): """ Creates the grammar for an EAN 13 code. These are the codes on thirteen digits barcodes. :param name: name for the field :return: grammar for an EAN 13 field """ if name is None: name = 'EAN 13 Field' field = basic.numeric(13) field = field.set...
python
def ean_13(name=None): """ Creates the grammar for an EAN 13 code. These are the codes on thirteen digits barcodes. :param name: name for the field :return: grammar for an EAN 13 field """ if name is None: name = 'EAN 13 Field' field = basic.numeric(13) field = field.set...
[ "def", "ean_13", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'EAN 13 Field'", "field", "=", "basic", ".", "numeric", "(", "13", ")", "field", "=", "field", ".", "setName", "(", "name", ")", "return", "field", ...
Creates the grammar for an EAN 13 code. These are the codes on thirteen digits barcodes. :param name: name for the field :return: grammar for an EAN 13 field
[ "Creates", "the", "grammar", "for", "an", "EAN", "13", "code", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L174-L191
weso/CWR-DataApi
cwr/grammar/field/special.py
isrc
def isrc(name=None): """ Creates the grammar for an ISRC code. ISRC stands for International Standard Recording Code, which is the standard ISO 3901. This stores information identifying a particular recording. :param name: name for the field :return: grammar for an ISRC field """ ...
python
def isrc(name=None): """ Creates the grammar for an ISRC code. ISRC stands for International Standard Recording Code, which is the standard ISO 3901. This stores information identifying a particular recording. :param name: name for the field :return: grammar for an ISRC field """ ...
[ "def", "isrc", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'ISRC Field'", "field", "=", "_isrc_short", "(", "name", ")", "|", "_isrc_long", "(", "name", ")", "field", ".", "setName", "(", "name", ")", "return", ...
Creates the grammar for an ISRC code. ISRC stands for International Standard Recording Code, which is the standard ISO 3901. This stores information identifying a particular recording. :param name: name for the field :return: grammar for an ISRC field
[ "Creates", "the", "grammar", "for", "an", "ISRC", "code", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L194-L213
weso/CWR-DataApi
cwr/grammar/field/special.py
_isrc_long
def _isrc_long(name=None): """ Creates the grammar for a short ISRC code. ISRC stands for International Standard Recording Code, which is the standard ISO 3901. This stores information identifying a particular recording. This variant contain no separator for the parts, and follows the pattern:...
python
def _isrc_long(name=None): """ Creates the grammar for a short ISRC code. ISRC stands for International Standard Recording Code, which is the standard ISO 3901. This stores information identifying a particular recording. This variant contain no separator for the parts, and follows the pattern:...
[ "def", "_isrc_long", "(", "name", "=", "None", ")", ":", "config", "=", "CWRTables", "(", ")", "if", "name", "is", "None", ":", "name", "=", "'ISRC Field'", "country", "=", "config", ".", "get_data", "(", "'isrc_country_code'", ")", "# registrant = basic.alp...
Creates the grammar for a short ISRC code. ISRC stands for International Standard Recording Code, which is the standard ISO 3901. This stores information identifying a particular recording. This variant contain no separator for the parts, and follows the pattern: CCXXXYYNNNNN Where each code ...
[ "Creates", "the", "grammar", "for", "a", "short", "ISRC", "code", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L267-L314
weso/CWR-DataApi
cwr/grammar/field/special.py
visan
def visan(name=None): """ Creates the grammar for a V-ISAN code. This is a variation on the ISAN (International Standard Audiovisual Number) :param name: name for the field :return: grammar for an ISRC field """ if name is None: name = 'V-ISAN Field' field = pp.Regex('[0-9]{2...
python
def visan(name=None): """ Creates the grammar for a V-ISAN code. This is a variation on the ISAN (International Standard Audiovisual Number) :param name: name for the field :return: grammar for an ISRC field """ if name is None: name = 'V-ISAN Field' field = pp.Regex('[0-9]{2...
[ "def", "visan", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'V-ISAN Field'", "field", "=", "pp", ".", "Regex", "(", "'[0-9]{25}'", ")", "field", ".", "setName", "(", "name", ")", "return", "field", ".", "setResu...
Creates the grammar for a V-ISAN code. This is a variation on the ISAN (International Standard Audiovisual Number) :param name: name for the field :return: grammar for an ISRC field
[ "Creates", "the", "grammar", "for", "a", "V", "-", "ISAN", "code", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L317-L334
weso/CWR-DataApi
cwr/grammar/field/special.py
audio_visual_key
def audio_visual_key(name=None): """ Creates the grammar for an Audio Visual Key code. This is a variation on the ISAN (International Standard Audiovisual Number) :param name: name for the field :return: grammar for an ISRC field """ if name is None: name = 'AVI Field' societ...
python
def audio_visual_key(name=None): """ Creates the grammar for an Audio Visual Key code. This is a variation on the ISAN (International Standard Audiovisual Number) :param name: name for the field :return: grammar for an ISRC field """ if name is None: name = 'AVI Field' societ...
[ "def", "audio_visual_key", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'AVI Field'", "society_code", "=", "basic", ".", "numeric", "(", "3", ")", "society_code", "=", "society_code", ".", "setName", "(", "'Society Cod...
Creates the grammar for an Audio Visual Key code. This is a variation on the ISAN (International Standard Audiovisual Number) :param name: name for the field :return: grammar for an ISRC field
[ "Creates", "the", "grammar", "for", "an", "Audio", "Visual", "Key", "code", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L337-L367
weso/CWR-DataApi
cwr/grammar/field/special.py
date_time
def date_time(name=None): """ Creates the grammar for a date and time field, which is a combination of the Date (D) and Time or Duration field (T). This field requires first a Date, and then a Time, without any space in between. :param name: name for the field :return: grammar for a Date a...
python
def date_time(name=None): """ Creates the grammar for a date and time field, which is a combination of the Date (D) and Time or Duration field (T). This field requires first a Date, and then a Time, without any space in between. :param name: name for the field :return: grammar for a Date a...
[ "def", "date_time", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'Date and Time Field'", "date", "=", "basic", ".", "date", "(", "'Date'", ")", "time", "=", "basic", ".", "time", "(", "'Time'", ")", "date", "=", ...
Creates the grammar for a date and time field, which is a combination of the Date (D) and Time or Duration field (T). This field requires first a Date, and then a Time, without any space in between. :param name: name for the field :return: grammar for a Date and Time field
[ "Creates", "the", "grammar", "for", "a", "date", "and", "time", "field", "which", "is", "a", "combination", "of", "the", "Date", "(", "D", ")", "and", "Time", "or", "Duration", "field", "(", "T", ")", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L380-L406
weso/CWR-DataApi
cwr/grammar/field/special.py
lookup_int
def lookup_int(values, name=None): """ Lookup field which transforms the result into an integer. :param values: values allowed :param name: name for the field :return: grammar for the lookup field """ field = basic.lookup(values, name) field.addParseAction(lambda l: int(l[0])) ret...
python
def lookup_int(values, name=None): """ Lookup field which transforms the result into an integer. :param values: values allowed :param name: name for the field :return: grammar for the lookup field """ field = basic.lookup(values, name) field.addParseAction(lambda l: int(l[0])) ret...
[ "def", "lookup_int", "(", "values", ",", "name", "=", "None", ")", ":", "field", "=", "basic", ".", "lookup", "(", "values", ",", "name", ")", "field", ".", "addParseAction", "(", "lambda", "l", ":", "int", "(", "l", "[", "0", "]", ")", ")", "ret...
Lookup field which transforms the result into an integer. :param values: values allowed :param name: name for the field :return: grammar for the lookup field
[ "Lookup", "field", "which", "transforms", "the", "result", "into", "an", "integer", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/special.py#L419-L431
calmjs/calmjs
src/calmjs/interrogate.py
extract_function_argument
def extract_function_argument(text, f_name, f_argn, f_argt=asttypes.String): """ Extract a specific argument from a specific function name. Arguments: text The source text. f_name The name of the function f_argn The argument position f_argt The argument type...
python
def extract_function_argument(text, f_name, f_argn, f_argt=asttypes.String): """ Extract a specific argument from a specific function name. Arguments: text The source text. f_name The name of the function f_argn The argument position f_argt The argument type...
[ "def", "extract_function_argument", "(", "text", ",", "f_name", ",", "f_argn", ",", "f_argt", "=", "asttypes", ".", "String", ")", ":", "tree", "=", "parse", "(", "text", ")", "return", "list", "(", "filter_function_argument", "(", "tree", ",", "f_name", "...
Extract a specific argument from a specific function name. Arguments: text The source text. f_name The name of the function f_argn The argument position f_argt The argument type from calmjs.parse.asttypes; default: calmjs.parse.asttypes.String
[ "Extract", "a", "specific", "argument", "from", "a", "specific", "function", "name", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/interrogate.py#L71-L89
calmjs/calmjs
src/calmjs/interrogate.py
yield_amd_require_string_arguments
def yield_amd_require_string_arguments( node, pos, reserved_module=reserved_module, wrapped=define_wrapped): """ This yields only strings within the lists provided in the argument list at the specified position from a function call. Originally, this was implemented for yield a list of m...
python
def yield_amd_require_string_arguments( node, pos, reserved_module=reserved_module, wrapped=define_wrapped): """ This yields only strings within the lists provided in the argument list at the specified position from a function call. Originally, this was implemented for yield a list of m...
[ "def", "yield_amd_require_string_arguments", "(", "node", ",", "pos", ",", "reserved_module", "=", "reserved_module", ",", "wrapped", "=", "define_wrapped", ")", ":", "for", "i", ",", "child", "in", "enumerate", "(", "node", ".", "args", ".", "items", "[", "...
This yields only strings within the lists provided in the argument list at the specified position from a function call. Originally, this was implemented for yield a list of module names to be imported as represented by this given node, which must be of the FunctionCall type.
[ "This", "yields", "only", "strings", "within", "the", "lists", "provided", "in", "the", "argument", "list", "at", "the", "specified", "position", "from", "a", "function", "call", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/interrogate.py#L110-L127
calmjs/calmjs
src/calmjs/interrogate.py
yield_string_argument
def yield_string_argument(node, pos): """ Yield just a string argument from position of the function call. """ if not isinstance(node.args.items[pos], asttypes.String): return yield to_str(node.args.items[pos])
python
def yield_string_argument(node, pos): """ Yield just a string argument from position of the function call. """ if not isinstance(node.args.items[pos], asttypes.String): return yield to_str(node.args.items[pos])
[ "def", "yield_string_argument", "(", "node", ",", "pos", ")", ":", "if", "not", "isinstance", "(", "node", ".", "args", ".", "items", "[", "pos", "]", ",", "asttypes", ".", "String", ")", ":", "return", "yield", "to_str", "(", "node", ".", "args", "....
Yield just a string argument from position of the function call.
[ "Yield", "just", "a", "string", "argument", "from", "position", "of", "the", "function", "call", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/interrogate.py#L132-L139
calmjs/calmjs
src/calmjs/interrogate.py
yield_module_imports
def yield_module_imports(root, checks=string_imports()): """ Gather all require and define calls from unbundled JavaScript source files and yield all module names. The imports can either be of the CommonJS or AMD syntax. """ if not isinstance(root, asttypes.Node): raise TypeError('prov...
python
def yield_module_imports(root, checks=string_imports()): """ Gather all require and define calls from unbundled JavaScript source files and yield all module names. The imports can either be of the CommonJS or AMD syntax. """ if not isinstance(root, asttypes.Node): raise TypeError('prov...
[ "def", "yield_module_imports", "(", "root", ",", "checks", "=", "string_imports", "(", ")", ")", ":", "if", "not", "isinstance", "(", "root", ",", "asttypes", ".", "Node", ")", ":", "raise", "TypeError", "(", "'provided root must be a node'", ")", "for", "ch...
Gather all require and define calls from unbundled JavaScript source files and yield all module names. The imports can either be of the CommonJS or AMD syntax.
[ "Gather", "all", "require", "and", "define", "calls", "from", "unbundled", "JavaScript", "source", "files", "and", "yield", "all", "module", "names", ".", "The", "imports", "can", "either", "be", "of", "the", "CommonJS", "or", "AMD", "syntax", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/interrogate.py#L184-L199
calmjs/calmjs
src/calmjs/interrogate.py
yield_module_imports_nodes
def yield_module_imports_nodes(root, checks=import_nodes()): """ Yield all nodes that provide an import """ if not isinstance(root, asttypes.Node): raise TypeError('provided root must be a node') for child in yield_function(root, deep_filter): for f, condition in checks: ...
python
def yield_module_imports_nodes(root, checks=import_nodes()): """ Yield all nodes that provide an import """ if not isinstance(root, asttypes.Node): raise TypeError('provided root must be a node') for child in yield_function(root, deep_filter): for f, condition in checks: ...
[ "def", "yield_module_imports_nodes", "(", "root", ",", "checks", "=", "import_nodes", "(", ")", ")", ":", "if", "not", "isinstance", "(", "root", ",", "asttypes", ".", "Node", ")", ":", "raise", "TypeError", "(", "'provided root must be a node'", ")", "for", ...
Yield all nodes that provide an import
[ "Yield", "all", "nodes", "that", "provide", "an", "import" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/interrogate.py#L212-L225
pandeylab/pythomics
pythomics/parsers/fasta.py
FastaIterator.open_fasta_index
def open_fasta_index(self): """ custom type for file made w/ buildFastaIndex, fai for ones made with samtools """ index = self.fasta_index try: handle = open(index, 'rb') except (IOError, TypeError): sys.stderr.write('index not found, creating it\n...
python
def open_fasta_index(self): """ custom type for file made w/ buildFastaIndex, fai for ones made with samtools """ index = self.fasta_index try: handle = open(index, 'rb') except (IOError, TypeError): sys.stderr.write('index not found, creating it\n...
[ "def", "open_fasta_index", "(", "self", ")", ":", "index", "=", "self", ".", "fasta_index", "try", ":", "handle", "=", "open", "(", "index", ",", "'rb'", ")", "except", "(", "IOError", ",", "TypeError", ")", ":", "sys", ".", "stderr", ".", "write", "...
custom type for file made w/ buildFastaIndex, fai for ones made with samtools
[ "custom", "type", "for", "file", "made", "w", "/", "buildFastaIndex", "fai", "for", "ones", "made", "with", "samtools" ]
train
https://github.com/pandeylab/pythomics/blob/ab0a5651a2e02a25def4d277b35fa09d1631bfcb/pythomics/parsers/fasta.py#L69-L88
pandeylab/pythomics
pythomics/parsers/fasta.py
FastaIterator.get_sequence
def get_sequence(self, chrom, start, end, strand='+', indexing=(-1, 0)): """ chromosome is entered relative to the file it was built with, so it can be 'chr11' or '11', start/end are coordinates, which default to python style [0,1) internally. So positions should be entered with (1,1) in...
python
def get_sequence(self, chrom, start, end, strand='+', indexing=(-1, 0)): """ chromosome is entered relative to the file it was built with, so it can be 'chr11' or '11', start/end are coordinates, which default to python style [0,1) internally. So positions should be entered with (1,1) in...
[ "def", "get_sequence", "(", "self", ",", "chrom", ",", "start", ",", "end", ",", "strand", "=", "'+'", ",", "indexing", "=", "(", "-", "1", ",", "0", ")", ")", ":", "try", ":", "divisor", "=", "int", "(", "self", ".", "sequence_index", "[", "chro...
chromosome is entered relative to the file it was built with, so it can be 'chr11' or '11', start/end are coordinates, which default to python style [0,1) internally. So positions should be entered with (1,1) indexing. This can be changed with the indexing keyword. The default is for everything ...
[ "chromosome", "is", "entered", "relative", "to", "the", "file", "it", "was", "built", "with", "so", "it", "can", "be", "chr11", "or", "11", "start", "/", "end", "are", "coordinates", "which", "default", "to", "python", "style", "[", "0", "1", ")", "int...
train
https://github.com/pandeylab/pythomics/blob/ab0a5651a2e02a25def4d277b35fa09d1631bfcb/pythomics/parsers/fasta.py#L90-L125
calmjs/calmjs
src/calmjs/module.py
resolve_child_module_registries_lineage
def resolve_child_module_registries_lineage(registry): """ For a given child module registry, attempt to resolve the lineage. Return an iterator, yielding from parent down to the input registry, inclusive of the input registry. """ children = [registry] while isinstance(registry, BaseChild...
python
def resolve_child_module_registries_lineage(registry): """ For a given child module registry, attempt to resolve the lineage. Return an iterator, yielding from parent down to the input registry, inclusive of the input registry. """ children = [registry] while isinstance(registry, BaseChild...
[ "def", "resolve_child_module_registries_lineage", "(", "registry", ")", ":", "children", "=", "[", "registry", "]", "while", "isinstance", "(", "registry", ",", "BaseChildModuleRegistry", ")", ":", "if", "registry", ".", "parent", "in", "children", ":", "# this sh...
For a given child module registry, attempt to resolve the lineage. Return an iterator, yielding from parent down to the input registry, inclusive of the input registry.
[ "For", "a", "given", "child", "module", "registry", "attempt", "to", "resolve", "the", "lineage", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/module.py#L74-L119
pandeylab/pythomics
pythomics/proteomics/structures.py
PeptideObject.addModification
def addModification(self, aa,position, modMass, modType): """ !!!!MODIFICATION POSITION IS 0 BASED!!!!!! Modifications are stored internally as a tuple with this format: (amino acid modified, index in peptide of amino acid, modification type, modification mass) ie (M, 7, Oxidatio...
python
def addModification(self, aa,position, modMass, modType): """ !!!!MODIFICATION POSITION IS 0 BASED!!!!!! Modifications are stored internally as a tuple with this format: (amino acid modified, index in peptide of amino acid, modification type, modification mass) ie (M, 7, Oxidatio...
[ "def", "addModification", "(", "self", ",", "aa", ",", "position", ",", "modMass", ",", "modType", ")", ":", "#clean up xtandem", "if", "not", "modType", ":", "#try to figure out what it is", "tmass", "=", "abs", "(", "modMass", ")", "smass", "=", "str", "("...
!!!!MODIFICATION POSITION IS 0 BASED!!!!!! Modifications are stored internally as a tuple with this format: (amino acid modified, index in peptide of amino acid, modification type, modification mass) ie (M, 7, Oxidation, 15.9...) such as: M35(o) for an oxidized methionine at residue 35
[ "!!!!MODIFICATION", "POSITION", "IS", "0", "BASED!!!!!!", "Modifications", "are", "stored", "internally", "as", "a", "tuple", "with", "this", "format", ":", "(", "amino", "acid", "modified", "index", "in", "peptide", "of", "amino", "acid", "modification", "type"...
train
https://github.com/pandeylab/pythomics/blob/ab0a5651a2e02a25def4d277b35fa09d1631bfcb/pythomics/proteomics/structures.py#L84-L107
calmjs/calmjs
src/calmjs/indexer.py
resource_filename_mod_dist
def resource_filename_mod_dist(module_name, dist): """ Given a module name and a distribution, attempt to resolve the actual path to the module. """ try: return pkg_resources.resource_filename( dist.as_requirement(), join(*module_name.split('.'))) except pkg_resources.Distri...
python
def resource_filename_mod_dist(module_name, dist): """ Given a module name and a distribution, attempt to resolve the actual path to the module. """ try: return pkg_resources.resource_filename( dist.as_requirement(), join(*module_name.split('.'))) except pkg_resources.Distri...
[ "def", "resource_filename_mod_dist", "(", "module_name", ",", "dist", ")", ":", "try", ":", "return", "pkg_resources", ".", "resource_filename", "(", "dist", ".", "as_requirement", "(", ")", ",", "join", "(", "*", "module_name", ".", "split", "(", "'.'", ")"...
Given a module name and a distribution, attempt to resolve the actual path to the module.
[ "Given", "a", "module", "name", "and", "a", "distribution", "attempt", "to", "resolve", "the", "actual", "path", "to", "the", "module", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L31-L45
calmjs/calmjs
src/calmjs/indexer.py
resource_filename_mod_entry_point
def resource_filename_mod_entry_point(module_name, entry_point): """ If a given package declares a namespace and also provide submodules nested at that namespace level, and for whatever reason that module is needed, Python's import mechanism will not have a path associated with that module. However...
python
def resource_filename_mod_entry_point(module_name, entry_point): """ If a given package declares a namespace and also provide submodules nested at that namespace level, and for whatever reason that module is needed, Python's import mechanism will not have a path associated with that module. However...
[ "def", "resource_filename_mod_entry_point", "(", "module_name", ",", "entry_point", ")", ":", "if", "entry_point", ".", "dist", "is", "None", ":", "# distribution missing is typically caused by mocked entry", "# points from tests; silently falling back to basic lookup", "result", ...
If a given package declares a namespace and also provide submodules nested at that namespace level, and for whatever reason that module is needed, Python's import mechanism will not have a path associated with that module. However, if given an entry_point, this path can be resolved through its distribu...
[ "If", "a", "given", "package", "declares", "a", "namespace", "and", "also", "provide", "submodules", "nested", "at", "that", "namespace", "level", "and", "for", "whatever", "reason", "that", "module", "is", "needed", "Python", "s", "import", "mechanism", "will...
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L83-L113
calmjs/calmjs
src/calmjs/indexer.py
modgen
def modgen( module, entry_point, modpath='pkg_resources', globber='root', fext=JS_EXT, registry=_utils): """ JavaScript styled module location listing generator. Arguments: module The Python module to start fetching from. entry_point This is the original en...
python
def modgen( module, entry_point, modpath='pkg_resources', globber='root', fext=JS_EXT, registry=_utils): """ JavaScript styled module location listing generator. Arguments: module The Python module to start fetching from. entry_point This is the original en...
[ "def", "modgen", "(", "module", ",", "entry_point", ",", "modpath", "=", "'pkg_resources'", ",", "globber", "=", "'root'", ",", "fext", "=", "JS_EXT", ",", "registry", "=", "_utils", ")", ":", "globber_f", "=", "globber", "if", "callable", "(", "globber", ...
JavaScript styled module location listing generator. Arguments: module The Python module to start fetching from. entry_point This is the original entry point that has a distribution reference such that the resource_filename API call may be used to locate the actual resourc...
[ "JavaScript", "styled", "module", "location", "listing", "generator", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L116-L177
calmjs/calmjs
src/calmjs/indexer.py
register
def register(util_type, registry=_utils): """ Crude, local registration decorator for a crude local registry of all utilities local to this module. """ def marker(f): mark = util_type + '_' if not f.__name__.startswith(mark): raise TypeError( 'not registe...
python
def register(util_type, registry=_utils): """ Crude, local registration decorator for a crude local registry of all utilities local to this module. """ def marker(f): mark = util_type + '_' if not f.__name__.startswith(mark): raise TypeError( 'not registe...
[ "def", "register", "(", "util_type", ",", "registry", "=", "_utils", ")", ":", "def", "marker", "(", "f", ")", ":", "mark", "=", "util_type", "+", "'_'", "if", "not", "f", ".", "__name__", ".", "startswith", "(", "mark", ")", ":", "raise", "TypeError...
Crude, local registration decorator for a crude local registry of all utilities local to this module.
[ "Crude", "local", "registration", "decorator", "for", "a", "crude", "local", "registry", "of", "all", "utilities", "local", "to", "this", "module", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L180-L193
calmjs/calmjs
src/calmjs/indexer.py
modpath_all
def modpath_all(module, entry_point): """ Provides the raw __path__. Incompatible with PEP 302-based import hooks and incompatible with zip_safe packages. Deprecated. Will be removed by calmjs-4.0. """ module_paths = getattr(module, '__path__', []) if not module_paths: logger.war...
python
def modpath_all(module, entry_point): """ Provides the raw __path__. Incompatible with PEP 302-based import hooks and incompatible with zip_safe packages. Deprecated. Will be removed by calmjs-4.0. """ module_paths = getattr(module, '__path__', []) if not module_paths: logger.war...
[ "def", "modpath_all", "(", "module", ",", "entry_point", ")", ":", "module_paths", "=", "getattr", "(", "module", ",", "'__path__'", ",", "[", "]", ")", "if", "not", "module_paths", ":", "logger", ".", "warning", "(", "\"module '%s' does not appear to be a names...
Provides the raw __path__. Incompatible with PEP 302-based import hooks and incompatible with zip_safe packages. Deprecated. Will be removed by calmjs-4.0.
[ "Provides", "the", "raw", "__path__", ".", "Incompatible", "with", "PEP", "302", "-", "based", "import", "hooks", "and", "incompatible", "with", "zip_safe", "packages", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L197-L212
calmjs/calmjs
src/calmjs/indexer.py
modpath_last
def modpath_last(module, entry_point): """ Provides the raw __path__. Incompatible with PEP 302-based import hooks and incompatible with zip_safe packages. Deprecated. Will be removed by calmjs-4.0. """ module_paths = modpath_all(module, entry_point) if len(module_paths) > 1: log...
python
def modpath_last(module, entry_point): """ Provides the raw __path__. Incompatible with PEP 302-based import hooks and incompatible with zip_safe packages. Deprecated. Will be removed by calmjs-4.0. """ module_paths = modpath_all(module, entry_point) if len(module_paths) > 1: log...
[ "def", "modpath_last", "(", "module", ",", "entry_point", ")", ":", "module_paths", "=", "modpath_all", "(", "module", ",", "entry_point", ")", "if", "len", "(", "module_paths", ")", ">", "1", ":", "logger", ".", "info", "(", "\"module '%s' has multiple paths,...
Provides the raw __path__. Incompatible with PEP 302-based import hooks and incompatible with zip_safe packages. Deprecated. Will be removed by calmjs-4.0.
[ "Provides", "the", "raw", "__path__", ".", "Incompatible", "with", "PEP", "302", "-", "based", "import", "hooks", "and", "incompatible", "with", "zip_safe", "packages", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L216-L230
calmjs/calmjs
src/calmjs/indexer.py
modpath_pkg_resources
def modpath_pkg_resources(module, entry_point): """ Goes through pkg_resources for compliance with various PEPs. This one accepts a module as argument. """ result = [] try: path = resource_filename_mod_entry_point(module.__name__, entry_point) except ImportError: logger.war...
python
def modpath_pkg_resources(module, entry_point): """ Goes through pkg_resources for compliance with various PEPs. This one accepts a module as argument. """ result = [] try: path = resource_filename_mod_entry_point(module.__name__, entry_point) except ImportError: logger.war...
[ "def", "modpath_pkg_resources", "(", "module", ",", "entry_point", ")", ":", "result", "=", "[", "]", "try", ":", "path", "=", "resource_filename_mod_entry_point", "(", "module", ".", "__name__", ",", "entry_point", ")", "except", "ImportError", ":", "logger", ...
Goes through pkg_resources for compliance with various PEPs. This one accepts a module as argument.
[ "Goes", "through", "pkg_resources", "for", "compliance", "with", "various", "PEPs", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L234-L251
calmjs/calmjs
src/calmjs/indexer.py
mapper
def mapper(module, entry_point, modpath='pkg_resources', globber='root', modname='es6', fext=JS_EXT, registry=_utils): """ General mapper Loads components from the micro registry. """ modname_f = modname if callable(modname) else _utils['modname'][modname] return { ...
python
def mapper(module, entry_point, modpath='pkg_resources', globber='root', modname='es6', fext=JS_EXT, registry=_utils): """ General mapper Loads components from the micro registry. """ modname_f = modname if callable(modname) else _utils['modname'][modname] return { ...
[ "def", "mapper", "(", "module", ",", "entry_point", ",", "modpath", "=", "'pkg_resources'", ",", "globber", "=", "'root'", ",", "modname", "=", "'es6'", ",", "fext", "=", "JS_EXT", ",", "registry", "=", "_utils", ")", ":", "modname_f", "=", "modname", "i...
General mapper Loads components from the micro registry.
[ "General", "mapper" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L284-L301
calmjs/calmjs
src/calmjs/indexer.py
mapper_python
def mapper_python(module, entry_point, globber='root', fext=JS_EXT): """ Default mapper using python style globber Finds the latest path declared for the module at hand and extract a list of importable JS modules using the es6 module import format. """ return mapper( module, entry_poin...
python
def mapper_python(module, entry_point, globber='root', fext=JS_EXT): """ Default mapper using python style globber Finds the latest path declared for the module at hand and extract a list of importable JS modules using the es6 module import format. """ return mapper( module, entry_poin...
[ "def", "mapper_python", "(", "module", ",", "entry_point", ",", "globber", "=", "'root'", ",", "fext", "=", "JS_EXT", ")", ":", "return", "mapper", "(", "module", ",", "entry_point", "=", "entry_point", ",", "modpath", "=", "'pkg_resources'", ",", "globber",...
Default mapper using python style globber Finds the latest path declared for the module at hand and extract a list of importable JS modules using the es6 module import format.
[ "Default", "mapper", "using", "python", "style", "globber" ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/indexer.py#L319-L329
weso/CWR-DataApi
cwr/other.py
_ThreePartsCode._printable_id_code
def _printable_id_code(self): """ Returns the code in a printable form, filling with zeros if needed. :return: the ID code in a printable form """ code = str(self.id_code) while len(code) < self._code_size: code = '0' + code return code
python
def _printable_id_code(self): """ Returns the code in a printable form, filling with zeros if needed. :return: the ID code in a printable form """ code = str(self.id_code) while len(code) < self._code_size: code = '0' + code return code
[ "def", "_printable_id_code", "(", "self", ")", ":", "code", "=", "str", "(", "self", ".", "id_code", ")", "while", "len", "(", "code", ")", "<", "self", ".", "_code_size", ":", "code", "=", "'0'", "+", "code", "return", "code" ]
Returns the code in a printable form, filling with zeros if needed. :return: the ID code in a printable form
[ "Returns", "the", "code", "in", "a", "printable", "form", "filling", "with", "zeros", "if", "needed", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/other.py#L39-L49
weso/CWR-DataApi
cwr/other.py
ISWCCode._printable_id_code
def _printable_id_code(self): """ Returns the code in a printable form, separating it into groups of three characters using a point between them. :return: the ID code in a printable form """ code = super(ISWCCode, self)._printable_id_code() code1 = code[:3] ...
python
def _printable_id_code(self): """ Returns the code in a printable form, separating it into groups of three characters using a point between them. :return: the ID code in a printable form """ code = super(ISWCCode, self)._printable_id_code() code1 = code[:3] ...
[ "def", "_printable_id_code", "(", "self", ")", ":", "code", "=", "super", "(", "ISWCCode", ",", "self", ")", ".", "_printable_id_code", "(", ")", "code1", "=", "code", "[", ":", "3", "]", "code2", "=", "code", "[", "3", ":", "6", "]", "code3", "=",...
Returns the code in a printable form, separating it into groups of three characters using a point between them. :return: the ID code in a printable form
[ "Returns", "the", "code", "in", "a", "printable", "form", "separating", "it", "into", "groups", "of", "three", "characters", "using", "a", "point", "between", "them", "." ]
train
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/other.py#L128-L141
calmjs/calmjs
src/calmjs/vlqsm.py
SourceWriter.write
def write(self, s): """ Standard write, for standard sources part of the original file. """ lines = s.splitlines(True) for line in lines: self.current_mapping.append( (self.generated_col, self.index, self.row, self.col_last)) self.stream.w...
python
def write(self, s): """ Standard write, for standard sources part of the original file. """ lines = s.splitlines(True) for line in lines: self.current_mapping.append( (self.generated_col, self.index, self.row, self.col_last)) self.stream.w...
[ "def", "write", "(", "self", ",", "s", ")", ":", "lines", "=", "s", ".", "splitlines", "(", "True", ")", "for", "line", "in", "lines", ":", "self", ".", "current_mapping", ".", "append", "(", "(", "self", ".", "generated_col", ",", "self", ".", "in...
Standard write, for standard sources part of the original file.
[ "Standard", "write", "for", "standard", "sources", "part", "of", "the", "original", "file", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/vlqsm.py#L73-L90
calmjs/calmjs
src/calmjs/vlqsm.py
SourceWriter.discard
def discard(self, s): """ Discard from original file. """ lines = s.splitlines(True) for line in lines: if line[-1] not in '\r\n': if not self.warn: logger.warning( 'partial line discard UNSUPPORTED; source ...
python
def discard(self, s): """ Discard from original file. """ lines = s.splitlines(True) for line in lines: if line[-1] not in '\r\n': if not self.warn: logger.warning( 'partial line discard UNSUPPORTED; source ...
[ "def", "discard", "(", "self", ",", "s", ")", ":", "lines", "=", "s", ".", "splitlines", "(", "True", ")", "for", "line", "in", "lines", ":", "if", "line", "[", "-", "1", "]", "not", "in", "'\\r\\n'", ":", "if", "not", "self", ".", "warn", ":",...
Discard from original file.
[ "Discard", "from", "original", "file", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/vlqsm.py#L92-L108
calmjs/calmjs
src/calmjs/vlqsm.py
SourceWriter.write_padding
def write_padding(self, s): """ Write string that are not part of the original file. """ lines = s.splitlines(True) for line in lines: self.stream.write(line) if line[-1] in '\r\n': self._newline() else: # this ...
python
def write_padding(self, s): """ Write string that are not part of the original file. """ lines = s.splitlines(True) for line in lines: self.stream.write(line) if line[-1] in '\r\n': self._newline() else: # this ...
[ "def", "write_padding", "(", "self", ",", "s", ")", ":", "lines", "=", "s", ".", "splitlines", "(", "True", ")", "for", "line", "in", "lines", ":", "self", ".", "stream", ".", "write", "(", "line", ")", "if", "line", "[", "-", "1", "]", "in", "...
Write string that are not part of the original file.
[ "Write", "string", "that", "are", "not", "part", "of", "the", "original", "file", "." ]
train
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/vlqsm.py#L110-L122
Suor/django-easymoney
easymoney.py
format_currency
def format_currency(number, currency, format, locale=babel.numbers.LC_NUMERIC, force_frac=None, format_type='standard'): """Same as ``babel.numbers.format_currency``, but has ``force_frac`` argument instead of ``currency_digits``. If the ``force_frac`` argument is given, the argument is...
python
def format_currency(number, currency, format, locale=babel.numbers.LC_NUMERIC, force_frac=None, format_type='standard'): """Same as ``babel.numbers.format_currency``, but has ``force_frac`` argument instead of ``currency_digits``. If the ``force_frac`` argument is given, the argument is...
[ "def", "format_currency", "(", "number", ",", "currency", ",", "format", ",", "locale", "=", "babel", ".", "numbers", ".", "LC_NUMERIC", ",", "force_frac", "=", "None", ",", "format_type", "=", "'standard'", ")", ":", "locale", "=", "babel", ".", "core", ...
Same as ``babel.numbers.format_currency``, but has ``force_frac`` argument instead of ``currency_digits``. If the ``force_frac`` argument is given, the argument is passed down to ``pattern.apply``.
[ "Same", "as", "babel", ".", "numbers", ".", "format_currency", "but", "has", "force_frac", "argument", "instead", "of", "currency_digits", "." ]
train
https://github.com/Suor/django-easymoney/blob/c32d024a3c0e8d41f9f55e1f37ceea5e65c419e3/easymoney.py#L52-L78
cihai/cihai
examples/variants.py
run
def run(unihan_options={}): """Wrapped so we can test in tests/test_examples.py""" print("This example prints variant character data.") c = Cihai() if not c.unihan.is_bootstrapped: # download and install Unihan to db c.unihan.bootstrap(unihan_options) c.unihan.add_plugin( 'cihai.d...
python
def run(unihan_options={}): """Wrapped so we can test in tests/test_examples.py""" print("This example prints variant character data.") c = Cihai() if not c.unihan.is_bootstrapped: # download and install Unihan to db c.unihan.bootstrap(unihan_options) c.unihan.add_plugin( 'cihai.d...
[ "def", "run", "(", "unihan_options", "=", "{", "}", ")", ":", "print", "(", "\"This example prints variant character data.\"", ")", "c", "=", "Cihai", "(", ")", "if", "not", "c", ".", "unihan", ".", "is_bootstrapped", ":", "# download and install Unihan to db", ...
Wrapped so we can test in tests/test_examples.py
[ "Wrapped", "so", "we", "can", "test", "in", "tests", "/", "test_examples", ".", "py" ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/examples/variants.py#L15-L34
cihai/cihai
cihai/db.py
Database.reflect_db
def reflect_db(self): """ No-op to reflect db info. This is available as a method so the database can be reflected outside initialization (such bootstrapping unihan during CLI usage). """ self.metadata.reflect(views=True, extend_existing=True) self.base = automap...
python
def reflect_db(self): """ No-op to reflect db info. This is available as a method so the database can be reflected outside initialization (such bootstrapping unihan during CLI usage). """ self.metadata.reflect(views=True, extend_existing=True) self.base = automap...
[ "def", "reflect_db", "(", "self", ")", ":", "self", ".", "metadata", ".", "reflect", "(", "views", "=", "True", ",", "extend_existing", "=", "True", ")", "self", ".", "base", "=", "automap_base", "(", "metadata", "=", "self", ".", "metadata", ")", "sel...
No-op to reflect db info. This is available as a method so the database can be reflected outside initialization (such bootstrapping unihan during CLI usage).
[ "No", "-", "op", "to", "reflect", "db", "info", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/db.py#L24-L33
favalex/python-asciimathml
asciimathml.py
parse
def parse(s, element=Element, atomicstring=lambda s: s): """ Translates from ASCIIMathML (an easy to type and highly readable way to represent math formulas) into MathML (a w3c standard directly displayable by some web browsers). The function `parse()` generates a tree of elements: >>> import asciimathml ...
python
def parse(s, element=Element, atomicstring=lambda s: s): """ Translates from ASCIIMathML (an easy to type and highly readable way to represent math formulas) into MathML (a w3c standard directly displayable by some web browsers). The function `parse()` generates a tree of elements: >>> import asciimathml ...
[ "def", "parse", "(", "s", ",", "element", "=", "Element", ",", "atomicstring", "=", "lambda", "s", ":", "s", ")", ":", "global", "Element_", ",", "AtomicString_", "Element_", "=", "element", "AtomicString_", "=", "atomicstring", "s", ",", "nodes", "=", "...
Translates from ASCIIMathML (an easy to type and highly readable way to represent math formulas) into MathML (a w3c standard directly displayable by some web browsers). The function `parse()` generates a tree of elements: >>> import asciimathml >>> asciimathml.parse('sqrt 2') <Element math at b76fb28c> T...
[ "Translates", "from", "ASCIIMathML", "(", "an", "easy", "to", "type", "and", "highly", "readable", "way", "to", "represent", "math", "formulas", ")", "into", "MathML", "(", "a", "w3c", "standard", "directly", "displayable", "by", "some", "web", "browsers", "...
train
https://github.com/favalex/python-asciimathml/blob/d6b6740a143947452339a7829a18b55315574b2d/asciimathml.py#L109-L138
favalex/python-asciimathml
asciimathml.py
trace_parser
def trace_parser(p): """ Decorator for tracing the parser. Use it to decorate functions with signature: string -> (string, nodes) and a trace of the progress made by the parser will be printed to stderr. Currently parse_exprs(), parse_expr() and parse_m() have the right signature. """ ...
python
def trace_parser(p): """ Decorator for tracing the parser. Use it to decorate functions with signature: string -> (string, nodes) and a trace of the progress made by the parser will be printed to stderr. Currently parse_exprs(), parse_expr() and parse_m() have the right signature. """ ...
[ "def", "trace_parser", "(", "p", ")", ":", "def", "nodes_to_string", "(", "n", ")", ":", "if", "isinstance", "(", "n", ",", "list", ")", ":", "result", "=", "'[ '", "for", "m", "in", "map", "(", "nodes_to_string", ",", "n", ")", ":", "result", "+="...
Decorator for tracing the parser. Use it to decorate functions with signature: string -> (string, nodes) and a trace of the progress made by the parser will be printed to stderr. Currently parse_exprs(), parse_expr() and parse_m() have the right signature.
[ "Decorator", "for", "tracing", "the", "parser", "." ]
train
https://github.com/favalex/python-asciimathml/blob/d6b6740a143947452339a7829a18b55315574b2d/asciimathml.py#L157-L208
baccuslab/shannon
shannon/bottleneck.py
remove_symbol_from_dist
def remove_symbol_from_dist(dist, index): ''' prob is a ndarray representing a probability distribution. index is a number between 0 and and the number of symbols ( len(prob)-1 ) return the probability distribution if the element at 'index' was no longer available ''' if type(dist) is not Distri...
python
def remove_symbol_from_dist(dist, index): ''' prob is a ndarray representing a probability distribution. index is a number between 0 and and the number of symbols ( len(prob)-1 ) return the probability distribution if the element at 'index' was no longer available ''' if type(dist) is not Distri...
[ "def", "remove_symbol_from_dist", "(", "dist", ",", "index", ")", ":", "if", "type", "(", "dist", ")", "is", "not", "Distribution", ":", "raise", "TypeError", "(", "\"remove_symbol_from_dist got an object ot type {0}\"", ".", "format", "(", "type", "(", "dist", ...
prob is a ndarray representing a probability distribution. index is a number between 0 and and the number of symbols ( len(prob)-1 ) return the probability distribution if the element at 'index' was no longer available
[ "prob", "is", "a", "ndarray", "representing", "a", "probability", "distribution", ".", "index", "is", "a", "number", "between", "0", "and", "and", "the", "number", "of", "symbols", "(", "len", "(", "prob", ")", "-", "1", ")", "return", "the", "probabilit...
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/bottleneck.py#L16-L28
baccuslab/shannon
shannon/bottleneck.py
change_response
def change_response(x, prob, index): ''' change every response in x that matches 'index' by randomly sampling from prob ''' #pdb.set_trace() N = (x==index).sum() #x[x==index]=9 x[x==index] = dist.sample(N)
python
def change_response(x, prob, index): ''' change every response in x that matches 'index' by randomly sampling from prob ''' #pdb.set_trace() N = (x==index).sum() #x[x==index]=9 x[x==index] = dist.sample(N)
[ "def", "change_response", "(", "x", ",", "prob", ",", "index", ")", ":", "#pdb.set_trace()", "N", "=", "(", "x", "==", "index", ")", ".", "sum", "(", ")", "#x[x==index]=9", "x", "[", "x", "==", "index", "]", "=", "dist", ".", "sample", "(", "N", ...
change every response in x that matches 'index' by randomly sampling from prob
[ "change", "every", "response", "in", "x", "that", "matches", "index", "by", "randomly", "sampling", "from", "prob" ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/bottleneck.py#L31-L38
baccuslab/shannon
shannon/bottleneck.py
toy_example
def toy_example(): """ Make a toy example where x is uniformly distributed with N bits and y follows x but with symbol dependent noise. x=0 -> y=0 x=1 -> y=1 + e x=2 -> y=2 + 2*e ... x=n -> y=n + n*e where by n*e I am saying that the noise grows """ #pdb.set_trace() N=4 ...
python
def toy_example(): """ Make a toy example where x is uniformly distributed with N bits and y follows x but with symbol dependent noise. x=0 -> y=0 x=1 -> y=1 + e x=2 -> y=2 + 2*e ... x=n -> y=n + n*e where by n*e I am saying that the noise grows """ #pdb.set_trace() N=4 ...
[ "def", "toy_example", "(", ")", ":", "#pdb.set_trace()", "N", "=", "4", "m", "=", "100", "x", "=", "np", ".", "zeros", "(", "m", "*", "(", "2", "**", "N", ")", ")", "y", "=", "np", ".", "zeros", "(", "m", "*", "(", "2", "**", "N", ")", ")...
Make a toy example where x is uniformly distributed with N bits and y follows x but with symbol dependent noise. x=0 -> y=0 x=1 -> y=1 + e x=2 -> y=2 + 2*e ... x=n -> y=n + n*e where by n*e I am saying that the noise grows
[ "Make", "a", "toy", "example", "where", "x", "is", "uniformly", "distributed", "with", "N", "bits", "and", "y", "follows", "x", "but", "with", "symbol", "dependent", "noise", ".", "x", "=", "0", "-", ">", "y", "=", "0", "x", "=", "1", "-", ">", "...
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/bottleneck.py#L40-L62
baccuslab/shannon
shannon/bottleneck.py
differentiate_mi
def differentiate_mi(x, y): ''' for each symbol in x, change x such that there are no more of such symbols (replacing by a random distribution with the same proba of all other symbols) and compute mi(new_x, y) ''' #pdb.set_trace() dist = Distribution(discrete.symbols_to_prob(x)) diff = ...
python
def differentiate_mi(x, y): ''' for each symbol in x, change x such that there are no more of such symbols (replacing by a random distribution with the same proba of all other symbols) and compute mi(new_x, y) ''' #pdb.set_trace() dist = Distribution(discrete.symbols_to_prob(x)) diff = ...
[ "def", "differentiate_mi", "(", "x", ",", "y", ")", ":", "#pdb.set_trace()", "dist", "=", "Distribution", "(", "discrete", ".", "symbols_to_prob", "(", "x", ")", ")", "diff", "=", "np", ".", "zeros", "(", "len", "(", "dist", ".", "prob", ")", ")", "f...
for each symbol in x, change x such that there are no more of such symbols (replacing by a random distribution with the same proba of all other symbols) and compute mi(new_x, y)
[ "for", "each", "symbol", "in", "x", "change", "x", "such", "that", "there", "are", "no", "more", "of", "such", "symbols", "(", "replacing", "by", "a", "random", "distribution", "with", "the", "same", "proba", "of", "all", "other", "symbols", ")", "and", ...
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/bottleneck.py#L64-L83
baccuslab/shannon
shannon/bottleneck.py
Distribution.sample
def sample(self, *args): ''' generate a random number in [0,1) and return the index into self.prob such that self.prob[index] <= random_number but self.prob[index+1] > random_number implementation note: the problem is identical to finding the index into self.cumsum where the ran...
python
def sample(self, *args): ''' generate a random number in [0,1) and return the index into self.prob such that self.prob[index] <= random_number but self.prob[index+1] > random_number implementation note: the problem is identical to finding the index into self.cumsum where the ran...
[ "def", "sample", "(", "self", ",", "*", "args", ")", ":", "return", "self", ".", "cumsum", ".", "searchsorted", "(", "np", ".", "random", ".", "rand", "(", "*", "args", ")", ")" ]
generate a random number in [0,1) and return the index into self.prob such that self.prob[index] <= random_number but self.prob[index+1] > random_number implementation note: the problem is identical to finding the index into self.cumsum where the random number should be inserted to keep the arr...
[ "generate", "a", "random", "number", "in", "[", "0", "1", ")", "and", "return", "the", "index", "into", "self", ".", "prob", "such", "that", "self", ".", "prob", "[", "index", "]", "<", "=", "random_number", "but", "self", ".", "prob", "[", "index", ...
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/bottleneck.py#L95-L110
cihai/cihai
cihai/log.py
default_log_template
def default_log_template(self, record): """Return the prefix for the log message. Template for Formatter. :param: record: :py:class:`logging.LogRecord` object. this is passed in from inside the :py:meth:`logging.Formatter.format` record. """ reset = Style.RESET_ALL levelname = [ LEVEL...
python
def default_log_template(self, record): """Return the prefix for the log message. Template for Formatter. :param: record: :py:class:`logging.LogRecord` object. this is passed in from inside the :py:meth:`logging.Formatter.format` record. """ reset = Style.RESET_ALL levelname = [ LEVEL...
[ "def", "default_log_template", "(", "self", ",", "record", ")", ":", "reset", "=", "Style", ".", "RESET_ALL", "levelname", "=", "[", "LEVEL_COLORS", ".", "get", "(", "record", ".", "levelname", ")", ",", "Style", ".", "BRIGHT", ",", "'(%(levelname)s)'", ",...
Return the prefix for the log message. Template for Formatter. :param: record: :py:class:`logging.LogRecord` object. this is passed in from inside the :py:meth:`logging.Formatter.format` record.
[ "Return", "the", "prefix", "for", "the", "log", "message", ".", "Template", "for", "Formatter", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/log.py#L24-L63
cihai/cihai
cihai/utils.py
merge_dict
def merge_dict(base, additional): """ Combine two dictionary-like objects. Notes ----- Code from https://github.com/pypa/warehouse Copyright 2013 Donald Stufft Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the Licens...
python
def merge_dict(base, additional): """ Combine two dictionary-like objects. Notes ----- Code from https://github.com/pypa/warehouse Copyright 2013 Donald Stufft Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the Licens...
[ "def", "merge_dict", "(", "base", ",", "additional", ")", ":", "if", "base", "is", "None", ":", "return", "additional", "if", "additional", "is", "None", ":", "return", "base", "if", "not", "(", "isinstance", "(", "base", ",", "collections", ".", "Mappin...
Combine two dictionary-like objects. Notes ----- Code from https://github.com/pypa/warehouse Copyright 2013 Donald Stufft Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at...
[ "Combine", "two", "dictionary", "-", "like", "objects", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/utils.py#L14-L54
cihai/cihai
cihai/config.py
expand_config
def expand_config(d, dirs): """ Expand configuration XDG variables, environmental variables, and tildes. Parameters ---------- d : dict config information dirs : appdirs.AppDirs XDG application mapping Notes ----- *Environmentable variables* are expanded via :py:fun...
python
def expand_config(d, dirs): """ Expand configuration XDG variables, environmental variables, and tildes. Parameters ---------- d : dict config information dirs : appdirs.AppDirs XDG application mapping Notes ----- *Environmentable variables* are expanded via :py:fun...
[ "def", "expand_config", "(", "d", ",", "dirs", ")", ":", "context", "=", "{", "'user_cache_dir'", ":", "dirs", ".", "user_cache_dir", ",", "'user_config_dir'", ":", "dirs", ".", "user_config_dir", ",", "'user_data_dir'", ":", "dirs", ".", "user_data_dir", ",",...
Expand configuration XDG variables, environmental variables, and tildes. Parameters ---------- d : dict config information dirs : appdirs.AppDirs XDG application mapping Notes ----- *Environmentable variables* are expanded via :py:func:`os.path.expandvars`. So ``${PWD}`...
[ "Expand", "configuration", "XDG", "variables", "environmental", "variables", "and", "tildes", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/config.py#L11-L57
cihai/cihai
cihai/data/unihan/bootstrap.py
bootstrap_unihan
def bootstrap_unihan(metadata, options={}): """Download, extract and import unihan to database.""" options = merge_dict(UNIHAN_ETL_DEFAULT_OPTIONS.copy(), options) p = unihan.Packager(options) p.download() data = p.export() table = create_unihan_table(UNIHAN_FIELDS, metadata) metadata.creat...
python
def bootstrap_unihan(metadata, options={}): """Download, extract and import unihan to database.""" options = merge_dict(UNIHAN_ETL_DEFAULT_OPTIONS.copy(), options) p = unihan.Packager(options) p.download() data = p.export() table = create_unihan_table(UNIHAN_FIELDS, metadata) metadata.creat...
[ "def", "bootstrap_unihan", "(", "metadata", ",", "options", "=", "{", "}", ")", ":", "options", "=", "merge_dict", "(", "UNIHAN_ETL_DEFAULT_OPTIONS", ".", "copy", "(", ")", ",", "options", ")", "p", "=", "unihan", ".", "Packager", "(", "options", ")", "p...
Download, extract and import unihan to database.
[ "Download", "extract", "and", "import", "unihan", "to", "database", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/data/unihan/bootstrap.py#L13-L22
cihai/cihai
cihai/data/unihan/bootstrap.py
is_bootstrapped
def is_bootstrapped(metadata): """Return True if cihai is correctly bootstrapped.""" fields = UNIHAN_FIELDS + DEFAULT_COLUMNS if TABLE_NAME in metadata.tables.keys(): table = metadata.tables[TABLE_NAME] if set(fields) == set(c.name for c in table.columns): return True el...
python
def is_bootstrapped(metadata): """Return True if cihai is correctly bootstrapped.""" fields = UNIHAN_FIELDS + DEFAULT_COLUMNS if TABLE_NAME in metadata.tables.keys(): table = metadata.tables[TABLE_NAME] if set(fields) == set(c.name for c in table.columns): return True el...
[ "def", "is_bootstrapped", "(", "metadata", ")", ":", "fields", "=", "UNIHAN_FIELDS", "+", "DEFAULT_COLUMNS", "if", "TABLE_NAME", "in", "metadata", ".", "tables", ".", "keys", "(", ")", ":", "table", "=", "metadata", ".", "tables", "[", "TABLE_NAME", "]", "...
Return True if cihai is correctly bootstrapped.
[ "Return", "True", "if", "cihai", "is", "correctly", "bootstrapped", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/data/unihan/bootstrap.py#L39-L50
cihai/cihai
cihai/data/unihan/bootstrap.py
create_unihan_table
def create_unihan_table(columns, metadata): """Create table and return :class:`sqlalchemy.Table`. Parameters ---------- columns : list columns for table, e.g. ``['kDefinition', 'kCantonese']`` metadata : :class:`sqlalchemy.schema.MetaData` Instance of sqlalchemy metadata Retur...
python
def create_unihan_table(columns, metadata): """Create table and return :class:`sqlalchemy.Table`. Parameters ---------- columns : list columns for table, e.g. ``['kDefinition', 'kCantonese']`` metadata : :class:`sqlalchemy.schema.MetaData` Instance of sqlalchemy metadata Retur...
[ "def", "create_unihan_table", "(", "columns", ",", "metadata", ")", ":", "if", "TABLE_NAME", "not", "in", "metadata", ".", "tables", ":", "table", "=", "Table", "(", "TABLE_NAME", ",", "metadata", ")", "table", ".", "append_column", "(", "Column", "(", "'c...
Create table and return :class:`sqlalchemy.Table`. Parameters ---------- columns : list columns for table, e.g. ``['kDefinition', 'kCantonese']`` metadata : :class:`sqlalchemy.schema.MetaData` Instance of sqlalchemy metadata Returns ------- :class:`sqlalchemy.schema.Table`...
[ "Create", "table", "and", "return", ":", "class", ":", "sqlalchemy", ".", "Table", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/data/unihan/bootstrap.py#L53-L81
namuyan/nem-ed25519
nem_ed25519/key.py
get_address
def get_address(pk, main_net=True, prefix=None): """ compute the nem-py address from the public one """ if isinstance(pk, str): pk = unhexlify(pk.encode()) assert len(pk) == 32, 'PK is 32bytes {}'.format(len(pk)) k = keccak_256(pk).digest() ripe = RIPEMD160.new(k).digest() if prefix is N...
python
def get_address(pk, main_net=True, prefix=None): """ compute the nem-py address from the public one """ if isinstance(pk, str): pk = unhexlify(pk.encode()) assert len(pk) == 32, 'PK is 32bytes {}'.format(len(pk)) k = keccak_256(pk).digest() ripe = RIPEMD160.new(k).digest() if prefix is N...
[ "def", "get_address", "(", "pk", ",", "main_net", "=", "True", ",", "prefix", "=", "None", ")", ":", "if", "isinstance", "(", "pk", ",", "str", ")", ":", "pk", "=", "unhexlify", "(", "pk", ".", "encode", "(", ")", ")", "assert", "len", "(", "pk",...
compute the nem-py address from the public one
[ "compute", "the", "nem", "-", "py", "address", "from", "the", "public", "one" ]
train
https://github.com/namuyan/nem-ed25519/blob/4f506a5335eb860a4cf1d102f76fcad93f9a55fc/nem_ed25519/key.py#L39-L52
cihai/cihai
cihai/data/unihan/dataset.py
Unihan.lookup_char
def lookup_char(self, char): """Return character information from datasets. Parameters ---------- char : str character / string to lookup Returns ------- :class:`sqlalchemy.orm.query.Query` : list of matches """ Unihan = s...
python
def lookup_char(self, char): """Return character information from datasets. Parameters ---------- char : str character / string to lookup Returns ------- :class:`sqlalchemy.orm.query.Query` : list of matches """ Unihan = s...
[ "def", "lookup_char", "(", "self", ",", "char", ")", ":", "Unihan", "=", "self", ".", "sql", ".", "base", ".", "classes", ".", "Unihan", "return", "self", ".", "sql", ".", "session", ".", "query", "(", "Unihan", ")", ".", "filter_by", "(", "char", ...
Return character information from datasets. Parameters ---------- char : str character / string to lookup Returns ------- :class:`sqlalchemy.orm.query.Query` : list of matches
[ "Return", "character", "information", "from", "datasets", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/data/unihan/dataset.py#L17-L31
cihai/cihai
cihai/data/unihan/dataset.py
Unihan.reverse_char
def reverse_char(self, hints): """Return QuerySet of objects from SQLAlchemy of results. Parameters ---------- hints: list of str strings to lookup Returns ------- :class:`sqlalchemy.orm.query.Query` : reverse matches """ ...
python
def reverse_char(self, hints): """Return QuerySet of objects from SQLAlchemy of results. Parameters ---------- hints: list of str strings to lookup Returns ------- :class:`sqlalchemy.orm.query.Query` : reverse matches """ ...
[ "def", "reverse_char", "(", "self", ",", "hints", ")", ":", "if", "isinstance", "(", "hints", ",", "string_types", ")", ":", "hints", "=", "[", "hints", "]", "Unihan", "=", "self", ".", "sql", ".", "base", ".", "classes", ".", "Unihan", "columns", "=...
Return QuerySet of objects from SQLAlchemy of results. Parameters ---------- hints: list of str strings to lookup Returns ------- :class:`sqlalchemy.orm.query.Query` : reverse matches
[ "Return", "QuerySet", "of", "objects", "from", "SQLAlchemy", "of", "results", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/data/unihan/dataset.py#L33-L53
cihai/cihai
cihai/data/unihan/dataset.py
Unihan.with_fields
def with_fields(self, *fields): """Returns list of characters with information for certain fields. Parameters ---------- *fields : list of str fields for which information should be available Returns ------- :class:`sqlalchemy.orm.query.Query` : ...
python
def with_fields(self, *fields): """Returns list of characters with information for certain fields. Parameters ---------- *fields : list of str fields for which information should be available Returns ------- :class:`sqlalchemy.orm.query.Query` : ...
[ "def", "with_fields", "(", "self", ",", "*", "fields", ")", ":", "Unihan", "=", "self", ".", "sql", ".", "base", ".", "classes", ".", "Unihan", "query", "=", "self", ".", "sql", ".", "session", ".", "query", "(", "Unihan", ")", "for", "field", "in"...
Returns list of characters with information for certain fields. Parameters ---------- *fields : list of str fields for which information should be available Returns ------- :class:`sqlalchemy.orm.query.Query` : list of matches
[ "Returns", "list", "of", "characters", "with", "information", "for", "certain", "fields", "." ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/data/unihan/dataset.py#L55-L72
baccuslab/shannon
shannon/continuous.py
entropy
def entropy(data=None, prob=None, method='nearest-neighbors', bins=None, errorVal=1e-5, units='bits'): ''' given a probability distribution (prob) or an interable of symbols (data) compute and return its continuous entropy. inputs: ------ data: samples by dimensions ndarray p...
python
def entropy(data=None, prob=None, method='nearest-neighbors', bins=None, errorVal=1e-5, units='bits'): ''' given a probability distribution (prob) or an interable of symbols (data) compute and return its continuous entropy. inputs: ------ data: samples by dimensions ndarray p...
[ "def", "entropy", "(", "data", "=", "None", ",", "prob", "=", "None", ",", "method", "=", "'nearest-neighbors'", ",", "bins", "=", "None", ",", "errorVal", "=", "1e-5", ",", "units", "=", "'bits'", ")", ":", "if", "prob", "is", "None", "and", "data",...
given a probability distribution (prob) or an interable of symbols (data) compute and return its continuous entropy. inputs: ------ data: samples by dimensions ndarray prob: iterable with probabilities method: 'nearest-neighbors', 'gaussian', or 'bin' bins...
[ "given", "a", "probability", "distribution", "(", "prob", ")", "or", "an", "interable", "of", "symbols", "(", "data", ")", "compute", "and", "return", "its", "continuous", "entropy", "." ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/continuous.py#L8-L127
baccuslab/shannon
shannon/continuous.py
mi
def mi(x, y, bins_x=None, bins_y=None, bins_xy=None, method='nearest-neighbors', units='bits'): ''' compute and return the mutual information between x and y inputs: ------- x, y: numpy arrays of shape samples x dimension method: 'nearest-neighbors', 'gaussian', or 'bin' ...
python
def mi(x, y, bins_x=None, bins_y=None, bins_xy=None, method='nearest-neighbors', units='bits'): ''' compute and return the mutual information between x and y inputs: ------- x, y: numpy arrays of shape samples x dimension method: 'nearest-neighbors', 'gaussian', or 'bin' ...
[ "def", "mi", "(", "x", ",", "y", ",", "bins_x", "=", "None", ",", "bins_y", "=", "None", ",", "bins_xy", "=", "None", ",", "method", "=", "'nearest-neighbors'", ",", "units", "=", "'bits'", ")", ":", "# dict.values() returns a view object that has to be conver...
compute and return the mutual information between x and y inputs: ------- x, y: numpy arrays of shape samples x dimension method: 'nearest-neighbors', 'gaussian', or 'bin' units: 'bits' or 'nats' output: ------- mi: float Notes: ------ ...
[ "compute", "and", "return", "the", "mutual", "information", "between", "x", "and", "y" ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/continuous.py#L158-L204
baccuslab/shannon
shannon/continuous.py
cond_entropy
def cond_entropy(x, y, bins_y=None, bins_xy=None, method='nearest-neighbors', units='bits'): ''' compute the conditional entropy H(X|Y). method: 'nearest-neighbors', 'gaussian', or 'bin' if 'bin' need to provide bins_y, and bins_xy units: 'bits' or 'nats' ''' HXY = entr...
python
def cond_entropy(x, y, bins_y=None, bins_xy=None, method='nearest-neighbors', units='bits'): ''' compute the conditional entropy H(X|Y). method: 'nearest-neighbors', 'gaussian', or 'bin' if 'bin' need to provide bins_y, and bins_xy units: 'bits' or 'nats' ''' HXY = entr...
[ "def", "cond_entropy", "(", "x", ",", "y", ",", "bins_y", "=", "None", ",", "bins_xy", "=", "None", ",", "method", "=", "'nearest-neighbors'", ",", "units", "=", "'bits'", ")", ":", "HXY", "=", "entropy", "(", "data", "=", "np", ".", "concatenate", "...
compute the conditional entropy H(X|Y). method: 'nearest-neighbors', 'gaussian', or 'bin' if 'bin' need to provide bins_y, and bins_xy units: 'bits' or 'nats'
[ "compute", "the", "conditional", "entropy", "H", "(", "X|Y", ")", "." ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/continuous.py#L207-L218
baccuslab/shannon
shannon/discrete.py
entropy
def entropy(data=None, prob=None, tol=1e-5): ''' given a probability distribution (prob) or an interable of symbols (data) compute and return its entropy inputs: ------ data: iterable of symbols prob: iterable with probabilities tol: if prob is given, 'e...
python
def entropy(data=None, prob=None, tol=1e-5): ''' given a probability distribution (prob) or an interable of symbols (data) compute and return its entropy inputs: ------ data: iterable of symbols prob: iterable with probabilities tol: if prob is given, 'e...
[ "def", "entropy", "(", "data", "=", "None", ",", "prob", "=", "None", ",", "tol", "=", "1e-5", ")", ":", "if", "prob", "is", "None", "and", "data", "is", "None", ":", "raise", "ValueError", "(", "\"%s.entropy requires either 'prob' or 'data' to be defined\"", ...
given a probability distribution (prob) or an interable of symbols (data) compute and return its entropy inputs: ------ data: iterable of symbols prob: iterable with probabilities tol: if prob is given, 'entropy' checks that the sum is about 1. ...
[ "given", "a", "probability", "distribution", "(", "prob", ")", "or", "an", "interable", "of", "symbols", "(", "data", ")", "compute", "and", "return", "its", "entropy" ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L14-L49
baccuslab/shannon
shannon/discrete.py
symbols_to_prob
def symbols_to_prob(symbols): ''' Return a dict mapping symbols to probability. input: ----- symbols: iterable of hashable items works well if symbols is a zip of iterables ''' myCounter = Counter(symbols) N = float(len(list(symbols))) # symbols might be...
python
def symbols_to_prob(symbols): ''' Return a dict mapping symbols to probability. input: ----- symbols: iterable of hashable items works well if symbols is a zip of iterables ''' myCounter = Counter(symbols) N = float(len(list(symbols))) # symbols might be...
[ "def", "symbols_to_prob", "(", "symbols", ")", ":", "myCounter", "=", "Counter", "(", "symbols", ")", "N", "=", "float", "(", "len", "(", "list", "(", "symbols", ")", ")", ")", "# symbols might be a zip object in python 3", "for", "k", "in", "myCounter", ":"...
Return a dict mapping symbols to probability. input: ----- symbols: iterable of hashable items works well if symbols is a zip of iterables
[ "Return", "a", "dict", "mapping", "symbols", "to", "probability", "." ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L52-L68
baccuslab/shannon
shannon/discrete.py
combine_symbols
def combine_symbols(*args): ''' Combine different symbols into a 'super'-symbol args can be an iterable of iterables that support hashing see example for 2D ndarray input usage: 1) combine two symbols, each a number into just one symbol x = numpy.random.randint(0,4,1000) y...
python
def combine_symbols(*args): ''' Combine different symbols into a 'super'-symbol args can be an iterable of iterables that support hashing see example for 2D ndarray input usage: 1) combine two symbols, each a number into just one symbol x = numpy.random.randint(0,4,1000) y...
[ "def", "combine_symbols", "(", "*", "args", ")", ":", "for", "arg", "in", "args", ":", "if", "len", "(", "arg", ")", "!=", "len", "(", "args", "[", "0", "]", ")", ":", "raise", "ValueError", "(", "\"combine_symbols got inputs with different sizes\"", ")", ...
Combine different symbols into a 'super'-symbol args can be an iterable of iterables that support hashing see example for 2D ndarray input usage: 1) combine two symbols, each a number into just one symbol x = numpy.random.randint(0,4,1000) y = numpy.random.randint(0,2,1000) ...
[ "Combine", "different", "symbols", "into", "a", "super", "-", "symbol" ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L71-L113
baccuslab/shannon
shannon/discrete.py
mi
def mi(x, y): ''' compute and return the mutual information between x and y inputs: ------- x, y: iterables of hashable items output: ------- mi: float Notes: ------ if you are trying to mix several symbols together as in mi(x, (y0,y1,...)), try ...
python
def mi(x, y): ''' compute and return the mutual information between x and y inputs: ------- x, y: iterables of hashable items output: ------- mi: float Notes: ------ if you are trying to mix several symbols together as in mi(x, (y0,y1,...)), try ...
[ "def", "mi", "(", "x", ",", "y", ")", ":", "# dict.values() returns a view object that has to be converted to a list before being", "# converted to an array", "# the following lines will execute properly in python3, but not python2 because there", "# is no zip object", "try", ":", "if", ...
compute and return the mutual information between x and y inputs: ------- x, y: iterables of hashable items output: ------- mi: float Notes: ------ if you are trying to mix several symbols together as in mi(x, (y0,y1,...)), try info[p] = _info.mi(x, info...
[ "compute", "and", "return", "the", "mutual", "information", "between", "x", "and", "y" ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L116-L150
baccuslab/shannon
shannon/discrete.py
cond_mi
def cond_mi(x, y, z): ''' compute and return the mutual information between x and y given z, I(x, y | z) inputs: ------- x, y, z: iterables with discrete symbols output: ------- mi: float implementation notes: --------------------- I(x, y | z) = H(x | z) ...
python
def cond_mi(x, y, z): ''' compute and return the mutual information between x and y given z, I(x, y | z) inputs: ------- x, y, z: iterables with discrete symbols output: ------- mi: float implementation notes: --------------------- I(x, y | z) = H(x | z) ...
[ "def", "cond_mi", "(", "x", ",", "y", ",", "z", ")", ":", "# dict.values() returns a view object that has to be converted to a list before being converted to an array", "probXZ", "=", "symbols_to_prob", "(", "combine_symbols", "(", "x", ",", "z", ")", ")", ".", "prob", ...
compute and return the mutual information between x and y given z, I(x, y | z) inputs: ------- x, y, z: iterables with discrete symbols output: ------- mi: float implementation notes: --------------------- I(x, y | z) = H(x | z) - H(x | y, z) ...
[ "compute", "and", "return", "the", "mutual", "information", "between", "x", "and", "y", "given", "z", "I", "(", "x", "y", "|", "z", ")" ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L153-L177
baccuslab/shannon
shannon/discrete.py
mi_chain_rule
def mi_chain_rule(X, y): ''' Decompose the information between all X and y according to the chain rule and return all the terms in the chain rule. Inputs: ------- X: iterable of iterables. You should be able to compute [mi(x, y) for x in X] y: iterable of symbols ...
python
def mi_chain_rule(X, y): ''' Decompose the information between all X and y according to the chain rule and return all the terms in the chain rule. Inputs: ------- X: iterable of iterables. You should be able to compute [mi(x, y) for x in X] y: iterable of symbols ...
[ "def", "mi_chain_rule", "(", "X", ",", "y", ")", ":", "# allocate ndarray output", "chain", "=", "np", ".", "zeros", "(", "len", "(", "X", ")", ")", "# first term in the expansion is not a conditional information, but the information between the first x and y", "chain", "...
Decompose the information between all X and y according to the chain rule and return all the terms in the chain rule. Inputs: ------- X: iterable of iterables. You should be able to compute [mi(x, y) for x in X] y: iterable of symbols output: ------- ndarray:...
[ "Decompose", "the", "information", "between", "all", "X", "and", "y", "according", "to", "the", "chain", "rule", "and", "return", "all", "the", "terms", "in", "the", "chain", "rule", "." ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L180-L208
baccuslab/shannon
shannon/discrete.py
KL_divergence
def KL_divergence(P,Q): ''' Compute the KL divergence between distributions P and Q P and Q should be dictionaries linking symbols to probabilities. the keys to P and Q should be the same. ''' assert(P.keys()==Q.keys()) distance = 0 for k in P.keys(): distance += P[k] *...
python
def KL_divergence(P,Q): ''' Compute the KL divergence between distributions P and Q P and Q should be dictionaries linking symbols to probabilities. the keys to P and Q should be the same. ''' assert(P.keys()==Q.keys()) distance = 0 for k in P.keys(): distance += P[k] *...
[ "def", "KL_divergence", "(", "P", ",", "Q", ")", ":", "assert", "(", "P", ".", "keys", "(", ")", "==", "Q", ".", "keys", "(", ")", ")", "distance", "=", "0", "for", "k", "in", "P", ".", "keys", "(", ")", ":", "distance", "+=", "P", "[", "k"...
Compute the KL divergence between distributions P and Q P and Q should be dictionaries linking symbols to probabilities. the keys to P and Q should be the same.
[ "Compute", "the", "KL", "divergence", "between", "distributions", "P", "and", "Q", "P", "and", "Q", "should", "be", "dictionaries", "linking", "symbols", "to", "probabilities", ".", "the", "keys", "to", "P", "and", "Q", "should", "be", "the", "same", "." ]
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L211-L224
baccuslab/shannon
shannon/discrete.py
bin
def bin(x, bins, maxX=None, minX=None): ''' bin signal x using 'binsN' bin. If minX, maxX are None, they default to the full range of the signal. If they are not None, everything above maxX gets assigned to binsN-1 and everything below minX gets assigned to 0, this is effectively the same as clippin...
python
def bin(x, bins, maxX=None, minX=None): ''' bin signal x using 'binsN' bin. If minX, maxX are None, they default to the full range of the signal. If they are not None, everything above maxX gets assigned to binsN-1 and everything below minX gets assigned to 0, this is effectively the same as clippin...
[ "def", "bin", "(", "x", ",", "bins", ",", "maxX", "=", "None", ",", "minX", "=", "None", ")", ":", "if", "maxX", "is", "None", ":", "maxX", "=", "x", ".", "max", "(", ")", "if", "minX", "is", "None", ":", "minX", "=", "x", ".", "min", "(", ...
bin signal x using 'binsN' bin. If minX, maxX are None, they default to the full range of the signal. If they are not None, everything above maxX gets assigned to binsN-1 and everything below minX gets assigned to 0, this is effectively the same as clipping x before passing it to 'bin' input: -----...
[ "bin", "signal", "x", "using", "binsN", "bin", ".", "If", "minX", "maxX", "are", "None", "they", "default", "to", "the", "full", "range", "of", "the", "signal", ".", "If", "they", "are", "not", "None", "everything", "above", "maxX", "gets", "assigned", ...
train
https://github.com/baccuslab/shannon/blob/38abb4d9e53208ffd1c4149ef9fdf3abceccac48/shannon/discrete.py#L227-L275
cihai/cihai
doc/conf.py
linkcode_resolve
def linkcode_resolve(domain, info): # NOQA: C901 """ Determine the URL corresponding to Python object Notes ----- From https://github.com/numpy/numpy/blob/v1.15.1/doc/source/conf.py, 7c49cfa on Jul 31. License BSD-3. https://github.com/numpy/numpy/blob/v1.15.1/LICENSE.txt """ if domain...
python
def linkcode_resolve(domain, info): # NOQA: C901 """ Determine the URL corresponding to Python object Notes ----- From https://github.com/numpy/numpy/blob/v1.15.1/doc/source/conf.py, 7c49cfa on Jul 31. License BSD-3. https://github.com/numpy/numpy/blob/v1.15.1/LICENSE.txt """ if domain...
[ "def", "linkcode_resolve", "(", "domain", ",", "info", ")", ":", "# NOQA: C901", "if", "domain", "!=", "'py'", ":", "return", "None", "modname", "=", "info", "[", "'module'", "]", "fullname", "=", "info", "[", "'fullname'", "]", "submod", "=", "sys", "."...
Determine the URL corresponding to Python object Notes ----- From https://github.com/numpy/numpy/blob/v1.15.1/doc/source/conf.py, 7c49cfa on Jul 31. License BSD-3. https://github.com/numpy/numpy/blob/v1.15.1/LICENSE.txt
[ "Determine", "the", "URL", "corresponding", "to", "Python", "object" ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/doc/conf.py#L127-L195
namuyan/nem-ed25519
nem_ed25519/utils.py
inv
def inv(z): """$= z^{-1} \mod q$, for z != 0""" # Adapted from curve25519_athlon.c in djb's Curve25519. z = qdiv(z) z2 = z * z % PRIME # 2 z9 = pow2(z2, 2) * z % PRIME # 9 z11 = z9 * z2 % PRIME # 11 z2_5_0 = (z11*z11) % PRIME * z9 % PRIME # 31 == 2^5 - 2^0 z2_10_0 = pow2(z2_5_0, 5) *...
python
def inv(z): """$= z^{-1} \mod q$, for z != 0""" # Adapted from curve25519_athlon.c in djb's Curve25519. z = qdiv(z) z2 = z * z % PRIME # 2 z9 = pow2(z2, 2) * z % PRIME # 9 z11 = z9 * z2 % PRIME # 11 z2_5_0 = (z11*z11) % PRIME * z9 % PRIME # 31 == 2^5 - 2^0 z2_10_0 = pow2(z2_5_0, 5) *...
[ "def", "inv", "(", "z", ")", ":", "# Adapted from curve25519_athlon.c in djb's Curve25519.", "z", "=", "qdiv", "(", "z", ")", "z2", "=", "z", "*", "z", "%", "PRIME", "# 2", "z9", "=", "pow2", "(", "z2", ",", "2", ")", "*", "z", "%", "PRIME", "# 9", ...
$= z^{-1} \mod q$, for z != 0
[ "$", "=", "z^", "{", "-", "1", "}", "\\", "mod", "q$", "for", "z", "!", "=", "0" ]
train
https://github.com/namuyan/nem-ed25519/blob/4f506a5335eb860a4cf1d102f76fcad93f9a55fc/nem_ed25519/utils.py#L145-L160
namuyan/nem-ed25519
nem_ed25519/utils.py
scalarmult_B
def scalarmult_B(e): """ Implements scalarmult(B, e) more efficiently. """ # scalarmult(B, l) is the identity e %= L P = IDENT for i in range(253): if e & 1: P = edwards_add(P=P, Q=Bpow[i]) e //= 2 assert e == 0, e return P
python
def scalarmult_B(e): """ Implements scalarmult(B, e) more efficiently. """ # scalarmult(B, l) is the identity e %= L P = IDENT for i in range(253): if e & 1: P = edwards_add(P=P, Q=Bpow[i]) e //= 2 assert e == 0, e return P
[ "def", "scalarmult_B", "(", "e", ")", ":", "# scalarmult(B, l) is the identity", "e", "%=", "L", "P", "=", "IDENT", "for", "i", "in", "range", "(", "253", ")", ":", "if", "e", "&", "1", ":", "P", "=", "edwards_add", "(", "P", "=", "P", ",", "Q", ...
Implements scalarmult(B, e) more efficiently.
[ "Implements", "scalarmult", "(", "B", "e", ")", "more", "efficiently", "." ]
train
https://github.com/namuyan/nem-ed25519/blob/4f506a5335eb860a4cf1d102f76fcad93f9a55fc/nem_ed25519/utils.py#L190-L202
namuyan/nem-ed25519
nem_ed25519/utils.py
recover
def recover(y): """ given a value y, recover the preimage x """ p = (y*y - 1) * inverse(D*y*y + 1) x = powmod(p, (PRIME+3) // 8, PRIME) if (x*x - p) % PRIME != 0: i = powmod(2, (PRIME-1) // 4, PRIME) x = (x*i) % PRIME if x % 2 != 0: x = PRIME - x return x
python
def recover(y): """ given a value y, recover the preimage x """ p = (y*y - 1) * inverse(D*y*y + 1) x = powmod(p, (PRIME+3) // 8, PRIME) if (x*x - p) % PRIME != 0: i = powmod(2, (PRIME-1) // 4, PRIME) x = (x*i) % PRIME if x % 2 != 0: x = PRIME - x return x
[ "def", "recover", "(", "y", ")", ":", "p", "=", "(", "y", "*", "y", "-", "1", ")", "*", "inverse", "(", "D", "*", "y", "*", "y", "+", "1", ")", "x", "=", "powmod", "(", "p", ",", "(", "PRIME", "+", "3", ")", "//", "8", ",", "PRIME", "...
given a value y, recover the preimage x
[ "given", "a", "value", "y", "recover", "the", "preimage", "x" ]
train
https://github.com/namuyan/nem-ed25519/blob/4f506a5335eb860a4cf1d102f76fcad93f9a55fc/nem_ed25519/utils.py#L263-L272
bmcfee/pyrubberband
pyrubberband/pyrb.py
__rubberband
def __rubberband(y, sr, **kwargs): '''Execute rubberband Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 sampling rate of y **kwargs keyword arguments to rubberband Returns ------- y...
python
def __rubberband(y, sr, **kwargs): '''Execute rubberband Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 sampling rate of y **kwargs keyword arguments to rubberband Returns ------- y...
[ "def", "__rubberband", "(", "y", ",", "sr", ",", "*", "*", "kwargs", ")", ":", "assert", "sr", ">", "0", "# Get the input and output tempfile", "fd", ",", "infile", "=", "tempfile", ".", "mkstemp", "(", "suffix", "=", "'.wav'", ")", "os", ".", "close", ...
Execute rubberband Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 sampling rate of y **kwargs keyword arguments to rubberband Returns ------- y_mod : np.ndarray [shape=(n,) or (n, c)] ...
[ "Execute", "rubberband" ]
train
https://github.com/bmcfee/pyrubberband/blob/3644d1688be27e334b0b06744e7b1149eaea47e0/pyrubberband/pyrb.py#L32-L94
bmcfee/pyrubberband
pyrubberband/pyrb.py
time_stretch
def time_stretch(y, sr, rate, rbargs=None): '''Apply a time stretch of `rate` to an audio time series. This uses the `tempo` form for rubberband, so the higher the rate, the faster the playback. Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either sing...
python
def time_stretch(y, sr, rate, rbargs=None): '''Apply a time stretch of `rate` to an audio time series. This uses the `tempo` form for rubberband, so the higher the rate, the faster the playback. Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either sing...
[ "def", "time_stretch", "(", "y", ",", "sr", ",", "rate", ",", "rbargs", "=", "None", ")", ":", "if", "rate", "<=", "0", ":", "raise", "ValueError", "(", "'rate must be strictly positive'", ")", "if", "rate", "==", "1.0", ":", "return", "y", "if", "rbar...
Apply a time stretch of `rate` to an audio time series. This uses the `tempo` form for rubberband, so the higher the rate, the faster the playback. Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 Sampli...
[ "Apply", "a", "time", "stretch", "of", "rate", "to", "an", "audio", "time", "series", "." ]
train
https://github.com/bmcfee/pyrubberband/blob/3644d1688be27e334b0b06744e7b1149eaea47e0/pyrubberband/pyrb.py#L97-L142
bmcfee/pyrubberband
pyrubberband/pyrb.py
timemap_stretch
def timemap_stretch(y, sr, time_map, rbargs=None): '''Apply a timemap stretch to an audio time series. A timemap stretch allows non-linear time-stretching by mapping source to target sample frame numbers for fixed time points within the audio data. This uses the `time` and `timemap` form for rubberban...
python
def timemap_stretch(y, sr, time_map, rbargs=None): '''Apply a timemap stretch to an audio time series. A timemap stretch allows non-linear time-stretching by mapping source to target sample frame numbers for fixed time points within the audio data. This uses the `time` and `timemap` form for rubberban...
[ "def", "timemap_stretch", "(", "y", ",", "sr", ",", "time_map", ",", "rbargs", "=", "None", ")", ":", "if", "rbargs", "is", "None", ":", "rbargs", "=", "dict", "(", ")", "is_positive", "=", "all", "(", "time_map", "[", "i", "]", "[", "0", "]", ">...
Apply a timemap stretch to an audio time series. A timemap stretch allows non-linear time-stretching by mapping source to target sample frame numbers for fixed time points within the audio data. This uses the `time` and `timemap` form for rubberband. Parameters ---------- y : np.ndarray [shap...
[ "Apply", "a", "timemap", "stretch", "to", "an", "audio", "time", "series", "." ]
train
https://github.com/bmcfee/pyrubberband/blob/3644d1688be27e334b0b06744e7b1149eaea47e0/pyrubberband/pyrb.py#L145-L221
bmcfee/pyrubberband
pyrubberband/pyrb.py
pitch_shift
def pitch_shift(y, sr, n_steps, rbargs=None): '''Apply a pitch shift to an audio time series. Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 Sampling rate of `y` n_steps : float Shift by `n_step...
python
def pitch_shift(y, sr, n_steps, rbargs=None): '''Apply a pitch shift to an audio time series. Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 Sampling rate of `y` n_steps : float Shift by `n_step...
[ "def", "pitch_shift", "(", "y", ",", "sr", ",", "n_steps", ",", "rbargs", "=", "None", ")", ":", "if", "n_steps", "==", "0", ":", "return", "y", "if", "rbargs", "is", "None", ":", "rbargs", "=", "dict", "(", ")", "rbargs", ".", "setdefault", "(", ...
Apply a pitch shift to an audio time series. Parameters ---------- y : np.ndarray [shape=(n,) or (n, c)] Audio time series, either single or multichannel sr : int > 0 Sampling rate of `y` n_steps : float Shift by `n_steps` semitones. rbargs Additional keyword ...
[ "Apply", "a", "pitch", "shift", "to", "an", "audio", "time", "series", "." ]
train
https://github.com/bmcfee/pyrubberband/blob/3644d1688be27e334b0b06744e7b1149eaea47e0/pyrubberband/pyrb.py#L224-L257
cihai/cihai
cihai/conversion.py
kuten_to_gb2312
def kuten_to_gb2312(kuten): """ Convert GB kuten / quwei form (94 zones * 94 points) to GB2312-1980 / ISO-2022-CN hex (internal representation) """ zone, point = int(kuten[:2]), int(kuten[2:]) hi, lo = hexd(zone + 0x20), hexd(point + 0x20) gb2312 = "%s%s" % (hi, lo) assert isinstance(g...
python
def kuten_to_gb2312(kuten): """ Convert GB kuten / quwei form (94 zones * 94 points) to GB2312-1980 / ISO-2022-CN hex (internal representation) """ zone, point = int(kuten[:2]), int(kuten[2:]) hi, lo = hexd(zone + 0x20), hexd(point + 0x20) gb2312 = "%s%s" % (hi, lo) assert isinstance(g...
[ "def", "kuten_to_gb2312", "(", "kuten", ")", ":", "zone", ",", "point", "=", "int", "(", "kuten", "[", ":", "2", "]", ")", ",", "int", "(", "kuten", "[", "2", ":", "]", ")", "hi", ",", "lo", "=", "hexd", "(", "zone", "+", "0x20", ")", ",", ...
Convert GB kuten / quwei form (94 zones * 94 points) to GB2312-1980 / ISO-2022-CN hex (internal representation)
[ "Convert", "GB", "kuten", "/", "quwei", "form", "(", "94", "zones", "*", "94", "points", ")", "to", "GB2312", "-", "1980", "/", "ISO", "-", "2022", "-", "CN", "hex", "(", "internal", "representation", ")" ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/conversion.py#L77-L88
cihai/cihai
cihai/conversion.py
gb2312_to_euc
def gb2312_to_euc(gb2312hex): """ Convert GB2312-1980 hex (internal representation) to EUC-CN hex (the "external encoding") """ hi, lo = int(gb2312hex[:2], 16), int(gb2312hex[2:], 16) hi, lo = hexd(hi + 0x80), hexd(lo + 0x80) euc = "%s%s" % (hi, lo) assert isinstance(euc, bytes) ret...
python
def gb2312_to_euc(gb2312hex): """ Convert GB2312-1980 hex (internal representation) to EUC-CN hex (the "external encoding") """ hi, lo = int(gb2312hex[:2], 16), int(gb2312hex[2:], 16) hi, lo = hexd(hi + 0x80), hexd(lo + 0x80) euc = "%s%s" % (hi, lo) assert isinstance(euc, bytes) ret...
[ "def", "gb2312_to_euc", "(", "gb2312hex", ")", ":", "hi", ",", "lo", "=", "int", "(", "gb2312hex", "[", ":", "2", "]", ",", "16", ")", ",", "int", "(", "gb2312hex", "[", "2", ":", "]", ",", "16", ")", "hi", ",", "lo", "=", "hexd", "(", "hi", ...
Convert GB2312-1980 hex (internal representation) to EUC-CN hex (the "external encoding")
[ "Convert", "GB2312", "-", "1980", "hex", "(", "internal", "representation", ")", "to", "EUC", "-", "CN", "hex", "(", "the", "external", "encoding", ")" ]
train
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/conversion.py#L91-L101