repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
loads/molotov | molotov/util.py | request | def request(endpoint, verb='GET', session_options=None, **options):
"""Performs a synchronous request.
Uses a dedicated event loop and aiohttp.ClientSession object.
Options:
- endpoint: the endpoint to call
- verb: the HTTP verb to use (defaults: GET)
- session_options: a dict containing opti... | python | def request(endpoint, verb='GET', session_options=None, **options):
"""Performs a synchronous request.
Uses a dedicated event loop and aiohttp.ClientSession object.
Options:
- endpoint: the endpoint to call
- verb: the HTTP verb to use (defaults: GET)
- session_options: a dict containing opti... | [
"def",
"request",
"(",
"endpoint",
",",
"verb",
"=",
"'GET'",
",",
"session_options",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"req",
"=",
"functools",
".",
"partial",
"(",
"_request",
",",
"endpoint",
",",
"verb",
",",
"session_options",
",",
... | Performs a synchronous request.
Uses a dedicated event loop and aiohttp.ClientSession object.
Options:
- endpoint: the endpoint to call
- verb: the HTTP verb to use (defaults: GET)
- session_options: a dict containing options to initialize the session
(defaults: None)
- options: extra o... | [
"Performs",
"a",
"synchronous",
"request",
"."
] | train | https://github.com/loads/molotov/blob/bd2c94e7f250e1fbb21940f02c68b4437655bc11/molotov/util.py#L179-L200 |
loads/molotov | molotov/util.py | json_request | def json_request(endpoint, verb='GET', session_options=None, **options):
"""Like :func:`molotov.request` but extracts json from the response.
"""
req = functools.partial(_request, endpoint, verb, session_options,
json=True, **options)
return _run_in_fresh_loop(req) | python | def json_request(endpoint, verb='GET', session_options=None, **options):
"""Like :func:`molotov.request` but extracts json from the response.
"""
req = functools.partial(_request, endpoint, verb, session_options,
json=True, **options)
return _run_in_fresh_loop(req) | [
"def",
"json_request",
"(",
"endpoint",
",",
"verb",
"=",
"'GET'",
",",
"session_options",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"req",
"=",
"functools",
".",
"partial",
"(",
"_request",
",",
"endpoint",
",",
"verb",
",",
"session_options",
",... | Like :func:`molotov.request` but extracts json from the response. | [
"Like",
":",
"func",
":",
"molotov",
".",
"request",
"but",
"extracts",
"json",
"from",
"the",
"response",
"."
] | train | https://github.com/loads/molotov/blob/bd2c94e7f250e1fbb21940f02c68b4437655bc11/molotov/util.py#L203-L208 |
loads/molotov | molotov/util.py | get_var | def get_var(name, factory=None):
"""Gets a global variable given its name.
If factory is not None and the variable is not set, factory
is a callable that will set the variable.
If not set, returns None.
"""
if name not in _VARS and factory is not None:
_VARS[name] = factory()
retur... | python | def get_var(name, factory=None):
"""Gets a global variable given its name.
If factory is not None and the variable is not set, factory
is a callable that will set the variable.
If not set, returns None.
"""
if name not in _VARS and factory is not None:
_VARS[name] = factory()
retur... | [
"def",
"get_var",
"(",
"name",
",",
"factory",
"=",
"None",
")",
":",
"if",
"name",
"not",
"in",
"_VARS",
"and",
"factory",
"is",
"not",
"None",
":",
"_VARS",
"[",
"name",
"]",
"=",
"factory",
"(",
")",
"return",
"_VARS",
".",
"get",
"(",
"name",
... | Gets a global variable given its name.
If factory is not None and the variable is not set, factory
is a callable that will set the variable.
If not set, returns None. | [
"Gets",
"a",
"global",
"variable",
"given",
"its",
"name",
"."
] | train | https://github.com/loads/molotov/blob/bd2c94e7f250e1fbb21940f02c68b4437655bc11/molotov/util.py#L225-L235 |
loads/molotov | molotov/worker.py | Worker.step | async def step(self, step_id, session, scenario=None):
""" single scenario call.
When it returns 1, it works. -1 the script failed,
0 the test is stopping or needs to stop.
"""
if scenario is None:
scenario = pick_scenario(self.wid, step_id)
try:
... | python | async def step(self, step_id, session, scenario=None):
""" single scenario call.
When it returns 1, it works. -1 the script failed,
0 the test is stopping or needs to stop.
"""
if scenario is None:
scenario = pick_scenario(self.wid, step_id)
try:
... | [
"async",
"def",
"step",
"(",
"self",
",",
"step_id",
",",
"session",
",",
"scenario",
"=",
"None",
")",
":",
"if",
"scenario",
"is",
"None",
":",
"scenario",
"=",
"pick_scenario",
"(",
"self",
".",
"wid",
",",
"step_id",
")",
"try",
":",
"await",
"se... | single scenario call.
When it returns 1, it works. -1 the script failed,
0 the test is stopping or needs to stop. | [
"single",
"scenario",
"call",
"."
] | train | https://github.com/loads/molotov/blob/bd2c94e7f250e1fbb21940f02c68b4437655bc11/molotov/worker.py#L194-L221 |
loads/molotov | molotov/slave.py | main | def main():
"""Moloslave clones a git repo and runs a molotov test
"""
parser = argparse.ArgumentParser(description='Github-based load test')
parser.add_argument('--version', action='store_true', default=False,
help='Displays version and exits.')
parser.add_argument('--virt... | python | def main():
"""Moloslave clones a git repo and runs a molotov test
"""
parser = argparse.ArgumentParser(description='Github-based load test')
parser.add_argument('--version', action='store_true', default=False,
help='Displays version and exits.')
parser.add_argument('--virt... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Github-based load test'",
")",
"parser",
".",
"add_argument",
"(",
"'--version'",
",",
"action",
"=",
"'store_true'",
",",
"default",
"=",
"False",
",",
... | Moloslave clones a git repo and runs a molotov test | [
"Moloslave",
"clones",
"a",
"git",
"repo",
"and",
"runs",
"a",
"molotov",
"test"
] | train | https://github.com/loads/molotov/blob/bd2c94e7f250e1fbb21940f02c68b4437655bc11/molotov/slave.py#L62-L122 |
joeyespo/gitpress | gitpress/helpers.py | remove_directory | def remove_directory(directory, show_warnings=True):
"""Deletes a directory and its contents.
Returns a list of errors in form (function, path, excinfo)."""
errors = []
def onerror(function, path, excinfo):
if show_warnings:
print 'Cannot delete %s: %s' % (os.path.relpath(directory)... | python | def remove_directory(directory, show_warnings=True):
"""Deletes a directory and its contents.
Returns a list of errors in form (function, path, excinfo)."""
errors = []
def onerror(function, path, excinfo):
if show_warnings:
print 'Cannot delete %s: %s' % (os.path.relpath(directory)... | [
"def",
"remove_directory",
"(",
"directory",
",",
"show_warnings",
"=",
"True",
")",
":",
"errors",
"=",
"[",
"]",
"def",
"onerror",
"(",
"function",
",",
"path",
",",
"excinfo",
")",
":",
"if",
"show_warnings",
":",
"print",
"'Cannot delete %s: %s'",
"%",
... | Deletes a directory and its contents.
Returns a list of errors in form (function, path, excinfo). | [
"Deletes",
"a",
"directory",
"and",
"its",
"contents",
".",
"Returns",
"a",
"list",
"of",
"errors",
"in",
"form",
"(",
"function",
"path",
"excinfo",
")",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/helpers.py#L13-L28 |
joeyespo/gitpress | gitpress/helpers.py | copy_files | def copy_files(source_files, target_directory, source_directory=None):
"""Copies a list of files to the specified directory.
If source_directory is provided, it will be prepended to each source file."""
try:
os.makedirs(target_directory)
except: # TODO: specific exception?
pass
f... | python | def copy_files(source_files, target_directory, source_directory=None):
"""Copies a list of files to the specified directory.
If source_directory is provided, it will be prepended to each source file."""
try:
os.makedirs(target_directory)
except: # TODO: specific exception?
pass
f... | [
"def",
"copy_files",
"(",
"source_files",
",",
"target_directory",
",",
"source_directory",
"=",
"None",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"target_directory",
")",
"except",
":",
"# TODO: specific exception?",
"pass",
"for",
"f",
"in",
"source_fi... | Copies a list of files to the specified directory.
If source_directory is provided, it will be prepended to each source file. | [
"Copies",
"a",
"list",
"of",
"files",
"to",
"the",
"specified",
"directory",
".",
"If",
"source_directory",
"is",
"provided",
"it",
"will",
"be",
"prepended",
"to",
"each",
"source",
"file",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/helpers.py#L31-L41 |
joeyespo/gitpress | gitpress/helpers.py | yes_or_no | def yes_or_no(message):
"""Gets user input and returns True for yes and False for no."""
while True:
print message, '(yes/no)',
line = raw_input()
if line is None:
return None
line = line.lower()
if line == 'y' or line == 'ye' or line == 'yes':
ret... | python | def yes_or_no(message):
"""Gets user input and returns True for yes and False for no."""
while True:
print message, '(yes/no)',
line = raw_input()
if line is None:
return None
line = line.lower()
if line == 'y' or line == 'ye' or line == 'yes':
ret... | [
"def",
"yes_or_no",
"(",
"message",
")",
":",
"while",
"True",
":",
"print",
"message",
",",
"'(yes/no)'",
",",
"line",
"=",
"raw_input",
"(",
")",
"if",
"line",
"is",
"None",
":",
"return",
"None",
"line",
"=",
"line",
".",
"lower",
"(",
")",
"if",
... | Gets user input and returns True for yes and False for no. | [
"Gets",
"user",
"input",
"and",
"returns",
"True",
"for",
"yes",
"and",
"False",
"for",
"no",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/helpers.py#L44-L55 |
joeyespo/gitpress | gitpress/plugins.py | list_plugins | def list_plugins(directory=None):
"""Gets a list of the installed themes."""
repo = require_repo(directory)
plugins = get_value(repo, 'plugins')
if not plugins or not isinstance(plugins, dict):
return None
return plugins.keys() | python | def list_plugins(directory=None):
"""Gets a list of the installed themes."""
repo = require_repo(directory)
plugins = get_value(repo, 'plugins')
if not plugins or not isinstance(plugins, dict):
return None
return plugins.keys() | [
"def",
"list_plugins",
"(",
"directory",
"=",
"None",
")",
":",
"repo",
"=",
"require_repo",
"(",
"directory",
")",
"plugins",
"=",
"get_value",
"(",
"repo",
",",
"'plugins'",
")",
"if",
"not",
"plugins",
"or",
"not",
"isinstance",
"(",
"plugins",
",",
"... | Gets a list of the installed themes. | [
"Gets",
"a",
"list",
"of",
"the",
"installed",
"themes",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/plugins.py#L5-L11 |
joeyespo/gitpress | gitpress/plugins.py | add_plugin | def add_plugin(plugin, directory=None):
"""Adds the specified plugin. This returns False if it was already added."""
repo = require_repo(directory)
plugins = get_value(repo, 'plugins', expect_type=dict)
if plugin in plugins:
return False
plugins[plugin] = {}
set_value(repo, 'plugins', p... | python | def add_plugin(plugin, directory=None):
"""Adds the specified plugin. This returns False if it was already added."""
repo = require_repo(directory)
plugins = get_value(repo, 'plugins', expect_type=dict)
if plugin in plugins:
return False
plugins[plugin] = {}
set_value(repo, 'plugins', p... | [
"def",
"add_plugin",
"(",
"plugin",
",",
"directory",
"=",
"None",
")",
":",
"repo",
"=",
"require_repo",
"(",
"directory",
")",
"plugins",
"=",
"get_value",
"(",
"repo",
",",
"'plugins'",
",",
"expect_type",
"=",
"dict",
")",
"if",
"plugin",
"in",
"plug... | Adds the specified plugin. This returns False if it was already added. | [
"Adds",
"the",
"specified",
"plugin",
".",
"This",
"returns",
"False",
"if",
"it",
"was",
"already",
"added",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/plugins.py#L14-L23 |
joeyespo/gitpress | gitpress/plugins.py | get_plugin_settings | def get_plugin_settings(plugin, directory=None):
"""Gets the settings for the specified plugin."""
repo = require_repo(directory)
plugins = get_value(repo, 'plugins')
return plugins.get(plugin) if isinstance(plugins, dict) else None | python | def get_plugin_settings(plugin, directory=None):
"""Gets the settings for the specified plugin."""
repo = require_repo(directory)
plugins = get_value(repo, 'plugins')
return plugins.get(plugin) if isinstance(plugins, dict) else None | [
"def",
"get_plugin_settings",
"(",
"plugin",
",",
"directory",
"=",
"None",
")",
":",
"repo",
"=",
"require_repo",
"(",
"directory",
")",
"plugins",
"=",
"get_value",
"(",
"repo",
",",
"'plugins'",
")",
"return",
"plugins",
".",
"get",
"(",
"plugin",
")",
... | Gets the settings for the specified plugin. | [
"Gets",
"the",
"settings",
"for",
"the",
"specified",
"plugin",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/plugins.py#L38-L42 |
joeyespo/gitpress | gitpress/previewing.py | preview | def preview(directory=None, host=None, port=None, watch=True):
"""Runs a local server to preview the working directory of a repository."""
directory = directory or '.'
host = host or '127.0.0.1'
port = port or 5000
# TODO: admin interface
# TODO: use cache_only to keep from modifying output di... | python | def preview(directory=None, host=None, port=None, watch=True):
"""Runs a local server to preview the working directory of a repository."""
directory = directory or '.'
host = host or '127.0.0.1'
port = port or 5000
# TODO: admin interface
# TODO: use cache_only to keep from modifying output di... | [
"def",
"preview",
"(",
"directory",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"watch",
"=",
"True",
")",
":",
"directory",
"=",
"directory",
"or",
"'.'",
"host",
"=",
"host",
"or",
"'127.0.0.1'",
"port",
"=",
"port",
"or",... | Runs a local server to preview the working directory of a repository. | [
"Runs",
"a",
"local",
"server",
"to",
"preview",
"the",
"working",
"directory",
"of",
"a",
"repository",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/previewing.py#L7-L23 |
joeyespo/gitpress | gitpress/repository.py | require_repo | def require_repo(directory=None):
"""Checks for a presentation repository and raises an exception if not found."""
if directory and not os.path.isdir(directory):
raise ValueError('Directory not found: ' + repr(directory))
repo = repo_path(directory)
if not os.path.isdir(repo):
raise Repo... | python | def require_repo(directory=None):
"""Checks for a presentation repository and raises an exception if not found."""
if directory and not os.path.isdir(directory):
raise ValueError('Directory not found: ' + repr(directory))
repo = repo_path(directory)
if not os.path.isdir(repo):
raise Repo... | [
"def",
"require_repo",
"(",
"directory",
"=",
"None",
")",
":",
"if",
"directory",
"and",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"raise",
"ValueError",
"(",
"'Directory not found: '",
"+",
"repr",
"(",
"directory",
")",
")",
... | Checks for a presentation repository and raises an exception if not found. | [
"Checks",
"for",
"a",
"presentation",
"repository",
"and",
"raises",
"an",
"exception",
"if",
"not",
"found",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/repository.py#L30-L37 |
joeyespo/gitpress | gitpress/repository.py | init | def init(directory=None):
"""Initializes a Gitpress presentation repository at the specified directory."""
repo = repo_path(directory)
if os.path.isdir(repo):
raise RepositoryAlreadyExistsError(directory, repo)
# Initialize repository with default template
shutil.copytree(default_template_p... | python | def init(directory=None):
"""Initializes a Gitpress presentation repository at the specified directory."""
repo = repo_path(directory)
if os.path.isdir(repo):
raise RepositoryAlreadyExistsError(directory, repo)
# Initialize repository with default template
shutil.copytree(default_template_p... | [
"def",
"init",
"(",
"directory",
"=",
"None",
")",
":",
"repo",
"=",
"repo_path",
"(",
"directory",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"repo",
")",
":",
"raise",
"RepositoryAlreadyExistsError",
"(",
"directory",
",",
"repo",
")",
"# Initial... | Initializes a Gitpress presentation repository at the specified directory. | [
"Initializes",
"a",
"Gitpress",
"presentation",
"repository",
"at",
"the",
"specified",
"directory",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/repository.py#L45-L59 |
joeyespo/gitpress | gitpress/repository.py | iterate_presentation_files | def iterate_presentation_files(path=None, excludes=None, includes=None):
"""Iterates the repository presentation files relative to 'path',
not including themes. Note that 'includes' take priority."""
# Defaults
if includes is None:
includes = []
if excludes is None:
excludes = []
... | python | def iterate_presentation_files(path=None, excludes=None, includes=None):
"""Iterates the repository presentation files relative to 'path',
not including themes. Note that 'includes' take priority."""
# Defaults
if includes is None:
includes = []
if excludes is None:
excludes = []
... | [
"def",
"iterate_presentation_files",
"(",
"path",
"=",
"None",
",",
"excludes",
"=",
"None",
",",
"includes",
"=",
"None",
")",
":",
"# Defaults",
"if",
"includes",
"is",
"None",
":",
"includes",
"=",
"[",
"]",
"if",
"excludes",
"is",
"None",
":",
"exclu... | Iterates the repository presentation files relative to 'path',
not including themes. Note that 'includes' take priority. | [
"Iterates",
"the",
"repository",
"presentation",
"files",
"relative",
"to",
"path",
"not",
"including",
"themes",
".",
"Note",
"that",
"includes",
"take",
"priority",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/repository.py#L68-L99 |
joeyespo/gitpress | gitpress/config.py | read_config_file | def read_config_file(path):
"""Returns the configuration from the specified file."""
try:
with open(path, 'r') as f:
return json.load(f, object_pairs_hook=OrderedDict)
except IOError as ex:
if ex != errno.ENOENT:
raise
return {} | python | def read_config_file(path):
"""Returns the configuration from the specified file."""
try:
with open(path, 'r') as f:
return json.load(f, object_pairs_hook=OrderedDict)
except IOError as ex:
if ex != errno.ENOENT:
raise
return {} | [
"def",
"read_config_file",
"(",
"path",
")",
":",
"try",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
",",
"object_pairs_hook",
"=",
"OrderedDict",
")",
"except",
"IOError",
"as",
"ex",
"... | Returns the configuration from the specified file. | [
"Returns",
"the",
"configuration",
"from",
"the",
"specified",
"file",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/config.py#L23-L31 |
joeyespo/gitpress | gitpress/config.py | write_config | def write_config(repo_directory, config):
"""Writes the specified configuration to the presentation repository."""
return write_config_file(os.path.join(repo_directory, config_file), config) | python | def write_config(repo_directory, config):
"""Writes the specified configuration to the presentation repository."""
return write_config_file(os.path.join(repo_directory, config_file), config) | [
"def",
"write_config",
"(",
"repo_directory",
",",
"config",
")",
":",
"return",
"write_config_file",
"(",
"os",
".",
"path",
".",
"join",
"(",
"repo_directory",
",",
"config_file",
")",
",",
"config",
")"
] | Writes the specified configuration to the presentation repository. | [
"Writes",
"the",
"specified",
"configuration",
"to",
"the",
"presentation",
"repository",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/config.py#L34-L36 |
joeyespo/gitpress | gitpress/config.py | write_config_file | def write_config_file(path, config):
"""Writes the specified configuration to the specified file."""
contents = json.dumps(config, indent=4, separators=(',', ': ')) + '\n'
try:
with open(path, 'w') as f:
f.write(contents)
return True
except IOError as ex:
if ex != err... | python | def write_config_file(path, config):
"""Writes the specified configuration to the specified file."""
contents = json.dumps(config, indent=4, separators=(',', ': ')) + '\n'
try:
with open(path, 'w') as f:
f.write(contents)
return True
except IOError as ex:
if ex != err... | [
"def",
"write_config_file",
"(",
"path",
",",
"config",
")",
":",
"contents",
"=",
"json",
".",
"dumps",
"(",
"config",
",",
"indent",
"=",
"4",
",",
"separators",
"=",
"(",
"','",
",",
"': '",
")",
")",
"+",
"'\\n'",
"try",
":",
"with",
"open",
"(... | Writes the specified configuration to the specified file. | [
"Writes",
"the",
"specified",
"configuration",
"to",
"the",
"specified",
"file",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/config.py#L39-L49 |
joeyespo/gitpress | gitpress/config.py | get_value | def get_value(repo_directory, key, expect_type=None):
"""Gets the value of the specified key in the config file."""
config = read_config(repo_directory)
value = config.get(key)
if expect_type and value is not None and not isinstance(value, expect_type):
raise ConfigSchemaError('Expected config v... | python | def get_value(repo_directory, key, expect_type=None):
"""Gets the value of the specified key in the config file."""
config = read_config(repo_directory)
value = config.get(key)
if expect_type and value is not None and not isinstance(value, expect_type):
raise ConfigSchemaError('Expected config v... | [
"def",
"get_value",
"(",
"repo_directory",
",",
"key",
",",
"expect_type",
"=",
"None",
")",
":",
"config",
"=",
"read_config",
"(",
"repo_directory",
")",
"value",
"=",
"config",
".",
"get",
"(",
"key",
")",
"if",
"expect_type",
"and",
"value",
"is",
"n... | Gets the value of the specified key in the config file. | [
"Gets",
"the",
"value",
"of",
"the",
"specified",
"key",
"in",
"the",
"config",
"file",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/config.py#L52-L59 |
joeyespo/gitpress | gitpress/config.py | set_value | def set_value(repo_directory, key, value, strict=True):
"""Sets the value of a particular key in the config file. This has no effect when setting to the same value."""
if value is None:
raise ValueError('Argument "value" must not be None.')
# Read values and do nothing if not making any changes
... | python | def set_value(repo_directory, key, value, strict=True):
"""Sets the value of a particular key in the config file. This has no effect when setting to the same value."""
if value is None:
raise ValueError('Argument "value" must not be None.')
# Read values and do nothing if not making any changes
... | [
"def",
"set_value",
"(",
"repo_directory",
",",
"key",
",",
"value",
",",
"strict",
"=",
"True",
")",
":",
"if",
"value",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Argument \"value\" must not be None.'",
")",
"# Read values and do nothing if not making any chan... | Sets the value of a particular key in the config file. This has no effect when setting to the same value. | [
"Sets",
"the",
"value",
"of",
"a",
"particular",
"key",
"in",
"the",
"config",
"file",
".",
"This",
"has",
"no",
"effect",
"when",
"setting",
"to",
"the",
"same",
"value",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/config.py#L62-L81 |
joeyespo/gitpress | gitpress/building.py | build | def build(content_directory=None, out_directory=None):
"""Builds the site from its content and presentation repository."""
content_directory = content_directory or '.'
out_directory = os.path.abspath(out_directory or default_out_directory)
repo = require_repo(content_directory)
# Prevent user mista... | python | def build(content_directory=None, out_directory=None):
"""Builds the site from its content and presentation repository."""
content_directory = content_directory or '.'
out_directory = os.path.abspath(out_directory or default_out_directory)
repo = require_repo(content_directory)
# Prevent user mista... | [
"def",
"build",
"(",
"content_directory",
"=",
"None",
",",
"out_directory",
"=",
"None",
")",
":",
"content_directory",
"=",
"content_directory",
"or",
"'.'",
"out_directory",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"out_directory",
"or",
"default_out_dire... | Builds the site from its content and presentation repository. | [
"Builds",
"the",
"site",
"from",
"its",
"content",
"and",
"presentation",
"repository",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/building.py#L9-L31 |
joeyespo/gitpress | gitpress/command.py | main | def main(argv=None):
"""The entry point of the application."""
if argv is None:
argv = sys.argv[1:]
usage = '\n\n\n'.join(__doc__.split('\n\n\n')[1:])
version = 'Gitpress ' + __version__
# Parse options
args = docopt(usage, argv=argv, version=version)
# Execute command
try:
... | python | def main(argv=None):
"""The entry point of the application."""
if argv is None:
argv = sys.argv[1:]
usage = '\n\n\n'.join(__doc__.split('\n\n\n')[1:])
version = 'Gitpress ' + __version__
# Parse options
args = docopt(usage, argv=argv, version=version)
# Execute command
try:
... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"usage",
"=",
"'\\n\\n\\n'",
".",
"join",
"(",
"__doc__",
".",
"split",
"(",
"'\\n\\n\\n'",
")",
"[",
"1",
... | The entry point of the application. | [
"The",
"entry",
"point",
"of",
"the",
"application",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/command.py#L40-L54 |
joeyespo/gitpress | gitpress/command.py | execute | def execute(args):
"""Executes the command indicated by the specified parsed arguments."""
def info(*message):
"""Displays a message unless -q was specified."""
if not args['-q']:
print ' '.join(map(str, message))
if args['init']:
try:
repo = init(args['<dir... | python | def execute(args):
"""Executes the command indicated by the specified parsed arguments."""
def info(*message):
"""Displays a message unless -q was specified."""
if not args['-q']:
print ' '.join(map(str, message))
if args['init']:
try:
repo = init(args['<dir... | [
"def",
"execute",
"(",
"args",
")",
":",
"def",
"info",
"(",
"*",
"message",
")",
":",
"\"\"\"Displays a message unless -q was specified.\"\"\"",
"if",
"not",
"args",
"[",
"'-q'",
"]",
":",
"print",
"' '",
".",
"join",
"(",
"map",
"(",
"str",
",",
"message... | Executes the command indicated by the specified parsed arguments. | [
"Executes",
"the",
"command",
"indicated",
"by",
"the",
"specified",
"parsed",
"arguments",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/command.py#L57-L145 |
joeyespo/gitpress | gitpress/command.py | gpp | def gpp(argv=None):
"""Shortcut function for running the previewing command."""
if argv is None:
argv = sys.argv[1:]
argv.insert(0, 'preview')
return main(argv) | python | def gpp(argv=None):
"""Shortcut function for running the previewing command."""
if argv is None:
argv = sys.argv[1:]
argv.insert(0, 'preview')
return main(argv) | [
"def",
"gpp",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"argv",
".",
"insert",
"(",
"0",
",",
"'preview'",
")",
"return",
"main",
"(",
"argv",
")"
] | Shortcut function for running the previewing command. | [
"Shortcut",
"function",
"for",
"running",
"the",
"previewing",
"command",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/command.py#L152-L157 |
joeyespo/gitpress | gitpress/themes.py | list_themes | def list_themes(directory=None):
"""Gets a list of the installed themes."""
repo = require_repo(directory)
path = os.path.join(repo, themes_dir)
return os.listdir(path) if os.path.isdir(path) else None | python | def list_themes(directory=None):
"""Gets a list of the installed themes."""
repo = require_repo(directory)
path = os.path.join(repo, themes_dir)
return os.listdir(path) if os.path.isdir(path) else None | [
"def",
"list_themes",
"(",
"directory",
"=",
"None",
")",
":",
"repo",
"=",
"require_repo",
"(",
"directory",
")",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"repo",
",",
"themes_dir",
")",
"return",
"os",
".",
"listdir",
"(",
"path",
")",
"if... | Gets a list of the installed themes. | [
"Gets",
"a",
"list",
"of",
"the",
"installed",
"themes",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/themes.py#L17-L21 |
joeyespo/gitpress | gitpress/themes.py | use_theme | def use_theme(theme, directory=None):
"""Switches to the specified theme. This returns False if switching to the already active theme."""
repo = require_repo(directory)
if theme not in list_themes(directory):
raise ThemeNotFoundError(theme)
old_theme = set_value(repo, 'theme', theme)
return... | python | def use_theme(theme, directory=None):
"""Switches to the specified theme. This returns False if switching to the already active theme."""
repo = require_repo(directory)
if theme not in list_themes(directory):
raise ThemeNotFoundError(theme)
old_theme = set_value(repo, 'theme', theme)
return... | [
"def",
"use_theme",
"(",
"theme",
",",
"directory",
"=",
"None",
")",
":",
"repo",
"=",
"require_repo",
"(",
"directory",
")",
"if",
"theme",
"not",
"in",
"list_themes",
"(",
"directory",
")",
":",
"raise",
"ThemeNotFoundError",
"(",
"theme",
")",
"old_the... | Switches to the specified theme. This returns False if switching to the already active theme. | [
"Switches",
"to",
"the",
"specified",
"theme",
".",
"This",
"returns",
"False",
"if",
"switching",
"to",
"the",
"already",
"active",
"theme",
"."
] | train | https://github.com/joeyespo/gitpress/blob/a23edb80b6e4a113d167217475344a01c92b5c6d/gitpress/themes.py#L24-L31 |
wrobstory/vincent | vincent/properties.py | PropertySet.fill_opacity | def fill_opacity(value):
"""ValueRef : int or float, opacity of the fill (0 to 1)
"""
if value.value:
_assert_is_type('fill_opacity.value', value.value,
(float, int))
if value.value < 0 or value.value > 1:
raise ValueError(
... | python | def fill_opacity(value):
"""ValueRef : int or float, opacity of the fill (0 to 1)
"""
if value.value:
_assert_is_type('fill_opacity.value', value.value,
(float, int))
if value.value < 0 or value.value > 1:
raise ValueError(
... | [
"def",
"fill_opacity",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'fill_opacity.value'",
",",
"value",
".",
"value",
",",
"(",
"float",
",",
"int",
")",
")",
"if",
"value",
".",
"value",
"<",
"0",
"or",
"value",
... | ValueRef : int or float, opacity of the fill (0 to 1) | [
"ValueRef",
":",
"int",
"or",
"float",
"opacity",
"of",
"the",
"fill",
"(",
"0",
"to",
"1",
")"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L89-L97 |
wrobstory/vincent | vincent/properties.py | PropertySet.stroke_width | def stroke_width(value):
"""ValueRef : int, width of the stroke in pixels
"""
if value.value:
_assert_is_type('stroke_width.value', value.value, int)
if value.value < 0:
raise ValueError('stroke width cannot be negative') | python | def stroke_width(value):
"""ValueRef : int, width of the stroke in pixels
"""
if value.value:
_assert_is_type('stroke_width.value', value.value, int)
if value.value < 0:
raise ValueError('stroke width cannot be negative') | [
"def",
"stroke_width",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'stroke_width.value'",
",",
"value",
".",
"value",
",",
"int",
")",
"if",
"value",
".",
"value",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'stroke... | ValueRef : int, width of the stroke in pixels | [
"ValueRef",
":",
"int",
"width",
"of",
"the",
"stroke",
"in",
"pixels"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L111-L117 |
wrobstory/vincent | vincent/properties.py | PropertySet.stroke_opacity | def stroke_opacity(value):
"""ValueRef : number, opacity of the stroke (0 to 1)
"""
if value.value:
_assert_is_type('stroke_opacity.value', value.value,
(float, int))
if value.value < 0 or value.value > 1:
raise ValueError(
... | python | def stroke_opacity(value):
"""ValueRef : number, opacity of the stroke (0 to 1)
"""
if value.value:
_assert_is_type('stroke_opacity.value', value.value,
(float, int))
if value.value < 0 or value.value > 1:
raise ValueError(
... | [
"def",
"stroke_opacity",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'stroke_opacity.value'",
",",
"value",
".",
"value",
",",
"(",
"float",
",",
"int",
")",
")",
"if",
"value",
".",
"value",
"<",
"0",
"or",
"valu... | ValueRef : number, opacity of the stroke (0 to 1) | [
"ValueRef",
":",
"number",
"opacity",
"of",
"the",
"stroke",
"(",
"0",
"to",
"1",
")"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L120-L128 |
wrobstory/vincent | vincent/properties.py | PropertySet.size | def size(value):
"""ValueRef : number, area of the mark in pixels
This is the total area of a symbol. For example, a value of 500 and
a ``shape`` of ``'circle'`` would result in circles with an area of
500 square pixels. Only used if ``type`` is ``'symbol'``.
"""
if valu... | python | def size(value):
"""ValueRef : number, area of the mark in pixels
This is the total area of a symbol. For example, a value of 500 and
a ``shape`` of ``'circle'`` would result in circles with an area of
500 square pixels. Only used if ``type`` is ``'symbol'``.
"""
if valu... | [
"def",
"size",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'size.value'",
",",
"value",
".",
"value",
",",
"int",
")",
"if",
"value",
".",
"value",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'size cannot be negativ... | ValueRef : number, area of the mark in pixels
This is the total area of a symbol. For example, a value of 500 and
a ``shape`` of ``'circle'`` would result in circles with an area of
500 square pixels. Only used if ``type`` is ``'symbol'``. | [
"ValueRef",
":",
"number",
"area",
"of",
"the",
"mark",
"in",
"pixels"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L131-L141 |
wrobstory/vincent | vincent/properties.py | PropertySet.shape | def shape(value):
"""ValueRef : string, type of symbol to use
Possible values are ``'circle'`` (default), ``'square'``,
``'cross'``, ``'diamond'``, ``'triangle-up'``, and
``'triangle-down'``. Only used if ``type`` is ``'symbol'``.
"""
if value.value:
_assert_... | python | def shape(value):
"""ValueRef : string, type of symbol to use
Possible values are ``'circle'`` (default), ``'square'``,
``'cross'``, ``'diamond'``, ``'triangle-up'``, and
``'triangle-down'``. Only used if ``type`` is ``'symbol'``.
"""
if value.value:
_assert_... | [
"def",
"shape",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'shape.value'",
",",
"value",
".",
"value",
",",
"str_types",
")",
"if",
"value",
".",
"value",
"not",
"in",
"PropertySet",
".",
"_valid_shapes",
":",
"rai... | ValueRef : string, type of symbol to use
Possible values are ``'circle'`` (default), ``'square'``,
``'cross'``, ``'diamond'``, ``'triangle-up'``, and
``'triangle-down'``. Only used if ``type`` is ``'symbol'``. | [
"ValueRef",
":",
"string",
"type",
"of",
"symbol",
"to",
"use"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L148-L158 |
wrobstory/vincent | vincent/properties.py | PropertySet.interpolate | def interpolate(value):
"""ValueRef : string, line interpolation method to use
Possible values for ``area`` types are `'linear'`,
``'step-before'``, ``'step-after'``, ``'basis'``, ``'basis-open'``,
``'cardinal'``, ``'cardinal-open'``, ``'monotone'``. ``line`` types
have all valu... | python | def interpolate(value):
"""ValueRef : string, line interpolation method to use
Possible values for ``area`` types are `'linear'`,
``'step-before'``, ``'step-after'``, ``'basis'``, ``'basis-open'``,
``'cardinal'``, ``'cardinal-open'``, ``'monotone'``. ``line`` types
have all valu... | [
"def",
"interpolate",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'shape.value'",
",",
"value",
".",
"value",
",",
"str_types",
")",
"if",
"value",
".",
"value",
"not",
"in",
"PropertySet",
".",
"_valid_methods",
":",... | ValueRef : string, line interpolation method to use
Possible values for ``area`` types are `'linear'`,
``'step-before'``, ``'step-after'``, ``'basis'``, ``'basis-open'``,
``'cardinal'``, ``'cardinal-open'``, ``'monotone'``. ``line`` types
have all values for ``area`` as well as ``'basis... | [
"ValueRef",
":",
"string",
"line",
"interpolation",
"method",
"to",
"use"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L206-L220 |
wrobstory/vincent | vincent/properties.py | PropertySet.align | def align(value):
"""ValueRef : string, horizontal alignment of mark
Possible values are ``'left'``, ``'right'``, and ``'center'``. Only
used if ``type`` is ``'image'`` or ``'text'``.
"""
if value.value:
_assert_is_type('shape.value', value.value, str_types)
... | python | def align(value):
"""ValueRef : string, horizontal alignment of mark
Possible values are ``'left'``, ``'right'``, and ``'center'``. Only
used if ``type`` is ``'image'`` or ``'text'``.
"""
if value.value:
_assert_is_type('shape.value', value.value, str_types)
... | [
"def",
"align",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'shape.value'",
",",
"value",
".",
"value",
",",
"str_types",
")",
"if",
"value",
".",
"value",
"not",
"in",
"PropertySet",
".",
"_valid_align",
":",
"rais... | ValueRef : string, horizontal alignment of mark
Possible values are ``'left'``, ``'right'``, and ``'center'``. Only
used if ``type`` is ``'image'`` or ``'text'``. | [
"ValueRef",
":",
"string",
"horizontal",
"alignment",
"of",
"mark"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L239-L248 |
wrobstory/vincent | vincent/properties.py | PropertySet.baseline | def baseline(value):
"""ValueRef : string, vertical alignment of mark
Possible values are ``'top'``, ``'middle'``, and ``'bottom'``. Only
used if ``type`` is ``'image'`` or ``'text'``.
"""
if value.value:
_assert_is_type('shape.value', value.value, str_types)
... | python | def baseline(value):
"""ValueRef : string, vertical alignment of mark
Possible values are ``'top'``, ``'middle'``, and ``'bottom'``. Only
used if ``type`` is ``'image'`` or ``'text'``.
"""
if value.value:
_assert_is_type('shape.value', value.value, str_types)
... | [
"def",
"baseline",
"(",
"value",
")",
":",
"if",
"value",
".",
"value",
":",
"_assert_is_type",
"(",
"'shape.value'",
",",
"value",
".",
"value",
",",
"str_types",
")",
"if",
"value",
".",
"value",
"not",
"in",
"PropertySet",
".",
"_valid_baseline",
":",
... | ValueRef : string, vertical alignment of mark
Possible values are ``'top'``, ``'middle'``, and ``'bottom'``. Only
used if ``type`` is ``'image'`` or ``'text'``. | [
"ValueRef",
":",
"string",
"vertical",
"alignment",
"of",
"mark"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/properties.py#L253-L262 |
wrobstory/vincent | vincent/transforms.py | Transform.type | def type(value):
"""string: property name in which to store the computed transform
value.
The valid transform types are as follows:
'array', 'copy', 'cross', 'facet', 'filter', 'flatten', 'fold',
'formula', 'slice', 'sort', 'stats', 'truncate', 'unique', 'window',
'zip',... | python | def type(value):
"""string: property name in which to store the computed transform
value.
The valid transform types are as follows:
'array', 'copy', 'cross', 'facet', 'filter', 'flatten', 'fold',
'formula', 'slice', 'sort', 'stats', 'truncate', 'unique', 'window',
'zip',... | [
"def",
"type",
"(",
"value",
")",
":",
"valid_transforms",
"=",
"frozenset",
"(",
"[",
"'array'",
",",
"'copy'",
",",
"'cross'",
",",
"'facet'",
",",
"'filter'",
",",
"'flatten'",
",",
"'fold'",
",",
"'formula'",
",",
"'slice'",
",",
"'sort'",
",",
"'sta... | string: property name in which to store the computed transform
value.
The valid transform types are as follows:
'array', 'copy', 'cross', 'facet', 'filter', 'flatten', 'fold',
'formula', 'slice', 'sort', 'stats', 'truncate', 'unique', 'window',
'zip', 'force', 'geo', 'geopath', ... | [
"string",
":",
"property",
"name",
"in",
"which",
"to",
"store",
"the",
"computed",
"transform",
"value",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/transforms.py#L28-L49 |
wrobstory/vincent | vincent/charts.py | data_type | def data_type(data, grouped=False, columns=None, key_on='idx', iter_idx=None):
'''Data type check for automatic import'''
if iter_idx:
return Data.from_mult_iters(idx=iter_idx, **data)
if pd:
if isinstance(data, (pd.Series, pd.DataFrame)):
return Data.from_pandas(data, grouped=gr... | python | def data_type(data, grouped=False, columns=None, key_on='idx', iter_idx=None):
'''Data type check for automatic import'''
if iter_idx:
return Data.from_mult_iters(idx=iter_idx, **data)
if pd:
if isinstance(data, (pd.Series, pd.DataFrame)):
return Data.from_pandas(data, grouped=gr... | [
"def",
"data_type",
"(",
"data",
",",
"grouped",
"=",
"False",
",",
"columns",
"=",
"None",
",",
"key_on",
"=",
"'idx'",
",",
"iter_idx",
"=",
"None",
")",
":",
"if",
"iter_idx",
":",
"return",
"Data",
".",
"from_mult_iters",
"(",
"idx",
"=",
"iter_idx... | Data type check for automatic import | [
"Data",
"type",
"check",
"for",
"automatic",
"import"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/charts.py#L28-L39 |
wrobstory/vincent | vincent/charts.py | Map.rebind | def rebind(self, column=None, brew='GnBu'):
"""Bind a new column to the data map
Parameters
----------
column: str, default None
Pandas DataFrame column name
brew: str, default None
Color brewer abbreviation. See colors.py
"""
self.data['... | python | def rebind(self, column=None, brew='GnBu'):
"""Bind a new column to the data map
Parameters
----------
column: str, default None
Pandas DataFrame column name
brew: str, default None
Color brewer abbreviation. See colors.py
"""
self.data['... | [
"def",
"rebind",
"(",
"self",
",",
"column",
"=",
"None",
",",
"brew",
"=",
"'GnBu'",
")",
":",
"self",
".",
"data",
"[",
"'table'",
"]",
"=",
"Data",
".",
"keypairs",
"(",
"self",
".",
"raw_data",
",",
"columns",
"=",
"[",
"self",
".",
"data_key",... | Bind a new column to the data map
Parameters
----------
column: str, default None
Pandas DataFrame column name
brew: str, default None
Color brewer abbreviation. See colors.py | [
"Bind",
"a",
"new",
"column",
"to",
"the",
"data",
"map"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/charts.py#L510-L527 |
wrobstory/vincent | vincent/visualization.py | Visualization.viewport | def viewport(value):
"""2-element list of ints : Dimensions of the viewport
The viewport is a bounding box containing the visualization. If the
dimensions of the visualization are larger than the viewport, then
the visualization will be scrollable.
If undefined, then the full v... | python | def viewport(value):
"""2-element list of ints : Dimensions of the viewport
The viewport is a bounding box containing the visualization. If the
dimensions of the visualization are larger than the viewport, then
the visualization will be scrollable.
If undefined, then the full v... | [
"def",
"viewport",
"(",
"value",
")",
":",
"if",
"len",
"(",
"value",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'viewport must have 2 dimensions'",
")",
"for",
"v",
"in",
"value",
":",
"_assert_is_type",
"(",
"'viewport dimension'",
",",
"v",
",",
... | 2-element list of ints : Dimensions of the viewport
The viewport is a bounding box containing the visualization. If the
dimensions of the visualization are larger than the viewport, then
the visualization will be scrollable.
If undefined, then the full visualization is shown. | [
"2",
"-",
"element",
"list",
"of",
"ints",
":",
"Dimensions",
"of",
"the",
"viewport"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L77-L91 |
wrobstory/vincent | vincent/visualization.py | Visualization.padding | def padding(value):
"""int or dict : Padding around visualization
The padding defines the distance between the edge of the
visualization canvas to the visualization box. It does not count as
part of the visualization width/height. Values cannot be negative.
If a dict, padding m... | python | def padding(value):
"""int or dict : Padding around visualization
The padding defines the distance between the edge of the
visualization canvas to the visualization box. It does not count as
part of the visualization width/height. Values cannot be negative.
If a dict, padding m... | [
"def",
"padding",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"required_keys",
"=",
"[",
"'top'",
",",
"'left'",
",",
"'right'",
",",
"'bottom'",
"]",
"for",
"key",
"in",
"required_keys",
":",
"if",
"key",
"not",
... | int or dict : Padding around visualization
The padding defines the distance between the edge of the
visualization canvas to the visualization box. It does not count as
part of the visualization width/height. Values cannot be negative.
If a dict, padding must have all keys ``''top'``, `... | [
"int",
"or",
"dict",
":",
"Padding",
"around",
"visualization"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L94-L119 |
wrobstory/vincent | vincent/visualization.py | Visualization.data | def data(value):
"""list or KeyedList of ``Data`` : Data definitions
This defines the data being visualized. See the :class:`Data` class
for details.
"""
for i, entry in enumerate(value):
_assert_is_type('data[{0}]'.format(i), entry, Data) | python | def data(value):
"""list or KeyedList of ``Data`` : Data definitions
This defines the data being visualized. See the :class:`Data` class
for details.
"""
for i, entry in enumerate(value):
_assert_is_type('data[{0}]'.format(i), entry, Data) | [
"def",
"data",
"(",
"value",
")",
":",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"value",
")",
":",
"_assert_is_type",
"(",
"'data[{0}]'",
".",
"format",
"(",
"i",
")",
",",
"entry",
",",
"Data",
")"
] | list or KeyedList of ``Data`` : Data definitions
This defines the data being visualized. See the :class:`Data` class
for details. | [
"list",
"or",
"KeyedList",
"of",
"Data",
":",
"Data",
"definitions"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L122-L129 |
wrobstory/vincent | vincent/visualization.py | Visualization.scales | def scales(value):
"""list or KeyedList of ``Scale`` : Scale definitions
Scales map the data from the domain of the data to some
visualization space (such as an x-axis). See the :class:`Scale`
class for details.
"""
for i, entry in enumerate(value):
_assert_i... | python | def scales(value):
"""list or KeyedList of ``Scale`` : Scale definitions
Scales map the data from the domain of the data to some
visualization space (such as an x-axis). See the :class:`Scale`
class for details.
"""
for i, entry in enumerate(value):
_assert_i... | [
"def",
"scales",
"(",
"value",
")",
":",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"value",
")",
":",
"_assert_is_type",
"(",
"'scales[{0}]'",
".",
"format",
"(",
"i",
")",
",",
"entry",
",",
"Scale",
")"
] | list or KeyedList of ``Scale`` : Scale definitions
Scales map the data from the domain of the data to some
visualization space (such as an x-axis). See the :class:`Scale`
class for details. | [
"list",
"or",
"KeyedList",
"of",
"Scale",
":",
"Scale",
"definitions"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L132-L140 |
wrobstory/vincent | vincent/visualization.py | Visualization.axes | def axes(value):
"""list or KeyedList of ``Axis`` : Axis definitions
Axes define the locations of the data being mapped by the scales.
See the :class:`Axis` class for details.
"""
for i, entry in enumerate(value):
_assert_is_type('axes[{0}]'.format(i), entry, Axis) | python | def axes(value):
"""list or KeyedList of ``Axis`` : Axis definitions
Axes define the locations of the data being mapped by the scales.
See the :class:`Axis` class for details.
"""
for i, entry in enumerate(value):
_assert_is_type('axes[{0}]'.format(i), entry, Axis) | [
"def",
"axes",
"(",
"value",
")",
":",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"value",
")",
":",
"_assert_is_type",
"(",
"'axes[{0}]'",
".",
"format",
"(",
"i",
")",
",",
"entry",
",",
"Axis",
")"
] | list or KeyedList of ``Axis`` : Axis definitions
Axes define the locations of the data being mapped by the scales.
See the :class:`Axis` class for details. | [
"list",
"or",
"KeyedList",
"of",
"Axis",
":",
"Axis",
"definitions"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L143-L150 |
wrobstory/vincent | vincent/visualization.py | Visualization.marks | def marks(value):
"""list or KeyedList of ``Mark`` : Mark definitions
Marks are the visual objects (such as lines, bars, etc.) that
represent the data in the visualization space. See the :class:`Mark`
class for details.
"""
for i, entry in enumerate(value):
_... | python | def marks(value):
"""list or KeyedList of ``Mark`` : Mark definitions
Marks are the visual objects (such as lines, bars, etc.) that
represent the data in the visualization space. See the :class:`Mark`
class for details.
"""
for i, entry in enumerate(value):
_... | [
"def",
"marks",
"(",
"value",
")",
":",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"value",
")",
":",
"_assert_is_type",
"(",
"'marks[{0}]'",
".",
"format",
"(",
"i",
")",
",",
"entry",
",",
"Mark",
")"
] | list or KeyedList of ``Mark`` : Mark definitions
Marks are the visual objects (such as lines, bars, etc.) that
represent the data in the visualization space. See the :class:`Mark`
class for details. | [
"list",
"or",
"KeyedList",
"of",
"Mark",
":",
"Mark",
"definitions"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L153-L161 |
wrobstory/vincent | vincent/visualization.py | Visualization.legends | def legends(value):
"""list or KeyedList of ``Legends`` : Legend definitions
Legends visualize scales, and take one or more scales as their input.
They can be customized via a LegendProperty object.
"""
for i, entry in enumerate(value):
_assert_is_type('legends[{0}]'... | python | def legends(value):
"""list or KeyedList of ``Legends`` : Legend definitions
Legends visualize scales, and take one or more scales as their input.
They can be customized via a LegendProperty object.
"""
for i, entry in enumerate(value):
_assert_is_type('legends[{0}]'... | [
"def",
"legends",
"(",
"value",
")",
":",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"value",
")",
":",
"_assert_is_type",
"(",
"'legends[{0}]'",
".",
"format",
"(",
"i",
")",
",",
"entry",
",",
"Legend",
")"
] | list or KeyedList of ``Legends`` : Legend definitions
Legends visualize scales, and take one or more scales as their input.
They can be customized via a LegendProperty object. | [
"list",
"or",
"KeyedList",
"of",
"Legends",
":",
"Legend",
"definitions"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L164-L171 |
wrobstory/vincent | vincent/visualization.py | Visualization.axis_titles | def axis_titles(self, x=None, y=None):
"""Apply axis titles to the figure.
This is a convenience method for manually modifying the "Axes" mark.
Parameters
----------
x: string, default 'null'
X-axis title
y: string, default 'null'
Y-axis title
... | python | def axis_titles(self, x=None, y=None):
"""Apply axis titles to the figure.
This is a convenience method for manually modifying the "Axes" mark.
Parameters
----------
x: string, default 'null'
X-axis title
y: string, default 'null'
Y-axis title
... | [
"def",
"axis_titles",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"keys",
"=",
"self",
".",
"axes",
".",
"get_keys",
"(",
")",
"if",
"keys",
":",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"==",
"'x'",
":",
"self",
... | Apply axis titles to the figure.
This is a convenience method for manually modifying the "Axes" mark.
Parameters
----------
x: string, default 'null'
X-axis title
y: string, default 'null'
Y-axis title
Example
-------
>>>vis.axis... | [
"Apply",
"axis",
"titles",
"to",
"the",
"figure",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L173-L201 |
wrobstory/vincent | vincent/visualization.py | Visualization._set_axis_properties | def _set_axis_properties(self, axis):
"""Set AxisProperties and PropertySets"""
if not getattr(axis, 'properties'):
axis.properties = AxisProperties()
for prop in ['ticks', 'axis', 'major_ticks', 'minor_ticks',
'title', 'labels']:
setattr(... | python | def _set_axis_properties(self, axis):
"""Set AxisProperties and PropertySets"""
if not getattr(axis, 'properties'):
axis.properties = AxisProperties()
for prop in ['ticks', 'axis', 'major_ticks', 'minor_ticks',
'title', 'labels']:
setattr(... | [
"def",
"_set_axis_properties",
"(",
"self",
",",
"axis",
")",
":",
"if",
"not",
"getattr",
"(",
"axis",
",",
"'properties'",
")",
":",
"axis",
".",
"properties",
"=",
"AxisProperties",
"(",
")",
"for",
"prop",
"in",
"[",
"'ticks'",
",",
"'axis'",
",",
... | Set AxisProperties and PropertySets | [
"Set",
"AxisProperties",
"and",
"PropertySets"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L203-L209 |
wrobstory/vincent | vincent/visualization.py | Visualization._set_all_axis_color | def _set_all_axis_color(self, axis, color):
"""Set axis ticks, title, labels to given color"""
for prop in ['ticks', 'axis', 'major_ticks', 'minor_ticks', 'title',
'labels']:
prop_set = getattr(axis.properties, prop)
if color and prop in ['title', 'labels']:
... | python | def _set_all_axis_color(self, axis, color):
"""Set axis ticks, title, labels to given color"""
for prop in ['ticks', 'axis', 'major_ticks', 'minor_ticks', 'title',
'labels']:
prop_set = getattr(axis.properties, prop)
if color and prop in ['title', 'labels']:
... | [
"def",
"_set_all_axis_color",
"(",
"self",
",",
"axis",
",",
"color",
")",
":",
"for",
"prop",
"in",
"[",
"'ticks'",
",",
"'axis'",
",",
"'major_ticks'",
",",
"'minor_ticks'",
",",
"'title'",
",",
"'labels'",
"]",
":",
"prop_set",
"=",
"getattr",
"(",
"a... | Set axis ticks, title, labels to given color | [
"Set",
"axis",
"ticks",
"title",
"labels",
"to",
"given",
"color"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L211-L220 |
wrobstory/vincent | vincent/visualization.py | Visualization._axis_properties | def _axis_properties(self, axis, title_size, title_offset, label_angle,
label_align, color):
"""Assign axis properties"""
if self.axes:
axis = [a for a in self.axes if a.scale == axis][0]
self._set_axis_properties(axis)
self._set_all_axis_colo... | python | def _axis_properties(self, axis, title_size, title_offset, label_angle,
label_align, color):
"""Assign axis properties"""
if self.axes:
axis = [a for a in self.axes if a.scale == axis][0]
self._set_axis_properties(axis)
self._set_all_axis_colo... | [
"def",
"_axis_properties",
"(",
"self",
",",
"axis",
",",
"title_size",
",",
"title_offset",
",",
"label_angle",
",",
"label_align",
",",
"color",
")",
":",
"if",
"self",
".",
"axes",
":",
"axis",
"=",
"[",
"a",
"for",
"a",
"in",
"self",
".",
"axes",
... | Assign axis properties | [
"Assign",
"axis",
"properties"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L222-L239 |
wrobstory/vincent | vincent/visualization.py | Visualization.common_axis_properties | def common_axis_properties(self, color=None, title_size=None):
"""Set common axis properties such as color
Parameters
----------
color: str, default None
Hex color str, etc
"""
if self.axes:
for axis in self.axes:
self._set_axis_pr... | python | def common_axis_properties(self, color=None, title_size=None):
"""Set common axis properties such as color
Parameters
----------
color: str, default None
Hex color str, etc
"""
if self.axes:
for axis in self.axes:
self._set_axis_pr... | [
"def",
"common_axis_properties",
"(",
"self",
",",
"color",
"=",
"None",
",",
"title_size",
"=",
"None",
")",
":",
"if",
"self",
".",
"axes",
":",
"for",
"axis",
"in",
"self",
".",
"axes",
":",
"self",
".",
"_set_axis_properties",
"(",
"axis",
")",
"se... | Set common axis properties such as color
Parameters
----------
color: str, default None
Hex color str, etc | [
"Set",
"common",
"axis",
"properties",
"such",
"as",
"color"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L241-L258 |
wrobstory/vincent | vincent/visualization.py | Visualization.x_axis_properties | def x_axis_properties(self, title_size=None, title_offset=None,
label_angle=None, label_align=None, color=None):
"""Change x-axis title font size and label angle
Parameters
----------
title_size: int, default None
Title size, in px
title_off... | python | def x_axis_properties(self, title_size=None, title_offset=None,
label_angle=None, label_align=None, color=None):
"""Change x-axis title font size and label angle
Parameters
----------
title_size: int, default None
Title size, in px
title_off... | [
"def",
"x_axis_properties",
"(",
"self",
",",
"title_size",
"=",
"None",
",",
"title_offset",
"=",
"None",
",",
"label_angle",
"=",
"None",
",",
"label_align",
"=",
"None",
",",
"color",
"=",
"None",
")",
":",
"self",
".",
"_axis_properties",
"(",
"'x'",
... | Change x-axis title font size and label angle
Parameters
----------
title_size: int, default None
Title size, in px
title_offset: int, default None
Pixel offset from given axis
label_angle: int, default None
label angle in degrees
labe... | [
"Change",
"x",
"-",
"axis",
"title",
"font",
"size",
"and",
"label",
"angle"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L260-L279 |
wrobstory/vincent | vincent/visualization.py | Visualization.y_axis_properties | def y_axis_properties(self, title_size=None, title_offset=None,
label_angle=None, label_align=None, color=None):
"""Change y-axis title font size and label angle
Parameters
----------
title_size: int, default None
Title size, in px
title_off... | python | def y_axis_properties(self, title_size=None, title_offset=None,
label_angle=None, label_align=None, color=None):
"""Change y-axis title font size and label angle
Parameters
----------
title_size: int, default None
Title size, in px
title_off... | [
"def",
"y_axis_properties",
"(",
"self",
",",
"title_size",
"=",
"None",
",",
"title_offset",
"=",
"None",
",",
"label_angle",
"=",
"None",
",",
"label_align",
"=",
"None",
",",
"color",
"=",
"None",
")",
":",
"self",
".",
"_axis_properties",
"(",
"'y'",
... | Change y-axis title font size and label angle
Parameters
----------
title_size: int, default None
Title size, in px
title_offset: int, default None
Pixel offset from given axis
label_angle: int, default None
label angle in degrees
labe... | [
"Change",
"y",
"-",
"axis",
"title",
"font",
"size",
"and",
"label",
"angle"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L281-L300 |
wrobstory/vincent | vincent/visualization.py | Visualization.legend | def legend(self, title=None, scale='color', text_color=None):
"""Convience method for adding a legend to the figure.
Important: This defaults to the color scale that is generated with
Line, Area, Stacked Line, etc charts. For bar charts, the scale ref is
usually 'y'.
Parameters... | python | def legend(self, title=None, scale='color', text_color=None):
"""Convience method for adding a legend to the figure.
Important: This defaults to the color scale that is generated with
Line, Area, Stacked Line, etc charts. For bar charts, the scale ref is
usually 'y'.
Parameters... | [
"def",
"legend",
"(",
"self",
",",
"title",
"=",
"None",
",",
"scale",
"=",
"'color'",
",",
"text_color",
"=",
"None",
")",
":",
"self",
".",
"legends",
".",
"append",
"(",
"Legend",
"(",
"title",
"=",
"title",
",",
"fill",
"=",
"scale",
",",
"offs... | Convience method for adding a legend to the figure.
Important: This defaults to the color scale that is generated with
Line, Area, Stacked Line, etc charts. For bar charts, the scale ref is
usually 'y'.
Parameters
----------
title: string, default None
Legen... | [
"Convience",
"method",
"for",
"adding",
"a",
"legend",
"to",
"the",
"figure",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L302-L325 |
wrobstory/vincent | vincent/visualization.py | Visualization.colors | def colors(self, brew=None, range_=None):
"""Convenience method for adding color brewer scales to charts with a
color scale, such as stacked or grouped bars.
See the colors here: http://colorbrewer2.org/
Or here: http://bl.ocks.org/mbostock/5577023
This assumes that a 'color' ... | python | def colors(self, brew=None, range_=None):
"""Convenience method for adding color brewer scales to charts with a
color scale, such as stacked or grouped bars.
See the colors here: http://colorbrewer2.org/
Or here: http://bl.ocks.org/mbostock/5577023
This assumes that a 'color' ... | [
"def",
"colors",
"(",
"self",
",",
"brew",
"=",
"None",
",",
"range_",
"=",
"None",
")",
":",
"if",
"brew",
":",
"self",
".",
"scales",
"[",
"'color'",
"]",
".",
"range",
"=",
"brews",
"[",
"brew",
"]",
"elif",
"range_",
":",
"self",
".",
"scales... | Convenience method for adding color brewer scales to charts with a
color scale, such as stacked or grouped bars.
See the colors here: http://colorbrewer2.org/
Or here: http://bl.ocks.org/mbostock/5577023
This assumes that a 'color' scale exists on your chart.
Parameters
... | [
"Convenience",
"method",
"for",
"adding",
"color",
"brewer",
"scales",
"to",
"charts",
"with",
"a",
"color",
"scale",
"such",
"as",
"stacked",
"or",
"grouped",
"bars",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L327-L348 |
wrobstory/vincent | vincent/visualization.py | Visualization.validate | def validate(self, require_all=True, scale='colors'):
"""Validate the visualization contents.
Parameters
----------
require_all : boolean, default True
If True (default), then all fields ``data``, ``scales``,
``axes``, and ``marks`` must be defined. The user is a... | python | def validate(self, require_all=True, scale='colors'):
"""Validate the visualization contents.
Parameters
----------
require_all : boolean, default True
If True (default), then all fields ``data``, ``scales``,
``axes``, and ``marks`` must be defined. The user is a... | [
"def",
"validate",
"(",
"self",
",",
"require_all",
"=",
"True",
",",
"scale",
"=",
"'colors'",
")",
":",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"validate",
"(",
")",
"required_attribs",
"=",
"(",
"'data'",
",",
"'scales'",
",",... | Validate the visualization contents.
Parameters
----------
require_all : boolean, default True
If True (default), then all fields ``data``, ``scales``,
``axes``, and ``marks`` must be defined. The user is allowed to
disable this if the intent is to define the... | [
"Validate",
"the",
"visualization",
"contents",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L350-L377 |
wrobstory/vincent | vincent/visualization.py | Visualization._repr_html_ | def _repr_html_(self):
"""Build the HTML representation for IPython."""
vis_id = str(uuid4()).replace("-", "")
html = """<div id="vis%s"></div>
<script>
( function() {
var _do_plot = function() {
if (typeof vg === 'undefined') {
window.addEventListener('vincent_libs_loade... | python | def _repr_html_(self):
"""Build the HTML representation for IPython."""
vis_id = str(uuid4()).replace("-", "")
html = """<div id="vis%s"></div>
<script>
( function() {
var _do_plot = function() {
if (typeof vg === 'undefined') {
window.addEventListener('vincent_libs_loade... | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"vis_id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
".",
"replace",
"(",
"\"-\"",
",",
"\"\"",
")",
"html",
"=",
"\"\"\"<div id=\"vis%s\"></div>\n<script>\n ( function() {\n var _do_plot = function() {\n if (typeof... | Build the HTML representation for IPython. | [
"Build",
"the",
"HTML",
"representation",
"for",
"IPython",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L379-L399 |
wrobstory/vincent | vincent/visualization.py | Visualization.display | def display(self):
"""Display the visualization inline in the IPython notebook.
This is deprecated, use the following instead::
from IPython.display import display
display(viz)
"""
from IPython.core.display import display, HTML
display(HTML(self._repr_ht... | python | def display(self):
"""Display the visualization inline in the IPython notebook.
This is deprecated, use the following instead::
from IPython.display import display
display(viz)
"""
from IPython.core.display import display, HTML
display(HTML(self._repr_ht... | [
"def",
"display",
"(",
"self",
")",
":",
"from",
"IPython",
".",
"core",
".",
"display",
"import",
"display",
",",
"HTML",
"display",
"(",
"HTML",
"(",
"self",
".",
"_repr_html_",
"(",
")",
")",
")"
] | Display the visualization inline in the IPython notebook.
This is deprecated, use the following instead::
from IPython.display import display
display(viz) | [
"Display",
"the",
"visualization",
"inline",
"in",
"the",
"IPython",
"notebook",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L401-L410 |
wrobstory/vincent | vincent/data.py | Data.validate | def validate(self, *args):
"""Validate contents of class
"""
super(self.__class__, self).validate(*args)
if not self.name:
raise ValidationError('name is required for Data') | python | def validate(self, *args):
"""Validate contents of class
"""
super(self.__class__, self).validate(*args)
if not self.name:
raise ValidationError('name is required for Data') | [
"def",
"validate",
"(",
"self",
",",
"*",
"args",
")",
":",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"validate",
"(",
"*",
"args",
")",
"if",
"not",
"self",
".",
"name",
":",
"raise",
"ValidationError",
"(",
"'name is required for... | Validate contents of class | [
"Validate",
"contents",
"of",
"class"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L122-L127 |
wrobstory/vincent | vincent/data.py | Data.serialize | def serialize(obj):
"""Convert an object into a JSON-serializable value
This is used by the ``from_pandas`` and ``from_numpy`` functions to
convert data to JSON-serializable types when loading.
"""
if isinstance(obj, str_types):
return obj
elif hasattr(obj, '... | python | def serialize(obj):
"""Convert an object into a JSON-serializable value
This is used by the ``from_pandas`` and ``from_numpy`` functions to
convert data to JSON-serializable types when loading.
"""
if isinstance(obj, str_types):
return obj
elif hasattr(obj, '... | [
"def",
"serialize",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"str_types",
")",
":",
"return",
"obj",
"elif",
"hasattr",
"(",
"obj",
",",
"'timetuple'",
")",
":",
"return",
"int",
"(",
"time",
".",
"mktime",
"(",
"obj",
".",
"timetup... | Convert an object into a JSON-serializable value
This is used by the ``from_pandas`` and ``from_numpy`` functions to
convert data to JSON-serializable types when loading. | [
"Convert",
"an",
"object",
"into",
"a",
"JSON",
"-",
"serializable",
"value"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L130-L151 |
wrobstory/vincent | vincent/data.py | Data.from_pandas | def from_pandas(cls, data, columns=None, key_on='idx', name=None,
series_key='data', grouped=False, records=False, **kwargs):
"""Load values from a pandas ``Series`` or ``DataFrame`` object
Parameters
----------
data : pandas ``Series`` or ``DataFrame``
P... | python | def from_pandas(cls, data, columns=None, key_on='idx', name=None,
series_key='data', grouped=False, records=False, **kwargs):
"""Load values from a pandas ``Series`` or ``DataFrame`` object
Parameters
----------
data : pandas ``Series`` or ``DataFrame``
P... | [
"def",
"from_pandas",
"(",
"cls",
",",
"data",
",",
"columns",
"=",
"None",
",",
"key_on",
"=",
"'idx'",
",",
"name",
"=",
"None",
",",
"series_key",
"=",
"'data'",
",",
"grouped",
"=",
"False",
",",
"records",
"=",
"False",
",",
"*",
"*",
"kwargs",
... | Load values from a pandas ``Series`` or ``DataFrame`` object
Parameters
----------
data : pandas ``Series`` or ``DataFrame``
Pandas object to import data from.
columns: list, default None
DataFrame columns to convert to Data. Keys default to col names.
... | [
"Load",
"values",
"from",
"a",
"pandas",
"Series",
"or",
"DataFrame",
"object"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L154-L234 |
wrobstory/vincent | vincent/data.py | Data.from_numpy | def from_numpy(cls, np_obj, name, columns, index=None, index_key=None,
**kwargs):
"""Load values from a numpy array
Parameters
----------
np_obj : numpy.ndarray
numpy array to load data from
name : string
``name`` field for the data
... | python | def from_numpy(cls, np_obj, name, columns, index=None, index_key=None,
**kwargs):
"""Load values from a numpy array
Parameters
----------
np_obj : numpy.ndarray
numpy array to load data from
name : string
``name`` field for the data
... | [
"def",
"from_numpy",
"(",
"cls",
",",
"np_obj",
",",
"name",
",",
"columns",
",",
"index",
"=",
"None",
",",
"index_key",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"np",
":",
"raise",
"LoadError",
"(",
"'numpy could not be imported'",
... | Load values from a numpy array
Parameters
----------
np_obj : numpy.ndarray
numpy array to load data from
name : string
``name`` field for the data
columns : iterable
Sequence of column names, from left to right. Must have same
len... | [
"Load",
"values",
"from",
"a",
"numpy",
"array"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L237-L291 |
wrobstory/vincent | vincent/data.py | Data.from_mult_iters | def from_mult_iters(cls, name=None, idx=None, **kwargs):
"""Load values from multiple iters
Parameters
----------
name : string, default None
Name of the data set. If None (default), the name will be set to
``'table'``.
idx: string, default None
... | python | def from_mult_iters(cls, name=None, idx=None, **kwargs):
"""Load values from multiple iters
Parameters
----------
name : string, default None
Name of the data set. If None (default), the name will be set to
``'table'``.
idx: string, default None
... | [
"def",
"from_mult_iters",
"(",
"cls",
",",
"name",
"=",
"None",
",",
"idx",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"'table'",
"lengths",
"=",
"[",
"len",
"(",
"v",
")",
"for",
"v",
"in",
"kwargs",
... | Load values from multiple iters
Parameters
----------
name : string, default None
Name of the data set. If None (default), the name will be set to
``'table'``.
idx: string, default None
Iterable to use for the data index
**kwargs : dict of ite... | [
"Load",
"values",
"from",
"multiple",
"iters"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L294-L339 |
wrobstory/vincent | vincent/data.py | Data.from_iter | def from_iter(cls, data, name=None):
"""Convenience method for loading data from an iterable.
Defaults to numerical indexing for x-axis.
Parameters
----------
data: iterable
An iterable of data (list, tuple, dict of key/val pairs)
name: string, default None
... | python | def from_iter(cls, data, name=None):
"""Convenience method for loading data from an iterable.
Defaults to numerical indexing for x-axis.
Parameters
----------
data: iterable
An iterable of data (list, tuple, dict of key/val pairs)
name: string, default None
... | [
"def",
"from_iter",
"(",
"cls",
",",
"data",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"'table'",
"if",
"isinstance",
"(",
"data",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"data",
"=",
"{",
"x",
":",
"y",
... | Convenience method for loading data from an iterable.
Defaults to numerical indexing for x-axis.
Parameters
----------
data: iterable
An iterable of data (list, tuple, dict of key/val pairs)
name: string, default None
Name of the data set. If None (defau... | [
"Convenience",
"method",
"for",
"loading",
"data",
"from",
"an",
"iterable",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L342-L364 |
wrobstory/vincent | vincent/data.py | Data.keypairs | def keypairs(cls, data, columns=None, use_index=False, name=None):
"""This will format the data as Key: Value pairs, rather than the
idx/col/val style. This is useful for some transforms, and to
key choropleth map data
Standard Data Types:
List: [0, 10, 20, 30, 40]
... | python | def keypairs(cls, data, columns=None, use_index=False, name=None):
"""This will format the data as Key: Value pairs, rather than the
idx/col/val style. This is useful for some transforms, and to
key choropleth map data
Standard Data Types:
List: [0, 10, 20, 30, 40]
... | [
"def",
"keypairs",
"(",
"cls",
",",
"data",
",",
"columns",
"=",
"None",
",",
"use_index",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"'table'",
"cls",
".",
"raw_data",
"=",
"data",
"# Tuples",
"if",
"i... | This will format the data as Key: Value pairs, rather than the
idx/col/val style. This is useful for some transforms, and to
key choropleth map data
Standard Data Types:
List: [0, 10, 20, 30, 40]
Paired Tuples: ((0, 1), (0, 2), (0, 3))
Dict: {'A': 10, 'B': 20... | [
"This",
"will",
"format",
"the",
"data",
"as",
"Key",
":",
"Value",
"pairs",
"rather",
"than",
"the",
"idx",
"/",
"col",
"/",
"val",
"style",
".",
"This",
"is",
"useful",
"for",
"some",
"transforms",
"and",
"to",
"key",
"choropleth",
"map",
"data"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L367-L430 |
wrobstory/vincent | vincent/data.py | Data._numpy_to_values | def _numpy_to_values(data):
'''Convert a NumPy array to values attribute'''
def to_list_no_index(xvals, yvals):
return [{"x": x, "y": np.asscalar(y)}
for x, y in zip(xvals, yvals)]
if len(data.shape) == 1 or data.shape[1] == 1:
xvals = range(data.shap... | python | def _numpy_to_values(data):
'''Convert a NumPy array to values attribute'''
def to_list_no_index(xvals, yvals):
return [{"x": x, "y": np.asscalar(y)}
for x, y in zip(xvals, yvals)]
if len(data.shape) == 1 or data.shape[1] == 1:
xvals = range(data.shap... | [
"def",
"_numpy_to_values",
"(",
"data",
")",
":",
"def",
"to_list_no_index",
"(",
"xvals",
",",
"yvals",
")",
":",
"return",
"[",
"{",
"\"x\"",
":",
"x",
",",
"\"y\"",
":",
"np",
".",
"asscalar",
"(",
"y",
")",
"}",
"for",
"x",
",",
"y",
"in",
"z... | Convert a NumPy array to values attribute | [
"Convert",
"a",
"NumPy",
"array",
"to",
"values",
"attribute"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L433-L460 |
wrobstory/vincent | vincent/data.py | Data.to_json | def to_json(self, validate=False, pretty_print=True, data_path=None):
"""Convert data to JSON
Parameters
----------
data_path : string
If not None, then data is written to a separate file at the
specified path. Note that the ``url`` attribute if the data must
... | python | def to_json(self, validate=False, pretty_print=True, data_path=None):
"""Convert data to JSON
Parameters
----------
data_path : string
If not None, then data is written to a separate file at the
specified path. Note that the ``url`` attribute if the data must
... | [
"def",
"to_json",
"(",
"self",
",",
"validate",
"=",
"False",
",",
"pretty_print",
"=",
"True",
",",
"data_path",
"=",
"None",
")",
":",
"# TODO: support writing to separate file",
"return",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"to_... | Convert data to JSON
Parameters
----------
data_path : string
If not None, then data is written to a separate file at the
specified path. Note that the ``url`` attribute if the data must
be set independently for the data to load correctly.
Returns
... | [
"Convert",
"data",
"to",
"JSON"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/data.py#L462-L479 |
wrobstory/vincent | vincent/core.py | initialize_notebook | def initialize_notebook():
"""Initialize the IPython notebook display elements"""
try:
from IPython.core.display import display, HTML
except ImportError:
print("IPython Notebook could not be loaded.")
# Thanks to @jakevdp:
# https://github.com/jakevdp/mpld3/blob/master/mpld3/_displa... | python | def initialize_notebook():
"""Initialize the IPython notebook display elements"""
try:
from IPython.core.display import display, HTML
except ImportError:
print("IPython Notebook could not be loaded.")
# Thanks to @jakevdp:
# https://github.com/jakevdp/mpld3/blob/master/mpld3/_displa... | [
"def",
"initialize_notebook",
"(",
")",
":",
"try",
":",
"from",
"IPython",
".",
"core",
".",
"display",
"import",
"display",
",",
"HTML",
"except",
"ImportError",
":",
"print",
"(",
"\"IPython Notebook could not be loaded.\"",
")",
"# Thanks to @jakevdp:",
"# https... | Initialize the IPython notebook display elements | [
"Initialize",
"the",
"IPython",
"notebook",
"display",
"elements"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/core.py#L25-L104 |
wrobstory/vincent | vincent/core.py | _assert_is_type | def _assert_is_type(name, value, value_type):
"""Assert that a value must be a given type."""
if not isinstance(value, value_type):
if type(value_type) is tuple:
types = ', '.join(t.__name__ for t in value_type)
raise ValueError('{0} must be one of ({1})'.format(name, types))
... | python | def _assert_is_type(name, value, value_type):
"""Assert that a value must be a given type."""
if not isinstance(value, value_type):
if type(value_type) is tuple:
types = ', '.join(t.__name__ for t in value_type)
raise ValueError('{0} must be one of ({1})'.format(name, types))
... | [
"def",
"_assert_is_type",
"(",
"name",
",",
"value",
",",
"value_type",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"value_type",
")",
":",
"if",
"type",
"(",
"value_type",
")",
"is",
"tuple",
":",
"types",
"=",
"', '",
".",
"join",
"(",
... | Assert that a value must be a given type. | [
"Assert",
"that",
"a",
"value",
"must",
"be",
"a",
"given",
"type",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/core.py#L107-L115 |
wrobstory/vincent | vincent/core.py | grammar | def grammar(grammar_type=None, grammar_name=None):
"""Decorator to define properties that map to the ``grammar``
dict. This dict is the canonical representation of the Vega grammar
within Vincent.
This decorator is intended for classes that map to some pre-defined JSON
structure, such as axes, data... | python | def grammar(grammar_type=None, grammar_name=None):
"""Decorator to define properties that map to the ``grammar``
dict. This dict is the canonical representation of the Vega grammar
within Vincent.
This decorator is intended for classes that map to some pre-defined JSON
structure, such as axes, data... | [
"def",
"grammar",
"(",
"grammar_type",
"=",
"None",
",",
"grammar_name",
"=",
"None",
")",
":",
"def",
"grammar_creator",
"(",
"validator",
",",
"name",
")",
":",
"def",
"setter",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"grammar_typ... | Decorator to define properties that map to the ``grammar``
dict. This dict is the canonical representation of the Vega grammar
within Vincent.
This decorator is intended for classes that map to some pre-defined JSON
structure, such as axes, data, marks, scales, etc. It is assumed that this
decorate... | [
"Decorator",
"to",
"define",
"properties",
"that",
"map",
"to",
"the",
"grammar",
"dict",
".",
"This",
"dict",
"is",
"the",
"canonical",
"representation",
"of",
"the",
"Vega",
"grammar",
"within",
"Vincent",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/core.py#L179-L250 |
wrobstory/vincent | vincent/core.py | GrammarClass.validate | def validate(self):
"""Validate the contents of the object.
This calls ``setattr`` for each of the class's grammar properties. It
will catch ``ValueError``s raised by the grammar property's setters
and re-raise them as :class:`ValidationError`.
"""
for key, val in self.g... | python | def validate(self):
"""Validate the contents of the object.
This calls ``setattr`` for each of the class's grammar properties. It
will catch ``ValueError``s raised by the grammar property's setters
and re-raise them as :class:`ValidationError`.
"""
for key, val in self.g... | [
"def",
"validate",
"(",
"self",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"grammar",
".",
"items",
"(",
")",
":",
"try",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"val",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"Vali... | Validate the contents of the object.
This calls ``setattr`` for each of the class's grammar properties. It
will catch ``ValueError``s raised by the grammar property's setters
and re-raise them as :class:`ValidationError`. | [
"Validate",
"the",
"contents",
"of",
"the",
"object",
"."
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/core.py#L302-L313 |
wrobstory/vincent | vincent/core.py | GrammarClass.to_json | def to_json(self, path=None, html_out=False,
html_path='vega_template.html', validate=False,
pretty_print=True):
"""Convert object to JSON
Parameters
----------
path: string, default None
Path to write JSON out. If there is no path provided, J... | python | def to_json(self, path=None, html_out=False,
html_path='vega_template.html', validate=False,
pretty_print=True):
"""Convert object to JSON
Parameters
----------
path: string, default None
Path to write JSON out. If there is no path provided, J... | [
"def",
"to_json",
"(",
"self",
",",
"path",
"=",
"None",
",",
"html_out",
"=",
"False",
",",
"html_path",
"=",
"'vega_template.html'",
",",
"validate",
"=",
"False",
",",
"pretty_print",
"=",
"True",
")",
":",
"if",
"validate",
":",
"self",
".",
"validat... | Convert object to JSON
Parameters
----------
path: string, default None
Path to write JSON out. If there is no path provided, JSON
will be returned as a string to the console.
html_out: boolean, default False
If True, vincent will output an simple HTM... | [
"Convert",
"object",
"to",
"JSON"
] | train | https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/core.py#L315-L366 |
alephdata/pantomime | pantomime/__init__.py | useful_mimetype | def useful_mimetype(text):
"""Check to see if the given mime type is a MIME type
which is useful in terms of how to treat this file.
"""
if text is None:
return False
mimetype = normalize_mimetype(text)
return mimetype not in [DEFAULT, PLAIN, None] | python | def useful_mimetype(text):
"""Check to see if the given mime type is a MIME type
which is useful in terms of how to treat this file.
"""
if text is None:
return False
mimetype = normalize_mimetype(text)
return mimetype not in [DEFAULT, PLAIN, None] | [
"def",
"useful_mimetype",
"(",
"text",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"False",
"mimetype",
"=",
"normalize_mimetype",
"(",
"text",
")",
"return",
"mimetype",
"not",
"in",
"[",
"DEFAULT",
",",
"PLAIN",
",",
"None",
"]"
] | Check to see if the given mime type is a MIME type
which is useful in terms of how to treat this file. | [
"Check",
"to",
"see",
"if",
"the",
"given",
"mime",
"type",
"is",
"a",
"MIME",
"type",
"which",
"is",
"useful",
"in",
"terms",
"of",
"how",
"to",
"treat",
"this",
"file",
"."
] | train | https://github.com/alephdata/pantomime/blob/818fe5d799ba045c1d908935f24c94a8438c3a60/pantomime/__init__.py#L19-L26 |
alephdata/pantomime | pantomime/__init__.py | normalize_extension | def normalize_extension(extension):
"""Normalise a file name extension."""
extension = decode_path(extension)
if extension is None:
return
if extension.startswith('.'):
extension = extension[1:]
if '.' in extension:
_, extension = os.path.splitext(extension)
extension = s... | python | def normalize_extension(extension):
"""Normalise a file name extension."""
extension = decode_path(extension)
if extension is None:
return
if extension.startswith('.'):
extension = extension[1:]
if '.' in extension:
_, extension = os.path.splitext(extension)
extension = s... | [
"def",
"normalize_extension",
"(",
"extension",
")",
":",
"extension",
"=",
"decode_path",
"(",
"extension",
")",
"if",
"extension",
"is",
"None",
":",
"return",
"if",
"extension",
".",
"startswith",
"(",
"'.'",
")",
":",
"extension",
"=",
"extension",
"[",
... | Normalise a file name extension. | [
"Normalise",
"a",
"file",
"name",
"extension",
"."
] | train | https://github.com/alephdata/pantomime/blob/818fe5d799ba045c1d908935f24c94a8438c3a60/pantomime/__init__.py#L29-L42 |
alphardex/looter | looter/__init__.py | fetch | def fetch(url: str, **kwargs) -> Selector:
"""
Send HTTP request and parse it as a DOM tree.
Args:
url (str): The url of the site.
Returns:
Selector: allows you to select parts of HTML text using CSS or XPath expressions.
"""
kwargs.setdefault('headers', DEFAULT_HEADERS)
tr... | python | def fetch(url: str, **kwargs) -> Selector:
"""
Send HTTP request and parse it as a DOM tree.
Args:
url (str): The url of the site.
Returns:
Selector: allows you to select parts of HTML text using CSS or XPath expressions.
"""
kwargs.setdefault('headers', DEFAULT_HEADERS)
tr... | [
"def",
"fetch",
"(",
"url",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"Selector",
":",
"kwargs",
".",
"setdefault",
"(",
"'headers'",
",",
"DEFAULT_HEADERS",
")",
"try",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"*",
"*",
"kwa... | Send HTTP request and parse it as a DOM tree.
Args:
url (str): The url of the site.
Returns:
Selector: allows you to select parts of HTML text using CSS or XPath expressions. | [
"Send",
"HTTP",
"request",
"and",
"parse",
"it",
"as",
"a",
"DOM",
"tree",
"."
] | train | https://github.com/alphardex/looter/blob/47fb7e44fe39c8528c1d6be94791798660d8804e/looter/__init__.py#L60-L79 |
alphardex/looter | looter/__init__.py | async_fetch | async def async_fetch(url: str, **kwargs) -> Selector:
"""
Do the fetch in an async style.
Args:
url (str): The url of the site.
Returns:
Selector: allows you to select parts of HTML text using CSS or XPath expressions.
"""
kwargs.setdefault('headers', DEFAULT_HEADERS)
asyn... | python | async def async_fetch(url: str, **kwargs) -> Selector:
"""
Do the fetch in an async style.
Args:
url (str): The url of the site.
Returns:
Selector: allows you to select parts of HTML text using CSS or XPath expressions.
"""
kwargs.setdefault('headers', DEFAULT_HEADERS)
asyn... | [
"async",
"def",
"async_fetch",
"(",
"url",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"Selector",
":",
"kwargs",
".",
"setdefault",
"(",
"'headers'",
",",
"DEFAULT_HEADERS",
")",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
"*",
"*",
"kwar... | Do the fetch in an async style.
Args:
url (str): The url of the site.
Returns:
Selector: allows you to select parts of HTML text using CSS or XPath expressions. | [
"Do",
"the",
"fetch",
"in",
"an",
"async",
"style",
"."
] | train | https://github.com/alphardex/looter/blob/47fb7e44fe39c8528c1d6be94791798660d8804e/looter/__init__.py#L82-L97 |
alphardex/looter | looter/__init__.py | view | def view(url: str, **kwargs) -> bool:
"""
View the page whether rendered properly. (ensure the <base> tag to make external links work)
Args:
url (str): The url of the site.
"""
kwargs.setdefault('headers', DEFAULT_HEADERS)
html = requests.get(url, **kwargs).content
if b'<base' not i... | python | def view(url: str, **kwargs) -> bool:
"""
View the page whether rendered properly. (ensure the <base> tag to make external links work)
Args:
url (str): The url of the site.
"""
kwargs.setdefault('headers', DEFAULT_HEADERS)
html = requests.get(url, **kwargs).content
if b'<base' not i... | [
"def",
"view",
"(",
"url",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"bool",
":",
"kwargs",
".",
"setdefault",
"(",
"'headers'",
",",
"DEFAULT_HEADERS",
")",
"html",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
".",
... | View the page whether rendered properly. (ensure the <base> tag to make external links work)
Args:
url (str): The url of the site. | [
"View",
"the",
"page",
"whether",
"rendered",
"properly",
".",
"(",
"ensure",
"the",
"<base",
">",
"tag",
"to",
"make",
"external",
"links",
"work",
")"
] | train | https://github.com/alphardex/looter/blob/47fb7e44fe39c8528c1d6be94791798660d8804e/looter/__init__.py#L100-L115 |
alphardex/looter | looter/__init__.py | links | def links(res: requests.models.Response,
search: str = None,
pattern: str = None) -> list:
"""Get the links of the page.
Args:
res (requests.models.Response): The response of the page.
search (str, optional): Defaults to None. Search the links you want.
pattern (str,... | python | def links(res: requests.models.Response,
search: str = None,
pattern: str = None) -> list:
"""Get the links of the page.
Args:
res (requests.models.Response): The response of the page.
search (str, optional): Defaults to None. Search the links you want.
pattern (str,... | [
"def",
"links",
"(",
"res",
":",
"requests",
".",
"models",
".",
"Response",
",",
"search",
":",
"str",
"=",
"None",
",",
"pattern",
":",
"str",
"=",
"None",
")",
"->",
"list",
":",
"hrefs",
"=",
"[",
"link",
".",
"to_text",
"(",
")",
"for",
"lin... | Get the links of the page.
Args:
res (requests.models.Response): The response of the page.
search (str, optional): Defaults to None. Search the links you want.
pattern (str, optional): Defaults to None. Search the links use a regex pattern.
Returns:
list: All the links of the p... | [
"Get",
"the",
"links",
"of",
"the",
"page",
"."
] | train | https://github.com/alphardex/looter/blob/47fb7e44fe39c8528c1d6be94791798660d8804e/looter/__init__.py#L118-L136 |
alphardex/looter | looter/__init__.py | save_as_json | def save_as_json(total: list,
name='data.json',
sort_by: str = None,
no_duplicate=False,
order='asc'):
"""Save what you crawled as a json file.
Args:
total (list): Total of data you crawled.
name (str, optional): Defaults to 'd... | python | def save_as_json(total: list,
name='data.json',
sort_by: str = None,
no_duplicate=False,
order='asc'):
"""Save what you crawled as a json file.
Args:
total (list): Total of data you crawled.
name (str, optional): Defaults to 'd... | [
"def",
"save_as_json",
"(",
"total",
":",
"list",
",",
"name",
"=",
"'data.json'",
",",
"sort_by",
":",
"str",
"=",
"None",
",",
"no_duplicate",
"=",
"False",
",",
"order",
"=",
"'asc'",
")",
":",
"if",
"sort_by",
":",
"reverse",
"=",
"order",
"==",
... | Save what you crawled as a json file.
Args:
total (list): Total of data you crawled.
name (str, optional): Defaults to 'data.json'. The name of the file.
sort_by (str, optional): Defaults to None. Sort items by a specific key.
no_duplicate (bool, optional): Defaults to False. If Tru... | [
"Save",
"what",
"you",
"crawled",
"as",
"a",
"json",
"file",
"."
] | train | https://github.com/alphardex/looter/blob/47fb7e44fe39c8528c1d6be94791798660d8804e/looter/__init__.py#L139-L159 |
alphardex/looter | looter/__init__.py | cli | def cli():
"""
Commandline for looter :d
"""
argv = docopt(__doc__, version=VERSION)
if argv['genspider']:
name = f"{argv['<name>']}.py"
use_async = argv['--async']
template = 'data_async.tmpl' if use_async else 'data.tmpl'
package_dir = Path(__file__).parent
... | python | def cli():
"""
Commandline for looter :d
"""
argv = docopt(__doc__, version=VERSION)
if argv['genspider']:
name = f"{argv['<name>']}.py"
use_async = argv['--async']
template = 'data_async.tmpl' if use_async else 'data.tmpl'
package_dir = Path(__file__).parent
... | [
"def",
"cli",
"(",
")",
":",
"argv",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"VERSION",
")",
"if",
"argv",
"[",
"'genspider'",
"]",
":",
"name",
"=",
"f\"{argv['<name>']}.py\"",
"use_async",
"=",
"argv",
"[",
"'--async'",
"]",
"template",
"="... | Commandline for looter :d | [
"Commandline",
"for",
"looter",
":",
"d"
] | train | https://github.com/alphardex/looter/blob/47fb7e44fe39c8528c1d6be94791798660d8804e/looter/__init__.py#L162-L187 |
gtaylor/python-colormath | colormath/color_objects.py | ColorBase.get_value_tuple | def get_value_tuple(self):
"""
Returns a tuple of the color's values (in order). For example,
an LabColor object will return (lab_l, lab_a, lab_b), where each
member of the tuple is the float value for said variable.
"""
retval = tuple()
for val in self.VALUES:
... | python | def get_value_tuple(self):
"""
Returns a tuple of the color's values (in order). For example,
an LabColor object will return (lab_l, lab_a, lab_b), where each
member of the tuple is the float value for said variable.
"""
retval = tuple()
for val in self.VALUES:
... | [
"def",
"get_value_tuple",
"(",
"self",
")",
":",
"retval",
"=",
"tuple",
"(",
")",
"for",
"val",
"in",
"self",
".",
"VALUES",
":",
"retval",
"+=",
"(",
"getattr",
"(",
"self",
",",
"val",
")",
",",
")",
"return",
"retval"
] | Returns a tuple of the color's values (in order). For example,
an LabColor object will return (lab_l, lab_a, lab_b), where each
member of the tuple is the float value for said variable. | [
"Returns",
"a",
"tuple",
"of",
"the",
"color",
"s",
"values",
"(",
"in",
"order",
")",
".",
"For",
"example",
"an",
"LabColor",
"object",
"will",
"return",
"(",
"lab_l",
"lab_a",
"lab_b",
")",
"where",
"each",
"member",
"of",
"the",
"tuple",
"is",
"the... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L32-L41 |
gtaylor/python-colormath | colormath/color_objects.py | IlluminantMixin.set_observer | def set_observer(self, observer):
"""
Validates and sets the color's observer angle.
.. note:: This only changes the observer angle value. It does no conversion
of the color's coordinates.
:param str observer: One of '2' or '10'.
"""
observer = str(observer)... | python | def set_observer(self, observer):
"""
Validates and sets the color's observer angle.
.. note:: This only changes the observer angle value. It does no conversion
of the color's coordinates.
:param str observer: One of '2' or '10'.
"""
observer = str(observer)... | [
"def",
"set_observer",
"(",
"self",
",",
"observer",
")",
":",
"observer",
"=",
"str",
"(",
"observer",
")",
"if",
"observer",
"not",
"in",
"color_constants",
".",
"OBSERVERS",
":",
"raise",
"InvalidObserverError",
"(",
"self",
")",
"self",
".",
"observer",
... | Validates and sets the color's observer angle.
.. note:: This only changes the observer angle value. It does no conversion
of the color's coordinates.
:param str observer: One of '2' or '10'. | [
"Validates",
"and",
"sets",
"the",
"color",
"s",
"observer",
"angle",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L71-L83 |
gtaylor/python-colormath | colormath/color_objects.py | IlluminantMixin.set_illuminant | def set_illuminant(self, illuminant):
"""
Validates and sets the color's illuminant.
.. note:: This only changes the illuminant. It does no conversion
of the color's coordinates. For this, you'll want to refer to
:py:meth:`XYZColor.apply_adaptation <colormath.color_objec... | python | def set_illuminant(self, illuminant):
"""
Validates and sets the color's illuminant.
.. note:: This only changes the illuminant. It does no conversion
of the color's coordinates. For this, you'll want to refer to
:py:meth:`XYZColor.apply_adaptation <colormath.color_objec... | [
"def",
"set_illuminant",
"(",
"self",
",",
"illuminant",
")",
":",
"illuminant",
"=",
"illuminant",
".",
"lower",
"(",
")",
"if",
"illuminant",
"not",
"in",
"color_constants",
".",
"ILLUMINANTS",
"[",
"self",
".",
"observer",
"]",
":",
"raise",
"InvalidIllum... | Validates and sets the color's illuminant.
.. note:: This only changes the illuminant. It does no conversion
of the color's coordinates. For this, you'll want to refer to
:py:meth:`XYZColor.apply_adaptation <colormath.color_objects.XYZColor.apply_adaptation>`.
.. tip:: Call thi... | [
"Validates",
"and",
"sets",
"the",
"color",
"s",
"illuminant",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L86-L101 |
gtaylor/python-colormath | colormath/color_objects.py | IlluminantMixin.get_illuminant_xyz | def get_illuminant_xyz(self, observer=None, illuminant=None):
"""
:param str observer: Get the XYZ values for another observer angle. Must
be either '2' or '10'.
:param str illuminant: Get the XYZ values for another illuminant.
:returns: the color's illuminant's XYZ values.
... | python | def get_illuminant_xyz(self, observer=None, illuminant=None):
"""
:param str observer: Get the XYZ values for another observer angle. Must
be either '2' or '10'.
:param str illuminant: Get the XYZ values for another illuminant.
:returns: the color's illuminant's XYZ values.
... | [
"def",
"get_illuminant_xyz",
"(",
"self",
",",
"observer",
"=",
"None",
",",
"illuminant",
"=",
"None",
")",
":",
"try",
":",
"if",
"observer",
"is",
"None",
":",
"observer",
"=",
"self",
".",
"observer",
"illums_observer",
"=",
"color_constants",
".",
"IL... | :param str observer: Get the XYZ values for another observer angle. Must
be either '2' or '10'.
:param str illuminant: Get the XYZ values for another illuminant.
:returns: the color's illuminant's XYZ values. | [
":",
"param",
"str",
"observer",
":",
"Get",
"the",
"XYZ",
"values",
"for",
"another",
"observer",
"angle",
".",
"Must",
"be",
"either",
"2",
"or",
"10",
".",
":",
"param",
"str",
"illuminant",
":",
"Get",
"the",
"XYZ",
"values",
"for",
"another",
"ill... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L103-L126 |
gtaylor/python-colormath | colormath/color_objects.py | SpectralColor.get_numpy_array | def get_numpy_array(self):
"""
Dump this color into NumPy array.
"""
# This holds the obect's spectral data, and will be passed to
# numpy.array() to create a numpy array (matrix) for the matrix math
# that will be done during the conversion to XYZ.
values = []
... | python | def get_numpy_array(self):
"""
Dump this color into NumPy array.
"""
# This holds the obect's spectral data, and will be passed to
# numpy.array() to create a numpy array (matrix) for the matrix math
# that will be done during the conversion to XYZ.
values = []
... | [
"def",
"get_numpy_array",
"(",
"self",
")",
":",
"# This holds the obect's spectral data, and will be passed to",
"# numpy.array() to create a numpy array (matrix) for the matrix math",
"# that will be done during the conversion to XYZ.",
"values",
"=",
"[",
"]",
"# Use the required value ... | Dump this color into NumPy array. | [
"Dump",
"this",
"color",
"into",
"NumPy",
"array",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L245-L262 |
gtaylor/python-colormath | colormath/color_objects.py | SpectralColor.calc_density | def calc_density(self, density_standard=None):
"""
Calculates the density of the SpectralColor. By default, Status T
density is used, and the correct density distribution (Red, Green,
or Blue) is chosen by comparing the Red, Green, and Blue components of
the spectral sample (the ... | python | def calc_density(self, density_standard=None):
"""
Calculates the density of the SpectralColor. By default, Status T
density is used, and the correct density distribution (Red, Green,
or Blue) is chosen by comparing the Red, Green, and Blue components of
the spectral sample (the ... | [
"def",
"calc_density",
"(",
"self",
",",
"density_standard",
"=",
"None",
")",
":",
"if",
"density_standard",
"is",
"not",
"None",
":",
"return",
"density",
".",
"ansi_density",
"(",
"self",
",",
"density_standard",
")",
"else",
":",
"return",
"density",
"."... | Calculates the density of the SpectralColor. By default, Status T
density is used, and the correct density distribution (Red, Green,
or Blue) is chosen by comparing the Red, Green, and Blue components of
the spectral sample (the values being red in via "filters"). | [
"Calculates",
"the",
"density",
"of",
"the",
"SpectralColor",
".",
"By",
"default",
"Status",
"T",
"density",
"is",
"used",
"and",
"the",
"correct",
"density",
"distribution",
"(",
"Red",
"Green",
"or",
"Blue",
")",
"is",
"chosen",
"by",
"comparing",
"the",
... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L264-L274 |
gtaylor/python-colormath | colormath/color_objects.py | XYZColor.apply_adaptation | def apply_adaptation(self, target_illuminant, adaptation='bradford'):
"""
This applies an adaptation matrix to change the XYZ color's illuminant.
You'll most likely only need this during RGB conversions.
"""
logger.debug(" \- Original illuminant: %s", self.illuminant)
lo... | python | def apply_adaptation(self, target_illuminant, adaptation='bradford'):
"""
This applies an adaptation matrix to change the XYZ color's illuminant.
You'll most likely only need this during RGB conversions.
"""
logger.debug(" \- Original illuminant: %s", self.illuminant)
lo... | [
"def",
"apply_adaptation",
"(",
"self",
",",
"target_illuminant",
",",
"adaptation",
"=",
"'bradford'",
")",
":",
"logger",
".",
"debug",
"(",
"\" \\- Original illuminant: %s\"",
",",
"self",
".",
"illuminant",
")",
"logger",
".",
"debug",
"(",
"\" \\- Target il... | This applies an adaptation matrix to change the XYZ color's illuminant.
You'll most likely only need this during RGB conversions. | [
"This",
"applies",
"an",
"adaptation",
"matrix",
"to",
"change",
"the",
"XYZ",
"color",
"s",
"illuminant",
".",
"You",
"ll",
"most",
"likely",
"only",
"need",
"this",
"during",
"RGB",
"conversions",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L448-L466 |
gtaylor/python-colormath | colormath/color_objects.py | BaseRGBColor._clamp_rgb_coordinate | def _clamp_rgb_coordinate(self, coord):
"""
Clamps an RGB coordinate, taking into account whether or not the
color is upscaled or not.
:param float coord: The coordinate value.
:rtype: float
:returns: The clamped value.
"""
if not self.is_upscaled:
... | python | def _clamp_rgb_coordinate(self, coord):
"""
Clamps an RGB coordinate, taking into account whether or not the
color is upscaled or not.
:param float coord: The coordinate value.
:rtype: float
:returns: The clamped value.
"""
if not self.is_upscaled:
... | [
"def",
"_clamp_rgb_coordinate",
"(",
"self",
",",
"coord",
")",
":",
"if",
"not",
"self",
".",
"is_upscaled",
":",
"return",
"min",
"(",
"max",
"(",
"coord",
",",
"0.0",
")",
",",
"1.0",
")",
"else",
":",
"return",
"min",
"(",
"max",
"(",
"coord",
... | Clamps an RGB coordinate, taking into account whether or not the
color is upscaled or not.
:param float coord: The coordinate value.
:rtype: float
:returns: The clamped value. | [
"Clamps",
"an",
"RGB",
"coordinate",
"taking",
"into",
"account",
"whether",
"or",
"not",
"the",
"color",
"is",
"upscaled",
"or",
"not",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L530-L542 |
gtaylor/python-colormath | colormath/color_objects.py | BaseRGBColor.get_upscaled_value_tuple | def get_upscaled_value_tuple(self):
"""
Scales an RGB color object from decimal 0.0-1.0 to int 0-255.
"""
# Scale up to 0-255 values.
rgb_r = int(math.floor(0.5 + self.rgb_r * 255))
rgb_g = int(math.floor(0.5 + self.rgb_g * 255))
rgb_b = int(math.floor(0.5 + self.... | python | def get_upscaled_value_tuple(self):
"""
Scales an RGB color object from decimal 0.0-1.0 to int 0-255.
"""
# Scale up to 0-255 values.
rgb_r = int(math.floor(0.5 + self.rgb_r * 255))
rgb_g = int(math.floor(0.5 + self.rgb_g * 255))
rgb_b = int(math.floor(0.5 + self.... | [
"def",
"get_upscaled_value_tuple",
"(",
"self",
")",
":",
"# Scale up to 0-255 values.",
"rgb_r",
"=",
"int",
"(",
"math",
".",
"floor",
"(",
"0.5",
"+",
"self",
".",
"rgb_r",
"*",
"255",
")",
")",
"rgb_g",
"=",
"int",
"(",
"math",
".",
"floor",
"(",
"... | Scales an RGB color object from decimal 0.0-1.0 to int 0-255. | [
"Scales",
"an",
"RGB",
"color",
"object",
"from",
"decimal",
"0",
".",
"0",
"-",
"1",
".",
"0",
"to",
"int",
"0",
"-",
"255",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L565-L574 |
gtaylor/python-colormath | colormath/color_objects.py | BaseRGBColor.get_rgb_hex | def get_rgb_hex(self):
"""
Converts the RGB value to a hex value in the form of: #RRGGBB
:rtype: str
"""
rgb_r, rgb_g, rgb_b = self.get_upscaled_value_tuple()
return '#%02x%02x%02x' % (rgb_r, rgb_g, rgb_b) | python | def get_rgb_hex(self):
"""
Converts the RGB value to a hex value in the form of: #RRGGBB
:rtype: str
"""
rgb_r, rgb_g, rgb_b = self.get_upscaled_value_tuple()
return '#%02x%02x%02x' % (rgb_r, rgb_g, rgb_b) | [
"def",
"get_rgb_hex",
"(",
"self",
")",
":",
"rgb_r",
",",
"rgb_g",
",",
"rgb_b",
"=",
"self",
".",
"get_upscaled_value_tuple",
"(",
")",
"return",
"'#%02x%02x%02x'",
"%",
"(",
"rgb_r",
",",
"rgb_g",
",",
"rgb_b",
")"
] | Converts the RGB value to a hex value in the form of: #RRGGBB
:rtype: str | [
"Converts",
"the",
"RGB",
"value",
"to",
"a",
"hex",
"value",
"in",
"the",
"form",
"of",
":",
"#RRGGBB"
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L576-L583 |
gtaylor/python-colormath | colormath/color_objects.py | BaseRGBColor.new_from_rgb_hex | def new_from_rgb_hex(cls, hex_str):
"""
Converts an RGB hex string like #RRGGBB and assigns the values to
this sRGBColor object.
:rtype: sRGBColor
"""
colorstring = hex_str.strip()
if colorstring[0] == '#':
colorstring = colorstring[1:]
if len... | python | def new_from_rgb_hex(cls, hex_str):
"""
Converts an RGB hex string like #RRGGBB and assigns the values to
this sRGBColor object.
:rtype: sRGBColor
"""
colorstring = hex_str.strip()
if colorstring[0] == '#':
colorstring = colorstring[1:]
if len... | [
"def",
"new_from_rgb_hex",
"(",
"cls",
",",
"hex_str",
")",
":",
"colorstring",
"=",
"hex_str",
".",
"strip",
"(",
")",
"if",
"colorstring",
"[",
"0",
"]",
"==",
"'#'",
":",
"colorstring",
"=",
"colorstring",
"[",
"1",
":",
"]",
"if",
"len",
"(",
"co... | Converts an RGB hex string like #RRGGBB and assigns the values to
this sRGBColor object.
:rtype: sRGBColor | [
"Converts",
"an",
"RGB",
"hex",
"string",
"like",
"#RRGGBB",
"and",
"assigns",
"the",
"values",
"to",
"this",
"sRGBColor",
"object",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_objects.py#L586-L600 |
gtaylor/python-colormath | colormath/color_diff_matrix.py | delta_e_cie1976 | def delta_e_cie1976(lab_color_vector, lab_color_matrix):
"""
Calculates the Delta E (CIE1976) between `lab_color_vector` and all
colors in `lab_color_matrix`.
"""
return numpy.sqrt(
numpy.sum(numpy.power(lab_color_vector - lab_color_matrix, 2), axis=1)) | python | def delta_e_cie1976(lab_color_vector, lab_color_matrix):
"""
Calculates the Delta E (CIE1976) between `lab_color_vector` and all
colors in `lab_color_matrix`.
"""
return numpy.sqrt(
numpy.sum(numpy.power(lab_color_vector - lab_color_matrix, 2), axis=1)) | [
"def",
"delta_e_cie1976",
"(",
"lab_color_vector",
",",
"lab_color_matrix",
")",
":",
"return",
"numpy",
".",
"sqrt",
"(",
"numpy",
".",
"sum",
"(",
"numpy",
".",
"power",
"(",
"lab_color_vector",
"-",
"lab_color_matrix",
",",
"2",
")",
",",
"axis",
"=",
"... | Calculates the Delta E (CIE1976) between `lab_color_vector` and all
colors in `lab_color_matrix`. | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE1976",
")",
"between",
"lab_color_vector",
"and",
"all",
"colors",
"in",
"lab_color_matrix",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff_matrix.py#L11-L17 |
gtaylor/python-colormath | colormath/color_diff_matrix.py | delta_e_cie1994 | def delta_e_cie1994(lab_color_vector, lab_color_matrix,
K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015):
"""
Calculates the Delta E (CIE1994) of two colors.
K_l:
0.045 graphic arts
0.048 textiles
K_2:
0.015 graphic arts
0.014 textiles
K_L:
1 default
... | python | def delta_e_cie1994(lab_color_vector, lab_color_matrix,
K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015):
"""
Calculates the Delta E (CIE1994) of two colors.
K_l:
0.045 graphic arts
0.048 textiles
K_2:
0.015 graphic arts
0.014 textiles
K_L:
1 default
... | [
"def",
"delta_e_cie1994",
"(",
"lab_color_vector",
",",
"lab_color_matrix",
",",
"K_L",
"=",
"1",
",",
"K_C",
"=",
"1",
",",
"K_H",
"=",
"1",
",",
"K_1",
"=",
"0.045",
",",
"K_2",
"=",
"0.015",
")",
":",
"C_1",
"=",
"numpy",
".",
"sqrt",
"(",
"nump... | Calculates the Delta E (CIE1994) of two colors.
K_l:
0.045 graphic arts
0.048 textiles
K_2:
0.015 graphic arts
0.014 textiles
K_L:
1 default
2 textiles | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE1994",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff_matrix.py#L21-L56 |
gtaylor/python-colormath | colormath/color_diff_matrix.py | delta_e_cmc | def delta_e_cmc(lab_color_vector, lab_color_matrix, pl=2, pc=1):
"""
Calculates the Delta E (CIE1994) of two colors.
CMC values
Acceptability: pl=2, pc=1
Perceptability: pl=1, pc=1
"""
L, a, b = lab_color_vector
C_1 = numpy.sqrt(numpy.sum(numpy.power(lab_color_vector[1:], 2)))
... | python | def delta_e_cmc(lab_color_vector, lab_color_matrix, pl=2, pc=1):
"""
Calculates the Delta E (CIE1994) of two colors.
CMC values
Acceptability: pl=2, pc=1
Perceptability: pl=1, pc=1
"""
L, a, b = lab_color_vector
C_1 = numpy.sqrt(numpy.sum(numpy.power(lab_color_vector[1:], 2)))
... | [
"def",
"delta_e_cmc",
"(",
"lab_color_vector",
",",
"lab_color_matrix",
",",
"pl",
"=",
"2",
",",
"pc",
"=",
"1",
")",
":",
"L",
",",
"a",
",",
"b",
"=",
"lab_color_vector",
"C_1",
"=",
"numpy",
".",
"sqrt",
"(",
"numpy",
".",
"sum",
"(",
"numpy",
... | Calculates the Delta E (CIE1994) of two colors.
CMC values
Acceptability: pl=2, pc=1
Perceptability: pl=1, pc=1 | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE1994",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff_matrix.py#L60-L109 |
gtaylor/python-colormath | colormath/color_diff_matrix.py | delta_e_cie2000 | def delta_e_cie2000(lab_color_vector, lab_color_matrix, Kl=1, Kc=1, Kh=1):
"""
Calculates the Delta E (CIE2000) of two colors.
"""
L, a, b = lab_color_vector
avg_Lp = (L + lab_color_matrix[:, 0]) / 2.0
C1 = numpy.sqrt(numpy.sum(numpy.power(lab_color_vector[1:], 2)))
C2 = numpy.sqrt(numpy.s... | python | def delta_e_cie2000(lab_color_vector, lab_color_matrix, Kl=1, Kc=1, Kh=1):
"""
Calculates the Delta E (CIE2000) of two colors.
"""
L, a, b = lab_color_vector
avg_Lp = (L + lab_color_matrix[:, 0]) / 2.0
C1 = numpy.sqrt(numpy.sum(numpy.power(lab_color_vector[1:], 2)))
C2 = numpy.sqrt(numpy.s... | [
"def",
"delta_e_cie2000",
"(",
"lab_color_vector",
",",
"lab_color_matrix",
",",
"Kl",
"=",
"1",
",",
"Kc",
"=",
"1",
",",
"Kh",
"=",
"1",
")",
":",
"L",
",",
"a",
",",
"b",
"=",
"lab_color_vector",
"avg_Lp",
"=",
"(",
"L",
"+",
"lab_color_matrix",
"... | Calculates the Delta E (CIE2000) of two colors. | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE2000",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff_matrix.py#L113-L169 |
gtaylor/python-colormath | colormath/density.py | ansi_density | def ansi_density(color, density_standard):
"""
Calculates density for the given SpectralColor using the spectral weighting
function provided. For example, ANSI_STATUS_T_RED. These may be found in
:py:mod:`colormath.density_standards`.
:param SpectralColor color: The SpectralColor object to calculat... | python | def ansi_density(color, density_standard):
"""
Calculates density for the given SpectralColor using the spectral weighting
function provided. For example, ANSI_STATUS_T_RED. These may be found in
:py:mod:`colormath.density_standards`.
:param SpectralColor color: The SpectralColor object to calculat... | [
"def",
"ansi_density",
"(",
"color",
",",
"density_standard",
")",
":",
"# Load the spec_XXXnm attributes into a Numpy array.",
"sample",
"=",
"color",
".",
"get_numpy_array",
"(",
")",
"# Matrix multiplication",
"intermediate",
"=",
"sample",
"*",
"density_standard",
"# ... | Calculates density for the given SpectralColor using the spectral weighting
function provided. For example, ANSI_STATUS_T_RED. These may be found in
:py:mod:`colormath.density_standards`.
:param SpectralColor color: The SpectralColor object to calculate
density for.
:param numpy.ndarray density... | [
"Calculates",
"density",
"for",
"the",
"given",
"SpectralColor",
"using",
"the",
"spectral",
"weighting",
"function",
"provided",
".",
"For",
"example",
"ANSI_STATUS_T_RED",
".",
"These",
"may",
"be",
"found",
"in",
":",
"py",
":",
"mod",
":",
"colormath",
"."... | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/density.py#L11-L35 |
gtaylor/python-colormath | colormath/density.py | auto_density | def auto_density(color):
"""
Given a SpectralColor, automatically choose the correct ANSI T filter.
Returns a tuple with a string representation of the filter the
calculated density.
:param SpectralColor color: The SpectralColor object to calculate
density for.
:rtype: float
:return... | python | def auto_density(color):
"""
Given a SpectralColor, automatically choose the correct ANSI T filter.
Returns a tuple with a string representation of the filter the
calculated density.
:param SpectralColor color: The SpectralColor object to calculate
density for.
:rtype: float
:return... | [
"def",
"auto_density",
"(",
"color",
")",
":",
"blue_density",
"=",
"ansi_density",
"(",
"color",
",",
"ANSI_STATUS_T_BLUE",
")",
"green_density",
"=",
"ansi_density",
"(",
"color",
",",
"ANSI_STATUS_T_GREEN",
")",
"red_density",
"=",
"ansi_density",
"(",
"color",... | Given a SpectralColor, automatically choose the correct ANSI T filter.
Returns a tuple with a string representation of the filter the
calculated density.
:param SpectralColor color: The SpectralColor object to calculate
density for.
:rtype: float
:returns: The density value, with the filter... | [
"Given",
"a",
"SpectralColor",
"automatically",
"choose",
"the",
"correct",
"ANSI",
"T",
"filter",
".",
"Returns",
"a",
"tuple",
"with",
"a",
"string",
"representation",
"of",
"the",
"filter",
"the",
"calculated",
"density",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/density.py#L38-L67 |
gtaylor/python-colormath | colormath/color_diff.py | _get_lab_color1_vector | def _get_lab_color1_vector(color):
"""
Converts an LabColor into a NumPy vector.
:param LabColor color:
:rtype: numpy.ndarray
"""
if not color.__class__.__name__ == 'LabColor':
raise ValueError(
"Delta E functions can only be used with two LabColor objects.")
return nump... | python | def _get_lab_color1_vector(color):
"""
Converts an LabColor into a NumPy vector.
:param LabColor color:
:rtype: numpy.ndarray
"""
if not color.__class__.__name__ == 'LabColor':
raise ValueError(
"Delta E functions can only be used with two LabColor objects.")
return nump... | [
"def",
"_get_lab_color1_vector",
"(",
"color",
")",
":",
"if",
"not",
"color",
".",
"__class__",
".",
"__name__",
"==",
"'LabColor'",
":",
"raise",
"ValueError",
"(",
"\"Delta E functions can only be used with two LabColor objects.\"",
")",
"return",
"numpy",
".",
"ar... | Converts an LabColor into a NumPy vector.
:param LabColor color:
:rtype: numpy.ndarray | [
"Converts",
"an",
"LabColor",
"into",
"a",
"NumPy",
"vector",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff.py#L12-L22 |
gtaylor/python-colormath | colormath/color_diff.py | delta_e_cie1976 | def delta_e_cie1976(color1, color2):
"""
Calculates the Delta E (CIE1976) of two colors.
"""
color1_vector = _get_lab_color1_vector(color1)
color2_matrix = _get_lab_color2_matrix(color2)
delta_e = color_diff_matrix.delta_e_cie1976(color1_vector, color2_matrix)[0]
return numpy.asscalar(delta_... | python | def delta_e_cie1976(color1, color2):
"""
Calculates the Delta E (CIE1976) of two colors.
"""
color1_vector = _get_lab_color1_vector(color1)
color2_matrix = _get_lab_color2_matrix(color2)
delta_e = color_diff_matrix.delta_e_cie1976(color1_vector, color2_matrix)[0]
return numpy.asscalar(delta_... | [
"def",
"delta_e_cie1976",
"(",
"color1",
",",
"color2",
")",
":",
"color1_vector",
"=",
"_get_lab_color1_vector",
"(",
"color1",
")",
"color2_matrix",
"=",
"_get_lab_color2_matrix",
"(",
"color2",
")",
"delta_e",
"=",
"color_diff_matrix",
".",
"delta_e_cie1976",
"("... | Calculates the Delta E (CIE1976) of two colors. | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE1976",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff.py#L39-L46 |
gtaylor/python-colormath | colormath/color_diff.py | delta_e_cie1994 | def delta_e_cie1994(color1, color2, K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015):
"""
Calculates the Delta E (CIE1994) of two colors.
K_l:
0.045 graphic arts
0.048 textiles
K_2:
0.015 graphic arts
0.014 textiles
K_L:
1 default
2 textiles
"""
color1_vector =... | python | def delta_e_cie1994(color1, color2, K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015):
"""
Calculates the Delta E (CIE1994) of two colors.
K_l:
0.045 graphic arts
0.048 textiles
K_2:
0.015 graphic arts
0.014 textiles
K_L:
1 default
2 textiles
"""
color1_vector =... | [
"def",
"delta_e_cie1994",
"(",
"color1",
",",
"color2",
",",
"K_L",
"=",
"1",
",",
"K_C",
"=",
"1",
",",
"K_H",
"=",
"1",
",",
"K_1",
"=",
"0.045",
",",
"K_2",
"=",
"0.015",
")",
":",
"color1_vector",
"=",
"_get_lab_color1_vector",
"(",
"color1",
")"... | Calculates the Delta E (CIE1994) of two colors.
K_l:
0.045 graphic arts
0.048 textiles
K_2:
0.015 graphic arts
0.014 textiles
K_L:
1 default
2 textiles | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE1994",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff.py#L50-L68 |
gtaylor/python-colormath | colormath/color_diff.py | delta_e_cie2000 | def delta_e_cie2000(color1, color2, Kl=1, Kc=1, Kh=1):
"""
Calculates the Delta E (CIE2000) of two colors.
"""
color1_vector = _get_lab_color1_vector(color1)
color2_matrix = _get_lab_color2_matrix(color2)
delta_e = color_diff_matrix.delta_e_cie2000(
color1_vector, color2_matrix, Kl=Kl, K... | python | def delta_e_cie2000(color1, color2, Kl=1, Kc=1, Kh=1):
"""
Calculates the Delta E (CIE2000) of two colors.
"""
color1_vector = _get_lab_color1_vector(color1)
color2_matrix = _get_lab_color2_matrix(color2)
delta_e = color_diff_matrix.delta_e_cie2000(
color1_vector, color2_matrix, Kl=Kl, K... | [
"def",
"delta_e_cie2000",
"(",
"color1",
",",
"color2",
",",
"Kl",
"=",
"1",
",",
"Kc",
"=",
"1",
",",
"Kh",
"=",
"1",
")",
":",
"color1_vector",
"=",
"_get_lab_color1_vector",
"(",
"color1",
")",
"color2_matrix",
"=",
"_get_lab_color2_matrix",
"(",
"color... | Calculates the Delta E (CIE2000) of two colors. | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CIE2000",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff.py#L72-L80 |
gtaylor/python-colormath | colormath/color_diff.py | delta_e_cmc | def delta_e_cmc(color1, color2, pl=2, pc=1):
"""
Calculates the Delta E (CMC) of two colors.
CMC values
Acceptability: pl=2, pc=1
Perceptability: pl=1, pc=1
"""
color1_vector = _get_lab_color1_vector(color1)
color2_matrix = _get_lab_color2_matrix(color2)
delta_e = color_diff_mat... | python | def delta_e_cmc(color1, color2, pl=2, pc=1):
"""
Calculates the Delta E (CMC) of two colors.
CMC values
Acceptability: pl=2, pc=1
Perceptability: pl=1, pc=1
"""
color1_vector = _get_lab_color1_vector(color1)
color2_matrix = _get_lab_color2_matrix(color2)
delta_e = color_diff_mat... | [
"def",
"delta_e_cmc",
"(",
"color1",
",",
"color2",
",",
"pl",
"=",
"2",
",",
"pc",
"=",
"1",
")",
":",
"color1_vector",
"=",
"_get_lab_color1_vector",
"(",
"color1",
")",
"color2_matrix",
"=",
"_get_lab_color2_matrix",
"(",
"color2",
")",
"delta_e",
"=",
... | Calculates the Delta E (CMC) of two colors.
CMC values
Acceptability: pl=2, pc=1
Perceptability: pl=1, pc=1 | [
"Calculates",
"the",
"Delta",
"E",
"(",
"CMC",
")",
"of",
"two",
"colors",
"."
] | train | https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/colormath/color_diff.py#L84-L96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.