partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Resource.require_http_allowed_method | Ensure that we're allowed to use this HTTP method. | armet/resources/resource/base.py | def require_http_allowed_method(cls, request):
"""Ensure that we're allowed to use this HTTP method."""
allowed = cls.meta.http_allowed_methods
if request.method not in allowed:
# The specified method is not allowed for the resource
# identified by the request URI.
... | def require_http_allowed_method(cls, request):
"""Ensure that we're allowed to use this HTTP method."""
allowed = cls.meta.http_allowed_methods
if request.method not in allowed:
# The specified method is not allowed for the resource
# identified by the request URI.
... | [
"Ensure",
"that",
"we",
"re",
"allowed",
"to",
"use",
"this",
"HTTP",
"method",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L542-L549 | [
"def",
"require_http_allowed_method",
"(",
"cls",
",",
"request",
")",
":",
"allowed",
"=",
"cls",
".",
"meta",
".",
"http_allowed_methods",
"if",
"request",
".",
"method",
"not",
"in",
"allowed",
":",
"# The specified method is not allowed for the resource",
"# ident... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.route | Processes every request.
Directs control flow to the appropriate HTTP/1.1 method. | armet/resources/resource/base.py | def route(self, request, response):
"""Processes every request.
Directs control flow to the appropriate HTTP/1.1 method.
"""
# Ensure that we're allowed to use this HTTP method.
self.require_http_allowed_method(request)
# Retrieve the function corresponding to this HTTP... | def route(self, request, response):
"""Processes every request.
Directs control flow to the appropriate HTTP/1.1 method.
"""
# Ensure that we're allowed to use this HTTP method.
self.require_http_allowed_method(request)
# Retrieve the function corresponding to this HTTP... | [
"Processes",
"every",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L551-L566 | [
"def",
"route",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# Ensure that we're allowed to use this HTTP method.",
"self",
".",
"require_http_allowed_method",
"(",
"request",
")",
"# Retrieve the function corresponding to this HTTP method.",
"function",
"=",
"get... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | Resource.options | Process an `OPTIONS` request.
Used to initiate a cross-origin request. All handling specific to
CORS requests is done on every request however this method also
returns a list of available methods. | armet/resources/resource/base.py | def options(self, request, response):
"""Process an `OPTIONS` request.
Used to initiate a cross-origin request. All handling specific to
CORS requests is done on every request however this method also
returns a list of available methods.
"""
# Gather a list available HTT... | def options(self, request, response):
"""Process an `OPTIONS` request.
Used to initiate a cross-origin request. All handling specific to
CORS requests is done on every request however this method also
returns a list of available methods.
"""
# Gather a list available HTT... | [
"Process",
"an",
"OPTIONS",
"request",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/resources/resource/base.py#L568-L580 | [
"def",
"options",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# Gather a list available HTTP/1.1 methods for this URI.",
"response",
"[",
"'Allowed'",
"]",
"=",
"', '",
".",
"join",
"(",
"self",
".",
"meta",
".",
"http_allowed_methods",
")",
"# All CO... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | resource | Wraps the decorated function in a lightweight resource. | armet/decorators.py | def resource(**kwargs):
"""Wraps the decorated function in a lightweight resource."""
def inner(function):
name = kwargs.pop('name', None)
if name is None:
name = utils.dasherize(function.__name__)
methods = kwargs.pop('methods', None)
if isinstance(methods, six.stri... | def resource(**kwargs):
"""Wraps the decorated function in a lightweight resource."""
def inner(function):
name = kwargs.pop('name', None)
if name is None:
name = utils.dasherize(function.__name__)
methods = kwargs.pop('methods', None)
if isinstance(methods, six.stri... | [
"Wraps",
"the",
"decorated",
"function",
"in",
"a",
"lightweight",
"resource",
"."
] | armet/python-armet | python | https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/decorators.py#L73-L117 | [
"def",
"resource",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"inner",
"(",
"function",
")",
":",
"name",
"=",
"kwargs",
".",
"pop",
"(",
"'name'",
",",
"None",
")",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"utils",
".",
"dasherize",
"(",
"fu... | d61eca9082256cb1e7f7f3c7f2fbc4b697157de7 |
valid | threewise | s -> (None, s0, s1), (s0, s1, s2), ... (sn-1, sn, None)
example:
for (last, cur, next) in threewise(l): | jtutils/jtutils.py | def threewise(iterable):
"""s -> (None, s0, s1), (s0, s1, s2), ... (sn-1, sn, None)
example:
for (last, cur, next) in threewise(l):
"""
a, b, c = itertools.tee(iterable,3)
def prepend(val, l):
yield val
for i in l: yield i
def postpend(val, l):
for i in l: yield i
... | def threewise(iterable):
"""s -> (None, s0, s1), (s0, s1, s2), ... (sn-1, sn, None)
example:
for (last, cur, next) in threewise(l):
"""
a, b, c = itertools.tee(iterable,3)
def prepend(val, l):
yield val
for i in l: yield i
def postpend(val, l):
for i in l: yield i
... | [
"s",
"-",
">",
"(",
"None",
"s0",
"s1",
")",
"(",
"s0",
"s1",
"s2",
")",
"...",
"(",
"sn",
"-",
"1",
"sn",
"None",
")",
"example",
":",
"for",
"(",
"last",
"cur",
"next",
")",
"in",
"threewise",
"(",
"l",
")",
":"
] | jasontrigg0/jtutils | python | https://github.com/jasontrigg0/jtutils/blob/e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a/jtutils/jtutils.py#L170-L185 | [
"def",
"threewise",
"(",
"iterable",
")",
":",
"a",
",",
"b",
",",
"c",
"=",
"itertools",
".",
"tee",
"(",
"iterable",
",",
"3",
")",
"def",
"prepend",
"(",
"val",
",",
"l",
")",
":",
"yield",
"val",
"for",
"i",
"in",
"l",
":",
"yield",
"i",
... | e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a |
valid | lines2less | input: lines = list / iterator of strings
eg: lines = ["This is the first line", "This is the second line"]
output: print those lines to stdout if the output is short + narrow
otherwise print the lines to less | jtutils/jtutils.py | def lines2less(lines):
"""
input: lines = list / iterator of strings
eg: lines = ["This is the first line", "This is the second line"]
output: print those lines to stdout if the output is short + narrow
otherwise print the lines to less
"""
lines = iter(lines) #cast list to iterator... | def lines2less(lines):
"""
input: lines = list / iterator of strings
eg: lines = ["This is the first line", "This is the second line"]
output: print those lines to stdout if the output is short + narrow
otherwise print the lines to less
"""
lines = iter(lines) #cast list to iterator... | [
"input",
":",
"lines",
"=",
"list",
"/",
"iterator",
"of",
"strings",
"eg",
":",
"lines",
"=",
"[",
"This",
"is",
"the",
"first",
"line",
"This",
"is",
"the",
"second",
"line",
"]"
] | jasontrigg0/jtutils | python | https://github.com/jasontrigg0/jtutils/blob/e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a/jtutils/jtutils.py#L194-L230 | [
"def",
"lines2less",
"(",
"lines",
")",
":",
"lines",
"=",
"iter",
"(",
"lines",
")",
"#cast list to iterator",
"#print output to stdout if small, otherwise to less",
"has_term",
"=",
"True",
"terminal_cols",
"=",
"100",
"try",
":",
"terminal_cols",
"=",
"terminal_siz... | e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a |
valid | lesspager | Use for streaming writes to a less process
Taken from pydoc.pipepager:
/usr/lib/python2.7/pydoc.py
and
/usr/lib/python3.5/pydoc.py | jtutils/jtutils.py | def lesspager(lines):
"""
Use for streaming writes to a less process
Taken from pydoc.pipepager:
/usr/lib/python2.7/pydoc.py
and
/usr/lib/python3.5/pydoc.py
"""
cmd = "less -S"
if sys.version_info[0] >= 3:
"""Page through text by feeding it to another program."""
impo... | def lesspager(lines):
"""
Use for streaming writes to a less process
Taken from pydoc.pipepager:
/usr/lib/python2.7/pydoc.py
and
/usr/lib/python3.5/pydoc.py
"""
cmd = "less -S"
if sys.version_info[0] >= 3:
"""Page through text by feeding it to another program."""
impo... | [
"Use",
"for",
"streaming",
"writes",
"to",
"a",
"less",
"process",
"Taken",
"from",
"pydoc",
".",
"pipepager",
":",
"/",
"usr",
"/",
"lib",
"/",
"python2",
".",
"7",
"/",
"pydoc",
".",
"py",
"and",
"/",
"usr",
"/",
"lib",
"/",
"python3",
".",
"5",
... | jasontrigg0/jtutils | python | https://github.com/jasontrigg0/jtutils/blob/e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a/jtutils/jtutils.py#L233-L273 | [
"def",
"lesspager",
"(",
"lines",
")",
":",
"cmd",
"=",
"\"less -S\"",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"\"\"\"Page through text by feeding it to another program.\"\"\"",
"import",
"subprocess",
"proc",
"=",
"subprocess",
".",
"Pope... | e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a |
valid | argmax | http://stackoverflow.com/questions/5098580/implementing-argmax-in-python | jtutils/jtutils.py | def argmax(l,f=None):
"""http://stackoverflow.com/questions/5098580/implementing-argmax-in-python"""
if f:
l = [f(i) for i in l]
return max(enumerate(l), key=lambda x:x[1])[0] | def argmax(l,f=None):
"""http://stackoverflow.com/questions/5098580/implementing-argmax-in-python"""
if f:
l = [f(i) for i in l]
return max(enumerate(l), key=lambda x:x[1])[0] | [
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"5098580",
"/",
"implementing",
"-",
"argmax",
"-",
"in",
"-",
"python"
] | jasontrigg0/jtutils | python | https://github.com/jasontrigg0/jtutils/blob/e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a/jtutils/jtutils.py#L275-L279 | [
"def",
"argmax",
"(",
"l",
",",
"f",
"=",
"None",
")",
":",
"if",
"f",
":",
"l",
"=",
"[",
"f",
"(",
"i",
")",
"for",
"i",
"in",
"l",
"]",
"return",
"max",
"(",
"enumerate",
"(",
"l",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
... | e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a |
valid | CookieDict.render_to_string | Render to cookie strings. | src/funkload_friendly/cookie.py | def render_to_string(self):
"""Render to cookie strings.
"""
values = ''
for key, value in self.items():
values += '{}={};'.format(key, value)
return values | def render_to_string(self):
"""Render to cookie strings.
"""
values = ''
for key, value in self.items():
values += '{}={};'.format(key, value)
return values | [
"Render",
"to",
"cookie",
"strings",
"."
] | tokibito/funkload-friendly | python | https://github.com/tokibito/funkload-friendly/blob/a60e8d2b76ba5ad6c16f8cfc347bd200bd45c189/src/funkload_friendly/cookie.py#L29-L35 | [
"def",
"render_to_string",
"(",
"self",
")",
":",
"values",
"=",
"''",
"for",
"key",
",",
"value",
"in",
"self",
".",
"items",
"(",
")",
":",
"values",
"+=",
"'{}={};'",
".",
"format",
"(",
"key",
",",
"value",
")",
"return",
"values"
] | a60e8d2b76ba5ad6c16f8cfc347bd200bd45c189 |
valid | CookieDict.from_cookie_string | update self with cookie_string. | src/funkload_friendly/cookie.py | def from_cookie_string(self, cookie_string):
"""update self with cookie_string.
"""
for key_value in cookie_string.split(';'):
if '=' in key_value:
key, value = key_value.split('=', 1)
else:
key = key_value
strip_key = key.strip... | def from_cookie_string(self, cookie_string):
"""update self with cookie_string.
"""
for key_value in cookie_string.split(';'):
if '=' in key_value:
key, value = key_value.split('=', 1)
else:
key = key_value
strip_key = key.strip... | [
"update",
"self",
"with",
"cookie_string",
"."
] | tokibito/funkload-friendly | python | https://github.com/tokibito/funkload-friendly/blob/a60e8d2b76ba5ad6c16f8cfc347bd200bd45c189/src/funkload_friendly/cookie.py#L37-L47 | [
"def",
"from_cookie_string",
"(",
"self",
",",
"cookie_string",
")",
":",
"for",
"key_value",
"in",
"cookie_string",
".",
"split",
"(",
"';'",
")",
":",
"if",
"'='",
"in",
"key_value",
":",
"key",
",",
"value",
"=",
"key_value",
".",
"split",
"(",
"'='",... | a60e8d2b76ba5ad6c16f8cfc347bd200bd45c189 |
valid | AuthPolicy._add_method | Adds a method to the internal lists of allowed or denied methods.
Each object in the internal list contains a resource ARN and a
condition statement. The condition statement can be null. | examples/api_gateway_with_authorizer/authorizer/src/policy.py | def _add_method(self, effect, verb, resource, conditions):
"""
Adds a method to the internal lists of allowed or denied methods.
Each object in the internal list contains a resource ARN and a
condition statement. The condition statement can be null.
"""
if verb != '*' and... | def _add_method(self, effect, verb, resource, conditions):
"""
Adds a method to the internal lists of allowed or denied methods.
Each object in the internal list contains a resource ARN and a
condition statement. The condition statement can be null.
"""
if verb != '*' and... | [
"Adds",
"a",
"method",
"to",
"the",
"internal",
"lists",
"of",
"allowed",
"or",
"denied",
"methods",
".",
"Each",
"object",
"in",
"the",
"internal",
"list",
"contains",
"a",
"resource",
"ARN",
"and",
"a",
"condition",
"statement",
".",
"The",
"condition",
... | rackerlabs/yoke | python | https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/examples/api_gateway_with_authorizer/authorizer/src/policy.py#L38-L72 | [
"def",
"_add_method",
"(",
"self",
",",
"effect",
",",
"verb",
",",
"resource",
",",
"conditions",
")",
":",
"if",
"verb",
"!=",
"'*'",
"and",
"not",
"hasattr",
"(",
"HttpVerb",
",",
"verb",
")",
":",
"raise",
"NameError",
"(",
"'Invalid HTTP verb '",
"+... | 00c01d6217b77f9ce14233a0f3686ac6f7b1c247 |
valid | AuthPolicy._get_effect_statement | This function loops over an array of objects containing
a resourceArn and conditions statement and generates
the array of statements for the policy. | examples/api_gateway_with_authorizer/authorizer/src/policy.py | def _get_effect_statement(self, effect, methods):
"""
This function loops over an array of objects containing
a resourceArn and conditions statement and generates
the array of statements for the policy.
"""
statements = []
if len(methods) > 0:
stateme... | def _get_effect_statement(self, effect, methods):
"""
This function loops over an array of objects containing
a resourceArn and conditions statement and generates
the array of statements for the policy.
"""
statements = []
if len(methods) > 0:
stateme... | [
"This",
"function",
"loops",
"over",
"an",
"array",
"of",
"objects",
"containing",
"a",
"resourceArn",
"and",
"conditions",
"statement",
"and",
"generates",
"the",
"array",
"of",
"statements",
"for",
"the",
"policy",
"."
] | rackerlabs/yoke | python | https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/examples/api_gateway_with_authorizer/authorizer/src/policy.py#L87-L109 | [
"def",
"_get_effect_statement",
"(",
"self",
",",
"effect",
",",
"methods",
")",
":",
"statements",
"=",
"[",
"]",
"if",
"len",
"(",
"methods",
")",
">",
"0",
":",
"statement",
"=",
"self",
".",
"_get_empty_statement",
"(",
"effect",
")",
"for",
"method"... | 00c01d6217b77f9ce14233a0f3686ac6f7b1c247 |
valid | AuthPolicy.allow_method_with_conditions | Adds an API Gateway method (Http verb + Resource path) to the
list of allowed methods and includes a condition for the policy
statement. More on AWS policy conditions here:
http://docs.aws.amazon.com/IAM/latest/UserGuide/
reference_policies_elements.html#Condition | examples/api_gateway_with_authorizer/authorizer/src/policy.py | def allow_method_with_conditions(self, verb, resource, conditions):
"""
Adds an API Gateway method (Http verb + Resource path) to the
list of allowed methods and includes a condition for the policy
statement. More on AWS policy conditions here:
http://docs.aws.amazon.com/IAM/late... | def allow_method_with_conditions(self, verb, resource, conditions):
"""
Adds an API Gateway method (Http verb + Resource path) to the
list of allowed methods and includes a condition for the policy
statement. More on AWS policy conditions here:
http://docs.aws.amazon.com/IAM/late... | [
"Adds",
"an",
"API",
"Gateway",
"method",
"(",
"Http",
"verb",
"+",
"Resource",
"path",
")",
"to",
"the",
"list",
"of",
"allowed",
"methods",
"and",
"includes",
"a",
"condition",
"for",
"the",
"policy",
"statement",
".",
"More",
"on",
"AWS",
"policy",
"c... | rackerlabs/yoke | python | https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/examples/api_gateway_with_authorizer/authorizer/src/policy.py#L133-L141 | [
"def",
"allow_method_with_conditions",
"(",
"self",
",",
"verb",
",",
"resource",
",",
"conditions",
")",
":",
"self",
".",
"_add_method",
"(",
"'Allow'",
",",
"verb",
",",
"resource",
",",
"conditions",
")"
] | 00c01d6217b77f9ce14233a0f3686ac6f7b1c247 |
valid | AuthPolicy.deny_method_with_conditions | Adds an API Gateway method (Http verb + Resource path) to the
list of denied methods and includes a condition for the policy
statement. More on AWS policy conditions here:
http://docs.aws.amazon.com/IAM/latest/UserGuide/
reference_policies_elements.html#Condition | examples/api_gateway_with_authorizer/authorizer/src/policy.py | def deny_method_with_conditions(self, verb, resource, conditions):
"""
Adds an API Gateway method (Http verb + Resource path) to the
list of denied methods and includes a condition for the policy
statement. More on AWS policy conditions here:
http://docs.aws.amazon.com/IAM/latest... | def deny_method_with_conditions(self, verb, resource, conditions):
"""
Adds an API Gateway method (Http verb + Resource path) to the
list of denied methods and includes a condition for the policy
statement. More on AWS policy conditions here:
http://docs.aws.amazon.com/IAM/latest... | [
"Adds",
"an",
"API",
"Gateway",
"method",
"(",
"Http",
"verb",
"+",
"Resource",
"path",
")",
"to",
"the",
"list",
"of",
"denied",
"methods",
"and",
"includes",
"a",
"condition",
"for",
"the",
"policy",
"statement",
".",
"More",
"on",
"AWS",
"policy",
"co... | rackerlabs/yoke | python | https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/examples/api_gateway_with_authorizer/authorizer/src/policy.py#L143-L151 | [
"def",
"deny_method_with_conditions",
"(",
"self",
",",
"verb",
",",
"resource",
",",
"conditions",
")",
":",
"self",
".",
"_add_method",
"(",
"'Deny'",
",",
"verb",
",",
"resource",
",",
"conditions",
")"
] | 00c01d6217b77f9ce14233a0f3686ac6f7b1c247 |
valid | AuthPolicy.build | Generates the policy document based on the internal lists of
allowed and denied conditions. This will generate a policy with
two main statements for the effect: one statement for Allow and
one statement for Deny. Methods that includes conditions will
have their own statement in the polic... | examples/api_gateway_with_authorizer/authorizer/src/policy.py | def build(self):
"""
Generates the policy document based on the internal lists of
allowed and denied conditions. This will generate a policy with
two main statements for the effect: one statement for Allow and
one statement for Deny. Methods that includes conditions will
... | def build(self):
"""
Generates the policy document based on the internal lists of
allowed and denied conditions. This will generate a policy with
two main statements for the effect: one statement for Allow and
one statement for Deny. Methods that includes conditions will
... | [
"Generates",
"the",
"policy",
"document",
"based",
"on",
"the",
"internal",
"lists",
"of",
"allowed",
"and",
"denied",
"conditions",
".",
"This",
"will",
"generate",
"a",
"policy",
"with",
"two",
"main",
"statements",
"for",
"the",
"effect",
":",
"one",
"sta... | rackerlabs/yoke | python | https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/examples/api_gateway_with_authorizer/authorizer/src/policy.py#L153-L178 | [
"def",
"build",
"(",
"self",
")",
":",
"if",
"(",
"(",
"self",
".",
"allowMethods",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"allowMethods",
")",
"==",
"0",
")",
"and",
"(",
"self",
".",
"denyMethods",
"is",
"None",
"or",
"len",
"(",
"self",
... | 00c01d6217b77f9ce14233a0f3686ac6f7b1c247 |
valid | Deployment.deref | AWS doesn't quite have Swagger 2.0 validation right and will fail
on some refs. So, we need to convert to deref before
upload. | yoke/deploy.py | def deref(self, data):
"""AWS doesn't quite have Swagger 2.0 validation right and will fail
on some refs. So, we need to convert to deref before
upload."""
# We have to make a deepcopy here to create a proper JSON
# compatible object, otherwise `json.dumps` fails when it
... | def deref(self, data):
"""AWS doesn't quite have Swagger 2.0 validation right and will fail
on some refs. So, we need to convert to deref before
upload."""
# We have to make a deepcopy here to create a proper JSON
# compatible object, otherwise `json.dumps` fails when it
... | [
"AWS",
"doesn",
"t",
"quite",
"have",
"Swagger",
"2",
".",
"0",
"validation",
"right",
"and",
"will",
"fail",
"on",
"some",
"refs",
".",
"So",
"we",
"need",
"to",
"convert",
"to",
"deref",
"before",
"upload",
"."
] | rackerlabs/yoke | python | https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/yoke/deploy.py#L357-L370 | [
"def",
"deref",
"(",
"self",
",",
"data",
")",
":",
"# We have to make a deepcopy here to create a proper JSON",
"# compatible object, otherwise `json.dumps` fails when it",
"# hits jsonref.JsonRef objects.",
"deref",
"=",
"copy",
".",
"deepcopy",
"(",
"jsonref",
".",
"JsonRef"... | 00c01d6217b77f9ce14233a0f3686ac6f7b1c247 |
valid | check_pre_requirements | Check all necessary system requirements to exist.
:param pre_requirements:
Sequence of pre-requirements to check by running
``where <pre_requirement>`` on Windows and ``which ...`` elsewhere. | bootstrapper.py | def check_pre_requirements(pre_requirements):
"""Check all necessary system requirements to exist.
:param pre_requirements:
Sequence of pre-requirements to check by running
``where <pre_requirement>`` on Windows and ``which ...`` elsewhere.
"""
pre_requirements = set(pre_requirements or... | def check_pre_requirements(pre_requirements):
"""Check all necessary system requirements to exist.
:param pre_requirements:
Sequence of pre-requirements to check by running
``where <pre_requirement>`` on Windows and ``which ...`` elsewhere.
"""
pre_requirements = set(pre_requirements or... | [
"Check",
"all",
"necessary",
"system",
"requirements",
"to",
"exist",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L68-L84 | [
"def",
"check_pre_requirements",
"(",
"pre_requirements",
")",
":",
"pre_requirements",
"=",
"set",
"(",
"pre_requirements",
"or",
"[",
"]",
")",
"pre_requirements",
".",
"add",
"(",
"'virtualenv'",
")",
"for",
"requirement",
"in",
"pre_requirements",
":",
"if",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | config_to_args | Convert config dict to arguments list.
:param config: Configuration dict. | bootstrapper.py | def config_to_args(config):
"""Convert config dict to arguments list.
:param config: Configuration dict.
"""
result = []
for key, value in iteritems(config):
if value is False:
continue
key = '--{0}'.format(key.replace('_', '-'))
if isinstance(value, (list, se... | def config_to_args(config):
"""Convert config dict to arguments list.
:param config: Configuration dict.
"""
result = []
for key, value in iteritems(config):
if value is False:
continue
key = '--{0}'.format(key.replace('_', '-'))
if isinstance(value, (list, se... | [
"Convert",
"config",
"dict",
"to",
"arguments",
"list",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L87-L108 | [
"def",
"config_to_args",
"(",
"config",
")",
":",
"result",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"config",
")",
":",
"if",
"value",
"is",
"False",
":",
"continue",
"key",
"=",
"'--{0}'",
".",
"format",
"(",
"key",
".",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | create_env | Create virtual environment.
:param env: Virtual environment name.
:param args: Pass given arguments to ``virtualenv`` script.
:param recerate: Recreate virtual environment? By default: False
:param ignore_activated:
Ignore already activated virtual environment and create new one. By
def... | bootstrapper.py | def create_env(env, args, recreate=False, ignore_activated=False, quiet=False):
"""Create virtual environment.
:param env: Virtual environment name.
:param args: Pass given arguments to ``virtualenv`` script.
:param recerate: Recreate virtual environment? By default: False
:param ignore_activated:
... | def create_env(env, args, recreate=False, ignore_activated=False, quiet=False):
"""Create virtual environment.
:param env: Virtual environment name.
:param args: Pass given arguments to ``virtualenv`` script.
:param recerate: Recreate virtual environment? By default: False
:param ignore_activated:
... | [
"Create",
"virtual",
"environment",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L111-L152 | [
"def",
"create_env",
"(",
"env",
",",
"args",
",",
"recreate",
"=",
"False",
",",
"ignore_activated",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"cmd",
"=",
"None",
"result",
"=",
"True",
"inside_env",
"=",
"hasattr",
"(",
"sys",
",",
"'real_p... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | error_handler | Decorator to error handling. | bootstrapper.py | def error_handler(func):
"""Decorator to error handling."""
@wraps(func)
def wrapper(*args, **kwargs):
"""
Run actual function and if exception catched and error handler enabled
put traceback to log file
"""
try:
return func(*args, **kwargs)
except... | def error_handler(func):
"""Decorator to error handling."""
@wraps(func)
def wrapper(*args, **kwargs):
"""
Run actual function and if exception catched and error handler enabled
put traceback to log file
"""
try:
return func(*args, **kwargs)
except... | [
"Decorator",
"to",
"error",
"handling",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L164-L183 | [
"def",
"error_handler",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n Run actual function and if exception catched and error handler enabled\n put traceback to log file... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | install | Install library or project into virtual environment.
:param env: Use given virtual environment name.
:param requirements: Use given requirements file for pip.
:param args: Pass given arguments to pip script.
:param ignore_activated:
Do not run pip inside already activated virtual environment. B... | bootstrapper.py | def install(env, requirements, args, ignore_activated=False,
install_dev_requirements=False, quiet=False):
"""Install library or project into virtual environment.
:param env: Use given virtual environment name.
:param requirements: Use given requirements file for pip.
:param args: Pass give... | def install(env, requirements, args, ignore_activated=False,
install_dev_requirements=False, quiet=False):
"""Install library or project into virtual environment.
:param env: Use given virtual environment name.
:param requirements: Use given requirements file for pip.
:param args: Pass give... | [
"Install",
"library",
"or",
"project",
"into",
"virtual",
"environment",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L193-L262 | [
"def",
"install",
"(",
"env",
",",
"requirements",
",",
"args",
",",
"ignore_activated",
"=",
"False",
",",
"install_dev_requirements",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"requirements",
")",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | iteritems | Iterate over dict items. | bootstrapper.py | def iteritems(data, **kwargs):
"""Iterate over dict items."""
return iter(data.items(**kwargs)) if IS_PY3 else data.iteritems(**kwargs) | def iteritems(data, **kwargs):
"""Iterate over dict items."""
return iter(data.items(**kwargs)) if IS_PY3 else data.iteritems(**kwargs) | [
"Iterate",
"over",
"dict",
"items",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L265-L267 | [
"def",
"iteritems",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"iter",
"(",
"data",
".",
"items",
"(",
"*",
"*",
"kwargs",
")",
")",
"if",
"IS_PY3",
"else",
"data",
".",
"iteritems",
"(",
"*",
"*",
"kwargs",
")"
] | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | iterkeys | Iterate over dict keys. | bootstrapper.py | def iterkeys(data, **kwargs):
"""Iterate over dict keys."""
return iter(data.keys(**kwargs)) if IS_PY3 else data.iterkeys(**kwargs) | def iterkeys(data, **kwargs):
"""Iterate over dict keys."""
return iter(data.keys(**kwargs)) if IS_PY3 else data.iterkeys(**kwargs) | [
"Iterate",
"over",
"dict",
"keys",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L270-L272 | [
"def",
"iterkeys",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"iter",
"(",
"data",
".",
"keys",
"(",
"*",
"*",
"kwargs",
")",
")",
"if",
"IS_PY3",
"else",
"data",
".",
"iterkeys",
"(",
"*",
"*",
"kwargs",
")"
] | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | main | r"""Bootstrap Python projects and libraries with virtualenv and pip.
Also check system requirements before bootstrap and run post bootstrap
hook if any.
:param \*args: Command line arguments list. | bootstrapper.py | def main(*args):
r"""Bootstrap Python projects and libraries with virtualenv and pip.
Also check system requirements before bootstrap and run post bootstrap
hook if any.
:param \*args: Command line arguments list.
"""
# Create parser, read arguments from direct input or command line
with d... | def main(*args):
r"""Bootstrap Python projects and libraries with virtualenv and pip.
Also check system requirements before bootstrap and run post bootstrap
hook if any.
:param \*args: Command line arguments list.
"""
# Create parser, read arguments from direct input or command line
with d... | [
"r",
"Bootstrap",
"Python",
"projects",
"and",
"libraries",
"with",
"virtualenv",
"and",
"pip",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L276-L331 | [
"def",
"main",
"(",
"*",
"args",
")",
":",
"# Create parser, read arguments from direct input or command line",
"with",
"disable_error_handler",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
"args",
"or",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"# Read cur... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | parse_args | Parse args from command line by creating argument parser instance and
process it.
:param args: Command line arguments list. | bootstrapper.py | def parse_args(args):
"""
Parse args from command line by creating argument parser instance and
process it.
:param args: Command line arguments list.
"""
from argparse import ArgumentParser
description = ('Bootstrap Python projects and libraries with virtualenv '
'and pi... | def parse_args(args):
"""
Parse args from command line by creating argument parser instance and
process it.
:param args: Command line arguments list.
"""
from argparse import ArgumentParser
description = ('Bootstrap Python projects and libraries with virtualenv '
'and pi... | [
"Parse",
"args",
"from",
"command",
"line",
"by",
"creating",
"argument",
"parser",
"instance",
"and",
"process",
"it",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L334-L388 | [
"def",
"parse_args",
"(",
"args",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
"description",
"=",
"(",
"'Bootstrap Python projects and libraries with virtualenv '",
"'and pip.'",
")",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"description",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | pip_cmd | r"""Run pip command in given or activated virtual environment.
:param env: Virtual environment name.
:param cmd: Pip subcommand to run.
:param ignore_activated:
Ignore activated virtual environment and use given venv instead. By
default: False
:param \*\*kwargs:
Additional keywo... | bootstrapper.py | def pip_cmd(env, cmd, ignore_activated=False, **kwargs):
r"""Run pip command in given or activated virtual environment.
:param env: Virtual environment name.
:param cmd: Pip subcommand to run.
:param ignore_activated:
Ignore activated virtual environment and use given venv instead. By
d... | def pip_cmd(env, cmd, ignore_activated=False, **kwargs):
r"""Run pip command in given or activated virtual environment.
:param env: Virtual environment name.
:param cmd: Pip subcommand to run.
:param ignore_activated:
Ignore activated virtual environment and use given venv instead. By
d... | [
"r",
"Run",
"pip",
"command",
"in",
"given",
"or",
"activated",
"virtual",
"environment",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L391-L428 | [
"def",
"pip_cmd",
"(",
"env",
",",
"cmd",
",",
"ignore_activated",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"cmd",
"=",
"tuple",
"(",
"cmd",
")",
"dirname",
"=",
"safe_path",
"(",
"env",
")",
"if",
"not",
"ignore_activated",
":",
"activated_env... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | prepare_args | Convert config dict to command line args line.
:param config: Configuration dict.
:param bootstrap: Bootstrapper configuration dict. | bootstrapper.py | def prepare_args(config, bootstrap):
"""Convert config dict to command line args line.
:param config: Configuration dict.
:param bootstrap: Bootstrapper configuration dict.
"""
config = copy.deepcopy(config)
environ = dict(copy.deepcopy(os.environ))
data = {'env': bootstrap['env'],
... | def prepare_args(config, bootstrap):
"""Convert config dict to command line args line.
:param config: Configuration dict.
:param bootstrap: Bootstrapper configuration dict.
"""
config = copy.deepcopy(config)
environ = dict(copy.deepcopy(os.environ))
data = {'env': bootstrap['env'],
... | [
"Convert",
"config",
"dict",
"to",
"command",
"line",
"args",
"line",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L431-L453 | [
"def",
"prepare_args",
"(",
"config",
",",
"bootstrap",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
")",
"environ",
"=",
"dict",
"(",
"copy",
".",
"deepcopy",
"(",
"os",
".",
"environ",
")",
")",
"data",
"=",
"{",
"'env'",
":",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | print_error | Print error message to stderr, using ANSI-colors.
:param message: Message to print
:param wrap:
Wrap message into ``ERROR: <message>. Exit...`` template. By default:
True | bootstrapper.py | def print_error(message, wrap=True):
"""Print error message to stderr, using ANSI-colors.
:param message: Message to print
:param wrap:
Wrap message into ``ERROR: <message>. Exit...`` template. By default:
True
"""
if wrap:
message = 'ERROR: {0}. Exit...'.format(message.rstr... | def print_error(message, wrap=True):
"""Print error message to stderr, using ANSI-colors.
:param message: Message to print
:param wrap:
Wrap message into ``ERROR: <message>. Exit...`` template. By default:
True
"""
if wrap:
message = 'ERROR: {0}. Exit...'.format(message.rstr... | [
"Print",
"error",
"message",
"to",
"stderr",
"using",
"ANSI",
"-",
"colors",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L456-L470 | [
"def",
"print_error",
"(",
"message",
",",
"wrap",
"=",
"True",
")",
":",
"if",
"wrap",
":",
"message",
"=",
"'ERROR: {0}. Exit...'",
".",
"format",
"(",
"message",
".",
"rstrip",
"(",
"'.'",
")",
")",
"colorizer",
"=",
"(",
"_color_wrap",
"(",
"colorama... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | print_message | Print message via ``subprocess.call`` function.
This helps to ensure consistent output and avoid situations where print
messages actually shown after messages from all inner threads.
:param message: Text message to print. | bootstrapper.py | def print_message(message=None):
"""Print message via ``subprocess.call`` function.
This helps to ensure consistent output and avoid situations where print
messages actually shown after messages from all inner threads.
:param message: Text message to print.
"""
kwargs = {'stdout': sys.stdout,
... | def print_message(message=None):
"""Print message via ``subprocess.call`` function.
This helps to ensure consistent output and avoid situations where print
messages actually shown after messages from all inner threads.
:param message: Text message to print.
"""
kwargs = {'stdout': sys.stdout,
... | [
"Print",
"message",
"via",
"subprocess",
".",
"call",
"function",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L473-L484 | [
"def",
"print_message",
"(",
"message",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"'stdout'",
":",
"sys",
".",
"stdout",
",",
"'stderr'",
":",
"sys",
".",
"stderr",
",",
"'shell'",
":",
"True",
"}",
"return",
"subprocess",
".",
"call",
"(",
"'echo \"{... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | read_config | Read and parse configuration file. By default, ``filename`` is relative
path to current work directory.
If no config file found, default ``CONFIG`` would be used.
:param filename: Read config from given filename.
:param args: Parsed command line arguments. | bootstrapper.py | def read_config(filename, args):
"""
Read and parse configuration file. By default, ``filename`` is relative
path to current work directory.
If no config file found, default ``CONFIG`` would be used.
:param filename: Read config from given filename.
:param args: Parsed command line arguments.
... | def read_config(filename, args):
"""
Read and parse configuration file. By default, ``filename`` is relative
path to current work directory.
If no config file found, default ``CONFIG`` would be used.
:param filename: Read config from given filename.
:param args: Parsed command line arguments.
... | [
"Read",
"and",
"parse",
"configuration",
"file",
".",
"By",
"default",
"filename",
"is",
"relative",
"path",
"to",
"current",
"work",
"directory",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L487-L583 | [
"def",
"read_config",
"(",
"filename",
",",
"args",
")",
":",
"# Initial vars",
"config",
"=",
"defaultdict",
"(",
"dict",
")",
"splitter",
"=",
"operator",
".",
"methodcaller",
"(",
"'split'",
",",
"' '",
")",
"converters",
"=",
"{",
"__script__",
":",
"{... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | run_cmd | r"""Call given command with ``subprocess.call`` function.
:param cmd: Command to run.
:type cmd: tuple or str
:param echo:
If enabled show command to call and its output in STDOUT, otherwise
hide all output. By default: False
:param fail_silently: Do not raise exception on error. By def... | bootstrapper.py | def run_cmd(cmd, echo=False, fail_silently=False, **kwargs):
r"""Call given command with ``subprocess.call`` function.
:param cmd: Command to run.
:type cmd: tuple or str
:param echo:
If enabled show command to call and its output in STDOUT, otherwise
hide all output. By default: False
... | def run_cmd(cmd, echo=False, fail_silently=False, **kwargs):
r"""Call given command with ``subprocess.call`` function.
:param cmd: Command to run.
:type cmd: tuple or str
:param echo:
If enabled show command to call and its output in STDOUT, otherwise
hide all output. By default: False
... | [
"r",
"Call",
"given",
"command",
"with",
"subprocess",
".",
"call",
"function",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L586-L626 | [
"def",
"run_cmd",
"(",
"cmd",
",",
"echo",
"=",
"False",
",",
"fail_silently",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"out",
",",
"err",
"=",
"None",
",",
"None",
"if",
"echo",
":",
"cmd_str",
"=",
"cmd",
"if",
"isinstance",
"(",
"cmd",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | run_hook | Run post-bootstrap hook if any.
:param hook: Hook to run.
:param config: Configuration dict.
:param quiet: Do not output messages to STDOUT/STDERR. By default: False | bootstrapper.py | def run_hook(hook, config, quiet=False):
"""Run post-bootstrap hook if any.
:param hook: Hook to run.
:param config: Configuration dict.
:param quiet: Do not output messages to STDOUT/STDERR. By default: False
"""
if not hook:
return True
if not quiet:
print_message('== Ste... | def run_hook(hook, config, quiet=False):
"""Run post-bootstrap hook if any.
:param hook: Hook to run.
:param config: Configuration dict.
:param quiet: Do not output messages to STDOUT/STDERR. By default: False
"""
if not hook:
return True
if not quiet:
print_message('== Ste... | [
"Run",
"post",
"-",
"bootstrap",
"hook",
"if",
"any",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L629-L650 | [
"def",
"run_hook",
"(",
"hook",
",",
"config",
",",
"quiet",
"=",
"False",
")",
":",
"if",
"not",
"hook",
":",
"return",
"True",
"if",
"not",
"quiet",
":",
"print_message",
"(",
"'== Step 3. Run post-bootstrap hook =='",
")",
"result",
"=",
"not",
"run_cmd",... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | save_traceback | Save error traceback to bootstrapper log file.
:param err: Catched exception. | bootstrapper.py | def save_traceback(err):
"""Save error traceback to bootstrapper log file.
:param err: Catched exception.
"""
# Store logs to ~/.bootstrapper directory
dirname = safe_path(os.path.expanduser(
os.path.join('~', '.{0}'.format(__script__))
))
# But ensure that directory exists
if ... | def save_traceback(err):
"""Save error traceback to bootstrapper log file.
:param err: Catched exception.
"""
# Store logs to ~/.bootstrapper directory
dirname = safe_path(os.path.expanduser(
os.path.join('~', '.{0}'.format(__script__))
))
# But ensure that directory exists
if ... | [
"Save",
"error",
"traceback",
"to",
"bootstrapper",
"log",
"file",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L661-L688 | [
"def",
"save_traceback",
"(",
"err",
")",
":",
"# Store logs to ~/.bootstrapper directory",
"dirname",
"=",
"safe_path",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'~'",
",",
"'.{0}'",
".",
"format",
"(",
"__script_... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | smart_str | Convert Python object to string.
:param value: Python object to convert.
:param encoding: Encoding to use if in Python 2 given object is unicode.
:param errors: Errors mode to use if in Python 2 given object is unicode. | bootstrapper.py | def smart_str(value, encoding='utf-8', errors='strict'):
"""Convert Python object to string.
:param value: Python object to convert.
:param encoding: Encoding to use if in Python 2 given object is unicode.
:param errors: Errors mode to use if in Python 2 given object is unicode.
"""
if not IS_P... | def smart_str(value, encoding='utf-8', errors='strict'):
"""Convert Python object to string.
:param value: Python object to convert.
:param encoding: Encoding to use if in Python 2 given object is unicode.
:param errors: Errors mode to use if in Python 2 given object is unicode.
"""
if not IS_P... | [
"Convert",
"Python",
"object",
"to",
"string",
"."
] | playpauseandstop/bootstrapper | python | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L691-L700 | [
"def",
"smart_str",
"(",
"value",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"not",
"IS_PY3",
"and",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"# noqa",
"return",
"value",
".",
"encode",
"(",
"encoding",
... | b216a05f2acb0b9f4919c4e010ff7b0f63fc1393 |
valid | copy_w_ext | Copy `srcfile` in `destdir` with name `basename + get_extension(srcfile)`.
Add pluses to the destination path basename if a file with the same name already
exists in `destdir`.
Parameters
----------
srcfile: str
destdir: str
basename:str
Returns
-------
dstpath: str | boyle/files/utils.py | def copy_w_ext(srcfile, destdir, basename):
""" Copy `srcfile` in `destdir` with name `basename + get_extension(srcfile)`.
Add pluses to the destination path basename if a file with the same name already
exists in `destdir`.
Parameters
----------
srcfile: str
destdir: str
basename:str... | def copy_w_ext(srcfile, destdir, basename):
""" Copy `srcfile` in `destdir` with name `basename + get_extension(srcfile)`.
Add pluses to the destination path basename if a file with the same name already
exists in `destdir`.
Parameters
----------
srcfile: str
destdir: str
basename:str... | [
"Copy",
"srcfile",
"in",
"destdir",
"with",
"name",
"basename",
"+",
"get_extension",
"(",
"srcfile",
")",
".",
"Add",
"pluses",
"to",
"the",
"destination",
"path",
"basename",
"if",
"a",
"file",
"with",
"the",
"same",
"name",
"already",
"exists",
"in",
"d... | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/utils.py#L18-L40 | [
"def",
"copy_w_ext",
"(",
"srcfile",
",",
"destdir",
",",
"basename",
")",
":",
"ext",
"=",
"get_extension",
"(",
"op",
".",
"basename",
"(",
"srcfile",
")",
")",
"dstpath",
"=",
"op",
".",
"join",
"(",
"destdir",
",",
"basename",
"+",
"ext",
")",
"r... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | copy_w_plus | Copy file from `src` path to `dst` path. If `dst` already exists, will add '+' characters
to the end of the basename without extension.
Parameters
----------
src: str
dst: str
Returns
-------
dstpath: str | boyle/files/utils.py | def copy_w_plus(src, dst):
"""Copy file from `src` path to `dst` path. If `dst` already exists, will add '+' characters
to the end of the basename without extension.
Parameters
----------
src: str
dst: str
Returns
-------
dstpath: str
"""
dst_ext = get_extension(dst)
d... | def copy_w_plus(src, dst):
"""Copy file from `src` path to `dst` path. If `dst` already exists, will add '+' characters
to the end of the basename without extension.
Parameters
----------
src: str
dst: str
Returns
-------
dstpath: str
"""
dst_ext = get_extension(dst)
d... | [
"Copy",
"file",
"from",
"src",
"path",
"to",
"dst",
"path",
".",
"If",
"dst",
"already",
"exists",
"will",
"add",
"+",
"characters",
"to",
"the",
"end",
"of",
"the",
"basename",
"without",
"extension",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/utils.py#L43-L65 | [
"def",
"copy_w_plus",
"(",
"src",
",",
"dst",
")",
":",
"dst_ext",
"=",
"get_extension",
"(",
"dst",
")",
"dst_pre",
"=",
"remove_ext",
"(",
"dst",
")",
"while",
"op",
".",
"exists",
"(",
"dst_pre",
"+",
"dst_ext",
")",
":",
"dst_pre",
"+=",
"'+'",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_abspath | Returns the absolute path of folderpath.
If the path does not exist, will raise IOError. | boyle/files/names.py | def get_abspath(folderpath):
"""Returns the absolute path of folderpath.
If the path does not exist, will raise IOError.
"""
if not op.exists(folderpath):
raise FolderNotFound(folderpath)
return op.abspath(folderpath) | def get_abspath(folderpath):
"""Returns the absolute path of folderpath.
If the path does not exist, will raise IOError.
"""
if not op.exists(folderpath):
raise FolderNotFound(folderpath)
return op.abspath(folderpath) | [
"Returns",
"the",
"absolute",
"path",
"of",
"folderpath",
".",
"If",
"the",
"path",
"does",
"not",
"exist",
"will",
"raise",
"IOError",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L22-L29 | [
"def",
"get_abspath",
"(",
"folderpath",
")",
":",
"if",
"not",
"op",
".",
"exists",
"(",
"folderpath",
")",
":",
"raise",
"FolderNotFound",
"(",
"folderpath",
")",
"return",
"op",
".",
"abspath",
"(",
"folderpath",
")"
] | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_extension | Return the extension of fpath.
Parameters
----------
fpath: string
File name or path
check_if_exists: bool
allowed_exts: dict
Dictionary of strings, where the key if the last part of a complex ('.' separated) extension
and the value is the previous part.
For example: for the '.nii... | boyle/files/names.py | def get_extension(filepath, check_if_exists=False, allowed_exts=ALLOWED_EXTS):
"""Return the extension of fpath.
Parameters
----------
fpath: string
File name or path
check_if_exists: bool
allowed_exts: dict
Dictionary of strings, where the key if the last part of a complex ('.' separ... | def get_extension(filepath, check_if_exists=False, allowed_exts=ALLOWED_EXTS):
"""Return the extension of fpath.
Parameters
----------
fpath: string
File name or path
check_if_exists: bool
allowed_exts: dict
Dictionary of strings, where the key if the last part of a complex ('.' separ... | [
"Return",
"the",
"extension",
"of",
"fpath",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L43-L74 | [
"def",
"get_extension",
"(",
"filepath",
",",
"check_if_exists",
"=",
"False",
",",
"allowed_exts",
"=",
"ALLOWED_EXTS",
")",
":",
"if",
"check_if_exists",
":",
"if",
"not",
"op",
".",
"exists",
"(",
"filepath",
")",
":",
"raise",
"IOError",
"(",
"'File not ... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | add_extension_if_needed | Add the extension ext to fpath if it doesn't have it.
Parameters
----------
filepath: str
File name or path
ext: str
File extension
check_if_exists: bool
Returns
-------
File name or path with extension added, if needed. | boyle/files/names.py | def add_extension_if_needed(filepath, ext, check_if_exists=False):
"""Add the extension ext to fpath if it doesn't have it.
Parameters
----------
filepath: str
File name or path
ext: str
File extension
check_if_exists: bool
Returns
-------
File name or path with extension... | def add_extension_if_needed(filepath, ext, check_if_exists=False):
"""Add the extension ext to fpath if it doesn't have it.
Parameters
----------
filepath: str
File name or path
ext: str
File extension
check_if_exists: bool
Returns
-------
File name or path with extension... | [
"Add",
"the",
"extension",
"ext",
"to",
"fpath",
"if",
"it",
"doesn",
"t",
"have",
"it",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L77-L101 | [
"def",
"add_extension_if_needed",
"(",
"filepath",
",",
"ext",
",",
"check_if_exists",
"=",
"False",
")",
":",
"if",
"not",
"filepath",
".",
"endswith",
"(",
"ext",
")",
":",
"filepath",
"+=",
"ext",
"if",
"check_if_exists",
":",
"if",
"not",
"op",
".",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | parse_subjects_list | Parses a file with a list of: <subject_file>:<subject_class_label>.
Parameters
----------
filepath: str
Path to file with a list of: <subject_file>:<subject_class_label>.
Where ':' can be any split character
datadir: str
String to be path prefix of each line of the fname content,
only ... | boyle/files/names.py | def parse_subjects_list(filepath, datadir='', split=':', labelsf=None):
"""Parses a file with a list of: <subject_file>:<subject_class_label>.
Parameters
----------
filepath: str
Path to file with a list of: <subject_file>:<subject_class_label>.
Where ':' can be any split character
datadir... | def parse_subjects_list(filepath, datadir='', split=':', labelsf=None):
"""Parses a file with a list of: <subject_file>:<subject_class_label>.
Parameters
----------
filepath: str
Path to file with a list of: <subject_file>:<subject_class_label>.
Where ':' can be any split character
datadir... | [
"Parses",
"a",
"file",
"with",
"a",
"list",
"of",
":",
"<subject_file",
">",
":",
"<subject_class_label",
">",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L153-L202 | [
"def",
"parse_subjects_list",
"(",
"filepath",
",",
"datadir",
"=",
"''",
",",
"split",
"=",
"':'",
",",
"labelsf",
"=",
"None",
")",
":",
"labels",
"=",
"[",
"]",
"subjs",
"=",
"[",
"]",
"if",
"datadir",
":",
"datadir",
"+=",
"op",
".",
"sep",
"wi... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | create_subjects_file | Creates a file where each line is <subject_file>:<subject_class_label>.
Parameters
----------
filelist: list of str
List of filepaths
labels: list of int, str or labels that can be transformed with str()
List of labels
output_file: str
Output file path
split: str
Split charac... | boyle/files/names.py | def create_subjects_file(filelist, labels, output_file, split=':'):
"""Creates a file where each line is <subject_file>:<subject_class_label>.
Parameters
----------
filelist: list of str
List of filepaths
labels: list of int, str or labels that can be transformed with str()
List of labels
... | def create_subjects_file(filelist, labels, output_file, split=':'):
"""Creates a file where each line is <subject_file>:<subject_class_label>.
Parameters
----------
filelist: list of str
List of filepaths
labels: list of int, str or labels that can be transformed with str()
List of labels
... | [
"Creates",
"a",
"file",
"where",
"each",
"line",
"is",
"<subject_file",
">",
":",
"<subject_class_label",
">",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L205-L234 | [
"def",
"create_subjects_file",
"(",
"filelist",
",",
"labels",
",",
"output_file",
",",
"split",
"=",
"':'",
")",
":",
"if",
"len",
"(",
"filelist",
")",
"!=",
"len",
"(",
"labels",
")",
":",
"raise",
"ValueError",
"(",
"'Expected `filelist` and `labels` to ha... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | join_path_to_filelist | Joins path to each line in filelist
Parameters
----------
path: str
filelist: list of str
Returns
-------
list of filepaths | boyle/files/names.py | def join_path_to_filelist(path, filelist):
"""Joins path to each line in filelist
Parameters
----------
path: str
filelist: list of str
Returns
-------
list of filepaths
"""
return [op.join(path, str(item)) for item in filelist] | def join_path_to_filelist(path, filelist):
"""Joins path to each line in filelist
Parameters
----------
path: str
filelist: list of str
Returns
-------
list of filepaths
"""
return [op.join(path, str(item)) for item in filelist] | [
"Joins",
"path",
"to",
"each",
"line",
"in",
"filelist"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L237-L250 | [
"def",
"join_path_to_filelist",
"(",
"path",
",",
"filelist",
")",
":",
"return",
"[",
"op",
".",
"join",
"(",
"path",
",",
"str",
"(",
"item",
")",
")",
"for",
"item",
"in",
"filelist",
"]"
] | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | remove_all | Deletes all files in filelist
Parameters
----------
filelist: list of str
List of the file paths to be removed
folder: str
Path to be used as common directory for all file paths in filelist | boyle/files/names.py | def remove_all(filelist, folder=''):
"""Deletes all files in filelist
Parameters
----------
filelist: list of str
List of the file paths to be removed
folder: str
Path to be used as common directory for all file paths in filelist
"""
if not folder:
for f in filelist... | def remove_all(filelist, folder=''):
"""Deletes all files in filelist
Parameters
----------
filelist: list of str
List of the file paths to be removed
folder: str
Path to be used as common directory for all file paths in filelist
"""
if not folder:
for f in filelist... | [
"Deletes",
"all",
"files",
"in",
"filelist"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L253-L269 | [
"def",
"remove_all",
"(",
"filelist",
",",
"folder",
"=",
"''",
")",
":",
"if",
"not",
"folder",
":",
"for",
"f",
"in",
"filelist",
":",
"os",
".",
"remove",
"(",
"f",
")",
"else",
":",
"for",
"f",
"in",
"filelist",
":",
"os",
".",
"remove",
"(",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_folder_subpath | Returns a folder path of path with depth given by folder_dept:
Parameters
----------
path: str
folder_depth: int > 0
Returns
-------
A folder path
Example
-------
>>> get_folder_subpath('/home/user/mydoc/work/notes.txt', 3)
>>> '/home/user/mydoc' | boyle/files/names.py | def get_folder_subpath(path, folder_depth):
"""
Returns a folder path of path with depth given by folder_dept:
Parameters
----------
path: str
folder_depth: int > 0
Returns
-------
A folder path
Example
-------
>>> get_folder_subpath('/home/user/mydoc/work/notes.txt',... | def get_folder_subpath(path, folder_depth):
"""
Returns a folder path of path with depth given by folder_dept:
Parameters
----------
path: str
folder_depth: int > 0
Returns
-------
A folder path
Example
-------
>>> get_folder_subpath('/home/user/mydoc/work/notes.txt',... | [
"Returns",
"a",
"folder",
"path",
"of",
"path",
"with",
"depth",
"given",
"by",
"folder_dept",
":"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L272-L294 | [
"def",
"get_folder_subpath",
"(",
"path",
",",
"folder_depth",
")",
":",
"if",
"path",
"[",
"0",
"]",
"==",
"op",
".",
"sep",
":",
"folder_depth",
"+=",
"1",
"return",
"op",
".",
"sep",
".",
"join",
"(",
"path",
".",
"split",
"(",
"op",
".",
"sep",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_temp_dir | Uses tempfile to create a TemporaryDirectory using
the default arguments.
The folder is created using tempfile.mkdtemp() function.
Parameters
----------
prefix: str
Name prefix for the temporary folder.
basepath: str
Directory where the new folder must be created.
The default direc... | boyle/files/names.py | def get_temp_dir(prefix=None, basepath=None):
"""
Uses tempfile to create a TemporaryDirectory using
the default arguments.
The folder is created using tempfile.mkdtemp() function.
Parameters
----------
prefix: str
Name prefix for the temporary folder.
basepath: str
Directory w... | def get_temp_dir(prefix=None, basepath=None):
"""
Uses tempfile to create a TemporaryDirectory using
the default arguments.
The folder is created using tempfile.mkdtemp() function.
Parameters
----------
prefix: str
Name prefix for the temporary folder.
basepath: str
Directory w... | [
"Uses",
"tempfile",
"to",
"create",
"a",
"TemporaryDirectory",
"using",
"the",
"default",
"arguments",
".",
"The",
"folder",
"is",
"created",
"using",
"tempfile",
".",
"mkdtemp",
"()",
"function",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L329-L354 | [
"def",
"get_temp_dir",
"(",
"prefix",
"=",
"None",
",",
"basepath",
"=",
"None",
")",
":",
"if",
"basepath",
"is",
"None",
":",
"return",
"tempfile",
".",
"TemporaryDirectory",
"(",
"dir",
"=",
"basepath",
")",
"else",
":",
"return",
"tempfile",
".",
"Te... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | ux_file_len | Returns the length of the file using the 'wc' GNU command
Parameters
----------
filepath: str
Returns
-------
float | boyle/files/names.py | def ux_file_len(filepath):
"""Returns the length of the file using the 'wc' GNU command
Parameters
----------
filepath: str
Returns
-------
float
"""
p = subprocess.Popen(['wc', '-l', filepath], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
result, er... | def ux_file_len(filepath):
"""Returns the length of the file using the 'wc' GNU command
Parameters
----------
filepath: str
Returns
-------
float
"""
p = subprocess.Popen(['wc', '-l', filepath], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
result, er... | [
"Returns",
"the",
"length",
"of",
"the",
"file",
"using",
"the",
"wc",
"GNU",
"command"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/names.py#L357-L377 | [
"def",
"ux_file_len",
"(",
"filepath",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'wc'",
",",
"'-l'",
",",
"filepath",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"result",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | merge | Merge two dictionaries.
Values that evaluate to true take priority over falsy values.
`dict_1` takes priority over `dict_2`. | boyle/utils/rcfile.py | def merge(dict_1, dict_2):
"""Merge two dictionaries.
Values that evaluate to true take priority over falsy values.
`dict_1` takes priority over `dict_2`.
"""
return dict((str(key), dict_1.get(key) or dict_2.get(key))
for key in set(dict_2) | set(dict_1)) | def merge(dict_1, dict_2):
"""Merge two dictionaries.
Values that evaluate to true take priority over falsy values.
`dict_1` takes priority over `dict_2`.
"""
return dict((str(key), dict_1.get(key) or dict_2.get(key))
for key in set(dict_2) | set(dict_1)) | [
"Merge",
"two",
"dictionaries",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L14-L22 | [
"def",
"merge",
"(",
"dict_1",
",",
"dict_2",
")",
":",
"return",
"dict",
"(",
"(",
"str",
"(",
"key",
")",
",",
"dict_1",
".",
"get",
"(",
"key",
")",
"or",
"dict_2",
".",
"get",
"(",
"key",
")",
")",
"for",
"key",
"in",
"set",
"(",
"dict_2",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_sys_path | Return a folder path if it exists.
First will check if it is an existing system path, if it is, will return it
expanded and absoluted.
If this fails will look for the rcpath variable in the app_name rcfiles or
exclusively within the given section_name, if given.
Parameters
----------
rcpa... | boyle/utils/rcfile.py | def get_sys_path(rcpath, app_name, section_name=None):
"""Return a folder path if it exists.
First will check if it is an existing system path, if it is, will return it
expanded and absoluted.
If this fails will look for the rcpath variable in the app_name rcfiles or
exclusively within the given s... | def get_sys_path(rcpath, app_name, section_name=None):
"""Return a folder path if it exists.
First will check if it is an existing system path, if it is, will return it
expanded and absoluted.
If this fails will look for the rcpath variable in the app_name rcfiles or
exclusively within the given s... | [
"Return",
"a",
"folder",
"path",
"if",
"it",
"exists",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L83-L142 | [
"def",
"get_sys_path",
"(",
"rcpath",
",",
"app_name",
",",
"section_name",
"=",
"None",
")",
":",
"# first check if it is an existing path",
"if",
"op",
".",
"exists",
"(",
"rcpath",
")",
":",
"return",
"op",
".",
"realpath",
"(",
"op",
".",
"expanduser",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | rcfile | Read environment variables and config files and return them merged with
predefined list of arguments.
Parameters
----------
appname: str
Application name, used for config files and environment variable
names.
section: str
Name of the section to be read. If this is not set: ... | boyle/utils/rcfile.py | def rcfile(appname, section=None, args={}, strip_dashes=True):
"""Read environment variables and config files and return them merged with
predefined list of arguments.
Parameters
----------
appname: str
Application name, used for config files and environment variable
names.
sec... | def rcfile(appname, section=None, args={}, strip_dashes=True):
"""Read environment variables and config files and return them merged with
predefined list of arguments.
Parameters
----------
appname: str
Application name, used for config files and environment variable
names.
sec... | [
"Read",
"environment",
"variables",
"and",
"config",
"files",
"and",
"return",
"them",
"merged",
"with",
"predefined",
"list",
"of",
"arguments",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L145-L243 | [
"def",
"rcfile",
"(",
"appname",
",",
"section",
"=",
"None",
",",
"args",
"=",
"{",
"}",
",",
"strip_dashes",
"=",
"True",
")",
":",
"if",
"strip_dashes",
":",
"for",
"k",
"in",
"args",
".",
"keys",
"(",
")",
":",
"args",
"[",
"k",
".",
"lstrip"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_rcfile_section | Return the dictionary containing the rcfile section configuration
variables.
Parameters
----------
section_name: str
Name of the section in the rcfiles.
app_name: str
Name of the application to look for its rcfiles.
Returns
-------
settings: dict
Dict with vari... | boyle/utils/rcfile.py | def get_rcfile_section(app_name, section_name):
""" Return the dictionary containing the rcfile section configuration
variables.
Parameters
----------
section_name: str
Name of the section in the rcfiles.
app_name: str
Name of the application to look for its rcfiles.
Retur... | def get_rcfile_section(app_name, section_name):
""" Return the dictionary containing the rcfile section configuration
variables.
Parameters
----------
section_name: str
Name of the section in the rcfiles.
app_name: str
Name of the application to look for its rcfiles.
Retur... | [
"Return",
"the",
"dictionary",
"containing",
"the",
"rcfile",
"section",
"configuration",
"variables",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L245-L270 | [
"def",
"get_rcfile_section",
"(",
"app_name",
",",
"section_name",
")",
":",
"try",
":",
"settings",
"=",
"rcfile",
"(",
"app_name",
",",
"section_name",
")",
"except",
"IOError",
":",
"raise",
"except",
":",
"raise",
"KeyError",
"(",
"'Error looking for section... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_rcfile_variable_value | Return the value of the variable in the section_name section of the
app_name rc file.
Parameters
----------
var_name: str
Name of the variable to be searched for.
section_name: str
Name of the section in the rcfiles.
app_name: str
Name of the application to look for it... | boyle/utils/rcfile.py | def get_rcfile_variable_value(var_name, app_name, section_name=None):
""" Return the value of the variable in the section_name section of the
app_name rc file.
Parameters
----------
var_name: str
Name of the variable to be searched for.
section_name: str
Name of the section in ... | def get_rcfile_variable_value(var_name, app_name, section_name=None):
""" Return the value of the variable in the section_name section of the
app_name rc file.
Parameters
----------
var_name: str
Name of the variable to be searched for.
section_name: str
Name of the section in ... | [
"Return",
"the",
"value",
"of",
"the",
"variable",
"in",
"the",
"section_name",
"section",
"of",
"the",
"app_name",
"rc",
"file",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L273-L299 | [
"def",
"get_rcfile_variable_value",
"(",
"var_name",
",",
"app_name",
",",
"section_name",
"=",
"None",
")",
":",
"cfg",
"=",
"get_rcfile_section",
"(",
"app_name",
",",
"section_name",
")",
"if",
"var_name",
"in",
"cfg",
":",
"raise",
"KeyError",
"(",
"'Optio... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | find_in_sections | Return the section and the value of the variable where the first
var_name is found in the app_name rcfiles.
Parameters
----------
var_name: str
Name of the variable to be searched for.
app_name: str
Name of the application to look for its rcfiles.
Returns
-------
secti... | boyle/utils/rcfile.py | def find_in_sections(var_name, app_name):
""" Return the section and the value of the variable where the first
var_name is found in the app_name rcfiles.
Parameters
----------
var_name: str
Name of the variable to be searched for.
app_name: str
Name of the application to look f... | def find_in_sections(var_name, app_name):
""" Return the section and the value of the variable where the first
var_name is found in the app_name rcfiles.
Parameters
----------
var_name: str
Name of the variable to be searched for.
app_name: str
Name of the application to look f... | [
"Return",
"the",
"section",
"and",
"the",
"value",
"of",
"the",
"variable",
"where",
"the",
"first",
"var_name",
"is",
"found",
"in",
"the",
"app_name",
"rcfiles",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/rcfile.py#L302-L337 | [
"def",
"find_in_sections",
"(",
"var_name",
",",
"app_name",
")",
":",
"sections",
"=",
"get_sections",
"(",
"app_name",
")",
"if",
"not",
"sections",
":",
"raise",
"ValueError",
"(",
"'No sections found in {} rcfiles.'",
".",
"format",
"(",
"app_name",
")",
")"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | filter_list | Filters the lst using pattern.
If pattern starts with '(' it will be considered a re regular expression,
otherwise it will use fnmatch filter.
:param lst: list of strings
:param pattern: string
:return: list of strings
Filtered list of strings | boyle/files/file_tree_map.py | def filter_list(lst, pattern):
"""
Filters the lst using pattern.
If pattern starts with '(' it will be considered a re regular expression,
otherwise it will use fnmatch filter.
:param lst: list of strings
:param pattern: string
:return: list of strings
Filtered list of strings
""... | def filter_list(lst, pattern):
"""
Filters the lst using pattern.
If pattern starts with '(' it will be considered a re regular expression,
otherwise it will use fnmatch filter.
:param lst: list of strings
:param pattern: string
:return: list of strings
Filtered list of strings
""... | [
"Filters",
"the",
"lst",
"using",
"pattern",
".",
"If",
"pattern",
"starts",
"with",
"(",
"it",
"will",
"be",
"considered",
"a",
"re",
"regular",
"expression",
"otherwise",
"it",
"will",
"use",
"fnmatch",
"filter",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L23-L49 | [
"def",
"filter_list",
"(",
"lst",
",",
"pattern",
")",
":",
"if",
"is_fnmatch_regex",
"(",
"pattern",
")",
"and",
"not",
"is_regex",
"(",
"pattern",
")",
":",
"#use fnmatch",
"log",
".",
"info",
"(",
"'Using fnmatch for {0}'",
".",
"format",
"(",
"pattern",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_subdict | Given a nested dictionary adict.
This returns its childen just below the path.
The path is a string composed of adict keys separated by sep.
:param adict: nested dict
:param path: str
:param sep: str
:return: dict or list or leaf of treemap | boyle/files/file_tree_map.py | def get_subdict(adict, path, sep=os.sep):
"""
Given a nested dictionary adict.
This returns its childen just below the path.
The path is a string composed of adict keys separated by sep.
:param adict: nested dict
:param path: str
:param sep: str
:return: dict or list or leaf of treem... | def get_subdict(adict, path, sep=os.sep):
"""
Given a nested dictionary adict.
This returns its childen just below the path.
The path is a string composed of adict keys separated by sep.
:param adict: nested dict
:param path: str
:param sep: str
:return: dict or list or leaf of treem... | [
"Given",
"a",
"nested",
"dictionary",
"adict",
".",
"This",
"returns",
"its",
"childen",
"just",
"below",
"the",
"path",
".",
"The",
"path",
"is",
"a",
"string",
"composed",
"of",
"adict",
"keys",
"separated",
"by",
"sep",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L63-L78 | [
"def",
"get_subdict",
"(",
"adict",
",",
"path",
",",
"sep",
"=",
"os",
".",
"sep",
")",
":",
"return",
"reduce",
"(",
"adict",
".",
"__class__",
".",
"get",
",",
"[",
"p",
"for",
"p",
"in",
"op",
".",
"split",
"(",
"sep",
")",
"if",
"p",
"]",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_dict_leaves | Given a nested dictionary, this returns all its leave elements in a list.
:param adict:
:return: list | boyle/files/file_tree_map.py | def get_dict_leaves(data):
"""
Given a nested dictionary, this returns all its leave elements in a list.
:param adict:
:return: list
"""
result = []
if isinstance(data, dict):
for item in data.values():
result.extend(get_dict_leaves(item))
elif isinstance(data, list... | def get_dict_leaves(data):
"""
Given a nested dictionary, this returns all its leave elements in a list.
:param adict:
:return: list
"""
result = []
if isinstance(data, dict):
for item in data.values():
result.extend(get_dict_leaves(item))
elif isinstance(data, list... | [
"Given",
"a",
"nested",
"dictionary",
"this",
"returns",
"all",
"its",
"leave",
"elements",
"in",
"a",
"list",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L85-L102 | [
"def",
"get_dict_leaves",
"(",
"data",
")",
":",
"result",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"for",
"item",
"in",
"data",
".",
"values",
"(",
")",
":",
"result",
".",
"extend",
"(",
"get_dict_leaves",
"(",
"item",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_possible_paths | Looks for path_regex within base_path. Each match is append
in the returned list.
path_regex may contain subfolder structure.
If any part of the folder structure is a
:param base_path: str
:param path_regex: str
:return list of strings | boyle/files/file_tree_map.py | def get_possible_paths(base_path, path_regex):
"""
Looks for path_regex within base_path. Each match is append
in the returned list.
path_regex may contain subfolder structure.
If any part of the folder structure is a
:param base_path: str
:param path_regex: str
:return list of string... | def get_possible_paths(base_path, path_regex):
"""
Looks for path_regex within base_path. Each match is append
in the returned list.
path_regex may contain subfolder structure.
If any part of the folder structure is a
:param base_path: str
:param path_regex: str
:return list of string... | [
"Looks",
"for",
"path_regex",
"within",
"base_path",
".",
"Each",
"match",
"is",
"append",
"in",
"the",
"returned",
"list",
".",
"path_regex",
"may",
"contain",
"subfolder",
"structure",
".",
"If",
"any",
"part",
"of",
"the",
"folder",
"structure",
"is",
"a"... | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L105-L147 | [
"def",
"get_possible_paths",
"(",
"base_path",
",",
"path_regex",
")",
":",
"if",
"not",
"path_regex",
":",
"return",
"[",
"]",
"if",
"len",
"(",
"path_regex",
")",
"<",
"1",
":",
"return",
"[",
"]",
"if",
"path_regex",
"[",
"0",
"]",
"==",
"os",
"."... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | FileTreeMap.create_folder | Will create dirpath folder. If dirpath already exists and overwrite is False,
will append a '+' suffix to dirpath until dirpath does not exist. | boyle/files/file_tree_map.py | def create_folder(dirpath, overwrite=False):
""" Will create dirpath folder. If dirpath already exists and overwrite is False,
will append a '+' suffix to dirpath until dirpath does not exist."""
if not overwrite:
while op.exists(dirpath):
dirpath += '+'
os.m... | def create_folder(dirpath, overwrite=False):
""" Will create dirpath folder. If dirpath already exists and overwrite is False,
will append a '+' suffix to dirpath until dirpath does not exist."""
if not overwrite:
while op.exists(dirpath):
dirpath += '+'
os.m... | [
"Will",
"create",
"dirpath",
"folder",
".",
"If",
"dirpath",
"already",
"exists",
"and",
"overwrite",
"is",
"False",
"will",
"append",
"a",
"+",
"suffix",
"to",
"dirpath",
"until",
"dirpath",
"does",
"not",
"exist",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L326-L334 | [
"def",
"create_folder",
"(",
"dirpath",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"not",
"overwrite",
":",
"while",
"op",
".",
"exists",
"(",
"dirpath",
")",
":",
"dirpath",
"+=",
"'+'",
"os",
".",
"makedirs",
"(",
"dirpath",
",",
"exist_ok",
"="... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | FileTreeMap._import_config | Imports filetree and root_path variable values from the filepath.
:param filepath:
:return: root_path and filetree | boyle/files/file_tree_map.py | def _import_config(filepath):
"""
Imports filetree and root_path variable values from the filepath.
:param filepath:
:return: root_path and filetree
"""
if not op.isfile(filepath):
raise IOError('Data config file not found. '
'Got: {... | def _import_config(filepath):
"""
Imports filetree and root_path variable values from the filepath.
:param filepath:
:return: root_path and filetree
"""
if not op.isfile(filepath):
raise IOError('Data config file not found. '
'Got: {... | [
"Imports",
"filetree",
"and",
"root_path",
"variable",
"values",
"from",
"the",
"filepath",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L337-L356 | [
"def",
"_import_config",
"(",
"filepath",
")",
":",
"if",
"not",
"op",
".",
"isfile",
"(",
"filepath",
")",
":",
"raise",
"IOError",
"(",
"'Data config file not found. '",
"'Got: {0}'",
".",
"format",
"(",
"filepath",
")",
")",
"cfg",
"=",
"import_pyfile",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | FileTreeMap.remove_nodes | Remove the nodes that match the pattern. | boyle/files/file_tree_map.py | def remove_nodes(self, pattern, adict):
"""
Remove the nodes that match the pattern.
"""
mydict = self._filetree if adict is None else adict
if isinstance(mydict, dict):
for nom in mydict.keys():
if isinstance(mydict[nom], dict):
m... | def remove_nodes(self, pattern, adict):
"""
Remove the nodes that match the pattern.
"""
mydict = self._filetree if adict is None else adict
if isinstance(mydict, dict):
for nom in mydict.keys():
if isinstance(mydict[nom], dict):
m... | [
"Remove",
"the",
"nodes",
"that",
"match",
"the",
"pattern",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L382-L401 | [
"def",
"remove_nodes",
"(",
"self",
",",
"pattern",
",",
"adict",
")",
":",
"mydict",
"=",
"self",
".",
"_filetree",
"if",
"adict",
"is",
"None",
"else",
"adict",
"if",
"isinstance",
"(",
"mydict",
",",
"dict",
")",
":",
"for",
"nom",
"in",
"mydict",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | FileTreeMap.count_node_match | Return the number of nodes that match the pattern.
:param pattern:
:param adict:
:return: int | boyle/files/file_tree_map.py | def count_node_match(self, pattern, adict=None):
"""
Return the number of nodes that match the pattern.
:param pattern:
:param adict:
:return: int
"""
mydict = self._filetree if adict is None else adict
k = 0
if isinstance(mydict, dict):
... | def count_node_match(self, pattern, adict=None):
"""
Return the number of nodes that match the pattern.
:param pattern:
:param adict:
:return: int
"""
mydict = self._filetree if adict is None else adict
k = 0
if isinstance(mydict, dict):
... | [
"Return",
"the",
"number",
"of",
"nodes",
"that",
"match",
"the",
"pattern",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L403-L423 | [
"def",
"count_node_match",
"(",
"self",
",",
"pattern",
",",
"adict",
"=",
"None",
")",
":",
"mydict",
"=",
"self",
".",
"_filetree",
"if",
"adict",
"is",
"None",
"else",
"adict",
"k",
"=",
"0",
"if",
"isinstance",
"(",
"mydict",
",",
"dict",
")",
":... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | as_float_array | Converts an array-like to an array of floats
The new dtype will be np.float32 or np.float64, depending on the original
type. The function can create a copy or modify the argument depending
on the argument copy.
Parameters
----------
X : {array-like, sparse matrix}
copy : bool, optional
... | boyle/utils/validation.py | def as_float_array(X, copy=True, force_all_finite=True):
"""Converts an array-like to an array of floats
The new dtype will be np.float32 or np.float64, depending on the original
type. The function can create a copy or modify the argument depending
on the argument copy.
Parameters
----------
... | def as_float_array(X, copy=True, force_all_finite=True):
"""Converts an array-like to an array of floats
The new dtype will be np.float32 or np.float64, depending on the original
type. The function can create a copy or modify the argument depending
on the argument copy.
Parameters
----------
... | [
"Converts",
"an",
"array",
"-",
"like",
"to",
"an",
"array",
"of",
"floats"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L57-L87 | [
"def",
"as_float_array",
"(",
"X",
",",
"copy",
"=",
"True",
",",
"force_all_finite",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"matrix",
")",
"or",
"(",
"not",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
"and... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | _num_samples | Return number of samples in array-like x. | boyle/utils/validation.py | def _num_samples(x):
"""Return number of samples in array-like x."""
if not hasattr(x, '__len__') and not hasattr(x, 'shape'):
if hasattr(x, '__array__'):
x = np.asarray(x)
else:
raise TypeError("Expected sequence or array-like, got %r" % x)
return x.shape[0] if hasat... | def _num_samples(x):
"""Return number of samples in array-like x."""
if not hasattr(x, '__len__') and not hasattr(x, 'shape'):
if hasattr(x, '__array__'):
x = np.asarray(x)
else:
raise TypeError("Expected sequence or array-like, got %r" % x)
return x.shape[0] if hasat... | [
"Return",
"number",
"of",
"samples",
"in",
"array",
"-",
"like",
"x",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L90-L97 | [
"def",
"_num_samples",
"(",
"x",
")",
":",
"if",
"not",
"hasattr",
"(",
"x",
",",
"'__len__'",
")",
"and",
"not",
"hasattr",
"(",
"x",
",",
"'shape'",
")",
":",
"if",
"hasattr",
"(",
"x",
",",
"'__array__'",
")",
":",
"x",
"=",
"np",
".",
"asarra... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | check_consistent_length | Check that all arrays have consistent first dimensions.
Checks whether all objects in arrays have the same shape or length.
Parameters
----------
arrays : list or tuple of input objects.
Objects that will be checked for consistent length. | boyle/utils/validation.py | def check_consistent_length(*arrays):
"""Check that all arrays have consistent first dimensions.
Checks whether all objects in arrays have the same shape or length.
Parameters
----------
arrays : list or tuple of input objects.
Objects that will be checked for consistent length.
"""
... | def check_consistent_length(*arrays):
"""Check that all arrays have consistent first dimensions.
Checks whether all objects in arrays have the same shape or length.
Parameters
----------
arrays : list or tuple of input objects.
Objects that will be checked for consistent length.
"""
... | [
"Check",
"that",
"all",
"arrays",
"have",
"consistent",
"first",
"dimensions",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L100-L114 | [
"def",
"check_consistent_length",
"(",
"*",
"arrays",
")",
":",
"uniques",
"=",
"np",
".",
"unique",
"(",
"[",
"_num_samples",
"(",
"X",
")",
"for",
"X",
"in",
"arrays",
"if",
"X",
"is",
"not",
"None",
"]",
")",
"if",
"len",
"(",
"uniques",
")",
">... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | indexable | Make arrays indexable for cross-validation.
Checks consistent length, passes through None, and ensures that everything
can be indexed by converting sparse matrices to csr and converting
non-interable objects to arrays.
Parameters
----------
iterables : lists, dataframes, arrays, sparse matrice... | boyle/utils/validation.py | def indexable(*iterables):
"""Make arrays indexable for cross-validation.
Checks consistent length, passes through None, and ensures that everything
can be indexed by converting sparse matrices to csr and converting
non-interable objects to arrays.
Parameters
----------
iterables : lists, ... | def indexable(*iterables):
"""Make arrays indexable for cross-validation.
Checks consistent length, passes through None, and ensures that everything
can be indexed by converting sparse matrices to csr and converting
non-interable objects to arrays.
Parameters
----------
iterables : lists, ... | [
"Make",
"arrays",
"indexable",
"for",
"cross",
"-",
"validation",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L117-L140 | [
"def",
"indexable",
"(",
"*",
"iterables",
")",
":",
"result",
"=",
"[",
"]",
"for",
"X",
"in",
"iterables",
":",
"if",
"sp",
".",
"issparse",
"(",
"X",
")",
":",
"result",
".",
"append",
"(",
"X",
".",
"tocsr",
"(",
")",
")",
"elif",
"hasattr",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | check_array | Input validation on an array, list, sparse matrix or similar.
By default, the input is converted to an at least 2nd numpy array.
Parameters
----------
array : object
Input object to check / convert.
accept_sparse : string, list of string or None (default=None)
String[s] representi... | boyle/utils/validation.py | def check_array(array, accept_sparse=None, dtype=None, order=None, copy=False,
force_all_finite=True, ensure_2d=True, allow_nd=False):
"""Input validation on an array, list, sparse matrix or similar.
By default, the input is converted to an at least 2nd numpy array.
Parameters
--------... | def check_array(array, accept_sparse=None, dtype=None, order=None, copy=False,
force_all_finite=True, ensure_2d=True, allow_nd=False):
"""Input validation on an array, list, sparse matrix or similar.
By default, the input is converted to an at least 2nd numpy array.
Parameters
--------... | [
"Input",
"validation",
"on",
"an",
"array",
"list",
"sparse",
"matrix",
"or",
"similar",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L205-L259 | [
"def",
"check_array",
"(",
"array",
",",
"accept_sparse",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"order",
"=",
"None",
",",
"copy",
"=",
"False",
",",
"force_all_finite",
"=",
"True",
",",
"ensure_2d",
"=",
"True",
",",
"allow_nd",
"=",
"False",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | check_X_y | Input validation for standard estimators.
Checks X and y for consistent length, enforces X 2d and y 1d.
Standard input checks are only applied to y. For multi-label y,
set multi_ouput=True to allow 2d and sparse y.
Parameters
----------
X : nd-array, list or sparse matrix
Input data.
... | boyle/utils/validation.py | def check_X_y(X, y, accept_sparse=None, dtype=None, order=None, copy=False,
force_all_finite=True, ensure_2d=True, allow_nd=False,
multi_output=False):
"""Input validation for standard estimators.
Checks X and y for consistent length, enforces X 2d and y 1d.
Standard input check... | def check_X_y(X, y, accept_sparse=None, dtype=None, order=None, copy=False,
force_all_finite=True, ensure_2d=True, allow_nd=False,
multi_output=False):
"""Input validation for standard estimators.
Checks X and y for consistent length, enforces X 2d and y 1d.
Standard input check... | [
"Input",
"validation",
"for",
"standard",
"estimators",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L262-L316 | [
"def",
"check_X_y",
"(",
"X",
",",
"y",
",",
"accept_sparse",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"order",
"=",
"None",
",",
"copy",
"=",
"False",
",",
"force_all_finite",
"=",
"True",
",",
"ensure_2d",
"=",
"True",
",",
"allow_nd",
"=",
"Fa... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | column_or_1d | Ravel column or 1d numpy array, else raises an error
Parameters
----------
y : array-like
Returns
-------
y : array | boyle/utils/validation.py | def column_or_1d(y, warn=False):
""" Ravel column or 1d numpy array, else raises an error
Parameters
----------
y : array-like
Returns
-------
y : array
"""
shape = np.shape(y)
if len(shape) == 1:
return np.ravel(y)
if len(shape) == 2 and shape[1] == 1:
if ... | def column_or_1d(y, warn=False):
""" Ravel column or 1d numpy array, else raises an error
Parameters
----------
y : array-like
Returns
-------
y : array
"""
shape = np.shape(y)
if len(shape) == 1:
return np.ravel(y)
if len(shape) == 2 and shape[1] == 1:
if ... | [
"Ravel",
"column",
"or",
"1d",
"numpy",
"array",
"else",
"raises",
"an",
"error"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L319-L342 | [
"def",
"column_or_1d",
"(",
"y",
",",
"warn",
"=",
"False",
")",
":",
"shape",
"=",
"np",
".",
"shape",
"(",
"y",
")",
"if",
"len",
"(",
"shape",
")",
"==",
"1",
":",
"return",
"np",
".",
"ravel",
"(",
"y",
")",
"if",
"len",
"(",
"shape",
")"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | warn_if_not_float | Warning utility function to check that data type is floating point.
Returns True if a warning was raised (i.e. the input is not float) and
False otherwise, for easier input validation. | boyle/utils/validation.py | def warn_if_not_float(X, estimator='This algorithm'):
"""Warning utility function to check that data type is floating point.
Returns True if a warning was raised (i.e. the input is not float) and
False otherwise, for easier input validation.
"""
if not isinstance(estimator, str):
estimator ... | def warn_if_not_float(X, estimator='This algorithm'):
"""Warning utility function to check that data type is floating point.
Returns True if a warning was raised (i.e. the input is not float) and
False otherwise, for easier input validation.
"""
if not isinstance(estimator, str):
estimator ... | [
"Warning",
"utility",
"function",
"to",
"check",
"that",
"data",
"type",
"is",
"floating",
"point",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/validation.py#L345-L357 | [
"def",
"warn_if_not_float",
"(",
"X",
",",
"estimator",
"=",
"'This algorithm'",
")",
":",
"if",
"not",
"isinstance",
"(",
"estimator",
",",
"str",
")",
":",
"estimator",
"=",
"estimator",
".",
"__class__",
".",
"__name__",
"if",
"X",
".",
"dtype",
".",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | as_ndarray | Convert an arbitrary array to numpy.ndarray.
In the case of a memmap array, a copy is automatically made to break the
link with the underlying file (whatever the value of the "copy" keyword).
The purpose of this function is mainly to get rid of memmap objects, but
it can be used for other purposes. In... | boyle/utils/numpy_conversions.py | def as_ndarray(arr, copy=False, dtype=None, order='K'):
"""Convert an arbitrary array to numpy.ndarray.
In the case of a memmap array, a copy is automatically made to break the
link with the underlying file (whatever the value of the "copy" keyword).
The purpose of this function is mainly to get rid o... | def as_ndarray(arr, copy=False, dtype=None, order='K'):
"""Convert an arbitrary array to numpy.ndarray.
In the case of a memmap array, a copy is automatically made to break the
link with the underlying file (whatever the value of the "copy" keyword).
The purpose of this function is mainly to get rid o... | [
"Convert",
"an",
"arbitrary",
"array",
"to",
"numpy",
".",
"ndarray",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/numpy_conversions.py#L37-L121 | [
"def",
"as_ndarray",
"(",
"arr",
",",
"copy",
"=",
"False",
",",
"dtype",
"=",
"None",
",",
"order",
"=",
"'K'",
")",
":",
"if",
"order",
"not",
"in",
"(",
"'C'",
",",
"'F'",
",",
"'A'",
",",
"'K'",
",",
"None",
")",
":",
"raise",
"ValueError",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | xfm_atlas_to_functional | Call FSL tools to apply transformations to a given atlas to a functional image.
Given the transformation matrices.
Parameters
----------
atlas_filepath: str
Path to the 3D atlas volume file.
anatbrain_filepath: str
Path to the anatomical brain volume file (skull-stripped and regist... | boyle/nifti/cpac_helpers.py | def xfm_atlas_to_functional(atlas_filepath, anatbrain_filepath, meanfunc_filepath,
atlas2anat_nonlin_xfm_filepath, is_atlas2anat_inverted,
anat2func_lin_xfm_filepath,
atlasinanat_out_filepath, atlasinfunc_out_filepath,
... | def xfm_atlas_to_functional(atlas_filepath, anatbrain_filepath, meanfunc_filepath,
atlas2anat_nonlin_xfm_filepath, is_atlas2anat_inverted,
anat2func_lin_xfm_filepath,
atlasinanat_out_filepath, atlasinfunc_out_filepath,
... | [
"Call",
"FSL",
"tools",
"to",
"apply",
"transformations",
"to",
"a",
"given",
"atlas",
"to",
"a",
"functional",
"image",
".",
"Given",
"the",
"transformation",
"matrices",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/cpac_helpers.py#L19-L118 | [
"def",
"xfm_atlas_to_functional",
"(",
"atlas_filepath",
",",
"anatbrain_filepath",
",",
"meanfunc_filepath",
",",
"atlas2anat_nonlin_xfm_filepath",
",",
"is_atlas2anat_inverted",
",",
"anat2func_lin_xfm_filepath",
",",
"atlasinanat_out_filepath",
",",
"atlasinfunc_out_filepath",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | fwhm2sigma | Convert a FWHM value to sigma in a Gaussian kernel.
Parameters
----------
fwhm: float or numpy.array
fwhm value or values
Returns
-------
fwhm: float or numpy.array
sigma values | boyle/nifti/smooth.py | def fwhm2sigma(fwhm):
"""Convert a FWHM value to sigma in a Gaussian kernel.
Parameters
----------
fwhm: float or numpy.array
fwhm value or values
Returns
-------
fwhm: float or numpy.array
sigma values
"""
fwhm = np.asarray(fwhm)
return fwhm / np.sqrt(8 * np.log(... | def fwhm2sigma(fwhm):
"""Convert a FWHM value to sigma in a Gaussian kernel.
Parameters
----------
fwhm: float or numpy.array
fwhm value or values
Returns
-------
fwhm: float or numpy.array
sigma values
"""
fwhm = np.asarray(fwhm)
return fwhm / np.sqrt(8 * np.log(... | [
"Convert",
"a",
"FWHM",
"value",
"to",
"sigma",
"in",
"a",
"Gaussian",
"kernel",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/smooth.py#L38-L52 | [
"def",
"fwhm2sigma",
"(",
"fwhm",
")",
":",
"fwhm",
"=",
"np",
".",
"asarray",
"(",
"fwhm",
")",
"return",
"fwhm",
"/",
"np",
".",
"sqrt",
"(",
"8",
"*",
"np",
".",
"log",
"(",
"2",
")",
")"
] | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | sigma2fwhm | Convert a sigma in a Gaussian kernel to a FWHM value.
Parameters
----------
sigma: float or numpy.array
sigma value or values
Returns
-------
fwhm: float or numpy.array
fwhm values corresponding to `sigma` values | boyle/nifti/smooth.py | def sigma2fwhm(sigma):
"""Convert a sigma in a Gaussian kernel to a FWHM value.
Parameters
----------
sigma: float or numpy.array
sigma value or values
Returns
-------
fwhm: float or numpy.array
fwhm values corresponding to `sigma` values
"""
sigma = np.asarray(sigma)... | def sigma2fwhm(sigma):
"""Convert a sigma in a Gaussian kernel to a FWHM value.
Parameters
----------
sigma: float or numpy.array
sigma value or values
Returns
-------
fwhm: float or numpy.array
fwhm values corresponding to `sigma` values
"""
sigma = np.asarray(sigma)... | [
"Convert",
"a",
"sigma",
"in",
"a",
"Gaussian",
"kernel",
"to",
"a",
"FWHM",
"value",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/smooth.py#L55-L69 | [
"def",
"sigma2fwhm",
"(",
"sigma",
")",
":",
"sigma",
"=",
"np",
".",
"asarray",
"(",
"sigma",
")",
"return",
"np",
".",
"sqrt",
"(",
"8",
"*",
"np",
".",
"log",
"(",
"2",
")",
")",
"*",
"sigma"
] | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | _smooth_data_array | Smooth images with a a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
Parameters
----------
arr: numpy.ndarray
3D or 4D array, with image number as last dimension.
affine: numpy.ndarray
Image affine transformation matrix for image.
fwhm: sca... | boyle/nifti/smooth.py | def _smooth_data_array(arr, affine, fwhm, copy=True):
"""Smooth images with a a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
Parameters
----------
arr: numpy.ndarray
3D or 4D array, with image number as last dimension.
affine: numpy.ndarray
... | def _smooth_data_array(arr, affine, fwhm, copy=True):
"""Smooth images with a a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
Parameters
----------
arr: numpy.ndarray
3D or 4D array, with image number as last dimension.
affine: numpy.ndarray
... | [
"Smooth",
"images",
"with",
"a",
"a",
"Gaussian",
"filter",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/smooth.py#L77-L127 | [
"def",
"_smooth_data_array",
"(",
"arr",
",",
"affine",
",",
"fwhm",
",",
"copy",
"=",
"True",
")",
":",
"if",
"arr",
".",
"dtype",
".",
"kind",
"==",
"'i'",
":",
"if",
"arr",
".",
"dtype",
"==",
"np",
".",
"int64",
":",
"arr",
"=",
"arr",
".",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | smooth_imgs | Smooth images using a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of each image in images.
In all cases, non-finite values in input are zeroed.
Parameters
----------
imgs: str or img-like object or iterable of img-like objects
See boyle.nifti.read.read_img
... | boyle/nifti/smooth.py | def smooth_imgs(images, fwhm):
"""Smooth images using a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of each image in images.
In all cases, non-finite values in input are zeroed.
Parameters
----------
imgs: str or img-like object or iterable of img-like objects
... | def smooth_imgs(images, fwhm):
"""Smooth images using a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of each image in images.
In all cases, non-finite values in input are zeroed.
Parameters
----------
imgs: str or img-like object or iterable of img-like objects
... | [
"Smooth",
"images",
"using",
"a",
"Gaussian",
"filter",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/smooth.py#L130-L171 | [
"def",
"smooth_imgs",
"(",
"images",
",",
"fwhm",
")",
":",
"if",
"fwhm",
"<=",
"0",
":",
"return",
"images",
"if",
"not",
"isinstance",
"(",
"images",
",",
"string_types",
")",
"and",
"hasattr",
"(",
"images",
",",
"'__iter__'",
")",
":",
"only_one",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | _smooth_array | Smooth images by applying a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
This is copied and slightly modified from nilearn:
https://github.com/nilearn/nilearn/blob/master/nilearn/image/image.py
Added the **kwargs argument.
Parameters
==========
arr: num... | boyle/nifti/smooth.py | def _smooth_array(arr, affine, fwhm=None, ensure_finite=True, copy=True, **kwargs):
"""Smooth images by applying a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
This is copied and slightly modified from nilearn:
https://github.com/nilearn/nilearn/blob/master/nilearn/... | def _smooth_array(arr, affine, fwhm=None, ensure_finite=True, copy=True, **kwargs):
"""Smooth images by applying a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
This is copied and slightly modified from nilearn:
https://github.com/nilearn/nilearn/blob/master/nilearn/... | [
"Smooth",
"images",
"by",
"applying",
"a",
"Gaussian",
"filter",
".",
"Apply",
"a",
"Gaussian",
"filter",
"along",
"the",
"three",
"first",
"dimensions",
"of",
"arr",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/smooth.py#L174-L244 | [
"def",
"_smooth_array",
"(",
"arr",
",",
"affine",
",",
"fwhm",
"=",
"None",
",",
"ensure_finite",
"=",
"True",
",",
"copy",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"arr",
".",
"dtype",
".",
"kind",
"==",
"'i'",
":",
"if",
"arr",
".... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | smooth_img | Smooth images by applying a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
In all cases, non-finite values in input image are replaced by zeros.
This is copied and slightly modified from nilearn:
https://github.com/nilearn/nilearn/blob/master/nilearn/image/image.py
... | boyle/nifti/smooth.py | def smooth_img(imgs, fwhm, **kwargs):
"""Smooth images by applying a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
In all cases, non-finite values in input image are replaced by zeros.
This is copied and slightly modified from nilearn:
https://github.com/nilearn/... | def smooth_img(imgs, fwhm, **kwargs):
"""Smooth images by applying a Gaussian filter.
Apply a Gaussian filter along the three first dimensions of arr.
In all cases, non-finite values in input image are replaced by zeros.
This is copied and slightly modified from nilearn:
https://github.com/nilearn/... | [
"Smooth",
"images",
"by",
"applying",
"a",
"Gaussian",
"filter",
".",
"Apply",
"a",
"Gaussian",
"filter",
"along",
"the",
"three",
"first",
"dimensions",
"of",
"arr",
".",
"In",
"all",
"cases",
"non",
"-",
"finite",
"values",
"in",
"input",
"image",
"are",... | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/smooth.py#L247-L297 | [
"def",
"smooth_img",
"(",
"imgs",
",",
"fwhm",
",",
"*",
"*",
"kwargs",
")",
":",
"# Use hasattr() instead of isinstance to workaround a Python 2.6/2.7 bug",
"# See http://bugs.python.org/issue7624",
"if",
"hasattr",
"(",
"imgs",
",",
"\"__iter__\"",
")",
"and",
"not",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | ClientCertAuthentication.signed_session | Create requests session with any required auth headers
applied.
:rtype: requests.Session. | rcctl/rcctl/auth.py | def signed_session(self, session=None):
"""Create requests session with any required auth headers
applied.
:rtype: requests.Session.
"""
if session:
session = super(ClientCertAuthentication, self).signed_session(session)
else:
session = super(Cli... | def signed_session(self, session=None):
"""Create requests session with any required auth headers
applied.
:rtype: requests.Session.
"""
if session:
session = super(ClientCertAuthentication, self).signed_session(session)
else:
session = super(Cli... | [
"Create",
"requests",
"session",
"with",
"any",
"required",
"auth",
"headers",
"applied",
"."
] | shalabhms/reliable-collections-cli | python | https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/auth.py#L20-L39 | [
"def",
"signed_session",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"session",
":",
"session",
"=",
"super",
"(",
"ClientCertAuthentication",
",",
"self",
")",
".",
"signed_session",
"(",
"session",
")",
"else",
":",
"session",
"=",
"super",... | 195d69816fb5a6e1e9ab0ab66b606b1248b4780d |
valid | AdalAuthentication.signed_session | Create requests session with AAD auth headers
:rtype: requests.Session. | rcctl/rcctl/auth.py | def signed_session(self, session=None):
"""Create requests session with AAD auth headers
:rtype: requests.Session.
"""
from sfctl.config import (aad_metadata, aad_cache)
if session:
session = super(AdalAuthentication, self).signed_session(session)
else:
... | def signed_session(self, session=None):
"""Create requests session with AAD auth headers
:rtype: requests.Session.
"""
from sfctl.config import (aad_metadata, aad_cache)
if session:
session = super(AdalAuthentication, self).signed_session(session)
else:
... | [
"Create",
"requests",
"session",
"with",
"AAD",
"auth",
"headers"
] | shalabhms/reliable-collections-cli | python | https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/auth.py#L47-L71 | [
"def",
"signed_session",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"from",
"sfctl",
".",
"config",
"import",
"(",
"aad_metadata",
",",
"aad_cache",
")",
"if",
"session",
":",
"session",
"=",
"super",
"(",
"AdalAuthentication",
",",
"self",
")",
... | 195d69816fb5a6e1e9ab0ab66b606b1248b4780d |
valid | voxspace_to_mmspace | Return a grid with coordinates in 3D physical space for `img`. | boyle/nifti/coord_transform.py | def voxspace_to_mmspace(img):
""" Return a grid with coordinates in 3D physical space for `img`."""
shape, affine = img.shape[:3], img.affine
coords = np.array(np.meshgrid(*(range(i) for i in shape), indexing='ij'))
coords = np.rollaxis(coords, 0, len(shape) + 1)
mm_coords = nib.affines.apply_affine... | def voxspace_to_mmspace(img):
""" Return a grid with coordinates in 3D physical space for `img`."""
shape, affine = img.shape[:3], img.affine
coords = np.array(np.meshgrid(*(range(i) for i in shape), indexing='ij'))
coords = np.rollaxis(coords, 0, len(shape) + 1)
mm_coords = nib.affines.apply_affine... | [
"Return",
"a",
"grid",
"with",
"coordinates",
"in",
"3D",
"physical",
"space",
"for",
"img",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/coord_transform.py#L18-L25 | [
"def",
"voxspace_to_mmspace",
"(",
"img",
")",
":",
"shape",
",",
"affine",
"=",
"img",
".",
"shape",
"[",
":",
"3",
"]",
",",
"img",
".",
"affine",
"coords",
"=",
"np",
".",
"array",
"(",
"np",
".",
"meshgrid",
"(",
"*",
"(",
"range",
"(",
"i",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | voxcoord_to_mm | Parameters
----------
cm: nipy.core.reference.coordinate_map.CoordinateMap
i, j, k: floats
Voxel coordinates
Returns
-------
Triplet with real 3D world coordinates | boyle/nifti/coord_transform.py | def voxcoord_to_mm(cm, i, j, k):
'''
Parameters
----------
cm: nipy.core.reference.coordinate_map.CoordinateMap
i, j, k: floats
Voxel coordinates
Returns
-------
Triplet with real 3D world coordinates
'''
try:
mm = cm([i, j, k])
except Exception as exc:
... | def voxcoord_to_mm(cm, i, j, k):
'''
Parameters
----------
cm: nipy.core.reference.coordinate_map.CoordinateMap
i, j, k: floats
Voxel coordinates
Returns
-------
Triplet with real 3D world coordinates
'''
try:
mm = cm([i, j, k])
except Exception as exc:
... | [
"Parameters",
"----------",
"cm",
":",
"nipy",
".",
"core",
".",
"reference",
".",
"coordinate_map",
".",
"CoordinateMap"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/coord_transform.py#L28-L47 | [
"def",
"voxcoord_to_mm",
"(",
"cm",
",",
"i",
",",
"j",
",",
"k",
")",
":",
"try",
":",
"mm",
"=",
"cm",
"(",
"[",
"i",
",",
"j",
",",
"k",
"]",
")",
"except",
"Exception",
"as",
"exc",
":",
"raise",
"Exception",
"(",
"'Error on converting coordina... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | mm_to_voxcoord | Parameters
----------
cm: nipy.core.reference.coordinate_map.CoordinateMap
x, y, z: floats
Physical coordinates
Returns
-------
Triplet with 3D voxel coordinates | boyle/nifti/coord_transform.py | def mm_to_voxcoord(cm, x, y, z):
'''
Parameters
----------
cm: nipy.core.reference.coordinate_map.CoordinateMap
x, y, z: floats
Physical coordinates
Returns
-------
Triplet with 3D voxel coordinates
'''
try:
vox = cm.inverse()([x, y, z])
except Exception as ... | def mm_to_voxcoord(cm, x, y, z):
'''
Parameters
----------
cm: nipy.core.reference.coordinate_map.CoordinateMap
x, y, z: floats
Physical coordinates
Returns
-------
Triplet with 3D voxel coordinates
'''
try:
vox = cm.inverse()([x, y, z])
except Exception as ... | [
"Parameters",
"----------",
"cm",
":",
"nipy",
".",
"core",
".",
"reference",
".",
"coordinate_map",
".",
"CoordinateMap"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/coord_transform.py#L50-L68 | [
"def",
"mm_to_voxcoord",
"(",
"cm",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"try",
":",
"vox",
"=",
"cm",
".",
"inverse",
"(",
")",
"(",
"[",
"x",
",",
"y",
",",
"z",
"]",
")",
"except",
"Exception",
"as",
"exc",
":",
"raise",
"Exception",
"(... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_3D_coordmap | Gets a 3D CoordinateMap from img.
Parameters
----------
img: nib.Nifti1Image or nipy Image
Returns
-------
nipy.core.reference.coordinate_map.CoordinateMap | boyle/nifti/coord_transform.py | def get_3D_coordmap(img):
'''
Gets a 3D CoordinateMap from img.
Parameters
----------
img: nib.Nifti1Image or nipy Image
Returns
-------
nipy.core.reference.coordinate_map.CoordinateMap
'''
if isinstance(img, nib.Nifti1Image):
img = nifti2nipy(img)
if img.ndim == 4... | def get_3D_coordmap(img):
'''
Gets a 3D CoordinateMap from img.
Parameters
----------
img: nib.Nifti1Image or nipy Image
Returns
-------
nipy.core.reference.coordinate_map.CoordinateMap
'''
if isinstance(img, nib.Nifti1Image):
img = nifti2nipy(img)
if img.ndim == 4... | [
"Gets",
"a",
"3D",
"CoordinateMap",
"from",
"img",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/coord_transform.py#L71-L92 | [
"def",
"get_3D_coordmap",
"(",
"img",
")",
":",
"if",
"isinstance",
"(",
"img",
",",
"nib",
".",
"Nifti1Image",
")",
":",
"img",
"=",
"nifti2nipy",
"(",
"img",
")",
"if",
"img",
".",
"ndim",
"==",
"4",
":",
"from",
"nipy",
".",
"core",
".",
"refere... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_img_info | Return the header and affine matrix from a Nifti file.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Image.
If niimg is a string, consider it as a p... | boyle/nifti/read.py | def get_img_info(image):
"""Return the header and affine matrix from a Nifti file.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Image.
If niimg... | def get_img_info(image):
"""Return the header and affine matrix from a Nifti file.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Image.
If niimg... | [
"Return",
"the",
"header",
"and",
"affine",
"matrix",
"from",
"a",
"Nifti",
"file",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L66-L88 | [
"def",
"get_img_info",
"(",
"image",
")",
":",
"try",
":",
"img",
"=",
"check_img",
"(",
"image",
")",
"except",
"Exception",
"as",
"exc",
":",
"raise",
"Exception",
"(",
"'Error reading file {0}.'",
".",
"format",
"(",
"repr_imgs",
"(",
"image",
")",
")",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_img_data | Return the voxel matrix of the Nifti file.
If safe_mode will make a copy of the img before returning the data, so the input image is not modified.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data() and g... | boyle/nifti/read.py | def get_img_data(image, copy=True):
"""Return the voxel matrix of the Nifti file.
If safe_mode will make a copy of the img before returning the data, so the input image is not modified.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image... | def get_img_data(image, copy=True):
"""Return the voxel matrix of the Nifti file.
If safe_mode will make a copy of the img before returning the data, so the input image is not modified.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image... | [
"Return",
"the",
"voxel",
"matrix",
"of",
"the",
"Nifti",
"file",
".",
"If",
"safe_mode",
"will",
"make",
"a",
"copy",
"of",
"the",
"img",
"before",
"returning",
"the",
"data",
"so",
"the",
"input",
"image",
"is",
"not",
"modified",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L91-L119 | [
"def",
"get_img_data",
"(",
"image",
",",
"copy",
"=",
"True",
")",
":",
"try",
":",
"img",
"=",
"check_img",
"(",
"image",
")",
"if",
"copy",
":",
"return",
"get_data",
"(",
"img",
")",
"else",
":",
"return",
"img",
".",
"get_data",
"(",
")",
"exc... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | load_nipy_img | Read a Nifti file and return as nipy.Image
Parameters
----------
param nii_file: str
Nifti file path
Returns
-------
nipy.Image | boyle/nifti/read.py | def load_nipy_img(nii_file):
"""Read a Nifti file and return as nipy.Image
Parameters
----------
param nii_file: str
Nifti file path
Returns
-------
nipy.Image
"""
# delayed import because could not install nipy on Python 3 on OSX
import nipy
if not os.path.exists(... | def load_nipy_img(nii_file):
"""Read a Nifti file and return as nipy.Image
Parameters
----------
param nii_file: str
Nifti file path
Returns
-------
nipy.Image
"""
# delayed import because could not install nipy on Python 3 on OSX
import nipy
if not os.path.exists(... | [
"Read",
"a",
"Nifti",
"file",
"and",
"return",
"as",
"nipy",
".",
"Image"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L122-L143 | [
"def",
"load_nipy_img",
"(",
"nii_file",
")",
":",
"# delayed import because could not install nipy on Python 3 on OSX",
"import",
"nipy",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"nii_file",
")",
":",
"raise",
"FileNotFound",
"(",
"nii_file",
")",
"try",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | niftilist_to_array | From the list of absolute paths to nifti files, creates a Numpy array
with the data.
Parameters
----------
img_filelist: list of str
List of absolute file paths to nifti files. All nifti files must have
the same shape.
outdtype: dtype
Type of the elements of the array, if ... | boyle/nifti/read.py | def niftilist_to_array(img_filelist, outdtype=None):
"""
From the list of absolute paths to nifti files, creates a Numpy array
with the data.
Parameters
----------
img_filelist: list of str
List of absolute file paths to nifti files. All nifti files must have
the same shape.
... | def niftilist_to_array(img_filelist, outdtype=None):
"""
From the list of absolute paths to nifti files, creates a Numpy array
with the data.
Parameters
----------
img_filelist: list of str
List of absolute file paths to nifti files. All nifti files must have
the same shape.
... | [
"From",
"the",
"list",
"of",
"absolute",
"paths",
"to",
"nifti",
"files",
"creates",
"a",
"Numpy",
"array",
"with",
"the",
"data",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L146-L187 | [
"def",
"niftilist_to_array",
"(",
"img_filelist",
",",
"outdtype",
"=",
"None",
")",
":",
"try",
":",
"first_img",
"=",
"img_filelist",
"[",
"0",
"]",
"vol",
"=",
"get_img_data",
"(",
"first_img",
")",
"except",
"IndexError",
"as",
"ie",
":",
"raise",
"Exc... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | _crop_img_to | Crops image to a smaller size
Crop img to size indicated by slices and modify the affine accordingly.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Ima... | boyle/nifti/read.py | def _crop_img_to(image, slices, copy=True):
"""Crops image to a smaller size
Crop img to size indicated by slices and modify the affine accordingly.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data(... | def _crop_img_to(image, slices, copy=True):
"""Crops image to a smaller size
Crop img to size indicated by slices and modify the affine accordingly.
Parameters
----------
image: img-like object or str
Can either be:
- a file path to a Nifti image
- any object with get_data(... | [
"Crops",
"image",
"to",
"a",
"smaller",
"size"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L190-L244 | [
"def",
"_crop_img_to",
"(",
"image",
",",
"slices",
",",
"copy",
"=",
"True",
")",
":",
"img",
"=",
"check_img",
"(",
"image",
")",
"data",
"=",
"img",
".",
"get_data",
"(",
")",
"affine",
"=",
"img",
".",
"get_affine",
"(",
")",
"cropped_data",
"=",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | crop_img | Crops img as much as possible
Will crop img, removing as many zero entries as possible
without touching non-zero entries. Will leave one voxel of
zero padding around the obtained non-zero area in order to
avoid sampling issues later on.
Parameters
----------
image: img-like object or str
... | boyle/nifti/read.py | def crop_img(image, rtol=1e-8, copy=True):
"""Crops img as much as possible
Will crop img, removing as many zero entries as possible
without touching non-zero entries. Will leave one voxel of
zero padding around the obtained non-zero area in order to
avoid sampling issues later on.
Parameters
... | def crop_img(image, rtol=1e-8, copy=True):
"""Crops img as much as possible
Will crop img, removing as many zero entries as possible
without touching non-zero entries. Will leave one voxel of
zero padding around the obtained non-zero area in order to
avoid sampling issues later on.
Parameters
... | [
"Crops",
"img",
"as",
"much",
"as",
"possible"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L247-L300 | [
"def",
"crop_img",
"(",
"image",
",",
"rtol",
"=",
"1e-8",
",",
"copy",
"=",
"True",
")",
":",
"img",
"=",
"check_img",
"(",
"image",
")",
"data",
"=",
"img",
".",
"get_data",
"(",
")",
"infinity_norm",
"=",
"max",
"(",
"-",
"data",
".",
"min",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | new_img_like | Create a new image of the same class as the reference image
Parameters
----------
ref_niimg: image
Reference image. The new image will be of the same type.
data: numpy array
Data to be stored in the image
affine: 4x4 numpy array, optional
Transformation matrix
copy_he... | boyle/nifti/read.py | def new_img_like(ref_niimg, data, affine=None, copy_header=False):
"""Create a new image of the same class as the reference image
Parameters
----------
ref_niimg: image
Reference image. The new image will be of the same type.
data: numpy array
Data to be stored in the image
af... | def new_img_like(ref_niimg, data, affine=None, copy_header=False):
"""Create a new image of the same class as the reference image
Parameters
----------
ref_niimg: image
Reference image. The new image will be of the same type.
data: numpy array
Data to be stored in the image
af... | [
"Create",
"a",
"new",
"image",
"of",
"the",
"same",
"class",
"as",
"the",
"reference",
"image"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/read.py#L303-L353 | [
"def",
"new_img_like",
"(",
"ref_niimg",
",",
"data",
",",
"affine",
"=",
"None",
",",
"copy_header",
"=",
"False",
")",
":",
"# Hand-written loading code to avoid too much memory consumption",
"if",
"not",
"(",
"hasattr",
"(",
"ref_niimg",
",",
"'get_data'",
")",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | save_variables_to_hdf5 | Parameters
----------
file_path: str
variables: dict
Dictionary with objects. Object name -> object
mode: str
HDF5 file access mode
See h5py documentation for details.
r Readonly, file must exist
r+ Read/write, file must exist
w Create file, truncat... | boyle/hdf5.py | def save_variables_to_hdf5(file_path, variables, mode='w', h5path='/'):
"""
Parameters
----------
file_path: str
variables: dict
Dictionary with objects. Object name -> object
mode: str
HDF5 file access mode
See h5py documentation for details.
r Readonly, file... | def save_variables_to_hdf5(file_path, variables, mode='w', h5path='/'):
"""
Parameters
----------
file_path: str
variables: dict
Dictionary with objects. Object name -> object
mode: str
HDF5 file access mode
See h5py documentation for details.
r Readonly, file... | [
"Parameters",
"----------",
"file_path",
":",
"str"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/hdf5.py#L25-L79 | [
"def",
"save_variables_to_hdf5",
"(",
"file_path",
",",
"variables",
",",
"mode",
"=",
"'w'",
",",
"h5path",
"=",
"'/'",
")",
":",
"if",
"not",
"isinstance",
"(",
"variables",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"'Expected `variables` to be a di... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | get_h5file | Return the h5py.File given its file path.
Parameters
----------
file_path: string
HDF5 file path
mode: string
r Readonly, file must exist
r+ Read/write, file must exist
w Create file, truncate if exists
w- Create file, fail if exists
a Read/write... | boyle/hdf5.py | def get_h5file(file_path, mode='r'):
""" Return the h5py.File given its file path.
Parameters
----------
file_path: string
HDF5 file path
mode: string
r Readonly, file must exist
r+ Read/write, file must exist
w Create file, truncate if exists
w- Creat... | def get_h5file(file_path, mode='r'):
""" Return the h5py.File given its file path.
Parameters
----------
file_path: string
HDF5 file path
mode: string
r Readonly, file must exist
r+ Read/write, file must exist
w Create file, truncate if exists
w- Creat... | [
"Return",
"the",
"h5py",
".",
"File",
"given",
"its",
"file",
"path",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/hdf5.py#L85-L112 | [
"def",
"get_h5file",
"(",
"file_path",
",",
"mode",
"=",
"'r'",
")",
":",
"if",
"not",
"op",
".",
"exists",
"(",
"file_path",
")",
":",
"raise",
"IOError",
"(",
"'Could not find file {}.'",
".",
"format",
"(",
"file_path",
")",
")",
"try",
":",
"h5file",... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | extract_datasets | Return all dataset contents from h5path group in h5file in an OrderedDict.
Parameters
----------
h5file: h5py.File
HDF5 file object
h5path: str
HDF5 group path to read datasets from
Returns
-------
datasets: OrderedDict
Dict with variables contained in file_path/h5... | boyle/hdf5.py | def extract_datasets(h5file, h5path='/'):
""" Return all dataset contents from h5path group in h5file in an OrderedDict.
Parameters
----------
h5file: h5py.File
HDF5 file object
h5path: str
HDF5 group path to read datasets from
Returns
-------
datasets: OrderedDict
... | def extract_datasets(h5file, h5path='/'):
""" Return all dataset contents from h5path group in h5file in an OrderedDict.
Parameters
----------
h5file: h5py.File
HDF5 file object
h5path: str
HDF5 group path to read datasets from
Returns
-------
datasets: OrderedDict
... | [
"Return",
"all",
"dataset",
"contents",
"from",
"h5path",
"group",
"in",
"h5file",
"in",
"an",
"OrderedDict",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/hdf5.py#L172-L204 | [
"def",
"extract_datasets",
"(",
"h5file",
",",
"h5path",
"=",
"'/'",
")",
":",
"if",
"isinstance",
"(",
"h5file",
",",
"str",
")",
":",
"_h5file",
"=",
"h5py",
".",
"File",
"(",
"h5file",
",",
"mode",
"=",
"'r'",
")",
"else",
":",
"_h5file",
"=",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | _get_node_names | Return the node of type node_type names within h5path of h5file.
Parameters
----------
h5file: h5py.File
HDF5 file object
h5path: str
HDF5 group path to get the group names from
node_type: h5py object type
HDF5 object type
Returns
-------
names: list of str
... | boyle/hdf5.py | def _get_node_names(h5file, h5path='/', node_type=h5py.Dataset):
"""Return the node of type node_type names within h5path of h5file.
Parameters
----------
h5file: h5py.File
HDF5 file object
h5path: str
HDF5 group path to get the group names from
node_type: h5py object type
... | def _get_node_names(h5file, h5path='/', node_type=h5py.Dataset):
"""Return the node of type node_type names within h5path of h5file.
Parameters
----------
h5file: h5py.File
HDF5 file object
h5path: str
HDF5 group path to get the group names from
node_type: h5py object type
... | [
"Return",
"the",
"node",
"of",
"type",
"node_type",
"names",
"within",
"h5path",
"of",
"h5file",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/hdf5.py#L213-L252 | [
"def",
"_get_node_names",
"(",
"h5file",
",",
"h5path",
"=",
"'/'",
",",
"node_type",
"=",
"h5py",
".",
"Dataset",
")",
":",
"if",
"isinstance",
"(",
"h5file",
",",
"str",
")",
":",
"_h5file",
"=",
"get_h5file",
"(",
"h5file",
",",
"mode",
"=",
"'r'",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NeuroImageSet.mask | self.mask setter
Parameters
----------
image: str or img-like object.
See NeuroImage constructor docstring. | boyle/nifti/sets.py | def mask(self, image):
""" self.mask setter
Parameters
----------
image: str or img-like object.
See NeuroImage constructor docstring.
"""
if image is None:
self._mask = None
try:
mask = load_mask(image)
except Excepti... | def mask(self, image):
""" self.mask setter
Parameters
----------
image: str or img-like object.
See NeuroImage constructor docstring.
"""
if image is None:
self._mask = None
try:
mask = load_mask(image)
except Excepti... | [
"self",
".",
"mask",
"setter"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L72-L88 | [
"def",
"mask",
"(",
"self",
",",
"image",
")",
":",
"if",
"image",
"is",
"None",
":",
"self",
".",
"_mask",
"=",
"None",
"try",
":",
"mask",
"=",
"load_mask",
"(",
"image",
")",
"except",
"Exception",
"as",
"exc",
":",
"raise",
"Exception",
"(",
"'... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NeuroImageSet.check_compatibility | Parameters
----------
one_img: str or img-like object.
See NeuroImage constructor docstring.
anoter_img: str or img-like object.
See NeuroImage constructor docstring.
If None will use the first image of self.images, if there is any.
Raises
--... | boyle/nifti/sets.py | def check_compatibility(self, one_img, another_img=None):
"""
Parameters
----------
one_img: str or img-like object.
See NeuroImage constructor docstring.
anoter_img: str or img-like object.
See NeuroImage constructor docstring.
If None will u... | def check_compatibility(self, one_img, another_img=None):
"""
Parameters
----------
one_img: str or img-like object.
See NeuroImage constructor docstring.
anoter_img: str or img-like object.
See NeuroImage constructor docstring.
If None will u... | [
"Parameters",
"----------",
"one_img",
":",
"str",
"or",
"img",
"-",
"like",
"object",
".",
"See",
"NeuroImage",
"constructor",
"docstring",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L100-L132 | [
"def",
"check_compatibility",
"(",
"self",
",",
"one_img",
",",
"another_img",
"=",
"None",
")",
":",
"if",
"another_img",
"is",
"None",
":",
"if",
"len",
"(",
"self",
".",
"items",
")",
">",
"0",
":",
"another_img",
"=",
"self",
".",
"items",
"[",
"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NeuroImageSet.set_labels | Parameters
----------
labels: list of int or str
This list will be checked to have the same size as
Raises
------
ValueError
if len(labels) != self.n_subjs | boyle/nifti/sets.py | def set_labels(self, labels):
"""
Parameters
----------
labels: list of int or str
This list will be checked to have the same size as
Raises
------
ValueError
if len(labels) != self.n_subjs
"""
if not isinstance(labels, str... | def set_labels(self, labels):
"""
Parameters
----------
labels: list of int or str
This list will be checked to have the same size as
Raises
------
ValueError
if len(labels) != self.n_subjs
"""
if not isinstance(labels, str... | [
"Parameters",
"----------",
"labels",
":",
"list",
"of",
"int",
"or",
"str",
"This",
"list",
"will",
"be",
"checked",
"to",
"have",
"the",
"same",
"size",
"as"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L149-L165 | [
"def",
"set_labels",
"(",
"self",
",",
"labels",
")",
":",
"if",
"not",
"isinstance",
"(",
"labels",
",",
"string_types",
")",
"and",
"len",
"(",
"labels",
")",
"!=",
"self",
".",
"n_subjs",
":",
"raise",
"ValueError",
"(",
"'The number of given labels ({}) ... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NeuroImageSet._load_images_and_labels | Read the images, load them into self.items and set the labels. | boyle/nifti/sets.py | def _load_images_and_labels(self, images, labels=None):
"""Read the images, load them into self.items and set the labels."""
if not isinstance(images, (list, tuple)):
raise ValueError('Expected an iterable (list or tuple) of strings or img-like objects. '
'Got a ... | def _load_images_and_labels(self, images, labels=None):
"""Read the images, load them into self.items and set the labels."""
if not isinstance(images, (list, tuple)):
raise ValueError('Expected an iterable (list or tuple) of strings or img-like objects. '
'Got a ... | [
"Read",
"the",
"images",
"load",
"them",
"into",
"self",
".",
"items",
"and",
"set",
"the",
"labels",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L167-L197 | [
"def",
"_load_images_and_labels",
"(",
"self",
",",
"images",
",",
"labels",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"images",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"ValueError",
"(",
"'Expected an iterable (list or tuple) of s... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NeuroImageSet.to_matrix | Return numpy.ndarray with the masked or flatten image data and
the relevant information (mask indices and volume shape).
Parameters
----------
smooth__fwhm: int
Integer indicating the size of the FWHM Gaussian smoothing kernel
to smooth the subject volumes bef... | boyle/nifti/sets.py | def to_matrix(self, smooth_fwhm=0, outdtype=None):
"""Return numpy.ndarray with the masked or flatten image data and
the relevant information (mask indices and volume shape).
Parameters
----------
smooth__fwhm: int
Integer indicating the size of the FWHM Gaussian ... | def to_matrix(self, smooth_fwhm=0, outdtype=None):
"""Return numpy.ndarray with the masked or flatten image data and
the relevant information (mask indices and volume shape).
Parameters
----------
smooth__fwhm: int
Integer indicating the size of the FWHM Gaussian ... | [
"Return",
"numpy",
".",
"ndarray",
"with",
"the",
"masked",
"or",
"flatten",
"image",
"data",
"and",
"the",
"relevant",
"information",
"(",
"mask",
"indices",
"and",
"volume",
"shape",
")",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L199-L272 | [
"def",
"to_matrix",
"(",
"self",
",",
"smooth_fwhm",
"=",
"0",
",",
"outdtype",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"all_compatible",
":",
"raise",
"ValueError",
"(",
"\"`self.all_compatible` must be True in order to use this function.\"",
")",
"if",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NeuroImageSet.to_file | Save the Numpy array created from to_matrix function to the output_file.
Will save into the file: outmat, mask_indices, vol_shape and self.others (put here whatever you want)
data: Numpy array with shape N x prod(vol.shape)
containing the N files as flat vectors.
mas... | boyle/nifti/sets.py | def to_file(self, output_file, smooth_fwhm=0, outdtype=None):
"""Save the Numpy array created from to_matrix function to the output_file.
Will save into the file: outmat, mask_indices, vol_shape and self.others (put here whatever you want)
data: Numpy array with shape N x prod(vol.shape)
... | def to_file(self, output_file, smooth_fwhm=0, outdtype=None):
"""Save the Numpy array created from to_matrix function to the output_file.
Will save into the file: outmat, mask_indices, vol_shape and self.others (put here whatever you want)
data: Numpy array with shape N x prod(vol.shape)
... | [
"Save",
"the",
"Numpy",
"array",
"created",
"from",
"to_matrix",
"function",
"to",
"the",
"output_file",
"."
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L274-L317 | [
"def",
"to_file",
"(",
"self",
",",
"output_file",
",",
"smooth_fwhm",
"=",
"0",
",",
"outdtype",
"=",
"None",
")",
":",
"outmat",
",",
"mask_indices",
",",
"mask_shape",
"=",
"self",
".",
"to_matrix",
"(",
"smooth_fwhm",
",",
"outdtype",
")",
"exporter",
... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
valid | NiftiSubjectsSet._init_subj_data | Parameters
----------
subj_files: list or dict of str
file_path -> int/str | boyle/nifti/sets.py | def _init_subj_data(self, subj_files):
"""
Parameters
----------
subj_files: list or dict of str
file_path -> int/str
"""
try:
if isinstance(subj_files, list):
self.from_list(subj_files)
elif isinstance(subj_files, dict... | def _init_subj_data(self, subj_files):
"""
Parameters
----------
subj_files: list or dict of str
file_path -> int/str
"""
try:
if isinstance(subj_files, list):
self.from_list(subj_files)
elif isinstance(subj_files, dict... | [
"Parameters",
"----------",
"subj_files",
":",
"list",
"or",
"dict",
"of",
"str",
"file_path",
"-",
">",
"int",
"/",
"str"
] | Neurita/boyle | python | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L348-L364 | [
"def",
"_init_subj_data",
"(",
"self",
",",
"subj_files",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"subj_files",
",",
"list",
")",
":",
"self",
".",
"from_list",
"(",
"subj_files",
")",
"elif",
"isinstance",
"(",
"subj_files",
",",
"dict",
")",
":"... | 2dae7199849395a209c887d5f30506e1de8a9ad9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.