repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
bierschenk/ode | ode/integrators.py | euler | def euler(dfun, xzero, timerange, timestep):
'''Euler method integration. This function wraps the Euler class.
:param dfun:
derivative function of the system.
The differential system arranged as a series of first-order
equations: \\dot{X} = dfun(t, x)
:param xzer... | python | def euler(dfun, xzero, timerange, timestep):
'''Euler method integration. This function wraps the Euler class.
:param dfun:
derivative function of the system.
The differential system arranged as a series of first-order
equations: \\dot{X} = dfun(t, x)
:param xzer... | [
"def",
"euler",
"(",
"dfun",
",",
"xzero",
",",
"timerange",
",",
"timestep",
")",
":",
"return",
"zip",
"(",
"*",
"list",
"(",
"Euler",
"(",
"dfun",
",",
"xzero",
",",
"timerange",
",",
"timestep",
")",
")",
")"
] | Euler method integration. This function wraps the Euler class.
:param dfun:
derivative function of the system.
The differential system arranged as a series of first-order
equations: \\dot{X} = dfun(t, x)
:param xzero:
the initial condition of the system
... | [
"Euler",
"method",
"integration",
".",
"This",
"function",
"wraps",
"the",
"Euler",
"class",
"."
] | train | https://github.com/bierschenk/ode/blob/01fb714874926f0988a4bb250d2a0c8a2429e4f0/ode/integrators.py#L72-L88 |
bierschenk/ode | ode/integrators.py | verlet | def verlet(dfun, xzero, vzero, timerange, timestep):
'''Verlet method integration. This function wraps the Verlet class.
:param dfun:
second derivative function of the system.
The differential system arranged as a series of second-order
equations: \ddot{X} = dfun(t, x)
... | python | def verlet(dfun, xzero, vzero, timerange, timestep):
'''Verlet method integration. This function wraps the Verlet class.
:param dfun:
second derivative function of the system.
The differential system arranged as a series of second-order
equations: \ddot{X} = dfun(t, x)
... | [
"def",
"verlet",
"(",
"dfun",
",",
"xzero",
",",
"vzero",
",",
"timerange",
",",
"timestep",
")",
":",
"return",
"zip",
"(",
"*",
"list",
"(",
"Verlet",
"(",
"dfun",
",",
"xzero",
",",
"vzero",
",",
"timerange",
",",
"timestep",
")",
")",
")"
] | Verlet method integration. This function wraps the Verlet class.
:param dfun:
second derivative function of the system.
The differential system arranged as a series of second-order
equations: \ddot{X} = dfun(t, x)
:param xzero:
the initial condition of th... | [
"Verlet",
"method",
"integration",
".",
"This",
"function",
"wraps",
"the",
"Verlet",
"class",
"."
] | train | https://github.com/bierschenk/ode/blob/01fb714874926f0988a4bb250d2a0c8a2429e4f0/ode/integrators.py#L145-L163 |
bierschenk/ode | ode/integrators.py | backwardeuler | def backwardeuler(dfun, xzero, timerange, timestep):
'''Backward Euler method integration. This function wraps BackwardEuler.
:param dfun:
Derivative function of the system.
The differential system arranged as a series of first-order
equations: \dot{X} = dfun(t, x)
... | python | def backwardeuler(dfun, xzero, timerange, timestep):
'''Backward Euler method integration. This function wraps BackwardEuler.
:param dfun:
Derivative function of the system.
The differential system arranged as a series of first-order
equations: \dot{X} = dfun(t, x)
... | [
"def",
"backwardeuler",
"(",
"dfun",
",",
"xzero",
",",
"timerange",
",",
"timestep",
")",
":",
"return",
"zip",
"(",
"*",
"list",
"(",
"BackwardEuler",
"(",
"dfun",
",",
"xzero",
",",
"timerange",
",",
"timestep",
")",
")",
")"
] | Backward Euler method integration. This function wraps BackwardEuler.
:param dfun:
Derivative function of the system.
The differential system arranged as a series of first-order
equations: \dot{X} = dfun(t, x)
:param xzero:
The initial condition of the sy... | [
"Backward",
"Euler",
"method",
"integration",
".",
"This",
"function",
"wraps",
"BackwardEuler",
"."
] | train | https://github.com/bierschenk/ode/blob/01fb714874926f0988a4bb250d2a0c8a2429e4f0/ode/integrators.py#L228-L252 |
craigahobbs/chisel | src/chisel/app.py | Application.add_request | def add_request(self, request):
"""
Add a request object
"""
# Duplicate request name?
if request.name in self.requests:
raise ValueError('redefinition of request "{0}"'.format(request.name))
self.requests[request.name] = request
# Add the request UR... | python | def add_request(self, request):
"""
Add a request object
"""
# Duplicate request name?
if request.name in self.requests:
raise ValueError('redefinition of request "{0}"'.format(request.name))
self.requests[request.name] = request
# Add the request UR... | [
"def",
"add_request",
"(",
"self",
",",
"request",
")",
":",
"# Duplicate request name?",
"if",
"request",
".",
"name",
"in",
"self",
".",
"requests",
":",
"raise",
"ValueError",
"(",
"'redefinition of request \"{0}\"'",
".",
"format",
"(",
"request",
".",
"name... | Add a request object | [
"Add",
"a",
"request",
"object"
] | train | https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L44-L65 |
craigahobbs/chisel | src/chisel/app.py | Context.add_header | def add_header(self, key, value):
"""
Add a response header
"""
assert isinstance(key, str), 'header key must be of type str'
assert isinstance(value, str), 'header value must be of type str'
self.headers[key] = value | python | def add_header(self, key, value):
"""
Add a response header
"""
assert isinstance(key, str), 'header key must be of type str'
assert isinstance(value, str), 'header value must be of type str'
self.headers[key] = value | [
"def",
"add_header",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"key",
",",
"str",
")",
",",
"'header key must be of type str'",
"assert",
"isinstance",
"(",
"value",
",",
"str",
")",
",",
"'header value must be of type str'",
... | Add a response header | [
"Add",
"a",
"response",
"header"
] | train | https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L178-L185 |
craigahobbs/chisel | src/chisel/app.py | Context.response | def response(self, status, content_type, content, headers=None):
"""
Send an HTTP response
"""
assert not isinstance(content, (str, bytes)), 'response content cannot be of type str or bytes'
response_headers = [('Content-Type', content_type)]
if headers:
resp... | python | def response(self, status, content_type, content, headers=None):
"""
Send an HTTP response
"""
assert not isinstance(content, (str, bytes)), 'response content cannot be of type str or bytes'
response_headers = [('Content-Type', content_type)]
if headers:
resp... | [
"def",
"response",
"(",
"self",
",",
"status",
",",
"content_type",
",",
"content",
",",
"headers",
"=",
"None",
")",
":",
"assert",
"not",
"isinstance",
"(",
"content",
",",
"(",
"str",
",",
"bytes",
")",
")",
",",
"'response content cannot be of type str o... | Send an HTTP response | [
"Send",
"an",
"HTTP",
"response"
] | train | https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L200-L210 |
craigahobbs/chisel | src/chisel/app.py | Context.response_text | def response_text(self, status, text=None, content_type='text/plain', encoding='utf-8', headers=None):
"""
Send a plain-text response
"""
if text is None:
if isinstance(status, str):
text = status
else:
text = status.phrase
... | python | def response_text(self, status, text=None, content_type='text/plain', encoding='utf-8', headers=None):
"""
Send a plain-text response
"""
if text is None:
if isinstance(status, str):
text = status
else:
text = status.phrase
... | [
"def",
"response_text",
"(",
"self",
",",
"status",
",",
"text",
"=",
"None",
",",
"content_type",
"=",
"'text/plain'",
",",
"encoding",
"=",
"'utf-8'",
",",
"headers",
"=",
"None",
")",
":",
"if",
"text",
"is",
"None",
":",
"if",
"isinstance",
"(",
"s... | Send a plain-text response | [
"Send",
"a",
"plain",
"-",
"text",
"response"
] | train | https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L212-L222 |
craigahobbs/chisel | src/chisel/app.py | Context.response_json | def response_json(self, status, response, content_type='application/json', encoding='utf-8', headers=None, jsonp=None):
"""
Send a JSON response
"""
encoder = JSONEncoder(
check_circular=self.app.validate_output,
allow_nan=False,
sort_keys=True,
... | python | def response_json(self, status, response, content_type='application/json', encoding='utf-8', headers=None, jsonp=None):
"""
Send a JSON response
"""
encoder = JSONEncoder(
check_circular=self.app.validate_output,
allow_nan=False,
sort_keys=True,
... | [
"def",
"response_json",
"(",
"self",
",",
"status",
",",
"response",
",",
"content_type",
"=",
"'application/json'",
",",
"encoding",
"=",
"'utf-8'",
",",
"headers",
"=",
"None",
",",
"jsonp",
"=",
"None",
")",
":",
"encoder",
"=",
"JSONEncoder",
"(",
"che... | Send a JSON response | [
"Send",
"a",
"JSON",
"response"
] | train | https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L224-L241 |
craigahobbs/chisel | src/chisel/app.py | Context.reconstruct_url | def reconstruct_url(self, path_info=None, query_string=None, relative=False):
"""
Reconstructs the request URL using the algorithm provided by PEP3333
"""
environ = self.environ
if relative:
url = ''
else:
url = environ['wsgi.url_scheme'] + '://'
... | python | def reconstruct_url(self, path_info=None, query_string=None, relative=False):
"""
Reconstructs the request URL using the algorithm provided by PEP3333
"""
environ = self.environ
if relative:
url = ''
else:
url = environ['wsgi.url_scheme'] + '://'
... | [
"def",
"reconstruct_url",
"(",
"self",
",",
"path_info",
"=",
"None",
",",
"query_string",
"=",
"None",
",",
"relative",
"=",
"False",
")",
":",
"environ",
"=",
"self",
".",
"environ",
"if",
"relative",
":",
"url",
"=",
"''",
"else",
":",
"url",
"=",
... | Reconstructs the request URL using the algorithm provided by PEP3333 | [
"Reconstructs",
"the",
"request",
"URL",
"using",
"the",
"algorithm",
"provided",
"by",
"PEP3333"
] | train | https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L243-L281 |
HolmesNL/confidence | confidence/io.py | read_xdg_config_dirs | def read_xdg_config_dirs(name, extension):
"""
Read from files found in XDG-specified system-wide configuration paths,
defaulting to ``/etc/xdg``. Depends on ``XDG_CONFIG_DIRS`` environment
variable.
:param name: application or configuration set name
:param extension: file extension to look for... | python | def read_xdg_config_dirs(name, extension):
"""
Read from files found in XDG-specified system-wide configuration paths,
defaulting to ``/etc/xdg``. Depends on ``XDG_CONFIG_DIRS`` environment
variable.
:param name: application or configuration set name
:param extension: file extension to look for... | [
"def",
"read_xdg_config_dirs",
"(",
"name",
",",
"extension",
")",
":",
"# find optional value of ${XDG_CONFIG_DIRS}",
"config_dirs",
"=",
"environ",
".",
"get",
"(",
"'XDG_CONFIG_DIRS'",
")",
"if",
"config_dirs",
":",
"# PATH-like env vars operate in decreasing precedence, r... | Read from files found in XDG-specified system-wide configuration paths,
defaulting to ``/etc/xdg``. Depends on ``XDG_CONFIG_DIRS`` environment
variable.
:param name: application or configuration set name
:param extension: file extension to look for
:return: a `.Configuration` instance with values r... | [
"Read",
"from",
"files",
"found",
"in",
"XDG",
"-",
"specified",
"system",
"-",
"wide",
"configuration",
"paths",
"defaulting",
"to",
"/",
"etc",
"/",
"xdg",
".",
"Depends",
"on",
"XDG_CONFIG_DIRS",
"environment",
"variable",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L12-L35 |
HolmesNL/confidence | confidence/io.py | read_xdg_config_home | def read_xdg_config_home(name, extension):
"""
Read from file found in XDG-specified configuration home directory,
expanding to ``${HOME}/.config/name.extension`` by default. Depends on
``XDG_CONFIG_HOME`` or ``HOME`` environment variables.
:param name: application or configuration set name
:pa... | python | def read_xdg_config_home(name, extension):
"""
Read from file found in XDG-specified configuration home directory,
expanding to ``${HOME}/.config/name.extension`` by default. Depends on
``XDG_CONFIG_HOME`` or ``HOME`` environment variables.
:param name: application or configuration set name
:pa... | [
"def",
"read_xdg_config_home",
"(",
"name",
",",
"extension",
")",
":",
"# find optional value of ${XDG_CONFIG_HOME}",
"config_home",
"=",
"environ",
".",
"get",
"(",
"'XDG_CONFIG_HOME'",
")",
"if",
"not",
"config_home",
":",
"# XDG spec: \"If $XDG_CONFIG_HOME is either not... | Read from file found in XDG-specified configuration home directory,
expanding to ``${HOME}/.config/name.extension`` by default. Depends on
``XDG_CONFIG_HOME`` or ``HOME`` environment variables.
:param name: application or configuration set name
:param extension: file extension to look for
:return: ... | [
"Read",
"from",
"file",
"found",
"in",
"XDG",
"-",
"specified",
"configuration",
"home",
"directory",
"expanding",
"to",
"$",
"{",
"HOME",
"}",
"/",
".",
"config",
"/",
"name",
".",
"extension",
"by",
"default",
".",
"Depends",
"on",
"XDG_CONFIG_HOME",
"or... | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L38-L57 |
HolmesNL/confidence | confidence/io.py | read_envvars | def read_envvars(name, extension):
"""
Read environment variables starting with ``NAME_``, where subsequent
underscores are interpreted as namespaces. Underscores can be retained as
namespaces by doubling them up, e.g. ``NAME_SPA__CE_KEY`` would be
accessible in the resulting `.Configuration` as
... | python | def read_envvars(name, extension):
"""
Read environment variables starting with ``NAME_``, where subsequent
underscores are interpreted as namespaces. Underscores can be retained as
namespaces by doubling them up, e.g. ``NAME_SPA__CE_KEY`` would be
accessible in the resulting `.Configuration` as
... | [
"def",
"read_envvars",
"(",
"name",
",",
"extension",
")",
":",
"prefix",
"=",
"'{}_'",
".",
"format",
"(",
"name",
")",
"prefix_len",
"=",
"len",
"(",
"prefix",
")",
"envvar_file",
"=",
"'{}_config_file'",
".",
"format",
"(",
"name",
")",
"# create a new ... | Read environment variables starting with ``NAME_``, where subsequent
underscores are interpreted as namespaces. Underscores can be retained as
namespaces by doubling them up, e.g. ``NAME_SPA__CE_KEY`` would be
accessible in the resulting `.Configuration` as
``c.spa_ce.key``, where ``c`` is the `.Configu... | [
"Read",
"environment",
"variables",
"starting",
"with",
"NAME_",
"where",
"subsequent",
"underscores",
"are",
"interpreted",
"as",
"namespaces",
".",
"Underscores",
"can",
"be",
"retained",
"as",
"namespaces",
"by",
"doubling",
"them",
"up",
"e",
".",
"g",
".",
... | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L60-L96 |
HolmesNL/confidence | confidence/io.py | read_envvar_file | def read_envvar_file(name, extension):
"""
Read values from a file provided as a environment variable
``NAME_CONFIG_FILE``.
:param name: environment variable prefix to look for (without the
``_CONFIG_FILE``)
:param extension: *(unused)*
:return: a `.Configuration`, possibly `.NotConfigu... | python | def read_envvar_file(name, extension):
"""
Read values from a file provided as a environment variable
``NAME_CONFIG_FILE``.
:param name: environment variable prefix to look for (without the
``_CONFIG_FILE``)
:param extension: *(unused)*
:return: a `.Configuration`, possibly `.NotConfigu... | [
"def",
"read_envvar_file",
"(",
"name",
",",
"extension",
")",
":",
"envvar_file",
"=",
"environ",
".",
"get",
"(",
"'{}_config_file'",
".",
"format",
"(",
"name",
")",
".",
"upper",
"(",
")",
")",
"if",
"envvar_file",
":",
"# envvar set, load value as file",
... | Read values from a file provided as a environment variable
``NAME_CONFIG_FILE``.
:param name: environment variable prefix to look for (without the
``_CONFIG_FILE``)
:param extension: *(unused)*
:return: a `.Configuration`, possibly `.NotConfigured` | [
"Read",
"values",
"from",
"a",
"file",
"provided",
"as",
"a",
"environment",
"variable",
"NAME_CONFIG_FILE",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L99-L115 |
HolmesNL/confidence | confidence/io.py | read_envvar_dir | def read_envvar_dir(envvar, name, extension):
"""
Read values from a file located in a directory specified by a particular
environment file. ``read_envvar_dir('HOME', 'example', 'yaml')`` would
look for a file at ``/home/user/example.yaml``. When the environment
variable isn't set or the file does n... | python | def read_envvar_dir(envvar, name, extension):
"""
Read values from a file located in a directory specified by a particular
environment file. ``read_envvar_dir('HOME', 'example', 'yaml')`` would
look for a file at ``/home/user/example.yaml``. When the environment
variable isn't set or the file does n... | [
"def",
"read_envvar_dir",
"(",
"envvar",
",",
"name",
",",
"extension",
")",
":",
"config_dir",
"=",
"environ",
".",
"get",
"(",
"envvar",
")",
"if",
"not",
"config_dir",
":",
"return",
"NotConfigured",
"# envvar is set, construct full file path, expanding user to all... | Read values from a file located in a directory specified by a particular
environment file. ``read_envvar_dir('HOME', 'example', 'yaml')`` would
look for a file at ``/home/user/example.yaml``. When the environment
variable isn't set or the file does not exist, `NotConfigured` will be
returned.
:para... | [
"Read",
"values",
"from",
"a",
"file",
"located",
"in",
"a",
"directory",
"specified",
"by",
"a",
"particular",
"environment",
"file",
".",
"read_envvar_dir",
"(",
"HOME",
"example",
"yaml",
")",
"would",
"look",
"for",
"a",
"file",
"at",
"/",
"home",
"/",... | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L118-L137 |
HolmesNL/confidence | confidence/io.py | loaders | def loaders(*specifiers):
"""
Generates loaders in the specified order.
Arguments can be `.Locality` instances, producing the loader(s) available
for that locality, `str` instances (used as file path templates) or
`callable`s. These can be mixed:
.. code-block:: python
# define a load... | python | def loaders(*specifiers):
"""
Generates loaders in the specified order.
Arguments can be `.Locality` instances, producing the loader(s) available
for that locality, `str` instances (used as file path templates) or
`callable`s. These can be mixed:
.. code-block:: python
# define a load... | [
"def",
"loaders",
"(",
"*",
"specifiers",
")",
":",
"for",
"specifier",
"in",
"specifiers",
":",
"if",
"isinstance",
"(",
"specifier",
",",
"Locality",
")",
":",
"# localities can carry multiple loaders, flatten this",
"yield",
"from",
"_LOADERS",
"[",
"specifier",
... | Generates loaders in the specified order.
Arguments can be `.Locality` instances, producing the loader(s) available
for that locality, `str` instances (used as file path templates) or
`callable`s. These can be mixed:
.. code-block:: python
# define a load order using predefined user-local loc... | [
"Generates",
"loaders",
"in",
"the",
"specified",
"order",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L184-L214 |
HolmesNL/confidence | confidence/io.py | load | def load(*fps, missing=Missing.silent):
"""
Read a `.Configuration` instance from file-like objects.
:param fps: file-like objects (supporting ``.read()``)
:param missing: policy to be used when a configured key is missing, either
as a `.Missing` instance or a default value
:return: a `.Con... | python | def load(*fps, missing=Missing.silent):
"""
Read a `.Configuration` instance from file-like objects.
:param fps: file-like objects (supporting ``.read()``)
:param missing: policy to be used when a configured key is missing, either
as a `.Missing` instance or a default value
:return: a `.Con... | [
"def",
"load",
"(",
"*",
"fps",
",",
"missing",
"=",
"Missing",
".",
"silent",
")",
":",
"return",
"Configuration",
"(",
"*",
"(",
"yaml",
".",
"safe_load",
"(",
"fp",
".",
"read",
"(",
")",
")",
"for",
"fp",
"in",
"fps",
")",
",",
"missing",
"="... | Read a `.Configuration` instance from file-like objects.
:param fps: file-like objects (supporting ``.read()``)
:param missing: policy to be used when a configured key is missing, either
as a `.Missing` instance or a default value
:return: a `.Configuration` instance providing values from *fps*
... | [
"Read",
"a",
".",
"Configuration",
"instance",
"from",
"file",
"-",
"like",
"objects",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L223-L233 |
HolmesNL/confidence | confidence/io.py | loadf | def loadf(*fnames, default=_NoDefault, missing=Missing.silent):
"""
Read a `.Configuration` instance from named files.
:param fnames: name of the files to ``open()``
:param default: `dict` or `.Configuration` to use when a file does not
exist (default is to raise a `FileNotFoundError`)
:par... | python | def loadf(*fnames, default=_NoDefault, missing=Missing.silent):
"""
Read a `.Configuration` instance from named files.
:param fnames: name of the files to ``open()``
:param default: `dict` or `.Configuration` to use when a file does not
exist (default is to raise a `FileNotFoundError`)
:par... | [
"def",
"loadf",
"(",
"*",
"fnames",
",",
"default",
"=",
"_NoDefault",
",",
"missing",
"=",
"Missing",
".",
"silent",
")",
":",
"def",
"readf",
"(",
"fname",
")",
":",
"if",
"default",
"is",
"_NoDefault",
"or",
"path",
".",
"exists",
"(",
"fname",
")... | Read a `.Configuration` instance from named files.
:param fnames: name of the files to ``open()``
:param default: `dict` or `.Configuration` to use when a file does not
exist (default is to raise a `FileNotFoundError`)
:param missing: policy to be used when a configured key is missing, either
... | [
"Read",
"a",
".",
"Configuration",
"instance",
"from",
"named",
"files",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L236-L257 |
HolmesNL/confidence | confidence/io.py | loads | def loads(*strings, missing=Missing.silent):
"""
Read a `.Configuration` instance from strings.
:param strings: configuration contents
:param missing: policy to be used when a configured key is missing, either
as a `.Missing` instance or a default value
:return: a `.Configuration` instance ... | python | def loads(*strings, missing=Missing.silent):
"""
Read a `.Configuration` instance from strings.
:param strings: configuration contents
:param missing: policy to be used when a configured key is missing, either
as a `.Missing` instance or a default value
:return: a `.Configuration` instance ... | [
"def",
"loads",
"(",
"*",
"strings",
",",
"missing",
"=",
"Missing",
".",
"silent",
")",
":",
"return",
"Configuration",
"(",
"*",
"(",
"yaml",
".",
"safe_load",
"(",
"string",
")",
"for",
"string",
"in",
"strings",
")",
",",
"missing",
"=",
"missing",... | Read a `.Configuration` instance from strings.
:param strings: configuration contents
:param missing: policy to be used when a configured key is missing, either
as a `.Missing` instance or a default value
:return: a `.Configuration` instance providing values from *strings*
:rtype: `.Configurati... | [
"Read",
"a",
".",
"Configuration",
"instance",
"from",
"strings",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L260-L270 |
HolmesNL/confidence | confidence/io.py | load_name | def load_name(*names, load_order=DEFAULT_LOAD_ORDER, extension='yaml', missing=Missing.silent):
"""
Read a `.Configuration` instance by name, trying to read from files in
increasing significance. The default load order is `.system`, `.user`,
`.application`, `.environment`.
Multiple names are combin... | python | def load_name(*names, load_order=DEFAULT_LOAD_ORDER, extension='yaml', missing=Missing.silent):
"""
Read a `.Configuration` instance by name, trying to read from files in
increasing significance. The default load order is `.system`, `.user`,
`.application`, `.environment`.
Multiple names are combin... | [
"def",
"load_name",
"(",
"*",
"names",
",",
"load_order",
"=",
"DEFAULT_LOAD_ORDER",
",",
"extension",
"=",
"'yaml'",
",",
"missing",
"=",
"Missing",
".",
"silent",
")",
":",
"def",
"generate_sources",
"(",
")",
":",
"# argument order for product matters, for name... | Read a `.Configuration` instance by name, trying to read from files in
increasing significance. The default load order is `.system`, `.user`,
`.application`, `.environment`.
Multiple names are combined with multiple loaders using names as the 'inner
loop / selector', loading ``/etc/name1.yaml`` and ``/... | [
"Read",
"a",
".",
"Configuration",
"instance",
"by",
"name",
"trying",
"to",
"read",
"from",
"files",
"in",
"increasing",
"significance",
".",
"The",
"default",
"load",
"order",
"is",
".",
"system",
".",
"user",
".",
"application",
".",
"environment",
"."
] | train | https://github.com/HolmesNL/confidence/blob/e14d2d8769a01fa55676716f7a2f22714c2616d3/confidence/io.py#L273-L304 |
hassa/BeatCop | beatcop.py | Lock.acquire | def acquire(self, block=True):
"""Acquire lock. Blocks until acquired if `block` is `True`, otherwise returns `False` if the lock could not be acquired."""
while True:
# Try to set the lock
if self.redis.set(self.name, self.value, px=self.timeout, nx=True):
# It's... | python | def acquire(self, block=True):
"""Acquire lock. Blocks until acquired if `block` is `True`, otherwise returns `False` if the lock could not be acquired."""
while True:
# Try to set the lock
if self.redis.set(self.name, self.value, px=self.timeout, nx=True):
# It's... | [
"def",
"acquire",
"(",
"self",
",",
"block",
"=",
"True",
")",
":",
"while",
"True",
":",
"# Try to set the lock",
"if",
"self",
".",
"redis",
".",
"set",
"(",
"self",
".",
"name",
",",
"self",
".",
"value",
",",
"px",
"=",
"self",
".",
"timeout",
... | Acquire lock. Blocks until acquired if `block` is `True`, otherwise returns `False` if the lock could not be acquired. | [
"Acquire",
"lock",
".",
"Blocks",
"until",
"acquired",
"if",
"block",
"is",
"True",
"otherwise",
"returns",
"False",
"if",
"the",
"lock",
"could",
"not",
"be",
"acquired",
"."
] | train | https://github.com/hassa/BeatCop/blob/bf7721e17a7828728b15c5833f047d858111197c/beatcop.py#L59-L70 |
hassa/BeatCop | beatcop.py | Lock.refresh | def refresh(self):
"""Refresh an existing lock to prevent it from expiring.
Uses a LUA (EVAL) script to ensure only a lock which we own is being overwritten.
Returns True if refresh succeeded, False if not."""
keys = [self.name]
args = [self.value, self.timeout]
# Redis d... | python | def refresh(self):
"""Refresh an existing lock to prevent it from expiring.
Uses a LUA (EVAL) script to ensure only a lock which we own is being overwritten.
Returns True if refresh succeeded, False if not."""
keys = [self.name]
args = [self.value, self.timeout]
# Redis d... | [
"def",
"refresh",
"(",
"self",
")",
":",
"keys",
"=",
"[",
"self",
".",
"name",
"]",
"args",
"=",
"[",
"self",
".",
"value",
",",
"self",
".",
"timeout",
"]",
"# Redis docs claim EVALs are atomic, and I'm inclined to believe it.",
"if",
"hasattr",
"(",
"self",... | Refresh an existing lock to prevent it from expiring.
Uses a LUA (EVAL) script to ensure only a lock which we own is being overwritten.
Returns True if refresh succeeded, False if not. | [
"Refresh",
"an",
"existing",
"lock",
"to",
"prevent",
"it",
"from",
"expiring",
".",
"Uses",
"a",
"LUA",
"(",
"EVAL",
")",
"script",
"to",
"ensure",
"only",
"a",
"lock",
"which",
"we",
"own",
"is",
"being",
"overwritten",
".",
"Returns",
"True",
"if",
... | train | https://github.com/hassa/BeatCop/blob/bf7721e17a7828728b15c5833f047d858111197c/beatcop.py#L72-L83 |
hassa/BeatCop | beatcop.py | BeatCop.run | def run(self):
"""Run process if nobody else is, otherwise wait until we're needed. Never returns."""
log.info("Waiting for lock, currently held by %s", self.lock.who())
if self.lock.acquire():
log.info("Lock '%s' acquired", self.lockname)
# We got the lock, so we make s... | python | def run(self):
"""Run process if nobody else is, otherwise wait until we're needed. Never returns."""
log.info("Waiting for lock, currently held by %s", self.lock.who())
if self.lock.acquire():
log.info("Lock '%s' acquired", self.lockname)
# We got the lock, so we make s... | [
"def",
"run",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Waiting for lock, currently held by %s\"",
",",
"self",
".",
"lock",
".",
"who",
"(",
")",
")",
"if",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"Loc... | Run process if nobody else is, otherwise wait until we're needed. Never returns. | [
"Run",
"process",
"if",
"nobody",
"else",
"is",
"otherwise",
"wait",
"until",
"we",
"re",
"needed",
".",
"Never",
"returns",
"."
] | train | https://github.com/hassa/BeatCop/blob/bf7721e17a7828728b15c5833f047d858111197c/beatcop.py#L140-L170 |
hassa/BeatCop | beatcop.py | BeatCop.spawn | def spawn(self, command):
"""Spawn process."""
if self.shell:
args = command
else:
args = shlex.split(command)
return subprocess.Popen(args, shell=self.shell) | python | def spawn(self, command):
"""Spawn process."""
if self.shell:
args = command
else:
args = shlex.split(command)
return subprocess.Popen(args, shell=self.shell) | [
"def",
"spawn",
"(",
"self",
",",
"command",
")",
":",
"if",
"self",
".",
"shell",
":",
"args",
"=",
"command",
"else",
":",
"args",
"=",
"shlex",
".",
"split",
"(",
"command",
")",
"return",
"subprocess",
".",
"Popen",
"(",
"args",
",",
"shell",
"... | Spawn process. | [
"Spawn",
"process",
"."
] | train | https://github.com/hassa/BeatCop/blob/bf7721e17a7828728b15c5833f047d858111197c/beatcop.py#L172-L178 |
hassa/BeatCop | beatcop.py | BeatCop.cleanup | def cleanup(self):
"""Clean up, making sure the process is stopped before we pack up and go home."""
if self.process is None: # Process wasn't running yet, so nothing to worry about
return
if self.process.poll() is None:
log.info("Sending TERM to %d", self.process.pid)
... | python | def cleanup(self):
"""Clean up, making sure the process is stopped before we pack up and go home."""
if self.process is None: # Process wasn't running yet, so nothing to worry about
return
if self.process.poll() is None:
log.info("Sending TERM to %d", self.process.pid)
... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"if",
"self",
".",
"process",
"is",
"None",
":",
"# Process wasn't running yet, so nothing to worry about",
"return",
"if",
"self",
".",
"process",
".",
"poll",
"(",
")",
"is",
"None",
":",
"log",
".",
"info",
"(",
... | Clean up, making sure the process is stopped before we pack up and go home. | [
"Clean",
"up",
"making",
"sure",
"the",
"process",
"is",
"stopped",
"before",
"we",
"pack",
"up",
"and",
"go",
"home",
"."
] | train | https://github.com/hassa/BeatCop/blob/bf7721e17a7828728b15c5833f047d858111197c/beatcop.py#L180-L196 |
hassa/BeatCop | beatcop.py | BeatCop.handle_signal | def handle_signal(self, sig, frame):
"""Handles signals, surprisingly."""
if sig in [signal.SIGINT]:
log.warning("Ctrl-C pressed, shutting down...")
if sig in [signal.SIGTERM]:
log.warning("SIGTERM received, shutting down...")
self.cleanup()
sys.exit(-sig) | python | def handle_signal(self, sig, frame):
"""Handles signals, surprisingly."""
if sig in [signal.SIGINT]:
log.warning("Ctrl-C pressed, shutting down...")
if sig in [signal.SIGTERM]:
log.warning("SIGTERM received, shutting down...")
self.cleanup()
sys.exit(-sig) | [
"def",
"handle_signal",
"(",
"self",
",",
"sig",
",",
"frame",
")",
":",
"if",
"sig",
"in",
"[",
"signal",
".",
"SIGINT",
"]",
":",
"log",
".",
"warning",
"(",
"\"Ctrl-C pressed, shutting down...\"",
")",
"if",
"sig",
"in",
"[",
"signal",
".",
"SIGTERM",... | Handles signals, surprisingly. | [
"Handles",
"signals",
"surprisingly",
"."
] | train | https://github.com/hassa/BeatCop/blob/bf7721e17a7828728b15c5833f047d858111197c/beatcop.py#L198-L205 |
alfredodeza/notario | notario/engine.py | validate | def validate(data, schema, defined_keys=False):
"""
Main entry point for the validation engine.
:param data: The incoming data, as a dictionary object.
:param schema: The schema from which data will be validated against
"""
if isinstance(data, dict):
validator = Validator(data, schema, ... | python | def validate(data, schema, defined_keys=False):
"""
Main entry point for the validation engine.
:param data: The incoming data, as a dictionary object.
:param schema: The schema from which data will be validated against
"""
if isinstance(data, dict):
validator = Validator(data, schema, ... | [
"def",
"validate",
"(",
"data",
",",
"schema",
",",
"defined_keys",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"validator",
"=",
"Validator",
"(",
"data",
",",
"schema",
",",
"defined_keys",
"=",
"defined_keys",
")",
... | Main entry point for the validation engine.
:param data: The incoming data, as a dictionary object.
:param schema: The schema from which data will be validated against | [
"Main",
"entry",
"point",
"for",
"the",
"validation",
"engine",
"."
] | train | https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/engine.py#L343-L354 |
alfredodeza/notario | notario/engine.py | Validator.traverser | def traverser(self, data, schema, tree):
"""
Traverses the dictionary, recursing onto itself if
it sees appropriate key/value pairs that indicate that
there is a need for more validation in a branch below us.
"""
if hasattr(schema, '__validator_leaf__'):
retur... | python | def traverser(self, data, schema, tree):
"""
Traverses the dictionary, recursing onto itself if
it sees appropriate key/value pairs that indicate that
there is a need for more validation in a branch below us.
"""
if hasattr(schema, '__validator_leaf__'):
retur... | [
"def",
"traverser",
"(",
"self",
",",
"data",
",",
"schema",
",",
"tree",
")",
":",
"if",
"hasattr",
"(",
"schema",
",",
"'__validator_leaf__'",
")",
":",
"return",
"schema",
"(",
"data",
",",
"tree",
")",
"if",
"hasattr",
"(",
"schema",
",",
"'must_va... | Traverses the dictionary, recursing onto itself if
it sees appropriate key/value pairs that indicate that
there is a need for more validation in a branch below us. | [
"Traverses",
"the",
"dictionary",
"recursing",
"onto",
"itself",
"if",
"it",
"sees",
"appropriate",
"key",
"/",
"value",
"pairs",
"that",
"indicate",
"that",
"there",
"is",
"a",
"need",
"for",
"more",
"validation",
"in",
"a",
"branch",
"below",
"us",
"."
] | train | https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/engine.py#L24-L118 |
alfredodeza/notario | notario/engine.py | Validator.key_leaf | def key_leaf(self, data, schema, tree):
"""
The deepest validation we can make in any given circumstance for a key.
Does not recurse, it will just receive both values and the tree,
passing them on to the :fun:`enforce` function.
"""
key, value = data
schema_key, s... | python | def key_leaf(self, data, schema, tree):
"""
The deepest validation we can make in any given circumstance for a key.
Does not recurse, it will just receive both values and the tree,
passing them on to the :fun:`enforce` function.
"""
key, value = data
schema_key, s... | [
"def",
"key_leaf",
"(",
"self",
",",
"data",
",",
"schema",
",",
"tree",
")",
":",
"key",
",",
"value",
"=",
"data",
"schema_key",
",",
"schema_value",
"=",
"schema",
"enforce",
"(",
"key",
",",
"schema_key",
",",
"tree",
",",
"'key'",
")"
] | The deepest validation we can make in any given circumstance for a key.
Does not recurse, it will just receive both values and the tree,
passing them on to the :fun:`enforce` function. | [
"The",
"deepest",
"validation",
"we",
"can",
"make",
"in",
"any",
"given",
"circumstance",
"for",
"a",
"key",
".",
"Does",
"not",
"recurse",
"it",
"will",
"just",
"receive",
"both",
"values",
"and",
"the",
"tree",
"passing",
"them",
"on",
"to",
"the",
":... | train | https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/engine.py#L121-L129 |
alfredodeza/notario | notario/engine.py | Validator.value_leaf | def value_leaf(self, data, schema, tree):
"""
The deepest validation we can make in any given circumstance for
a value. Does not recurse, it will just receive both values and the
tree, passing them on to the :fun:`enforce` function.
"""
key, value = data
schema_ke... | python | def value_leaf(self, data, schema, tree):
"""
The deepest validation we can make in any given circumstance for
a value. Does not recurse, it will just receive both values and the
tree, passing them on to the :fun:`enforce` function.
"""
key, value = data
schema_ke... | [
"def",
"value_leaf",
"(",
"self",
",",
"data",
",",
"schema",
",",
"tree",
")",
":",
"key",
",",
"value",
"=",
"data",
"schema_key",
",",
"schema_value",
"=",
"schema",
"if",
"hasattr",
"(",
"schema_value",
",",
"'__validator_leaf__'",
")",
":",
"return",
... | The deepest validation we can make in any given circumstance for
a value. Does not recurse, it will just receive both values and the
tree, passing them on to the :fun:`enforce` function. | [
"The",
"deepest",
"validation",
"we",
"can",
"make",
"in",
"any",
"given",
"circumstance",
"for",
"a",
"value",
".",
"Does",
"not",
"recurse",
"it",
"will",
"just",
"receive",
"both",
"values",
"and",
"the",
"tree",
"passing",
"them",
"on",
"to",
"the",
... | train | https://github.com/alfredodeza/notario/blob/d5dc2edfcb75d9291ced3f2551f368c35dd31475/notario/engine.py#L131-L142 |
RowleyGroup/pyqueue | pyqueue/utils.py | strfdelta | def strfdelta(tdelta, fmt):
"""
Used to format `datetime.timedelta` objects. Works just like `strftime`
>>> strfdelta(duration, '%H:%M:%S')
param tdelta: Time duration which is an instance of datetime.timedelta
param fmt: The pattern to format the timedelta with
rtype: str
"""
substitu... | python | def strfdelta(tdelta, fmt):
"""
Used to format `datetime.timedelta` objects. Works just like `strftime`
>>> strfdelta(duration, '%H:%M:%S')
param tdelta: Time duration which is an instance of datetime.timedelta
param fmt: The pattern to format the timedelta with
rtype: str
"""
substitu... | [
"def",
"strfdelta",
"(",
"tdelta",
",",
"fmt",
")",
":",
"substitutes",
"=",
"dict",
"(",
")",
"hours",
",",
"rem",
"=",
"divmod",
"(",
"tdelta",
".",
"total_seconds",
"(",
")",
",",
"3600",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"rem",
... | Used to format `datetime.timedelta` objects. Works just like `strftime`
>>> strfdelta(duration, '%H:%M:%S')
param tdelta: Time duration which is an instance of datetime.timedelta
param fmt: The pattern to format the timedelta with
rtype: str | [
"Used",
"to",
"format",
"datetime",
".",
"timedelta",
"objects",
".",
"Works",
"just",
"like",
"strftime"
] | train | https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/utils.py#L15-L32 |
RowleyGroup/pyqueue | pyqueue/utils.py | get_user_information | def get_user_information():
"""
Returns the user's information
:rtype: (str, int, str)
"""
try:
import pwd
_username = pwd.getpwuid(os.getuid())[0]
_userid = os.getuid()
_uname = os.uname()[1]
except ImportError:
import getpass
_username = getpass... | python | def get_user_information():
"""
Returns the user's information
:rtype: (str, int, str)
"""
try:
import pwd
_username = pwd.getpwuid(os.getuid())[0]
_userid = os.getuid()
_uname = os.uname()[1]
except ImportError:
import getpass
_username = getpass... | [
"def",
"get_user_information",
"(",
")",
":",
"try",
":",
"import",
"pwd",
"_username",
"=",
"pwd",
".",
"getpwuid",
"(",
"os",
".",
"getuid",
"(",
")",
")",
"[",
"0",
"]",
"_userid",
"=",
"os",
".",
"getuid",
"(",
")",
"_uname",
"=",
"os",
".",
... | Returns the user's information
:rtype: (str, int, str) | [
"Returns",
"the",
"user",
"s",
"information"
] | train | https://github.com/RowleyGroup/pyqueue/blob/24de6e1b06b9626ed94d0d5a859bc71bd3afbb4f/pyqueue/utils.py#L35-L53 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/computing_plugin.py | Plugin._login_azure_app_token | def _login_azure_app_token(client_id=None, client_secret=None, tenant_id=None):
"""
Authenticate APP using token credentials:
https://docs.microsoft.com/en-us/python/azure/python-sdk-azure-authenticate?view=azure-python
:return: ~ServicePrincipalCredentials credentials
"""
... | python | def _login_azure_app_token(client_id=None, client_secret=None, tenant_id=None):
"""
Authenticate APP using token credentials:
https://docs.microsoft.com/en-us/python/azure/python-sdk-azure-authenticate?view=azure-python
:return: ~ServicePrincipalCredentials credentials
"""
... | [
"def",
"_login_azure_app_token",
"(",
"client_id",
"=",
"None",
",",
"client_secret",
"=",
"None",
",",
"tenant_id",
"=",
"None",
")",
":",
"client_id",
"=",
"os",
".",
"getenv",
"(",
"'AZURE_CLIENT_ID'",
")",
"if",
"not",
"client_id",
"else",
"client_id",
"... | Authenticate APP using token credentials:
https://docs.microsoft.com/en-us/python/azure/python-sdk-azure-authenticate?view=azure-python
:return: ~ServicePrincipalCredentials credentials | [
"Authenticate",
"APP",
"using",
"token",
"credentials",
":",
"https",
":",
"//",
"docs",
".",
"microsoft",
".",
"com",
"/",
"en",
"-",
"us",
"/",
"python",
"/",
"azure",
"/",
"python",
"-",
"sdk",
"-",
"azure",
"-",
"authenticate?view",
"=",
"azure",
"... | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/computing_plugin.py#L42-L56 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/computing_plugin.py | Plugin.exec_container | def exec_container(self,
asset_url,
algorithm_url,
resource_group_name,
account_name,
account_key,
location,
share_name_input='compute',
... | python | def exec_container(self,
asset_url,
algorithm_url,
resource_group_name,
account_name,
account_key,
location,
share_name_input='compute',
... | [
"def",
"exec_container",
"(",
"self",
",",
"asset_url",
",",
"algorithm_url",
",",
"resource_group_name",
",",
"account_name",
",",
"account_key",
",",
"location",
",",
"share_name_input",
"=",
"'compute'",
",",
"share_name_output",
"=",
"'output'",
",",
"docker_ima... | Prepare a docker image that will run in the cloud, mounting the asset and executing the algorithm.
:param asset_url
:param algorithm_url
:param resource_group_name:
:param account_name:
:param account_key:
:param share_name_input:
:param share_name_output:
... | [
"Prepare",
"a",
"docker",
"image",
"that",
"will",
"run",
"in",
"the",
"cloud",
"mounting",
"the",
"asset",
"and",
"executing",
"the",
"algorithm",
".",
":",
"param",
"asset_url",
":",
"param",
"algorithm_url",
":",
"param",
"resource_group_name",
":",
":",
... | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/computing_plugin.py#L135-L184 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/computing_plugin.py | Plugin.list_container_groups | def list_container_groups(self, resource_group_name):
"""Lists the container groups in the specified resource group.
Arguments:
aci_client {azure.mgmt.containerinstance.ContainerInstanceManagementClient}
-- An authenticated container instance management client.
... | python | def list_container_groups(self, resource_group_name):
"""Lists the container groups in the specified resource group.
Arguments:
aci_client {azure.mgmt.containerinstance.ContainerInstanceManagementClient}
-- An authenticated container instance management client.
... | [
"def",
"list_container_groups",
"(",
"self",
",",
"resource_group_name",
")",
":",
"print",
"(",
"\"Listing container groups in resource group '{0}'...\"",
".",
"format",
"(",
"resource_group_name",
")",
")",
"container_groups",
"=",
"self",
".",
"client",
".",
"contain... | Lists the container groups in the specified resource group.
Arguments:
aci_client {azure.mgmt.containerinstance.ContainerInstanceManagementClient}
-- An authenticated container instance management client.
resource_group {azure.mgmt.resource.resources.models.Resource... | [
"Lists",
"the",
"container",
"groups",
"in",
"the",
"specified",
"resource",
"group",
"."
] | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/computing_plugin.py#L210-L224 |
nhoffman/fastalite | fastalite/fastalite.py | fastalite | def fastalite(handle):
"""Return a sequence of namedtuple objects from a fasta file with
attributes (id, description, seq) given open file-like object
``handle``
"""
Seq = namedtuple('Seq', ['id', 'description', 'seq'])
header, seq = '', []
for line in handle:
if line.startswith('... | python | def fastalite(handle):
"""Return a sequence of namedtuple objects from a fasta file with
attributes (id, description, seq) given open file-like object
``handle``
"""
Seq = namedtuple('Seq', ['id', 'description', 'seq'])
header, seq = '', []
for line in handle:
if line.startswith('... | [
"def",
"fastalite",
"(",
"handle",
")",
":",
"Seq",
"=",
"namedtuple",
"(",
"'Seq'",
",",
"[",
"'id'",
",",
"'description'",
",",
"'seq'",
"]",
")",
"header",
",",
"seq",
"=",
"''",
",",
"[",
"]",
"for",
"line",
"in",
"handle",
":",
"if",
"line",
... | Return a sequence of namedtuple objects from a fasta file with
attributes (id, description, seq) given open file-like object
``handle`` | [
"Return",
"a",
"sequence",
"of",
"namedtuple",
"objects",
"from",
"a",
"fasta",
"file",
"with",
"attributes",
"(",
"id",
"description",
"seq",
")",
"given",
"open",
"file",
"-",
"like",
"object",
"handle"
] | train | https://github.com/nhoffman/fastalite/blob/d544a9e2b5150cf59f0f9651f6f3d659caf13848/fastalite/fastalite.py#L52-L71 |
nhoffman/fastalite | fastalite/fastalite.py | fastqlite | def fastqlite(handle):
"""Return a sequence of namedtuple objects from a fastq file with
attributes (id, description, seq, qual) given open file-like
object ``handle``. This parser assumes that lines corresponding to
sequences and quality scores are not wrapped. Raises
``ValueError`` for malformed r... | python | def fastqlite(handle):
"""Return a sequence of namedtuple objects from a fastq file with
attributes (id, description, seq, qual) given open file-like
object ``handle``. This parser assumes that lines corresponding to
sequences and quality scores are not wrapped. Raises
``ValueError`` for malformed r... | [
"def",
"fastqlite",
"(",
"handle",
")",
":",
"Seq",
"=",
"namedtuple",
"(",
"'Seq'",
",",
"[",
"'id'",
",",
"'description'",
",",
"'seq'",
",",
"'qual'",
"]",
")",
"for",
"i",
",",
"chunk",
"in",
"enumerate",
"(",
"grouper",
"(",
"handle",
",",
"4",
... | Return a sequence of namedtuple objects from a fastq file with
attributes (id, description, seq, qual) given open file-like
object ``handle``. This parser assumes that lines corresponding to
sequences and quality scores are not wrapped. Raises
``ValueError`` for malformed records.
See https://doi.o... | [
"Return",
"a",
"sequence",
"of",
"namedtuple",
"objects",
"from",
"a",
"fastq",
"file",
"with",
"attributes",
"(",
"id",
"description",
"seq",
"qual",
")",
"given",
"open",
"file",
"-",
"like",
"object",
"handle",
".",
"This",
"parser",
"assumes",
"that",
... | train | https://github.com/nhoffman/fastalite/blob/d544a9e2b5150cf59f0f9651f6f3d659caf13848/fastalite/fastalite.py#L81-L105 |
juiceinc/recipe | recipe/ingredients.py | Dimension.cauldron_extras | def cauldron_extras(self):
""" Yield extra tuples containing a field name and a callable that takes
a row
"""
for extra in super(Dimension, self).cauldron_extras:
yield extra
if self.formatters:
prop = self.id + '_raw'
else:
prop = sel... | python | def cauldron_extras(self):
""" Yield extra tuples containing a field name and a callable that takes
a row
"""
for extra in super(Dimension, self).cauldron_extras:
yield extra
if self.formatters:
prop = self.id + '_raw'
else:
prop = sel... | [
"def",
"cauldron_extras",
"(",
"self",
")",
":",
"for",
"extra",
"in",
"super",
"(",
"Dimension",
",",
"self",
")",
".",
"cauldron_extras",
":",
"yield",
"extra",
"if",
"self",
".",
"formatters",
":",
"prop",
"=",
"self",
".",
"id",
"+",
"'_raw'",
"els... | Yield extra tuples containing a field name and a callable that takes
a row | [
"Yield",
"extra",
"tuples",
"containing",
"a",
"field",
"name",
"and",
"a",
"callable",
"that",
"takes",
"a",
"row"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/ingredients.py#L280-L292 |
juiceinc/recipe | recipe/ingredients.py | Dimension.make_column_suffixes | def make_column_suffixes(self):
""" Make sure we have the right column suffixes. These will be appended
to `id` when generating the query.
"""
if self.column_suffixes:
return self.column_suffixes
if len(self.columns) == 0:
return ()
elif len(self... | python | def make_column_suffixes(self):
""" Make sure we have the right column suffixes. These will be appended
to `id` when generating the query.
"""
if self.column_suffixes:
return self.column_suffixes
if len(self.columns) == 0:
return ()
elif len(self... | [
"def",
"make_column_suffixes",
"(",
"self",
")",
":",
"if",
"self",
".",
"column_suffixes",
":",
"return",
"self",
".",
"column_suffixes",
"if",
"len",
"(",
"self",
".",
"columns",
")",
"==",
"0",
":",
"return",
"(",
")",
"elif",
"len",
"(",
"self",
".... | Make sure we have the right column suffixes. These will be appended
to `id` when generating the query. | [
"Make",
"sure",
"we",
"have",
"the",
"right",
"column",
"suffixes",
".",
"These",
"will",
"be",
"appended",
"to",
"id",
"when",
"generating",
"the",
"query",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/ingredients.py#L294-L319 |
juiceinc/recipe | recipe/shelf.py | parse_condition | def parse_condition(
cond, selectable, aggregated=False, default_aggregation='sum'
):
"""Create a SQLAlchemy clause from a condition."""
if cond is None:
return None
else:
if 'and' in cond:
conditions = [
parse_condition(
c, selectable, ag... | python | def parse_condition(
cond, selectable, aggregated=False, default_aggregation='sum'
):
"""Create a SQLAlchemy clause from a condition."""
if cond is None:
return None
else:
if 'and' in cond:
conditions = [
parse_condition(
c, selectable, ag... | [
"def",
"parse_condition",
"(",
"cond",
",",
"selectable",
",",
"aggregated",
"=",
"False",
",",
"default_aggregation",
"=",
"'sum'",
")",
":",
"if",
"cond",
"is",
"None",
":",
"return",
"None",
"else",
":",
"if",
"'and'",
"in",
"cond",
":",
"conditions",
... | Create a SQLAlchemy clause from a condition. | [
"Create",
"a",
"SQLAlchemy",
"clause",
"from",
"a",
"condition",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L32-L100 |
juiceinc/recipe | recipe/shelf.py | tokenize | def tokenize(s):
""" Tokenize a string by splitting it by + and -
>>> tokenize('this + that')
['this', 'PLUS', 'that']
>>> tokenize('this+that')
['this', 'PLUS', 'that']
>>> tokenize('this+that-other')
['this', 'PLUS', 'that', 'MINUS', 'other']
"""
# Crude tokenization
s = s.... | python | def tokenize(s):
""" Tokenize a string by splitting it by + and -
>>> tokenize('this + that')
['this', 'PLUS', 'that']
>>> tokenize('this+that')
['this', 'PLUS', 'that']
>>> tokenize('this+that-other')
['this', 'PLUS', 'that', 'MINUS', 'other']
"""
# Crude tokenization
s = s.... | [
"def",
"tokenize",
"(",
"s",
")",
":",
"# Crude tokenization",
"s",
"=",
"s",
".",
"replace",
"(",
"'+'",
",",
"' PLUS '",
")",
".",
"replace",
"(",
"'-'",
",",
"' MINUS '",
")",
".",
"replace",
"(",
"'/'",
",",
"' DIVIDE '",
")",
".",
"replace",
"("... | Tokenize a string by splitting it by + and -
>>> tokenize('this + that')
['this', 'PLUS', 'that']
>>> tokenize('this+that')
['this', 'PLUS', 'that']
>>> tokenize('this+that-other')
['this', 'PLUS', 'that', 'MINUS', 'other'] | [
"Tokenize",
"a",
"string",
"by",
"splitting",
"it",
"by",
"+",
"and",
"-"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L103-L120 |
juiceinc/recipe | recipe/shelf.py | _find_in_columncollection | def _find_in_columncollection(columns, name):
""" Find a column in a column collection by name or _label"""
for col in columns:
if col.name == name or getattr(col, '_label', None) == name:
return col
return None | python | def _find_in_columncollection(columns, name):
""" Find a column in a column collection by name or _label"""
for col in columns:
if col.name == name or getattr(col, '_label', None) == name:
return col
return None | [
"def",
"_find_in_columncollection",
"(",
"columns",
",",
"name",
")",
":",
"for",
"col",
"in",
"columns",
":",
"if",
"col",
".",
"name",
"==",
"name",
"or",
"getattr",
"(",
"col",
",",
"'_label'",
",",
"None",
")",
"==",
"name",
":",
"return",
"col",
... | Find a column in a column collection by name or _label | [
"Find",
"a",
"column",
"in",
"a",
"column",
"collection",
"by",
"name",
"or",
"_label"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L123-L128 |
juiceinc/recipe | recipe/shelf.py | find_column | def find_column(selectable, name):
"""
Find a column named `name` in selectable
:param selectable:
:param name:
:return: A column object
"""
from recipe import Recipe
if isinstance(selectable, Recipe):
selectable = selectable.subquery()
# Selectable is a table
if isins... | python | def find_column(selectable, name):
"""
Find a column named `name` in selectable
:param selectable:
:param name:
:return: A column object
"""
from recipe import Recipe
if isinstance(selectable, Recipe):
selectable = selectable.subquery()
# Selectable is a table
if isins... | [
"def",
"find_column",
"(",
"selectable",
",",
"name",
")",
":",
"from",
"recipe",
"import",
"Recipe",
"if",
"isinstance",
"(",
"selectable",
",",
"Recipe",
")",
":",
"selectable",
"=",
"selectable",
".",
"subquery",
"(",
")",
"# Selectable is a table",
"if",
... | Find a column named `name` in selectable
:param selectable:
:param name:
:return: A column object | [
"Find",
"a",
"column",
"named",
"name",
"in",
"selectable"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L131-L165 |
juiceinc/recipe | recipe/shelf.py | parse_field | def parse_field(fld, selectable, aggregated=True, default_aggregation='sum'):
""" Parse a field object from yaml into a sqlalchemy expression """
# An aggregation is a callable that takes a single field expression
# None will perform no aggregation
aggregation_lookup = {
'sum': func.sum,
... | python | def parse_field(fld, selectable, aggregated=True, default_aggregation='sum'):
""" Parse a field object from yaml into a sqlalchemy expression """
# An aggregation is a callable that takes a single field expression
# None will perform no aggregation
aggregation_lookup = {
'sum': func.sum,
... | [
"def",
"parse_field",
"(",
"fld",
",",
"selectable",
",",
"aggregated",
"=",
"True",
",",
"default_aggregation",
"=",
"'sum'",
")",
":",
"# An aggregation is a callable that takes a single field expression",
"# None will perform no aggregation",
"aggregation_lookup",
"=",
"{"... | Parse a field object from yaml into a sqlalchemy expression | [
"Parse",
"a",
"field",
"object",
"from",
"yaml",
"into",
"a",
"sqlalchemy",
"expression"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L168-L279 |
juiceinc/recipe | recipe/shelf.py | ingredient_from_dict | def ingredient_from_dict(ingr_dict, selectable):
"""Create an ingredient from an dictionary.
This object will be deserialized from yaml """
# TODO: This is deprecated in favor of
# ingredient_from_validated_dict
# Describe the required params for each kind of ingredient
# The key is the param... | python | def ingredient_from_dict(ingr_dict, selectable):
"""Create an ingredient from an dictionary.
This object will be deserialized from yaml """
# TODO: This is deprecated in favor of
# ingredient_from_validated_dict
# Describe the required params for each kind of ingredient
# The key is the param... | [
"def",
"ingredient_from_dict",
"(",
"ingr_dict",
",",
"selectable",
")",
":",
"# TODO: This is deprecated in favor of",
"# ingredient_from_validated_dict",
"# Describe the required params for each kind of ingredient",
"# The key is the parameter name, the value is one of",
"# field: A parse_... | Create an ingredient from an dictionary.
This object will be deserialized from yaml | [
"Create",
"an",
"ingredient",
"from",
"an",
"dictionary",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L282-L368 |
juiceinc/recipe | recipe/shelf.py | parse_validated_field | def parse_validated_field(fld, selectable):
""" Converts a validated field to sqlalchemy. Field references are
looked up in selectable """
aggr_fn = IngredientValidator.aggregation_lookup[fld['aggregation']]
field = find_column(selectable, fld['value'])
for operator in fld.get('operators', []):
... | python | def parse_validated_field(fld, selectable):
""" Converts a validated field to sqlalchemy. Field references are
looked up in selectable """
aggr_fn = IngredientValidator.aggregation_lookup[fld['aggregation']]
field = find_column(selectable, fld['value'])
for operator in fld.get('operators', []):
... | [
"def",
"parse_validated_field",
"(",
"fld",
",",
"selectable",
")",
":",
"aggr_fn",
"=",
"IngredientValidator",
".",
"aggregation_lookup",
"[",
"fld",
"[",
"'aggregation'",
"]",
"]",
"field",
"=",
"find_column",
"(",
"selectable",
",",
"fld",
"[",
"'value'",
"... | Converts a validated field to sqlalchemy. Field references are
looked up in selectable | [
"Converts",
"a",
"validated",
"field",
"to",
"sqlalchemy",
".",
"Field",
"references",
"are",
"looked",
"up",
"in",
"selectable"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L371-L389 |
juiceinc/recipe | recipe/shelf.py | ingredient_from_validated_dict | def ingredient_from_validated_dict(ingr_dict, selectable):
""" Create an ingredient from an dictionary.
This object will be deserialized from yaml """
validator = IngredientValidator(schema=ingr_dict['kind'])
if not validator.validate(ingr_dict):
raise Exception(validator.errors)
ingr_dict... | python | def ingredient_from_validated_dict(ingr_dict, selectable):
""" Create an ingredient from an dictionary.
This object will be deserialized from yaml """
validator = IngredientValidator(schema=ingr_dict['kind'])
if not validator.validate(ingr_dict):
raise Exception(validator.errors)
ingr_dict... | [
"def",
"ingredient_from_validated_dict",
"(",
"ingr_dict",
",",
"selectable",
")",
":",
"validator",
"=",
"IngredientValidator",
"(",
"schema",
"=",
"ingr_dict",
"[",
"'kind'",
"]",
")",
"if",
"not",
"validator",
".",
"validate",
"(",
"ingr_dict",
")",
":",
"r... | Create an ingredient from an dictionary.
This object will be deserialized from yaml | [
"Create",
"an",
"ingredient",
"from",
"an",
"dictionary",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L392-L412 |
juiceinc/recipe | recipe/shelf.py | AutomaticShelf | def AutomaticShelf(table):
"""Given a SQLAlchemy Table, automatically generate a Shelf with metrics
and dimensions based on its schema.
"""
if hasattr(table, '__table__'):
table = table.__table__
config = introspect_table(table)
return Shelf.from_config(config, table) | python | def AutomaticShelf(table):
"""Given a SQLAlchemy Table, automatically generate a Shelf with metrics
and dimensions based on its schema.
"""
if hasattr(table, '__table__'):
table = table.__table__
config = introspect_table(table)
return Shelf.from_config(config, table) | [
"def",
"AutomaticShelf",
"(",
"table",
")",
":",
"if",
"hasattr",
"(",
"table",
",",
"'__table__'",
")",
":",
"table",
"=",
"table",
".",
"__table__",
"config",
"=",
"introspect_table",
"(",
"table",
")",
"return",
"Shelf",
".",
"from_config",
"(",
"config... | Given a SQLAlchemy Table, automatically generate a Shelf with metrics
and dimensions based on its schema. | [
"Given",
"a",
"SQLAlchemy",
"Table",
"automatically",
"generate",
"a",
"Shelf",
"with",
"metrics",
"and",
"dimensions",
"based",
"on",
"its",
"schema",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L764-L771 |
juiceinc/recipe | recipe/shelf.py | introspect_table | def introspect_table(table):
"""Given a SQLAlchemy Table object, return a Shelf description suitable
for passing to Shelf.from_config.
"""
d = {}
for c in table.columns:
if isinstance(c.type, String):
d[c.name] = {'kind': 'Dimension', 'field': c.name}
if isinstance(c.type... | python | def introspect_table(table):
"""Given a SQLAlchemy Table object, return a Shelf description suitable
for passing to Shelf.from_config.
"""
d = {}
for c in table.columns:
if isinstance(c.type, String):
d[c.name] = {'kind': 'Dimension', 'field': c.name}
if isinstance(c.type... | [
"def",
"introspect_table",
"(",
"table",
")",
":",
"d",
"=",
"{",
"}",
"for",
"c",
"in",
"table",
".",
"columns",
":",
"if",
"isinstance",
"(",
"c",
".",
"type",
",",
"String",
")",
":",
"d",
"[",
"c",
".",
"name",
"]",
"=",
"{",
"'kind'",
":",... | Given a SQLAlchemy Table object, return a Shelf description suitable
for passing to Shelf.from_config. | [
"Given",
"a",
"SQLAlchemy",
"Table",
"object",
"return",
"a",
"Shelf",
"description",
"suitable",
"for",
"passing",
"to",
"Shelf",
".",
"from_config",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L774-L784 |
juiceinc/recipe | recipe/shelf.py | Shelf.pop | def pop(self, k, d=_POP_DEFAULT):
"""Pop an ingredient off of this shelf."""
if d is _POP_DEFAULT:
return self._ingredients.pop(k)
else:
return self._ingredients.pop(k, d) | python | def pop(self, k, d=_POP_DEFAULT):
"""Pop an ingredient off of this shelf."""
if d is _POP_DEFAULT:
return self._ingredients.pop(k)
else:
return self._ingredients.pop(k, d) | [
"def",
"pop",
"(",
"self",
",",
"k",
",",
"d",
"=",
"_POP_DEFAULT",
")",
":",
"if",
"d",
"is",
"_POP_DEFAULT",
":",
"return",
"self",
".",
"_ingredients",
".",
"pop",
"(",
"k",
")",
"else",
":",
"return",
"self",
".",
"_ingredients",
".",
"pop",
"(... | Pop an ingredient off of this shelf. | [
"Pop",
"an",
"ingredient",
"off",
"of",
"this",
"shelf",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L531-L536 |
juiceinc/recipe | recipe/shelf.py | Shelf.dimension_ids | def dimension_ids(self):
""" Return the Dimensions on this shelf in the order in which
they were used."""
return self._sorted_ingredients([
d.id for d in self.values() if isinstance(d, Dimension)
]) | python | def dimension_ids(self):
""" Return the Dimensions on this shelf in the order in which
they were used."""
return self._sorted_ingredients([
d.id for d in self.values() if isinstance(d, Dimension)
]) | [
"def",
"dimension_ids",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sorted_ingredients",
"(",
"[",
"d",
".",
"id",
"for",
"d",
"in",
"self",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"d",
",",
"Dimension",
")",
"]",
")"
] | Return the Dimensions on this shelf in the order in which
they were used. | [
"Return",
"the",
"Dimensions",
"on",
"this",
"shelf",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"used",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L545-L550 |
juiceinc/recipe | recipe/shelf.py | Shelf.metric_ids | def metric_ids(self):
""" Return the Metrics on this shelf in the order in which
they were used. """
return self._sorted_ingredients([
d.id for d in self.values() if isinstance(d, Metric)
]) | python | def metric_ids(self):
""" Return the Metrics on this shelf in the order in which
they were used. """
return self._sorted_ingredients([
d.id for d in self.values() if isinstance(d, Metric)
]) | [
"def",
"metric_ids",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sorted_ingredients",
"(",
"[",
"d",
".",
"id",
"for",
"d",
"in",
"self",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"d",
",",
"Metric",
")",
"]",
")"
] | Return the Metrics on this shelf in the order in which
they were used. | [
"Return",
"the",
"Metrics",
"on",
"this",
"shelf",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"used",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L553-L558 |
juiceinc/recipe | recipe/shelf.py | Shelf.filter_ids | def filter_ids(self):
""" Return the Metrics on this shelf in the order in which
they were used. """
return self._sorted_ingredients([
d.id for d in self.values() if isinstance(d, Filter)
]) | python | def filter_ids(self):
""" Return the Metrics on this shelf in the order in which
they were used. """
return self._sorted_ingredients([
d.id for d in self.values() if isinstance(d, Filter)
]) | [
"def",
"filter_ids",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sorted_ingredients",
"(",
"[",
"d",
".",
"id",
"for",
"d",
"in",
"self",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"d",
",",
"Filter",
")",
"]",
")"
] | Return the Metrics on this shelf in the order in which
they were used. | [
"Return",
"the",
"Metrics",
"on",
"this",
"shelf",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"used",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L561-L566 |
juiceinc/recipe | recipe/shelf.py | Shelf.from_config | def from_config(
cls,
obj,
selectable,
ingredient_constructor=ingredient_from_validated_dict,
metadata=None
):
"""Create a shelf using a dict shelf definition.
:param obj: A Python dictionary describing a Shelf.
:param selectable: A SQLAlchemy Table, ... | python | def from_config(
cls,
obj,
selectable,
ingredient_constructor=ingredient_from_validated_dict,
metadata=None
):
"""Create a shelf using a dict shelf definition.
:param obj: A Python dictionary describing a Shelf.
:param selectable: A SQLAlchemy Table, ... | [
"def",
"from_config",
"(",
"cls",
",",
"obj",
",",
"selectable",
",",
"ingredient_constructor",
"=",
"ingredient_from_validated_dict",
",",
"metadata",
"=",
"None",
")",
":",
"from",
"recipe",
"import",
"Recipe",
"if",
"isinstance",
"(",
"selectable",
",",
"Reci... | Create a shelf using a dict shelf definition.
:param obj: A Python dictionary describing a Shelf.
:param selectable: A SQLAlchemy Table, a Recipe, a table name, or a
SQLAlchemy join to select from.
:param metadata: If `selectable` is passed as a table name, then in
order... | [
"Create",
"a",
"shelf",
"using",
"a",
"dict",
"shelf",
"definition",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L600-L638 |
juiceinc/recipe | recipe/shelf.py | Shelf.from_yaml | def from_yaml(cls, yaml_str, selectable, **kwargs):
"""Create a shelf using a yaml shelf definition.
:param yaml_str: A string containing yaml ingredient definitions.
:param selectable: A SQLAlchemy Table, a Recipe, or a SQLAlchemy
join to select from.
:return: A shelf that ... | python | def from_yaml(cls, yaml_str, selectable, **kwargs):
"""Create a shelf using a yaml shelf definition.
:param yaml_str: A string containing yaml ingredient definitions.
:param selectable: A SQLAlchemy Table, a Recipe, or a SQLAlchemy
join to select from.
:return: A shelf that ... | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_str",
",",
"selectable",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"safe_load",
"(",
"yaml_str",
")",
"return",
"cls",
".",
"from_config",
"(",
"obj",
",",
"selectable",
",",
"ingredient_constructor",
"=",
... | Create a shelf using a yaml shelf definition.
:param yaml_str: A string containing yaml ingredient definitions.
:param selectable: A SQLAlchemy Table, a Recipe, or a SQLAlchemy
join to select from.
:return: A shelf that contains the ingredients defined in yaml_str. | [
"Create",
"a",
"shelf",
"using",
"a",
"yaml",
"shelf",
"definition",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L641-L655 |
juiceinc/recipe | recipe/shelf.py | Shelf.from_validated_yaml | def from_validated_yaml(cls, yaml_str, selectable, **kwargs):
"""Create a shelf using a yaml shelf definition.
:param yaml_str: A string containing yaml ingredient definitions.
:param selectable: A SQLAlchemy Table, a Recipe, or a SQLAlchemy
join to select from.
:return: A shelf... | python | def from_validated_yaml(cls, yaml_str, selectable, **kwargs):
"""Create a shelf using a yaml shelf definition.
:param yaml_str: A string containing yaml ingredient definitions.
:param selectable: A SQLAlchemy Table, a Recipe, or a SQLAlchemy
join to select from.
:return: A shelf... | [
"def",
"from_validated_yaml",
"(",
"cls",
",",
"yaml_str",
",",
"selectable",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"safe_load",
"(",
"yaml_str",
")",
"return",
"cls",
".",
"from_config",
"(",
"obj",
",",
"selectable",
",",
"*",
"*",
"kwargs",
... | Create a shelf using a yaml shelf definition.
:param yaml_str: A string containing yaml ingredient definitions.
:param selectable: A SQLAlchemy Table, a Recipe, or a SQLAlchemy
join to select from.
:return: A shelf that contains the ingredients defined in yaml_str. | [
"Create",
"a",
"shelf",
"using",
"a",
"yaml",
"shelf",
"definition",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L658-L667 |
juiceinc/recipe | recipe/shelf.py | Shelf.find | def find(self, obj, filter_to_class=Ingredient, constructor=None):
"""
Find an Ingredient, optionally using the shelf.
:param obj: A string or Ingredient
:param filter_to_class: The Ingredient subclass that obj must be an
instance of
:param constructor: An optional call... | python | def find(self, obj, filter_to_class=Ingredient, constructor=None):
"""
Find an Ingredient, optionally using the shelf.
:param obj: A string or Ingredient
:param filter_to_class: The Ingredient subclass that obj must be an
instance of
:param constructor: An optional call... | [
"def",
"find",
"(",
"self",
",",
"obj",
",",
"filter_to_class",
"=",
"Ingredient",
",",
"constructor",
"=",
"None",
")",
":",
"if",
"callable",
"(",
"constructor",
")",
":",
"obj",
"=",
"constructor",
"(",
"obj",
",",
"shelf",
"=",
"self",
")",
"if",
... | Find an Ingredient, optionally using the shelf.
:param obj: A string or Ingredient
:param filter_to_class: The Ingredient subclass that obj must be an
instance of
:param constructor: An optional callable for building Ingredients
from obj
:return: An Ingredient of subcl... | [
"Find",
"an",
"Ingredient",
"optionally",
"using",
"the",
"shelf",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L669-L702 |
juiceinc/recipe | recipe/shelf.py | Shelf.brew_query_parts | def brew_query_parts(self):
""" Make columns, group_bys, filters, havings
"""
columns, group_bys, filters, havings = [], [], set(), set()
for ingredient in self.ingredients():
if ingredient.query_columns:
columns.extend(ingredient.query_columns)
if... | python | def brew_query_parts(self):
""" Make columns, group_bys, filters, havings
"""
columns, group_bys, filters, havings = [], [], set(), set()
for ingredient in self.ingredients():
if ingredient.query_columns:
columns.extend(ingredient.query_columns)
if... | [
"def",
"brew_query_parts",
"(",
"self",
")",
":",
"columns",
",",
"group_bys",
",",
"filters",
",",
"havings",
"=",
"[",
"]",
",",
"[",
"]",
",",
"set",
"(",
")",
",",
"set",
"(",
")",
"for",
"ingredient",
"in",
"self",
".",
"ingredients",
"(",
")"... | Make columns, group_bys, filters, havings | [
"Make",
"columns",
"group_bys",
"filters",
"havings"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L704-L723 |
juiceinc/recipe | recipe/shelf.py | Shelf.enchant | def enchant(self, list, cache_context=None):
""" Add any calculated values to each row of a resultset generating a
new namedtuple
:param list: a list of row results
:param cache_context: optional extra context for caching
:return: a list with ingredient.cauldron_extras added for... | python | def enchant(self, list, cache_context=None):
""" Add any calculated values to each row of a resultset generating a
new namedtuple
:param list: a list of row results
:param cache_context: optional extra context for caching
:return: a list with ingredient.cauldron_extras added for... | [
"def",
"enchant",
"(",
"self",
",",
"list",
",",
"cache_context",
"=",
"None",
")",
":",
"enchantedlist",
"=",
"[",
"]",
"if",
"list",
":",
"sample_item",
"=",
"list",
"[",
"0",
"]",
"# Extra fields to add to each row",
"# With extra callables",
"extra_fields",
... | Add any calculated values to each row of a resultset generating a
new namedtuple
:param list: a list of row results
:param cache_context: optional extra context for caching
:return: a list with ingredient.cauldron_extras added for all
ingredients | [
"Add",
"any",
"calculated",
"values",
"to",
"each",
"row",
"of",
"a",
"resultset",
"generating",
"a",
"new",
"namedtuple"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/shelf.py#L725-L761 |
juiceinc/recipe | recipe/extensions.py | AutomaticFilters.apply_automatic_filters | def apply_automatic_filters(self, value):
"""Toggles whether automatic filters are applied to a recipe. The
following will disable automatic filters for this recipe::
recipe.apply_automatic_filters(False)
"""
if self.apply != value:
self.dirty = True
... | python | def apply_automatic_filters(self, value):
"""Toggles whether automatic filters are applied to a recipe. The
following will disable automatic filters for this recipe::
recipe.apply_automatic_filters(False)
"""
if self.apply != value:
self.dirty = True
... | [
"def",
"apply_automatic_filters",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"apply",
"!=",
"value",
":",
"self",
".",
"dirty",
"=",
"True",
"self",
".",
"apply",
"=",
"value",
"return",
"self",
".",
"recipe"
] | Toggles whether automatic filters are applied to a recipe. The
following will disable automatic filters for this recipe::
recipe.apply_automatic_filters(False) | [
"Toggles",
"whether",
"automatic",
"filters",
"are",
"applied",
"to",
"a",
"recipe",
".",
"The",
"following",
"will",
"disable",
"automatic",
"filters",
"for",
"this",
"recipe",
"::"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L213-L222 |
juiceinc/recipe | recipe/extensions.py | AutomaticFilters.automatic_filters | def automatic_filters(self, value):
"""Sets a dictionary of automatic filters to apply to this recipe.
If your recipe uses a shelf that has dimensions 'state' and 'gender'
you could filter the data to Men in California and New Hampshire with::
shelf = Shelf({
'state'... | python | def automatic_filters(self, value):
"""Sets a dictionary of automatic filters to apply to this recipe.
If your recipe uses a shelf that has dimensions 'state' and 'gender'
you could filter the data to Men in California and New Hampshire with::
shelf = Shelf({
'state'... | [
"def",
"automatic_filters",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"dict",
")",
"self",
".",
"_automatic_filters",
"=",
"value",
"self",
".",
"dirty",
"=",
"True",
"return",
"self",
".",
"recipe"
] | Sets a dictionary of automatic filters to apply to this recipe.
If your recipe uses a shelf that has dimensions 'state' and 'gender'
you could filter the data to Men in California and New Hampshire with::
shelf = Shelf({
'state': Dimension(Census.state),
'gen... | [
"Sets",
"a",
"dictionary",
"of",
"automatic",
"filters",
"to",
"apply",
"to",
"this",
"recipe",
".",
"If",
"your",
"recipe",
"uses",
"a",
"shelf",
"that",
"has",
"dimensions",
"state",
"and",
"gender",
"you",
"could",
"filter",
"the",
"data",
"to",
"Men",
... | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L224-L282 |
juiceinc/recipe | recipe/extensions.py | SummarizeOver.modify_postquery_parts | def modify_postquery_parts(self, postquery_parts):
"""
Take a recipe that has dimensions
Resummarize it over one of the dimensions returning averages of the
metrics.
"""
if self._summarize_over is None:
return postquery_parts
assert self._summarize_ove... | python | def modify_postquery_parts(self, postquery_parts):
"""
Take a recipe that has dimensions
Resummarize it over one of the dimensions returning averages of the
metrics.
"""
if self._summarize_over is None:
return postquery_parts
assert self._summarize_ove... | [
"def",
"modify_postquery_parts",
"(",
"self",
",",
"postquery_parts",
")",
":",
"if",
"self",
".",
"_summarize_over",
"is",
"None",
":",
"return",
"postquery_parts",
"assert",
"self",
".",
"_summarize_over",
"in",
"self",
".",
"recipe",
".",
"dimension_ids",
"# ... | Take a recipe that has dimensions
Resummarize it over one of the dimensions returning averages of the
metrics. | [
"Take",
"a",
"recipe",
"that",
"has",
"dimensions",
"Resummarize",
"it",
"over",
"one",
"of",
"the",
"dimensions",
"returning",
"averages",
"of",
"the",
"metrics",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L334-L403 |
juiceinc/recipe | recipe/extensions.py | Anonymize.anonymize | def anonymize(self, value):
""" Should this recipe be anonymized"""
assert isinstance(value, bool)
if self._anonymize != value:
self.dirty = True
self._anonymize = value
# Builder pattern must return the recipe
return self.recipe | python | def anonymize(self, value):
""" Should this recipe be anonymized"""
assert isinstance(value, bool)
if self._anonymize != value:
self.dirty = True
self._anonymize = value
# Builder pattern must return the recipe
return self.recipe | [
"def",
"anonymize",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"bool",
")",
"if",
"self",
".",
"_anonymize",
"!=",
"value",
":",
"self",
".",
"dirty",
"=",
"True",
"self",
".",
"_anonymize",
"=",
"value",
"# Builder... | Should this recipe be anonymized | [
"Should",
"this",
"recipe",
"be",
"anonymized"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L430-L439 |
juiceinc/recipe | recipe/extensions.py | Anonymize.add_ingredients | def add_ingredients(self):
""" Put the anonymizers in the last position of formatters """
for ingredient in self.recipe._cauldron.values():
if hasattr(ingredient.meta, 'anonymizer'):
anonymizer = ingredient.meta.anonymizer
# Build a FakerAnonymizer if we have... | python | def add_ingredients(self):
""" Put the anonymizers in the last position of formatters """
for ingredient in self.recipe._cauldron.values():
if hasattr(ingredient.meta, 'anonymizer'):
anonymizer = ingredient.meta.anonymizer
# Build a FakerAnonymizer if we have... | [
"def",
"add_ingredients",
"(",
"self",
")",
":",
"for",
"ingredient",
"in",
"self",
".",
"recipe",
".",
"_cauldron",
".",
"values",
"(",
")",
":",
"if",
"hasattr",
"(",
"ingredient",
".",
"meta",
",",
"'anonymizer'",
")",
":",
"anonymizer",
"=",
"ingredi... | Put the anonymizers in the last position of formatters | [
"Put",
"the",
"anonymizers",
"in",
"the",
"last",
"position",
"of",
"formatters"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L441-L475 |
juiceinc/recipe | recipe/extensions.py | BlendRecipe.blend | def blend(self, blend_recipe, join_base, join_blend):
"""Blend a recipe into the base recipe.
This performs an inner join of the blend_recipe to the
base recipe's SQL.
"""
assert isinstance(blend_recipe, Recipe)
self.blend_recipes.append(blend_recipe)
self.blend_... | python | def blend(self, blend_recipe, join_base, join_blend):
"""Blend a recipe into the base recipe.
This performs an inner join of the blend_recipe to the
base recipe's SQL.
"""
assert isinstance(blend_recipe, Recipe)
self.blend_recipes.append(blend_recipe)
self.blend_... | [
"def",
"blend",
"(",
"self",
",",
"blend_recipe",
",",
"join_base",
",",
"join_blend",
")",
":",
"assert",
"isinstance",
"(",
"blend_recipe",
",",
"Recipe",
")",
"self",
".",
"blend_recipes",
".",
"append",
"(",
"blend_recipe",
")",
"self",
".",
"blend_types... | Blend a recipe into the base recipe.
This performs an inner join of the blend_recipe to the
base recipe's SQL. | [
"Blend",
"a",
"recipe",
"into",
"the",
"base",
"recipe",
".",
"This",
"performs",
"an",
"inner",
"join",
"of",
"the",
"blend_recipe",
"to",
"the",
"base",
"recipe",
"s",
"SQL",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L498-L509 |
juiceinc/recipe | recipe/extensions.py | BlendRecipe.modify_postquery_parts | def modify_postquery_parts(self, postquery_parts):
"""
Make the comparison recipe a subquery that is left joined to the
base recipe using dimensions that are shared between the recipes.
Hoist the metric from the comparison recipe up to the base query
while adding the suffix.
... | python | def modify_postquery_parts(self, postquery_parts):
"""
Make the comparison recipe a subquery that is left joined to the
base recipe using dimensions that are shared between the recipes.
Hoist the metric from the comparison recipe up to the base query
while adding the suffix.
... | [
"def",
"modify_postquery_parts",
"(",
"self",
",",
"postquery_parts",
")",
":",
"if",
"not",
"self",
".",
"blend_recipes",
":",
"return",
"postquery_parts",
"for",
"blend_recipe",
",",
"blend_type",
",",
"blend_criteria",
"in",
"zip",
"(",
"self",
".",
"blend_re... | Make the comparison recipe a subquery that is left joined to the
base recipe using dimensions that are shared between the recipes.
Hoist the metric from the comparison recipe up to the base query
while adding the suffix. | [
"Make",
"the",
"comparison",
"recipe",
"a",
"subquery",
"that",
"is",
"left",
"joined",
"to",
"the",
"base",
"recipe",
"using",
"dimensions",
"that",
"are",
"shared",
"between",
"the",
"recipes",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L525-L605 |
juiceinc/recipe | recipe/extensions.py | CompareRecipe.compare | def compare(self, compare_recipe, suffix='_compare'):
"""Adds a comparison recipe to a base recipe."""
assert isinstance(compare_recipe, Recipe)
assert isinstance(suffix, basestring)
self.compare_recipe.append(compare_recipe)
self.suffix.append(suffix)
self.dirty = True
... | python | def compare(self, compare_recipe, suffix='_compare'):
"""Adds a comparison recipe to a base recipe."""
assert isinstance(compare_recipe, Recipe)
assert isinstance(suffix, basestring)
self.compare_recipe.append(compare_recipe)
self.suffix.append(suffix)
self.dirty = True
... | [
"def",
"compare",
"(",
"self",
",",
"compare_recipe",
",",
"suffix",
"=",
"'_compare'",
")",
":",
"assert",
"isinstance",
"(",
"compare_recipe",
",",
"Recipe",
")",
"assert",
"isinstance",
"(",
"suffix",
",",
"basestring",
")",
"self",
".",
"compare_recipe",
... | Adds a comparison recipe to a base recipe. | [
"Adds",
"a",
"comparison",
"recipe",
"to",
"a",
"base",
"recipe",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L624-L631 |
juiceinc/recipe | recipe/extensions.py | CompareRecipe.modify_postquery_parts | def modify_postquery_parts(self, postquery_parts):
"""Make the comparison recipe a subquery that is left joined to the
base recipe using dimensions that are shared between the recipes.
Hoist the metric from the comparison recipe up to the base query
while adding the suffix.
"""... | python | def modify_postquery_parts(self, postquery_parts):
"""Make the comparison recipe a subquery that is left joined to the
base recipe using dimensions that are shared between the recipes.
Hoist the metric from the comparison recipe up to the base query
while adding the suffix.
"""... | [
"def",
"modify_postquery_parts",
"(",
"self",
",",
"postquery_parts",
")",
":",
"if",
"not",
"self",
".",
"compare_recipe",
":",
"return",
"postquery_parts",
"for",
"compare_recipe",
",",
"compare_suffix",
"in",
"zip",
"(",
"self",
".",
"compare_recipe",
",",
"s... | Make the comparison recipe a subquery that is left joined to the
base recipe using dimensions that are shared between the recipes.
Hoist the metric from the comparison recipe up to the base query
while adding the suffix. | [
"Make",
"the",
"comparison",
"recipe",
"a",
"subquery",
"that",
"is",
"left",
"joined",
"to",
"the",
"base",
"recipe",
"using",
"dimensions",
"that",
"are",
"shared",
"between",
"the",
"recipes",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/extensions.py#L633-L705 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/data_plugin.py | Plugin.list | def list(self, container_or_share_name, container=None, account=None):
"""List the blobs/files inside a container/share_name.
Args:
container_or_share_name(str): Name of the container/share_name where we want to list the blobs/files.
container(bool): flag to know it you are li... | python | def list(self, container_or_share_name, container=None, account=None):
"""List the blobs/files inside a container/share_name.
Args:
container_or_share_name(str): Name of the container/share_name where we want to list the blobs/files.
container(bool): flag to know it you are li... | [
"def",
"list",
"(",
"self",
",",
"container_or_share_name",
",",
"container",
"=",
"None",
",",
"account",
"=",
"None",
")",
":",
"key",
"=",
"self",
".",
"storage_client",
".",
"storage_accounts",
".",
"list_keys",
"(",
"self",
".",
"resource_group_name",
"... | List the blobs/files inside a container/share_name.
Args:
container_or_share_name(str): Name of the container/share_name where we want to list the blobs/files.
container(bool): flag to know it you are listing files or blobs.
account(str): The name of the storage account. | [
"List",
"the",
"blobs",
"/",
"files",
"inside",
"a",
"container",
"/",
"share_name",
".",
"Args",
":",
"container_or_share_name",
"(",
"str",
")",
":",
"Name",
"of",
"the",
"container",
"/",
"share_name",
"where",
"we",
"want",
"to",
"list",
"the",
"blobs"... | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/data_plugin.py#L89-L110 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/data_plugin.py | Plugin.generate_url | def generate_url(self, remote_file):
"""Sign a remote file to distribute. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
remote_file(str): The blob that we want to sign.
"""
parse_url = _parse_url(remote_file)
key = self.st... | python | def generate_url(self, remote_file):
"""Sign a remote file to distribute. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
remote_file(str): The blob that we want to sign.
"""
parse_url = _parse_url(remote_file)
key = self.st... | [
"def",
"generate_url",
"(",
"self",
",",
"remote_file",
")",
":",
"parse_url",
"=",
"_parse_url",
"(",
"remote_file",
")",
"key",
"=",
"self",
".",
"storage_client",
".",
"storage_accounts",
".",
"list_keys",
"(",
"self",
".",
"resource_group_name",
",",
"pars... | Sign a remote file to distribute. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
remote_file(str): The blob that we want to sign. | [
"Sign",
"a",
"remote",
"file",
"to",
"distribute",
".",
"The",
"azure",
"url",
"format",
"is",
"https",
":",
"//",
"myaccount",
".",
"blob",
".",
"core",
".",
"windows",
".",
"net",
"/",
"mycontainer",
"/",
"myblob",
".",
"Args",
":",
"remote_file",
"(... | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/data_plugin.py#L112-L145 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/data_plugin.py | Plugin.delete | def delete(self, remote_file):
"""Delete file from the cloud. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
remote_file(str): The path of the file to be deleted.
Raises:
:exc:`~..OsmosisError`: if the file is not uploaded co... | python | def delete(self, remote_file):
"""Delete file from the cloud. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
remote_file(str): The path of the file to be deleted.
Raises:
:exc:`~..OsmosisError`: if the file is not uploaded co... | [
"def",
"delete",
"(",
"self",
",",
"remote_file",
")",
":",
"if",
"'core.windows.net'",
"not",
"in",
"remote_file",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Source or destination must be a azure storage url (format \"",
"\"https://myaccount.blob.core.windows.net/my... | Delete file from the cloud. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
remote_file(str): The path of the file to be deleted.
Raises:
:exc:`~..OsmosisError`: if the file is not uploaded correctly. | [
"Delete",
"file",
"from",
"the",
"cloud",
".",
"The",
"azure",
"url",
"format",
"is",
"https",
":",
"//",
"myaccount",
".",
"blob",
".",
"core",
".",
"windows",
".",
"net",
"/",
"mycontainer",
"/",
"myblob",
".",
"Args",
":",
"remote_file",
"(",
"str",... | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/data_plugin.py#L147-L167 |
oceanprotocol/osmosis-azure-driver | osmosis_azure_driver/data_plugin.py | Plugin.copy | def copy(self, source_path, dest_path, account=None, group_name=None):
"""Copy file from a path to another path. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
source_path(str): The path of the file to be copied.
dest_path(str): The d... | python | def copy(self, source_path, dest_path, account=None, group_name=None):
"""Copy file from a path to another path. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
source_path(str): The path of the file to be copied.
dest_path(str): The d... | [
"def",
"copy",
"(",
"self",
",",
"source_path",
",",
"dest_path",
",",
"account",
"=",
"None",
",",
"group_name",
"=",
"None",
")",
":",
"if",
"'core.windows.net'",
"not",
"in",
"source_path",
"and",
"'core.windows.net'",
"not",
"in",
"dest_path",
":",
"self... | Copy file from a path to another path. The azure url format is https://myaccount.blob.core.windows.net/mycontainer/myblob.
Args:
source_path(str): The path of the file to be copied.
dest_path(str): The destination path where the file is going to be allocated.
Raises:
... | [
"Copy",
"file",
"from",
"a",
"path",
"to",
"another",
"path",
".",
"The",
"azure",
"url",
"format",
"is",
"https",
":",
"//",
"myaccount",
".",
"blob",
".",
"core",
".",
"windows",
".",
"net",
"/",
"mycontainer",
"/",
"myblob",
".",
"Args",
":",
"sou... | train | https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/data_plugin.py#L169-L207 |
juiceinc/recipe | recipe/utils.py | prettyprintable_sql | def prettyprintable_sql(statement, dialect=None, reindent=True):
"""
Generate an SQL expression string with bound parameters rendered inline
for the given SQLAlchemy statement. The function can also receive a
`sqlalchemy.orm.Query` object instead of statement.
WARNING: Should only be used for debug... | python | def prettyprintable_sql(statement, dialect=None, reindent=True):
"""
Generate an SQL expression string with bound parameters rendered inline
for the given SQLAlchemy statement. The function can also receive a
`sqlalchemy.orm.Query` object instead of statement.
WARNING: Should only be used for debug... | [
"def",
"prettyprintable_sql",
"(",
"statement",
",",
"dialect",
"=",
"None",
",",
"reindent",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"statement",
",",
"sqlalchemy",
".",
"orm",
".",
"Query",
")",
":",
"if",
"dialect",
"is",
"None",
":",
"dialect... | Generate an SQL expression string with bound parameters rendered inline
for the given SQLAlchemy statement. The function can also receive a
`sqlalchemy.orm.Query` object instead of statement.
WARNING: Should only be used for debugging. Inlining parameters is not
safe when handling user created... | [
"Generate",
"an",
"SQL",
"expression",
"string",
"with",
"bound",
"parameters",
"rendered",
"inline",
"for",
"the",
"given",
"SQLAlchemy",
"statement",
".",
"The",
"function",
"can",
"also",
"receive",
"a",
"sqlalchemy",
".",
"orm",
".",
"Query",
"object",
"in... | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/utils.py#L42-L78 |
juiceinc/recipe | recipe/validators.py | IngredientValidator._normalize_coerce_to_format_with_lookup | def _normalize_coerce_to_format_with_lookup(self, v):
""" Replace a format with a default """
try:
return self.format_lookup.get(v, v)
except TypeError:
# v is something we can't lookup (like a list)
return v | python | def _normalize_coerce_to_format_with_lookup(self, v):
""" Replace a format with a default """
try:
return self.format_lookup.get(v, v)
except TypeError:
# v is something we can't lookup (like a list)
return v | [
"def",
"_normalize_coerce_to_format_with_lookup",
"(",
"self",
",",
"v",
")",
":",
"try",
":",
"return",
"self",
".",
"format_lookup",
".",
"get",
"(",
"v",
",",
"v",
")",
"except",
"TypeError",
":",
"# v is something we can't lookup (like a list)",
"return",
"v"
... | Replace a format with a default | [
"Replace",
"a",
"format",
"with",
"a",
"default"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/validators.py#L66-L72 |
juiceinc/recipe | recipe/validators.py | IngredientValidator._normalize_coerce_to_field_dict | def _normalize_coerce_to_field_dict(self, v):
""" coerces strings to a dict {'value': str} """
def tokenize(s):
""" Tokenize a string by splitting it by + and -
>>> tokenize('this + that')
['this', '+', 'that']
>>> tokenize('this+that')
['th... | python | def _normalize_coerce_to_field_dict(self, v):
""" coerces strings to a dict {'value': str} """
def tokenize(s):
""" Tokenize a string by splitting it by + and -
>>> tokenize('this + that')
['this', '+', 'that']
>>> tokenize('this+that')
['th... | [
"def",
"_normalize_coerce_to_field_dict",
"(",
"self",
",",
"v",
")",
":",
"def",
"tokenize",
"(",
"s",
")",
":",
"\"\"\" Tokenize a string by splitting it by + and -\n\n >>> tokenize('this + that')\n ['this', '+', 'that']\n\n >>> tokenize('this+that')\n ... | coerces strings to a dict {'value': str} | [
"coerces",
"strings",
"to",
"a",
"dict",
"{",
"value",
":",
"str",
"}"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/validators.py#L80-L124 |
juiceinc/recipe | recipe/validators.py | IngredientValidator._validate_type_scalar | def _validate_type_scalar(self, value):
""" Is not a list or a dict """
if isinstance(
value, _int_types + (_str_type, float, date, datetime, bool)
):
return True | python | def _validate_type_scalar(self, value):
""" Is not a list or a dict """
if isinstance(
value, _int_types + (_str_type, float, date, datetime, bool)
):
return True | [
"def",
"_validate_type_scalar",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_int_types",
"+",
"(",
"_str_type",
",",
"float",
",",
"date",
",",
"datetime",
",",
"bool",
")",
")",
":",
"return",
"True"
] | Is not a list or a dict | [
"Is",
"not",
"a",
"list",
"or",
"a",
"dict"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/validators.py#L132-L137 |
juiceinc/recipe | recipe/core.py | Recipe.from_config | def from_config(cls, shelf, obj, **kwargs):
"""
Construct a Recipe from a plain Python dictionary.
Most of the directives only support named ingredients, specified as
strings, and looked up on the shelf. But filters can be specified as
objects.
Additionally, each Recipe... | python | def from_config(cls, shelf, obj, **kwargs):
"""
Construct a Recipe from a plain Python dictionary.
Most of the directives only support named ingredients, specified as
strings, and looked up on the shelf. But filters can be specified as
objects.
Additionally, each Recipe... | [
"def",
"from_config",
"(",
"cls",
",",
"shelf",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"subdict",
"(",
"d",
",",
"keys",
")",
":",
"new",
"=",
"{",
"}",
"for",
"k",
"in",
"keys",
":",
"if",
"k",
"in",
"d",
":",
"new",
"[",
"k... | Construct a Recipe from a plain Python dictionary.
Most of the directives only support named ingredients, specified as
strings, and looked up on the shelf. But filters can be specified as
objects.
Additionally, each RecipeExtension can extract and handle data from the
configura... | [
"Construct",
"a",
"Recipe",
"from",
"a",
"plain",
"Python",
"dictionary",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L145-L181 |
juiceinc/recipe | recipe/core.py | Recipe.shelf | def shelf(self, shelf=None):
""" Defines a shelf to use for this recipe """
if shelf is None:
self._shelf = Shelf({})
elif isinstance(shelf, Shelf):
self._shelf = shelf
elif isinstance(shelf, dict):
self._shelf = Shelf(shelf)
else:
... | python | def shelf(self, shelf=None):
""" Defines a shelf to use for this recipe """
if shelf is None:
self._shelf = Shelf({})
elif isinstance(shelf, Shelf):
self._shelf = shelf
elif isinstance(shelf, dict):
self._shelf = Shelf(shelf)
else:
... | [
"def",
"shelf",
"(",
"self",
",",
"shelf",
"=",
"None",
")",
":",
"if",
"shelf",
"is",
"None",
":",
"self",
".",
"_shelf",
"=",
"Shelf",
"(",
"{",
"}",
")",
"elif",
"isinstance",
"(",
"shelf",
",",
"Shelf",
")",
":",
"self",
".",
"_shelf",
"=",
... | Defines a shelf to use for this recipe | [
"Defines",
"a",
"shelf",
"to",
"use",
"for",
"this",
"recipe"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L217-L231 |
juiceinc/recipe | recipe/core.py | Recipe.metrics | def metrics(self, *metrics):
""" Add a list of Metric ingredients to the query. These can either be
Metric objects or strings representing metrics on the shelf.
The Metric expression will be added to the query's select statement.
The metric value is a property of each row of the result.... | python | def metrics(self, *metrics):
""" Add a list of Metric ingredients to the query. These can either be
Metric objects or strings representing metrics on the shelf.
The Metric expression will be added to the query's select statement.
The metric value is a property of each row of the result.... | [
"def",
"metrics",
"(",
"self",
",",
"*",
"metrics",
")",
":",
"for",
"m",
"in",
"metrics",
":",
"self",
".",
"_cauldron",
".",
"use",
"(",
"self",
".",
"_shelf",
".",
"find",
"(",
"m",
",",
"Metric",
")",
")",
"self",
".",
"dirty",
"=",
"True",
... | Add a list of Metric ingredients to the query. These can either be
Metric objects or strings representing metrics on the shelf.
The Metric expression will be added to the query's select statement.
The metric value is a property of each row of the result.
:param metrics: Metrics to add ... | [
"Add",
"a",
"list",
"of",
"Metric",
"ingredients",
"to",
"the",
"query",
".",
"These",
"can",
"either",
"be",
"Metric",
"objects",
"or",
"strings",
"representing",
"metrics",
"on",
"the",
"shelf",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L233-L248 |
juiceinc/recipe | recipe/core.py | Recipe.dimensions | def dimensions(self, *dimensions):
""" Add a list of Dimension ingredients to the query. These can either be
Dimension objects or strings representing dimensions on the shelf.
The Dimension expression will be added to the query's select statement
and to the group_by.
:param dim... | python | def dimensions(self, *dimensions):
""" Add a list of Dimension ingredients to the query. These can either be
Dimension objects or strings representing dimensions on the shelf.
The Dimension expression will be added to the query's select statement
and to the group_by.
:param dim... | [
"def",
"dimensions",
"(",
"self",
",",
"*",
"dimensions",
")",
":",
"for",
"d",
"in",
"dimensions",
":",
"self",
".",
"_cauldron",
".",
"use",
"(",
"self",
".",
"_shelf",
".",
"find",
"(",
"d",
",",
"Dimension",
")",
")",
"self",
".",
"dirty",
"=",... | Add a list of Dimension ingredients to the query. These can either be
Dimension objects or strings representing dimensions on the shelf.
The Dimension expression will be added to the query's select statement
and to the group_by.
:param dimensions: Dimensions to add to the recipe. Dimen... | [
"Add",
"a",
"list",
"of",
"Dimension",
"ingredients",
"to",
"the",
"query",
".",
"These",
"can",
"either",
"be",
"Dimension",
"objects",
"or",
"strings",
"representing",
"dimensions",
"on",
"the",
"shelf",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L254-L270 |
juiceinc/recipe | recipe/core.py | Recipe.filters | def filters(self, *filters):
"""
Add a list of Filter ingredients to the query. These can either be
Filter objects or strings representing filters on the service's shelf.
``.filters()`` are additive, calling .filters() more than once will add
to the list of filters being used by ... | python | def filters(self, *filters):
"""
Add a list of Filter ingredients to the query. These can either be
Filter objects or strings representing filters on the service's shelf.
``.filters()`` are additive, calling .filters() more than once will add
to the list of filters being used by ... | [
"def",
"filters",
"(",
"self",
",",
"*",
"filters",
")",
":",
"def",
"filter_constructor",
"(",
"f",
",",
"shelf",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"BinaryExpression",
")",
":",
"return",
"Filter",
"(",
"f",
")",
"else",
":",... | Add a list of Filter ingredients to the query. These can either be
Filter objects or strings representing filters on the service's shelf.
``.filters()`` are additive, calling .filters() more than once will add
to the list of filters being used by the recipe.
The Filter expression will b... | [
"Add",
"a",
"list",
"of",
"Filter",
"ingredients",
"to",
"the",
"query",
".",
"These",
"can",
"either",
"be",
"Filter",
"objects",
"or",
"strings",
"representing",
"filters",
"on",
"the",
"service",
"s",
"shelf",
".",
".",
"filters",
"()",
"are",
"additive... | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L276-L305 |
juiceinc/recipe | recipe/core.py | Recipe.order_by | def order_by(self, *order_bys):
""" Add a list of ingredients to order by to the query. These can
either be Dimension or Metric objects or strings representing
order_bys on the shelf.
The Order_by expression will be added to the query's order_by statement
:param order_bys: Orde... | python | def order_by(self, *order_bys):
""" Add a list of ingredients to order by to the query. These can
either be Dimension or Metric objects or strings representing
order_bys on the shelf.
The Order_by expression will be added to the query's order_by statement
:param order_bys: Orde... | [
"def",
"order_by",
"(",
"self",
",",
"*",
"order_bys",
")",
":",
"# Order bys shouldn't be added to the _cauldron",
"self",
".",
"_order_bys",
"=",
"[",
"]",
"for",
"ingr",
"in",
"order_bys",
":",
"order_by",
"=",
"self",
".",
"_shelf",
".",
"find",
"(",
"in... | Add a list of ingredients to order by to the query. These can
either be Dimension or Metric objects or strings representing
order_bys on the shelf.
The Order_by expression will be added to the query's order_by statement
:param order_bys: Order_bys to add to the recipe. Order_bys can
... | [
"Add",
"a",
"list",
"of",
"ingredients",
"to",
"order",
"by",
"to",
"the",
"query",
".",
"These",
"can",
"either",
"be",
"Dimension",
"or",
"Metric",
"objects",
"or",
"strings",
"representing",
"order_bys",
"on",
"the",
"shelf",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L311-L333 |
juiceinc/recipe | recipe/core.py | Recipe.limit | def limit(self, limit):
""" Limit the number of rows returned from the database.
:param limit: The number of rows to return in the recipe. 0 will
return all rows.
:type limit: int
"""
if self._limit != limit:
self.dirty = True
self._... | python | def limit(self, limit):
""" Limit the number of rows returned from the database.
:param limit: The number of rows to return in the recipe. 0 will
return all rows.
:type limit: int
"""
if self._limit != limit:
self.dirty = True
self._... | [
"def",
"limit",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"_limit",
"!=",
"limit",
":",
"self",
".",
"dirty",
"=",
"True",
"self",
".",
"_limit",
"=",
"limit",
"return",
"self"
] | Limit the number of rows returned from the database.
:param limit: The number of rows to return in the recipe. 0 will
return all rows.
:type limit: int | [
"Limit",
"the",
"number",
"of",
"rows",
"returned",
"from",
"the",
"database",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L345-L355 |
juiceinc/recipe | recipe/core.py | Recipe.offset | def offset(self, offset):
""" Offset a number of rows before returning rows from the database.
:param offset: The number of rows to offset in the recipe. 0 will
return from the first available row
:type offset: int
"""
if self._offset != offset:
... | python | def offset(self, offset):
""" Offset a number of rows before returning rows from the database.
:param offset: The number of rows to offset in the recipe. 0 will
return from the first available row
:type offset: int
"""
if self._offset != offset:
... | [
"def",
"offset",
"(",
"self",
",",
"offset",
")",
":",
"if",
"self",
".",
"_offset",
"!=",
"offset",
":",
"self",
".",
"dirty",
"=",
"True",
"self",
".",
"_offset",
"=",
"offset",
"return",
"self"
] | Offset a number of rows before returning rows from the database.
:param offset: The number of rows to offset in the recipe. 0 will
return from the first available row
:type offset: int | [
"Offset",
"a",
"number",
"of",
"rows",
"before",
"returning",
"rows",
"from",
"the",
"database",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L357-L367 |
juiceinc/recipe | recipe/core.py | Recipe._is_postgres | def _is_postgres(self):
""" Determine if the running engine is postgres """
if self._is_postgres_engine is None:
is_postgres_engine = False
try:
dialect = self.session.bind.engine.name
if 'redshift' in dialect or 'postg' in dialect or 'pg' in \
... | python | def _is_postgres(self):
""" Determine if the running engine is postgres """
if self._is_postgres_engine is None:
is_postgres_engine = False
try:
dialect = self.session.bind.engine.name
if 'redshift' in dialect or 'postg' in dialect or 'pg' in \
... | [
"def",
"_is_postgres",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_postgres_engine",
"is",
"None",
":",
"is_postgres_engine",
"=",
"False",
"try",
":",
"dialect",
"=",
"self",
".",
"session",
".",
"bind",
".",
"engine",
".",
"name",
"if",
"'redshift'",
... | Determine if the running engine is postgres | [
"Determine",
"if",
"the",
"running",
"engine",
"is",
"postgres"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L373-L385 |
juiceinc/recipe | recipe/core.py | Recipe._prepare_order_bys | def _prepare_order_bys(self):
""" Build a set of order by columns """
order_bys = OrderedSet()
if self._order_bys:
for ingredient in self._order_bys:
if isinstance(ingredient, Dimension):
# Reverse the ordering columns so that dimensions
... | python | def _prepare_order_bys(self):
""" Build a set of order by columns """
order_bys = OrderedSet()
if self._order_bys:
for ingredient in self._order_bys:
if isinstance(ingredient, Dimension):
# Reverse the ordering columns so that dimensions
... | [
"def",
"_prepare_order_bys",
"(",
"self",
")",
":",
"order_bys",
"=",
"OrderedSet",
"(",
")",
"if",
"self",
".",
"_order_bys",
":",
"for",
"ingredient",
"in",
"self",
".",
"_order_bys",
":",
"if",
"isinstance",
"(",
"ingredient",
",",
"Dimension",
")",
":"... | Build a set of order by columns | [
"Build",
"a",
"set",
"of",
"order",
"by",
"columns"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L387-L403 |
juiceinc/recipe | recipe/core.py | Recipe.query | def query(self):
"""
Generates a query using the ingredients supplied by the recipe.
:return: A SQLAlchemy query
"""
if len(self._cauldron.ingredients()) == 0:
raise BadRecipe('No ingredients have been added to this recipe')
if not self.dirty and self._query:... | python | def query(self):
"""
Generates a query using the ingredients supplied by the recipe.
:return: A SQLAlchemy query
"""
if len(self._cauldron.ingredients()) == 0:
raise BadRecipe('No ingredients have been added to this recipe')
if not self.dirty and self._query:... | [
"def",
"query",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_cauldron",
".",
"ingredients",
"(",
")",
")",
"==",
"0",
":",
"raise",
"BadRecipe",
"(",
"'No ingredients have been added to this recipe'",
")",
"if",
"not",
"self",
".",
"dirty",
"and... | Generates a query using the ingredients supplied by the recipe.
:return: A SQLAlchemy query | [
"Generates",
"a",
"query",
"using",
"the",
"ingredients",
"supplied",
"by",
"the",
"recipe",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L405-L479 |
juiceinc/recipe | recipe/core.py | Recipe.dirty | def dirty(self):
""" The recipe is dirty if it is flagged dirty or any extensions are
flagged dirty """
if self._dirty:
return True
else:
for extension in self.recipe_extensions:
if extension.dirty:
return True
return Fa... | python | def dirty(self):
""" The recipe is dirty if it is flagged dirty or any extensions are
flagged dirty """
if self._dirty:
return True
else:
for extension in self.recipe_extensions:
if extension.dirty:
return True
return Fa... | [
"def",
"dirty",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirty",
":",
"return",
"True",
"else",
":",
"for",
"extension",
"in",
"self",
".",
"recipe_extensions",
":",
"if",
"extension",
".",
"dirty",
":",
"return",
"True",
"return",
"False"
] | The recipe is dirty if it is flagged dirty or any extensions are
flagged dirty | [
"The",
"recipe",
"is",
"dirty",
"if",
"it",
"is",
"flagged",
"dirty",
"or",
"any",
"extensions",
"are",
"flagged",
"dirty"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L482-L491 |
juiceinc/recipe | recipe/core.py | Recipe.dirty | def dirty(self, value):
""" If dirty is true set the recipe to dirty flag. If false,
clear the recipe and all extension dirty flags """
if value:
self._dirty = True
else:
self._dirty = False
for extension in self.recipe_extensions:
exte... | python | def dirty(self, value):
""" If dirty is true set the recipe to dirty flag. If false,
clear the recipe and all extension dirty flags """
if value:
self._dirty = True
else:
self._dirty = False
for extension in self.recipe_extensions:
exte... | [
"def",
"dirty",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"self",
".",
"_dirty",
"=",
"True",
"else",
":",
"self",
".",
"_dirty",
"=",
"False",
"for",
"extension",
"in",
"self",
".",
"recipe_extensions",
":",
"extension",
".",
"dirty",
... | If dirty is true set the recipe to dirty flag. If false,
clear the recipe and all extension dirty flags | [
"If",
"dirty",
"is",
"true",
"set",
"the",
"recipe",
"to",
"dirty",
"flag",
".",
"If",
"false",
"clear",
"the",
"recipe",
"and",
"all",
"extension",
"dirty",
"flags"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L494-L502 |
juiceinc/recipe | recipe/core.py | Recipe.subquery | def subquery(self, name=None):
""" The recipe's query as a subquery suitable for use in joins or other
queries.
"""
query = self.query()
return query.subquery(name=name) | python | def subquery(self, name=None):
""" The recipe's query as a subquery suitable for use in joins or other
queries.
"""
query = self.query()
return query.subquery(name=name) | [
"def",
"subquery",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"query",
"=",
"self",
".",
"query",
"(",
")",
"return",
"query",
".",
"subquery",
"(",
"name",
"=",
"name",
")"
] | The recipe's query as a subquery suitable for use in joins or other
queries. | [
"The",
"recipe",
"s",
"query",
"as",
"a",
"subquery",
"suitable",
"for",
"use",
"in",
"joins",
"or",
"other",
"queries",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L519-L524 |
juiceinc/recipe | recipe/core.py | Recipe.as_table | def as_table(self, name=None):
""" Return an alias to a table
"""
if name is None:
name = self._id
return alias(self.subquery(), name=name) | python | def as_table(self, name=None):
""" Return an alias to a table
"""
if name is None:
name = self._id
return alias(self.subquery(), name=name) | [
"def",
"as_table",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"_id",
"return",
"alias",
"(",
"self",
".",
"subquery",
"(",
")",
",",
"name",
"=",
"name",
")"
] | Return an alias to a table | [
"Return",
"an",
"alias",
"to",
"a",
"table"
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L526-L531 |
juiceinc/recipe | recipe/core.py | Recipe.all | def all(self):
""" Return a (potentially cached) list of result objects.
"""
starttime = fetchtime = enchanttime = time.time()
fetched_from_cache = False
if self.dirty or self.all_dirty:
query = self.query()
self._all = query.all()
# If we're ... | python | def all(self):
""" Return a (potentially cached) list of result objects.
"""
starttime = fetchtime = enchanttime = time.time()
fetched_from_cache = False
if self.dirty or self.all_dirty:
query = self.query()
self._all = query.all()
# If we're ... | [
"def",
"all",
"(",
"self",
")",
":",
"starttime",
"=",
"fetchtime",
"=",
"enchanttime",
"=",
"time",
".",
"time",
"(",
")",
"fetched_from_cache",
"=",
"False",
"if",
"self",
".",
"dirty",
"or",
"self",
".",
"all_dirty",
":",
"query",
"=",
"self",
".",
... | Return a (potentially cached) list of result objects. | [
"Return",
"a",
"(",
"potentially",
"cached",
")",
"list",
"of",
"result",
"objects",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L533-L565 |
juiceinc/recipe | recipe/schemas.py | RecipeSchemas._validate_condition_keys | def _validate_condition_keys(self, field, value, error):
"""
Validates that all of the keys in one of the sets of keys are defined
as keys of ``value``.
"""
if 'field' in value:
operators = self.nonscalar_conditions + self.scalar_conditions
matches = sum(1... | python | def _validate_condition_keys(self, field, value, error):
"""
Validates that all of the keys in one of the sets of keys are defined
as keys of ``value``.
"""
if 'field' in value:
operators = self.nonscalar_conditions + self.scalar_conditions
matches = sum(1... | [
"def",
"_validate_condition_keys",
"(",
"self",
",",
"field",
",",
"value",
",",
"error",
")",
":",
"if",
"'field'",
"in",
"value",
":",
"operators",
"=",
"self",
".",
"nonscalar_conditions",
"+",
"self",
".",
"scalar_conditions",
"matches",
"=",
"sum",
"(",... | Validates that all of the keys in one of the sets of keys are defined
as keys of ``value``. | [
"Validates",
"that",
"all",
"of",
"the",
"keys",
"in",
"one",
"of",
"the",
"sets",
"of",
"keys",
"are",
"defined",
"as",
"keys",
"of",
"value",
"."
] | train | https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/schemas.py#L123-L149 |
lacava/few | few/selection.py | SurvivalMixin.survival | def survival(self,parents,offspring,elite=None,elite_index=None,X=None,X_O=None,F=None,F_O=None):
"""routes to the survival method, returns survivors"""
if self.sel == 'tournament':
survivors, survivor_index = self.tournament(parents + offspring, self.tourn_size, num_selections = len(parents... | python | def survival(self,parents,offspring,elite=None,elite_index=None,X=None,X_O=None,F=None,F_O=None):
"""routes to the survival method, returns survivors"""
if self.sel == 'tournament':
survivors, survivor_index = self.tournament(parents + offspring, self.tourn_size, num_selections = len(parents... | [
"def",
"survival",
"(",
"self",
",",
"parents",
",",
"offspring",
",",
"elite",
"=",
"None",
",",
"elite_index",
"=",
"None",
",",
"X",
"=",
"None",
",",
"X_O",
"=",
"None",
",",
"F",
"=",
"None",
",",
"F_O",
"=",
"None",
")",
":",
"if",
"self",
... | routes to the survival method, returns survivors | [
"routes",
"to",
"the",
"survival",
"method",
"returns",
"survivors"
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/selection.py#L19-L50 |
lacava/few | few/selection.py | SurvivalMixin.tournament | def tournament(self,individuals,tourn_size, num_selections=None):
"""conducts tournament selection of size tourn_size"""
winners = []
locs = []
if num_selections is None:
num_selections = len(individuals)
for i in np.arange(num_selections):
# sample pool ... | python | def tournament(self,individuals,tourn_size, num_selections=None):
"""conducts tournament selection of size tourn_size"""
winners = []
locs = []
if num_selections is None:
num_selections = len(individuals)
for i in np.arange(num_selections):
# sample pool ... | [
"def",
"tournament",
"(",
"self",
",",
"individuals",
",",
"tourn_size",
",",
"num_selections",
"=",
"None",
")",
":",
"winners",
"=",
"[",
"]",
"locs",
"=",
"[",
"]",
"if",
"num_selections",
"is",
"None",
":",
"num_selections",
"=",
"len",
"(",
"individ... | conducts tournament selection of size tourn_size | [
"conducts",
"tournament",
"selection",
"of",
"size",
"tourn_size"
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/selection.py#L52-L69 |
lacava/few | few/selection.py | SurvivalMixin.lexicase | def lexicase(self,F, num_selections=None, survival = False):
"""conducts lexicase selection for de-aggregated fitness vectors"""
if num_selections is None:
num_selections = F.shape[0]
winners = []
locs = []
individual_locs = np.arange(F.shape[0])
... | python | def lexicase(self,F, num_selections=None, survival = False):
"""conducts lexicase selection for de-aggregated fitness vectors"""
if num_selections is None:
num_selections = F.shape[0]
winners = []
locs = []
individual_locs = np.arange(F.shape[0])
... | [
"def",
"lexicase",
"(",
"self",
",",
"F",
",",
"num_selections",
"=",
"None",
",",
"survival",
"=",
"False",
")",
":",
"if",
"num_selections",
"is",
"None",
":",
"num_selections",
"=",
"F",
".",
"shape",
"[",
"0",
"]",
"winners",
"=",
"[",
"]",
"locs... | conducts lexicase selection for de-aggregated fitness vectors | [
"conducts",
"lexicase",
"selection",
"for",
"de",
"-",
"aggregated",
"fitness",
"vectors"
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/selection.py#L71-L100 |
lacava/few | few/selection.py | SurvivalMixin.epsilon_lexicase | def epsilon_lexicase(self, F, sizes, num_selections=None, survival = False):
"""conducts epsilon lexicase selection for de-aggregated fitness vectors"""
# pdb.set_trace()
if num_selections is None:
num_selections = F.shape[0]
if self.c: # use c library
# defi... | python | def epsilon_lexicase(self, F, sizes, num_selections=None, survival = False):
"""conducts epsilon lexicase selection for de-aggregated fitness vectors"""
# pdb.set_trace()
if num_selections is None:
num_selections = F.shape[0]
if self.c: # use c library
# defi... | [
"def",
"epsilon_lexicase",
"(",
"self",
",",
"F",
",",
"sizes",
",",
"num_selections",
"=",
"None",
",",
"survival",
"=",
"False",
")",
":",
"# pdb.set_trace()",
"if",
"num_selections",
"is",
"None",
":",
"num_selections",
"=",
"F",
".",
"shape",
"[",
"0",... | conducts epsilon lexicase selection for de-aggregated fitness vectors | [
"conducts",
"epsilon",
"lexicase",
"selection",
"for",
"de",
"-",
"aggregated",
"fitness",
"vectors"
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/selection.py#L128-L170 |
lacava/few | few/selection.py | SurvivalMixin.mad | def mad(self,x, axis=None):
"""median absolute deviation statistic"""
return np.median(np.abs(x - np.median(x, axis)), axis) | python | def mad(self,x, axis=None):
"""median absolute deviation statistic"""
return np.median(np.abs(x - np.median(x, axis)), axis) | [
"def",
"mad",
"(",
"self",
",",
"x",
",",
"axis",
"=",
"None",
")",
":",
"return",
"np",
".",
"median",
"(",
"np",
".",
"abs",
"(",
"x",
"-",
"np",
".",
"median",
"(",
"x",
",",
"axis",
")",
")",
",",
"axis",
")"
] | median absolute deviation statistic | [
"median",
"absolute",
"deviation",
"statistic"
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/selection.py#L173-L175 |
lacava/few | few/selection.py | SurvivalMixin.deterministic_crowding | def deterministic_crowding(self,parents,offspring,X_parents,X_offspring):
"""deterministic crowding implementation (for non-steady state).
offspring compete against the parent they are most similar to, here defined as
the parent they are most correlated with.
the offspring only replace t... | python | def deterministic_crowding(self,parents,offspring,X_parents,X_offspring):
"""deterministic crowding implementation (for non-steady state).
offspring compete against the parent they are most similar to, here defined as
the parent they are most correlated with.
the offspring only replace t... | [
"def",
"deterministic_crowding",
"(",
"self",
",",
"parents",
",",
"offspring",
",",
"X_parents",
",",
"X_offspring",
")",
":",
"# get children locations produced from crossover",
"cross_children",
"=",
"[",
"i",
"for",
"i",
",",
"o",
"in",
"enumerate",
"(",
"offs... | deterministic crowding implementation (for non-steady state).
offspring compete against the parent they are most similar to, here defined as
the parent they are most correlated with.
the offspring only replace their parent if they are more fit. | [
"deterministic",
"crowding",
"implementation",
"(",
"for",
"non",
"-",
"steady",
"state",
")",
".",
"offspring",
"compete",
"against",
"the",
"parent",
"they",
"are",
"most",
"similar",
"to",
"here",
"defined",
"as",
"the",
"parent",
"they",
"are",
"most",
"... | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/selection.py#L177-L208 |
lacava/few | few/variation.py | VariationMixin.variation | def variation(self,parents):
"""performs variation operators on parents."""
# downselect to features that are important
if (self.valid(parents) and
self.ml_type != 'SVC' and self.ml_type != 'SVR'):
# this is needed because svm has a bug that throws valueerror on
... | python | def variation(self,parents):
"""performs variation operators on parents."""
# downselect to features that are important
if (self.valid(parents) and
self.ml_type != 'SVC' and self.ml_type != 'SVR'):
# this is needed because svm has a bug that throws valueerror on
... | [
"def",
"variation",
"(",
"self",
",",
"parents",
")",
":",
"# downselect to features that are important",
"if",
"(",
"self",
".",
"valid",
"(",
"parents",
")",
"and",
"self",
".",
"ml_type",
"!=",
"'SVC'",
"and",
"self",
".",
"ml_type",
"!=",
"'SVR'",
")",
... | performs variation operators on parents. | [
"performs",
"variation",
"operators",
"on",
"parents",
"."
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L19-L109 |
lacava/few | few/variation.py | VariationMixin.cross | def cross(self,p_i,p_j, max_depth = 2):
"""subtree-like swap crossover between programs p_i and p_j."""
# only choose crossover points for out_types available in both programs
# pdb.set_trace()
# determine possible outttypes
types_p_i = [t for t in [p.out_type for p in p_i]]
... | python | def cross(self,p_i,p_j, max_depth = 2):
"""subtree-like swap crossover between programs p_i and p_j."""
# only choose crossover points for out_types available in both programs
# pdb.set_trace()
# determine possible outttypes
types_p_i = [t for t in [p.out_type for p in p_i]]
... | [
"def",
"cross",
"(",
"self",
",",
"p_i",
",",
"p_j",
",",
"max_depth",
"=",
"2",
")",
":",
"# only choose crossover points for out_types available in both programs",
"# pdb.set_trace()",
"# determine possible outttypes",
"types_p_i",
"=",
"[",
"t",
"for",
"t",
"in",
"... | subtree-like swap crossover between programs p_i and p_j. | [
"subtree",
"-",
"like",
"swap",
"crossover",
"between",
"programs",
"p_i",
"and",
"p_j",
"."
] | train | https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L111-L171 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.