repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
brunato/lograptor | lograptor/cache.py | LookupCache.getuname | def getuname(self, uid):
"""
Get the username of a given uid.
"""
uid = int(uid)
try:
return self.uidsmap[uid]
except KeyError:
pass
try:
name = pwd.getpwuid(uid)[0]
except (KeyError, AttributeError):
name =... | python | def getuname(self, uid):
"""
Get the username of a given uid.
"""
uid = int(uid)
try:
return self.uidsmap[uid]
except KeyError:
pass
try:
name = pwd.getpwuid(uid)[0]
except (KeyError, AttributeError):
name =... | [
"def",
"getuname",
"(",
"self",
",",
"uid",
")",
":",
"uid",
"=",
"int",
"(",
"uid",
")",
"try",
":",
"return",
"self",
".",
"uidsmap",
"[",
"uid",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"name",
"=",
"pwd",
".",
"getpwuid",
"(",
"uid... | Get the username of a given uid. | [
"Get",
"the",
"username",
"of",
"a",
"given",
"uid",
"."
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/cache.py#L166-L182 | train | Get the username of a given uid. |
mardix/Mocha | mocha/core.py | register_models | def register_models(**kwargs):
"""
Alias to register model
:param kwargs:
:return:
"""
[setattr(models, k, v) for k, v in kwargs.items()] | python | def register_models(**kwargs):
"""
Alias to register model
:param kwargs:
:return:
"""
[setattr(models, k, v) for k, v in kwargs.items()] | [
"def",
"register_models",
"(",
"*",
"*",
"kwargs",
")",
":",
"[",
"setattr",
"(",
"models",
",",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"]"
] | Alias to register model
:param kwargs:
:return: | [
"Alias",
"to",
"register",
"model",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L101-L107 | train | Alias to register model
|
mardix/Mocha | mocha/core.py | get_env | def get_env():
"""
Return the Capitalize environment name
It can be used to retrieve class base config
Default: Development
:returns: str Capitalized
"""
if not __ENV__:
env = os.environ["env"] if "env" in os.environ else "Dev"
set_env(env)
return __ENV__ | python | def get_env():
"""
Return the Capitalize environment name
It can be used to retrieve class base config
Default: Development
:returns: str Capitalized
"""
if not __ENV__:
env = os.environ["env"] if "env" in os.environ else "Dev"
set_env(env)
return __ENV__ | [
"def",
"get_env",
"(",
")",
":",
"if",
"not",
"__ENV__",
":",
"env",
"=",
"os",
".",
"environ",
"[",
"\"env\"",
"]",
"if",
"\"env\"",
"in",
"os",
".",
"environ",
"else",
"\"Dev\"",
"set_env",
"(",
"env",
")",
"return",
"__ENV__"
] | Return the Capitalize environment name
It can be used to retrieve class base config
Default: Development
:returns: str Capitalized | [
"Return",
"the",
"Capitalize",
"environment",
"name",
"It",
"can",
"be",
"used",
"to",
"retrieve",
"class",
"base",
"config",
"Default",
":",
"Development",
":",
"returns",
":",
"str",
"Capitalized"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L120-L130 | train | Returns the Capitalize environment name |
mardix/Mocha | mocha/core.py | get_app_env | def get_app_env():
"""
if the app and the envi are passed in the command line as 'app=$app:$env'
:return: tuple app, env
"""
app, env = None, get_env()
if "app" in os.environ:
app = os.environ["app"].lower()
if ":" in app:
app, env = os.environ["app"].split(":", 2)
... | python | def get_app_env():
"""
if the app and the envi are passed in the command line as 'app=$app:$env'
:return: tuple app, env
"""
app, env = None, get_env()
if "app" in os.environ:
app = os.environ["app"].lower()
if ":" in app:
app, env = os.environ["app"].split(":", 2)
... | [
"def",
"get_app_env",
"(",
")",
":",
"app",
",",
"env",
"=",
"None",
",",
"get_env",
"(",
")",
"if",
"\"app\"",
"in",
"os",
".",
"environ",
":",
"app",
"=",
"os",
".",
"environ",
"[",
"\"app\"",
"]",
".",
"lower",
"(",
")",
"if",
"\":\"",
"in",
... | if the app and the envi are passed in the command line as 'app=$app:$env'
:return: tuple app, env | [
"if",
"the",
"app",
"and",
"the",
"envi",
"are",
"passed",
"in",
"the",
"command",
"line",
"as",
"app",
"=",
"$app",
":",
"$env",
":",
"return",
":",
"tuple",
"app",
"env"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L133-L144 | train | Get the app and env from command line. |
mardix/Mocha | mocha/core.py | init_app | def init_app(kls):
"""
To bind middlewares, plugins that needs the 'app' object to init
Bound middlewares will be assigned on cls.init()
"""
if not hasattr(kls, "__call__"):
raise exceptions.MochaError("init_app: '%s' is not callable" % kls)
Mocha._init_apps.add(kls)
return kls | python | def init_app(kls):
"""
To bind middlewares, plugins that needs the 'app' object to init
Bound middlewares will be assigned on cls.init()
"""
if not hasattr(kls, "__call__"):
raise exceptions.MochaError("init_app: '%s' is not callable" % kls)
Mocha._init_apps.add(kls)
return kls | [
"def",
"init_app",
"(",
"kls",
")",
":",
"if",
"not",
"hasattr",
"(",
"kls",
",",
"\"__call__\"",
")",
":",
"raise",
"exceptions",
".",
"MochaError",
"(",
"\"init_app: '%s' is not callable\"",
"%",
"kls",
")",
"Mocha",
".",
"_init_apps",
".",
"add",
"(",
"... | To bind middlewares, plugins that needs the 'app' object to init
Bound middlewares will be assigned on cls.init() | [
"To",
"bind",
"middlewares",
"plugins",
"that",
"needs",
"the",
"app",
"object",
"to",
"init",
"Bound",
"middlewares",
"will",
"be",
"assigned",
"on",
"cls",
".",
"init",
"()"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L155-L163 | train | Initialize a new app object |
mardix/Mocha | mocha/core.py | register_package | def register_package(pkg, prefix=None):
"""
Allow to register an app packages by loading and exposing: templates, static,
and exceptions for abort()
Structure of package
root
| $package_name
| __init__.py
|
| /templates
... | python | def register_package(pkg, prefix=None):
"""
Allow to register an app packages by loading and exposing: templates, static,
and exceptions for abort()
Structure of package
root
| $package_name
| __init__.py
|
| /templates
... | [
"def",
"register_package",
"(",
"pkg",
",",
"prefix",
"=",
"None",
")",
":",
"root_pkg_dir",
"=",
"pkg",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"pkg",
")",
"and",
"\".\"",
"in",
"pkg",
":",
"root_pkg_dir",
"=",
"pkg_resources",
".",
"resour... | Allow to register an app packages by loading and exposing: templates, static,
and exceptions for abort()
Structure of package
root
| $package_name
| __init__.py
|
| /templates
|
|
|
... | [
"Allow",
"to",
"register",
"an",
"app",
"packages",
"by",
"loading",
"and",
"exposing",
":",
"templates",
"static",
"and",
"exceptions",
"for",
"abort",
"()"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L166-L211 | train | Register a package with the Mocha. |
mardix/Mocha | mocha/core.py | config | def config(key, default=None):
"""
Shortcut to access the application's config in your class
:param key: The key to access
:param default: The default value when None
:returns mixed:
"""
return Mocha._app.config.get(key, default) if Mocha._app else default | python | def config(key, default=None):
"""
Shortcut to access the application's config in your class
:param key: The key to access
:param default: The default value when None
:returns mixed:
"""
return Mocha._app.config.get(key, default) if Mocha._app else default | [
"def",
"config",
"(",
"key",
",",
"default",
"=",
"None",
")",
":",
"return",
"Mocha",
".",
"_app",
".",
"config",
".",
"get",
"(",
"key",
",",
"default",
")",
"if",
"Mocha",
".",
"_app",
"else",
"default"
] | Shortcut to access the application's config in your class
:param key: The key to access
:param default: The default value when None
:returns mixed: | [
"Shortcut",
"to",
"access",
"the",
"application",
"s",
"config",
"in",
"your",
"class",
":",
"param",
"key",
":",
"The",
"key",
"to",
"access",
":",
"param",
"default",
":",
"The",
"default",
"value",
"when",
"None",
":",
"returns",
"mixed",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L214-L221 | train | Shortcut to access the application s config in your class
|
mardix/Mocha | mocha/core.py | page_attr | def page_attr(title=None, **kwargs):
"""
Page Attr allows you to add page meta data in the request `g` context
:params **kwargs:
meta keys we're expecting:
title (str)
description (str)
url (str) (Will pick it up by itself if not set)
image (str)
site_name (str) ... | python | def page_attr(title=None, **kwargs):
"""
Page Attr allows you to add page meta data in the request `g` context
:params **kwargs:
meta keys we're expecting:
title (str)
description (str)
url (str) (Will pick it up by itself if not set)
image (str)
site_name (str) ... | [
"def",
"page_attr",
"(",
"title",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"default",
"=",
"dict",
"(",
"title",
"=",
"\"\"",
",",
"description",
"=",
"\"\"",
",",
"url",
"=",
"\"\"",
",",
"image",
"=",
"\"\"",
",",
"site_name",
"=",
"\"\"",... | Page Attr allows you to add page meta data in the request `g` context
:params **kwargs:
meta keys we're expecting:
title (str)
description (str)
url (str) (Will pick it up by itself if not set)
image (str)
site_name (str) (but can pick it up from config file)
obj... | [
"Page",
"Attr",
"allows",
"you",
"to",
"add",
"page",
"meta",
"data",
"in",
"the",
"request",
"g",
"context",
":",
"params",
"**",
"kwargs",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L224-L264 | train | Page Attr allows you to add meta data in the request g. |
mardix/Mocha | mocha/core.py | local_datetime | def local_datetime(utcdatetime, format=None, timezone=None):
"""
Return local datetime based on the timezone
It will automatically format the date.
To not format the date, set format=False
:param utcdatetime: Arrow or string
:param format: string of format or False
:param timezone: str... | python | def local_datetime(utcdatetime, format=None, timezone=None):
"""
Return local datetime based on the timezone
It will automatically format the date.
To not format the date, set format=False
:param utcdatetime: Arrow or string
:param format: string of format or False
:param timezone: str... | [
"def",
"local_datetime",
"(",
"utcdatetime",
",",
"format",
"=",
"None",
",",
"timezone",
"=",
"None",
")",
":",
"if",
"utcdatetime",
"is",
"None",
":",
"return",
"None",
"timezone",
"=",
"timezone",
"or",
"config",
"(",
"\"DATETIME_TIMEZONE\"",
",",
"\"US/E... | Return local datetime based on the timezone
It will automatically format the date.
To not format the date, set format=False
:param utcdatetime: Arrow or string
:param format: string of format or False
:param timezone: string, ie: US/Eastern
:return: | [
"Return",
"local",
"datetime",
"based",
"on",
"the",
"timezone",
"It",
"will",
"automatically",
"format",
"the",
"date",
".",
"To",
"not",
"format",
"the",
"date",
"set",
"format",
"=",
"False",
":",
"param",
"utcdatetime",
":",
"Arrow",
"or",
"string",
":... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L319-L342 | train | Returns a datetime object based on the timezone. |
mardix/Mocha | mocha/core.py | url_for | def url_for(endpoint, **kw):
"""
Mocha url_for is an alias to the flask url_for, with the ability of
passing the function signature to build the url, without knowing the endpoint
:param endpoint:
:param kw:
:return:
"""
_endpoint = None
if isinstance(endpoint, six.string_types):
... | python | def url_for(endpoint, **kw):
"""
Mocha url_for is an alias to the flask url_for, with the ability of
passing the function signature to build the url, without knowing the endpoint
:param endpoint:
:param kw:
:return:
"""
_endpoint = None
if isinstance(endpoint, six.string_types):
... | [
"def",
"url_for",
"(",
"endpoint",
",",
"*",
"*",
"kw",
")",
":",
"_endpoint",
"=",
"None",
"if",
"isinstance",
"(",
"endpoint",
",",
"six",
".",
"string_types",
")",
":",
"return",
"f_url_for",
"(",
"endpoint",
",",
"*",
"*",
"kw",
")",
"else",
":",... | Mocha url_for is an alias to the flask url_for, with the ability of
passing the function signature to build the url, without knowing the endpoint
:param endpoint:
:param kw:
:return: | [
"Mocha",
"url_for",
"is",
"an",
"alias",
"to",
"the",
"flask",
"url_for",
"with",
"the",
"ability",
"of",
"passing",
"the",
"function",
"signature",
"to",
"build",
"the",
"url",
"without",
"knowing",
"the",
"endpoint",
":",
"param",
"endpoint",
":",
":",
"... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L367-L392 | train | Mocha url_for is an alias to the flask url_for function. |
mardix/Mocha | mocha/core.py | redirect | def redirect(endpoint, **kw):
"""
Redirect allow to redirect dynamically using the classes methods without
knowing the right endpoint.
Expecting all endpoint have GET as method, it will try to pick the first
match, based on the endpoint provided or the based on the Rule map_url
An endpoint can ... | python | def redirect(endpoint, **kw):
"""
Redirect allow to redirect dynamically using the classes methods without
knowing the right endpoint.
Expecting all endpoint have GET as method, it will try to pick the first
match, based on the endpoint provided or the based on the Rule map_url
An endpoint can ... | [
"def",
"redirect",
"(",
"endpoint",
",",
"*",
"*",
"kw",
")",
":",
"_endpoint",
"=",
"None",
"if",
"isinstance",
"(",
"endpoint",
",",
"six",
".",
"string_types",
")",
":",
"_endpoint",
"=",
"endpoint",
"# valid for https:// or /path/",
"# Endpoint should not ha... | Redirect allow to redirect dynamically using the classes methods without
knowing the right endpoint.
Expecting all endpoint have GET as method, it will try to pick the first
match, based on the endpoint provided or the based on the Rule map_url
An endpoint can also be passed along with **kw
An htt... | [
"Redirect",
"allow",
"to",
"redirect",
"dynamically",
"using",
"the",
"classes",
"methods",
"without",
"knowing",
"the",
"right",
"endpoint",
".",
"Expecting",
"all",
"endpoint",
"have",
"GET",
"as",
"method",
"it",
"will",
"try",
"to",
"pick",
"the",
"first",... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L395-L442 | train | Redirect to the right endpoint. |
mardix/Mocha | mocha/core.py | _get_action_endpoint | def _get_action_endpoint(action):
"""
Return the endpoint base on the view's action
:param action:
:return:
"""
_endpoint = None
if is_method(action):
if hasattr(action, "_rule_cache"):
rc = action._rule_cache
if rc:
k = list(rc.keys())[0]
... | python | def _get_action_endpoint(action):
"""
Return the endpoint base on the view's action
:param action:
:return:
"""
_endpoint = None
if is_method(action):
if hasattr(action, "_rule_cache"):
rc = action._rule_cache
if rc:
k = list(rc.keys())[0]
... | [
"def",
"_get_action_endpoint",
"(",
"action",
")",
":",
"_endpoint",
"=",
"None",
"if",
"is_method",
"(",
"action",
")",
":",
"if",
"hasattr",
"(",
"action",
",",
"\"_rule_cache\"",
")",
":",
"rc",
"=",
"action",
".",
"_rule_cache",
"if",
"rc",
":",
"k",... | Return the endpoint base on the view's action
:param action:
:return: | [
"Return",
"the",
"endpoint",
"base",
"on",
"the",
"view",
"s",
"action",
":",
"param",
"action",
":",
":",
"return",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L445-L471 | train | Return the endpoint base on the view s action
|
mardix/Mocha | mocha/core.py | build_endpoint_route_name | def build_endpoint_route_name(cls, method_name, class_name=None):
"""
Build the route endpoint
It is recommended to place your views in /views directory, so it can build
the endpoint from it. If not, it will make the endpoint from the module name
The main reason for having the views directory, it is... | python | def build_endpoint_route_name(cls, method_name, class_name=None):
"""
Build the route endpoint
It is recommended to place your views in /views directory, so it can build
the endpoint from it. If not, it will make the endpoint from the module name
The main reason for having the views directory, it is... | [
"def",
"build_endpoint_route_name",
"(",
"cls",
",",
"method_name",
",",
"class_name",
"=",
"None",
")",
":",
"module",
"=",
"cls",
".",
"__module__",
".",
"split",
"(",
"\"views.\"",
")",
"[",
"1",
"]",
"if",
"\".views.\"",
"in",
"cls",
".",
"__module__",... | Build the route endpoint
It is recommended to place your views in /views directory, so it can build
the endpoint from it. If not, it will make the endpoint from the module name
The main reason for having the views directory, it is explicitly easy
to see the path of the view
:param cls: The view cla... | [
"Build",
"the",
"route",
"endpoint",
"It",
"is",
"recommended",
"to",
"place",
"your",
"views",
"in",
"/",
"views",
"directory",
"so",
"it",
"can",
"build",
"the",
"endpoint",
"from",
"it",
".",
"If",
"not",
"it",
"will",
"make",
"the",
"endpoint",
"from... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1168-L1184 | train | Build the route name for the view |
mardix/Mocha | mocha/core.py | apply_function_to_members | def apply_function_to_members(cls, fn):
"""
Apply a function to all the members of a class.
Used for decorators that is applied in a class and want all the members
to use it
:param cls: class
:param fn: function
:return:
"""
for name, method in get_interesting_members(Mocha, cls):
... | python | def apply_function_to_members(cls, fn):
"""
Apply a function to all the members of a class.
Used for decorators that is applied in a class and want all the members
to use it
:param cls: class
:param fn: function
:return:
"""
for name, method in get_interesting_members(Mocha, cls):
... | [
"def",
"apply_function_to_members",
"(",
"cls",
",",
"fn",
")",
":",
"for",
"name",
",",
"method",
"in",
"get_interesting_members",
"(",
"Mocha",
",",
"cls",
")",
":",
"setattr",
"(",
"cls",
",",
"name",
",",
"fn",
"(",
"method",
")",
")"
] | Apply a function to all the members of a class.
Used for decorators that is applied in a class and want all the members
to use it
:param cls: class
:param fn: function
:return: | [
"Apply",
"a",
"function",
"to",
"all",
"the",
"members",
"of",
"a",
"class",
".",
"Used",
"for",
"decorators",
"that",
"is",
"applied",
"in",
"a",
"class",
"and",
"want",
"all",
"the",
"members",
"to",
"use",
"it",
":",
"param",
"cls",
":",
"class",
... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1202-L1212 | train | Applies a function to all the members of a class. |
mardix/Mocha | mocha/core.py | get_true_argspec | def get_true_argspec(method):
"""Drills through layers of decorators attempting to locate the actual argspec for the method."""
argspec = inspect.getargspec(method)
args = argspec[0]
if args and args[0] == 'self':
return argspec
if hasattr(method, '__func__'):
method = method.__func... | python | def get_true_argspec(method):
"""Drills through layers of decorators attempting to locate the actual argspec for the method."""
argspec = inspect.getargspec(method)
args = argspec[0]
if args and args[0] == 'self':
return argspec
if hasattr(method, '__func__'):
method = method.__func... | [
"def",
"get_true_argspec",
"(",
"method",
")",
":",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"method",
")",
"args",
"=",
"argspec",
"[",
"0",
"]",
"if",
"args",
"and",
"args",
"[",
"0",
"]",
"==",
"'self'",
":",
"return",
"argspec",
"if",
"... | Drills through layers of decorators attempting to locate the actual argspec for the method. | [
"Drills",
"through",
"layers",
"of",
"decorators",
"attempting",
"to",
"locate",
"the",
"actual",
"argspec",
"for",
"the",
"method",
"."
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1215-L1237 | train | Drills through layers of decorators attempting to locate the actual argspec for the method. |
mardix/Mocha | mocha/core.py | set_view_attr | def set_view_attr(view, key, value, cls_name=None):
"""
Set the view attributes
:param view: object (class or instance method)
:param key: string - the key
:param value: mixed - the value
:param cls_name: str - To pass the class name associated to the view
in the case of decorators t... | python | def set_view_attr(view, key, value, cls_name=None):
"""
Set the view attributes
:param view: object (class or instance method)
:param key: string - the key
:param value: mixed - the value
:param cls_name: str - To pass the class name associated to the view
in the case of decorators t... | [
"def",
"set_view_attr",
"(",
"view",
",",
"key",
",",
"value",
",",
"cls_name",
"=",
"None",
")",
":",
"ns",
"=",
"view_namespace",
"(",
"view",
",",
"cls_name",
")",
"if",
"ns",
":",
"if",
"ns",
"not",
"in",
"_views_attr",
":",
"_views_attr",
"[",
"... | Set the view attributes
:param view: object (class or instance method)
:param key: string - the key
:param value: mixed - the value
:param cls_name: str - To pass the class name associated to the view
in the case of decorators that may not give the real class name
:return: | [
"Set",
"the",
"view",
"attributes",
":",
"param",
"view",
":",
"object",
"(",
"class",
"or",
"instance",
"method",
")",
":",
"param",
"key",
":",
"string",
"-",
"the",
"key",
":",
"param",
"value",
":",
"mixed",
"-",
"the",
"value",
":",
"param",
"cl... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1260-L1274 | train | Set the view attributes for the navigable object. |
mardix/Mocha | mocha/core.py | get_view_attr | def get_view_attr(view, key, default=None, cls_name=None):
"""
Get the attributes that was saved for the view
:param view: object (class or instance method)
:param key: string - the key
:param default: mixed - the default value
:param cls_name: str - To pass the class name associated to the view... | python | def get_view_attr(view, key, default=None, cls_name=None):
"""
Get the attributes that was saved for the view
:param view: object (class or instance method)
:param key: string - the key
:param default: mixed - the default value
:param cls_name: str - To pass the class name associated to the view... | [
"def",
"get_view_attr",
"(",
"view",
",",
"key",
",",
"default",
"=",
"None",
",",
"cls_name",
"=",
"None",
")",
":",
"ns",
"=",
"view_namespace",
"(",
"view",
",",
"cls_name",
")",
"if",
"ns",
":",
"if",
"ns",
"not",
"in",
"_views_attr",
":",
"retur... | Get the attributes that was saved for the view
:param view: object (class or instance method)
:param key: string - the key
:param default: mixed - the default value
:param cls_name: str - To pass the class name associated to the view
in the case of decorators that may not give the real class... | [
"Get",
"the",
"attributes",
"that",
"was",
"saved",
"for",
"the",
"view",
":",
"param",
"view",
":",
"object",
"(",
"class",
"or",
"instance",
"method",
")",
":",
"param",
"key",
":",
"string",
"-",
"the",
"key",
":",
"param",
"default",
":",
"mixed",
... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1277-L1292 | train | Get the attributes that were saved for the view. |
mardix/Mocha | mocha/core.py | view_namespace | def view_namespace(view, cls_name=None):
"""
Create the namespace from the view
:param view: object (class or instance method)
:param cls_name: str - To pass the class name associated to the view
in the case of decorators that may not give the real class name
:return: string or None
... | python | def view_namespace(view, cls_name=None):
"""
Create the namespace from the view
:param view: object (class or instance method)
:param cls_name: str - To pass the class name associated to the view
in the case of decorators that may not give the real class name
:return: string or None
... | [
"def",
"view_namespace",
"(",
"view",
",",
"cls_name",
"=",
"None",
")",
":",
"ns",
"=",
"view",
".",
"__module__",
"if",
"inspect",
".",
"isclass",
"(",
"view",
")",
":",
"ns",
"+=",
"\".%s\"",
"%",
"view",
".",
"__name__",
"else",
":",
"if",
"hasat... | Create the namespace from the view
:param view: object (class or instance method)
:param cls_name: str - To pass the class name associated to the view
in the case of decorators that may not give the real class name
:return: string or None | [
"Create",
"the",
"namespace",
"from",
"the",
"view",
":",
"param",
"view",
":",
"object",
"(",
"class",
"or",
"instance",
"method",
")",
":",
"param",
"cls_name",
":",
"str",
"-",
"To",
"pass",
"the",
"class",
"name",
"associated",
"to",
"the",
"view",
... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1295-L1315 | train | Create the namespace from the view object |
mardix/Mocha | mocha/core.py | _RequestProxy.route | def route(cls, rule=None, **kwargs):
"""
This decorator defines custom route for both class and methods in the view.
It behaves the same way as Flask's @app.route
on class:
It takes the following args
- rule: the root route of the endpoint
- d... | python | def route(cls, rule=None, **kwargs):
"""
This decorator defines custom route for both class and methods in the view.
It behaves the same way as Flask's @app.route
on class:
It takes the following args
- rule: the root route of the endpoint
- d... | [
"def",
"route",
"(",
"cls",
",",
"rule",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"_restricted_keys",
"=",
"[",
"\"route\"",
",",
"\"decorators\"",
"]",
"def",
"decorator",
"(",
"f",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"f",
")",
... | This decorator defines custom route for both class and methods in the view.
It behaves the same way as Flask's @app.route
on class:
It takes the following args
- rule: the root route of the endpoint
- decorators: a list of decorators to run on each method
... | [
"This",
"decorator",
"defines",
"custom",
"route",
"for",
"both",
"class",
"and",
"methods",
"in",
"the",
"view",
".",
"It",
"behaves",
"the",
"same",
"way",
"as",
"Flask",
"s",
"@app",
".",
"route"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L552-L593 | train | This decorator defines a custom route for both class and methods in the view. It is used to route for both class and methods in the view. |
mardix/Mocha | mocha/core.py | _RequestProxy.get_auth_token | def get_auth_token(cls):
"""
Return the authorization token
:return: string
"""
if 'Authorization' not in f_request.headers:
raise ValueError("Missing Authorization Bearer in headers")
data = f_request.headers['Authorization'].encode('ascii', 'ignore')
... | python | def get_auth_token(cls):
"""
Return the authorization token
:return: string
"""
if 'Authorization' not in f_request.headers:
raise ValueError("Missing Authorization Bearer in headers")
data = f_request.headers['Authorization'].encode('ascii', 'ignore')
... | [
"def",
"get_auth_token",
"(",
"cls",
")",
":",
"if",
"'Authorization'",
"not",
"in",
"f_request",
".",
"headers",
":",
"raise",
"ValueError",
"(",
"\"Missing Authorization Bearer in headers\"",
")",
"data",
"=",
"f_request",
".",
"headers",
"[",
"'Authorization'",
... | Return the authorization token
:return: string | [
"Return",
"the",
"authorization",
"token",
":",
"return",
":",
"string"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L600-L608 | train | Return the authorization token from the request headers. |
mardix/Mocha | mocha/core.py | Mocha.setup_installed_apps | def setup_installed_apps(cls):
"""
To import 3rd party applications along with associated properties
It is a list of dict or string.
When a dict, it contains the `app` key and the configuration,
if it's a string, it is just the app name
If you require dependencies from... | python | def setup_installed_apps(cls):
"""
To import 3rd party applications along with associated properties
It is a list of dict or string.
When a dict, it contains the `app` key and the configuration,
if it's a string, it is just the app name
If you require dependencies from... | [
"def",
"setup_installed_apps",
"(",
"cls",
")",
":",
"cls",
".",
"_installed_apps",
"=",
"cls",
".",
"_app",
".",
"config",
".",
"get",
"(",
"\"INSTALLED_APPS\"",
",",
"[",
"]",
")",
"if",
"cls",
".",
"_installed_apps",
":",
"def",
"import_app",
"(",
"mo... | To import 3rd party applications along with associated properties
It is a list of dict or string.
When a dict, it contains the `app` key and the configuration,
if it's a string, it is just the app name
If you require dependencies from other packages, dependencies
must be place... | [
"To",
"import",
"3rd",
"party",
"applications",
"along",
"with",
"associated",
"properties"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L746-L787 | train | This method sets up the installed 3rd party applications along with associated properties. |
mardix/Mocha | mocha/core.py | Mocha.render | def render(cls, data={}, _template=None, _layout=None, **kwargs):
"""
Render the view template based on the class and the method being invoked
:param data: The context data to pass to the template
:param _template: The file template to use. By default it will map the module/classname/act... | python | def render(cls, data={}, _template=None, _layout=None, **kwargs):
"""
Render the view template based on the class and the method being invoked
:param data: The context data to pass to the template
:param _template: The file template to use. By default it will map the module/classname/act... | [
"def",
"render",
"(",
"cls",
",",
"data",
"=",
"{",
"}",
",",
"_template",
"=",
"None",
",",
"_layout",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Invoke the page meta so it can always be set",
"page_attr",
"(",
")",
"# Add some global Mocha data in g, a... | Render the view template based on the class and the method being invoked
:param data: The context data to pass to the template
:param _template: The file template to use. By default it will map the module/classname/action.html
:param _layout: The body layout, must contain {% include __template__... | [
"Render",
"the",
"view",
"template",
"based",
"on",
"the",
"class",
"and",
"the",
"method",
"being",
"invoked",
":",
"param",
"data",
":",
"The",
"context",
"data",
"to",
"pass",
"to",
"the",
"template",
":",
"param",
"_template",
":",
"The",
"file",
"te... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L790-L822 | train | Render the view template based on the class and method being invoked. |
mardix/Mocha | mocha/core.py | Mocha._add_asset_bundle | def _add_asset_bundle(cls, path):
"""
Add a webassets bundle yml file
"""
f = "%s/assets.yml" % path
if os.path.isfile(f):
cls._asset_bundles.add(f) | python | def _add_asset_bundle(cls, path):
"""
Add a webassets bundle yml file
"""
f = "%s/assets.yml" % path
if os.path.isfile(f):
cls._asset_bundles.add(f) | [
"def",
"_add_asset_bundle",
"(",
"cls",
",",
"path",
")",
":",
"f",
"=",
"\"%s/assets.yml\"",
"%",
"path",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"f",
")",
":",
"cls",
".",
"_asset_bundles",
".",
"add",
"(",
"f",
")"
] | Add a webassets bundle yml file | [
"Add",
"a",
"webassets",
"bundle",
"yml",
"file"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L825-L831 | train | Add a webassets bundle yml file |
mardix/Mocha | mocha/core.py | Mocha._setup_db | def _setup_db(cls):
"""
Setup the DB connection if DB_URL is set
"""
uri = cls._app.config.get("DB_URL")
if uri:
db.connect__(uri, cls._app) | python | def _setup_db(cls):
"""
Setup the DB connection if DB_URL is set
"""
uri = cls._app.config.get("DB_URL")
if uri:
db.connect__(uri, cls._app) | [
"def",
"_setup_db",
"(",
"cls",
")",
":",
"uri",
"=",
"cls",
".",
"_app",
".",
"config",
".",
"get",
"(",
"\"DB_URL\"",
")",
"if",
"uri",
":",
"db",
".",
"connect__",
"(",
"uri",
",",
"cls",
".",
"_app",
")"
] | Setup the DB connection if DB_URL is set | [
"Setup",
"the",
"DB",
"connection",
"if",
"DB_URL",
"is",
"set"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L858-L864 | train | Setup the DB connection if DB_URL is set
|
mardix/Mocha | mocha/core.py | Mocha._expose_models | def _expose_models(cls):
"""
Register the models and assign them to `models`
:return:
"""
if db._IS_OK_:
register_models(**{m.__name__: m
for m in db.Model.__subclasses__()
if not hasattr(models, m.__name_... | python | def _expose_models(cls):
"""
Register the models and assign them to `models`
:return:
"""
if db._IS_OK_:
register_models(**{m.__name__: m
for m in db.Model.__subclasses__()
if not hasattr(models, m.__name_... | [
"def",
"_expose_models",
"(",
"cls",
")",
":",
"if",
"db",
".",
"_IS_OK_",
":",
"register_models",
"(",
"*",
"*",
"{",
"m",
".",
"__name__",
":",
"m",
"for",
"m",
"in",
"db",
".",
"Model",
".",
"__subclasses__",
"(",
")",
"if",
"not",
"hasattr",
"(... | Register the models and assign them to `models`
:return: | [
"Register",
"the",
"models",
"and",
"assign",
"them",
"to",
"models",
":",
"return",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L867-L875 | train | Register the models and assign them to models |
mardix/Mocha | mocha/core.py | Mocha._register | def _register(cls,
app,
base_route=None,
subdomain=None,
route_prefix=None,
trailing_slash=True):
"""Registers a Mocha class for use with a specific instance of a
Flask app. Any methods not prefixes with an undersc... | python | def _register(cls,
app,
base_route=None,
subdomain=None,
route_prefix=None,
trailing_slash=True):
"""Registers a Mocha class for use with a specific instance of a
Flask app. Any methods not prefixes with an undersc... | [
"def",
"_register",
"(",
"cls",
",",
"app",
",",
"base_route",
"=",
"None",
",",
"subdomain",
"=",
"None",
",",
"route_prefix",
"=",
"None",
",",
"trailing_slash",
"=",
"True",
")",
":",
"if",
"cls",
"is",
"Mocha",
":",
"raise",
"TypeError",
"(",
"\"cl... | Registers a Mocha class for use with a specific instance of a
Flask app. Any methods not prefixes with an underscore are candidates
to be routed and will have routes registered when this method is
called.
:param app: an instance of a Flask application
:param base_route: The bas... | [
"Registers",
"a",
"Mocha",
"class",
"for",
"use",
"with",
"a",
"specific",
"instance",
"of",
"a",
"Flask",
"app",
".",
"Any",
"methods",
"not",
"prefixes",
"with",
"an",
"underscore",
"are",
"candidates",
"to",
"be",
"routed",
"and",
"will",
"have",
"route... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L878-L999 | train | Registers a Mocha class for use with a specific instance of app. |
mardix/Mocha | mocha/core.py | Mocha.parse_options | def parse_options(cls, options):
"""Extracts subdomain and endpoint values from the options dict and returns
them along with a new dict without those values.
"""
options = options.copy()
subdomain = options.pop('subdomain', None)
endpoint = options.pop('endpoint', None... | python | def parse_options(cls, options):
"""Extracts subdomain and endpoint values from the options dict and returns
them along with a new dict without those values.
"""
options = options.copy()
subdomain = options.pop('subdomain', None)
endpoint = options.pop('endpoint', None... | [
"def",
"parse_options",
"(",
"cls",
",",
"options",
")",
":",
"options",
"=",
"options",
".",
"copy",
"(",
")",
"subdomain",
"=",
"options",
".",
"pop",
"(",
"'subdomain'",
",",
"None",
")",
"endpoint",
"=",
"options",
".",
"pop",
"(",
"'endpoint'",
",... | Extracts subdomain and endpoint values from the options dict and returns
them along with a new dict without those values. | [
"Extracts",
"subdomain",
"and",
"endpoint",
"values",
"from",
"the",
"options",
"dict",
"and",
"returns",
"them",
"along",
"with",
"a",
"new",
"dict",
"without",
"those",
"values",
"."
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1002-L1009 | train | Extracts subdomain endpoint and options from the options dict and returns
them along with a new dict without those values. |
mardix/Mocha | mocha/core.py | Mocha.make_proxy_method | def make_proxy_method(cls, name):
"""Creates a proxy function that can be used by Flasks routing. The
proxy instantiates the Mocha subclass and calls the appropriate
method.
:param name: the name of the method to create a proxy for
"""
i = cls()
view = getattr(i,... | python | def make_proxy_method(cls, name):
"""Creates a proxy function that can be used by Flasks routing. The
proxy instantiates the Mocha subclass and calls the appropriate
method.
:param name: the name of the method to create a proxy for
"""
i = cls()
view = getattr(i,... | [
"def",
"make_proxy_method",
"(",
"cls",
",",
"name",
")",
":",
"i",
"=",
"cls",
"(",
")",
"view",
"=",
"getattr",
"(",
"i",
",",
"name",
")",
"for",
"decorator",
"in",
"cls",
".",
"decorators",
":",
"view",
"=",
"decorator",
"(",
"view",
")",
"@",
... | Creates a proxy function that can be used by Flasks routing. The
proxy instantiates the Mocha subclass and calls the appropriate
method.
:param name: the name of the method to create a proxy for | [
"Creates",
"a",
"proxy",
"function",
"that",
"can",
"be",
"used",
"by",
"Flasks",
"routing",
".",
"The",
"proxy",
"instantiates",
"the",
"Mocha",
"subclass",
"and",
"calls",
"the",
"appropriate",
"method",
".",
":",
"param",
"name",
":",
"the",
"name",
"of... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1012-L1080 | train | Creates a proxy method that can be used by Flasks routing. The proxy method is called by the controller s methods. |
mardix/Mocha | mocha/core.py | Mocha.build_rule | def build_rule(cls, rule, method=None):
"""Creates a routing rule based on either the class name (minus the
'View' suffix) or the defined `base_route` attribute of the class
:param rule: the path portion that should be appended to the
route base
:param method: if a... | python | def build_rule(cls, rule, method=None):
"""Creates a routing rule based on either the class name (minus the
'View' suffix) or the defined `base_route` attribute of the class
:param rule: the path portion that should be appended to the
route base
:param method: if a... | [
"def",
"build_rule",
"(",
"cls",
",",
"rule",
",",
"method",
"=",
"None",
")",
":",
"rule_parts",
"=",
"[",
"]",
"if",
"cls",
".",
"route_prefix",
":",
"rule_parts",
".",
"append",
"(",
"cls",
".",
"route_prefix",
")",
"base_route",
"=",
"cls",
".",
... | Creates a routing rule based on either the class name (minus the
'View' suffix) or the defined `base_route` attribute of the class
:param rule: the path portion that should be appended to the
route base
:param method: if a method's arguments should be considered when
... | [
"Creates",
"a",
"routing",
"rule",
"based",
"on",
"either",
"the",
"class",
"name",
"(",
"minus",
"the",
"View",
"suffix",
")",
"or",
"the",
"defined",
"base_route",
"attribute",
"of",
"the",
"class"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1083-L1116 | train | Builds a routing rule based on the class name and the base_route attribute of the class. |
mardix/Mocha | mocha/core.py | Mocha.get_base_route | def get_base_route(cls):
"""Returns the route base to use for the current class."""
base_route = cls.__name__.lower()
if cls.base_route is not None:
base_route = cls.base_route
base_rule = parse_rule(base_route)
cls.base_args = [r[2] for r in base_rule]
... | python | def get_base_route(cls):
"""Returns the route base to use for the current class."""
base_route = cls.__name__.lower()
if cls.base_route is not None:
base_route = cls.base_route
base_rule = parse_rule(base_route)
cls.base_args = [r[2] for r in base_rule]
... | [
"def",
"get_base_route",
"(",
"cls",
")",
":",
"base_route",
"=",
"cls",
".",
"__name__",
".",
"lower",
"(",
")",
"if",
"cls",
".",
"base_route",
"is",
"not",
"None",
":",
"base_route",
"=",
"cls",
".",
"base_route",
"base_rule",
"=",
"parse_rule",
"(",
... | Returns the route base to use for the current class. | [
"Returns",
"the",
"route",
"base",
"to",
"use",
"for",
"the",
"current",
"class",
"."
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L1119-L1126 | train | Returns the base route to use for the current class. |
clement-alexandre/TotemBionet | totembionet/src/discrete_model/influence_graph.py | InfluenceGraph.find_gene_by_name | def find_gene_by_name(self, gene_name: str) -> Gene:
"""
Find and return a gene in the influence graph with the given name.
Raise an AttributeError if there is no gene in the graph with the given name.
"""
for gene in self.genes:
if gene.name == gene_name:
... | python | def find_gene_by_name(self, gene_name: str) -> Gene:
"""
Find and return a gene in the influence graph with the given name.
Raise an AttributeError if there is no gene in the graph with the given name.
"""
for gene in self.genes:
if gene.name == gene_name:
... | [
"def",
"find_gene_by_name",
"(",
"self",
",",
"gene_name",
":",
"str",
")",
"->",
"Gene",
":",
"for",
"gene",
"in",
"self",
".",
"genes",
":",
"if",
"gene",
".",
"name",
"==",
"gene_name",
":",
"return",
"gene",
"raise",
"AttributeError",
"(",
"f'gene \"... | Find and return a gene in the influence graph with the given name.
Raise an AttributeError if there is no gene in the graph with the given name. | [
"Find",
"and",
"return",
"a",
"gene",
"in",
"the",
"influence",
"graph",
"with",
"the",
"given",
"name",
".",
"Raise",
"an",
"AttributeError",
"if",
"there",
"is",
"no",
"gene",
"in",
"the",
"graph",
"with",
"the",
"given",
"name",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/influence_graph.py#L24-L32 | train | Find and return a gene in the influence graph with the given name. Raise an AttributeError if there is no gene with the given name. |
clement-alexandre/TotemBionet | totembionet/src/discrete_model/influence_graph.py | InfluenceGraph.find_multiplex_by_name | def find_multiplex_by_name(self, multiplex_name: str) -> Multiplex:
"""
Find and return a multiplex in the influence graph with the given name.
Raise an AttributeError if there is no multiplex in the graph with the given name.
"""
for multiplex in self.multiplexes:
i... | python | def find_multiplex_by_name(self, multiplex_name: str) -> Multiplex:
"""
Find and return a multiplex in the influence graph with the given name.
Raise an AttributeError if there is no multiplex in the graph with the given name.
"""
for multiplex in self.multiplexes:
i... | [
"def",
"find_multiplex_by_name",
"(",
"self",
",",
"multiplex_name",
":",
"str",
")",
"->",
"Multiplex",
":",
"for",
"multiplex",
"in",
"self",
".",
"multiplexes",
":",
"if",
"multiplex",
".",
"name",
"==",
"multiplex_name",
":",
"return",
"multiplex",
"raise"... | Find and return a multiplex in the influence graph with the given name.
Raise an AttributeError if there is no multiplex in the graph with the given name. | [
"Find",
"and",
"return",
"a",
"multiplex",
"in",
"the",
"influence",
"graph",
"with",
"the",
"given",
"name",
".",
"Raise",
"an",
"AttributeError",
"if",
"there",
"is",
"no",
"multiplex",
"in",
"the",
"graph",
"with",
"the",
"given",
"name",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/influence_graph.py#L38-L46 | train | Find and return a multiplex in the influence graph with the given name. Raise an AttributeError if there is no multiplex with the given name. |
clement-alexandre/TotemBionet | totembionet/src/discrete_model/influence_graph.py | InfluenceGraph.all_states | def all_states(self) -> Tuple[State, ...]:
""" Return all the possible states of this influence graph. """
return tuple(self._transform_list_of_states_to_state(states)
for states in self._cartesian_product_of_every_states_of_each_genes()) | python | def all_states(self) -> Tuple[State, ...]:
""" Return all the possible states of this influence graph. """
return tuple(self._transform_list_of_states_to_state(states)
for states in self._cartesian_product_of_every_states_of_each_genes()) | [
"def",
"all_states",
"(",
"self",
")",
"->",
"Tuple",
"[",
"State",
",",
"...",
"]",
":",
"return",
"tuple",
"(",
"self",
".",
"_transform_list_of_states_to_state",
"(",
"states",
")",
"for",
"states",
"in",
"self",
".",
"_cartesian_product_of_every_states_of_ea... | Return all the possible states of this influence graph. | [
"Return",
"all",
"the",
"possible",
"states",
"of",
"this",
"influence",
"graph",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/influence_graph.py#L48-L51 | train | Return all possible states of this influence graph. |
clement-alexandre/TotemBionet | totembionet/src/discrete_model/influence_graph.py | InfluenceGraph._cartesian_product_of_every_states_of_each_genes | def _cartesian_product_of_every_states_of_each_genes(self) -> Tuple[Tuple[int, ...]]:
"""
Private method which return the cartesian product of the states
of the genes in the model. It represents all the possible state for a given model.
Examples
--------
The model cont... | python | def _cartesian_product_of_every_states_of_each_genes(self) -> Tuple[Tuple[int, ...]]:
"""
Private method which return the cartesian product of the states
of the genes in the model. It represents all the possible state for a given model.
Examples
--------
The model cont... | [
"def",
"_cartesian_product_of_every_states_of_each_genes",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Tuple",
"[",
"int",
",",
"...",
"]",
"]",
":",
"if",
"not",
"self",
".",
"genes",
":",
"return",
"(",
")",
"return",
"tuple",
"(",
"product",
"(",
"*",
"[",... | Private method which return the cartesian product of the states
of the genes in the model. It represents all the possible state for a given model.
Examples
--------
The model contains 2 genes: operon = {0, 1, 2}
mucuB = {0, 1}
Then this metho... | [
"Private",
"method",
"which",
"return",
"the",
"cartesian",
"product",
"of",
"the",
"states",
"of",
"the",
"genes",
"in",
"the",
"model",
".",
"It",
"represents",
"all",
"the",
"possible",
"state",
"for",
"a",
"given",
"model",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/influence_graph.py#L53-L69 | train | Private method which returns the cartesian product of the states of each gene in the model. |
clement-alexandre/TotemBionet | totembionet/src/discrete_model/influence_graph.py | InfluenceGraph._transform_list_of_states_to_state | def _transform_list_of_states_to_state(self, state: List[int]) -> State:
"""
Private method which transform a list which contains the state of the gene
in the models to a State object.
Examples
--------
The model contains 2 genes: operon = {0, 1, 2}
... | python | def _transform_list_of_states_to_state(self, state: List[int]) -> State:
"""
Private method which transform a list which contains the state of the gene
in the models to a State object.
Examples
--------
The model contains 2 genes: operon = {0, 1, 2}
... | [
"def",
"_transform_list_of_states_to_state",
"(",
"self",
",",
"state",
":",
"List",
"[",
"int",
"]",
")",
"->",
"State",
":",
"return",
"State",
"(",
"{",
"gene",
":",
"state",
"[",
"i",
"]",
"for",
"i",
",",
"gene",
"in",
"enumerate",
"(",
"self",
... | Private method which transform a list which contains the state of the gene
in the models to a State object.
Examples
--------
The model contains 2 genes: operon = {0, 1, 2}
mucuB = {0, 1}
>>> graph._transform_list_of_states_to_dict_of_states(... | [
"Private",
"method",
"which",
"transform",
"a",
"list",
"which",
"contains",
"the",
"state",
"of",
"the",
"gene",
"in",
"the",
"models",
"to",
"a",
"State",
"object",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/influence_graph.py#L71-L86 | train | Private method which transforms a list of states to a State object. |
thespacedoctor/HMpTy | HMpTy/htm/htm.py | HTM.area | def area(
self):
"""*The mean area of triangles in this mesh in units of square degrees.*
**Usage:**
.. code-block:: python
mesh.area
"""
pi = numpy.pi
area0 = 4.0 * pi / 8.0
areadiv = 4.0 ** self.depth
area = area0 / are... | python | def area(
self):
"""*The mean area of triangles in this mesh in units of square degrees.*
**Usage:**
.. code-block:: python
mesh.area
"""
pi = numpy.pi
area0 = 4.0 * pi / 8.0
areadiv = 4.0 ** self.depth
area = area0 / are... | [
"def",
"area",
"(",
"self",
")",
":",
"pi",
"=",
"numpy",
".",
"pi",
"area0",
"=",
"4.0",
"*",
"pi",
"/",
"8.0",
"areadiv",
"=",
"4.0",
"**",
"self",
".",
"depth",
"area",
"=",
"area0",
"/",
"areadiv",
"*",
"(",
"180.0",
"/",
"pi",
")",
"**",
... | *The mean area of triangles in this mesh in units of square degrees.*
**Usage:**
.. code-block:: python
mesh.area | [
"*",
"The",
"mean",
"area",
"of",
"triangles",
"in",
"this",
"mesh",
"in",
"units",
"of",
"square",
"degrees",
".",
"*"
] | 3ce2bdb7ce3351468962ab907ede9a6074c15912 | https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/htm/htm.py#L56-L70 | train | Returns the area of the triangles in this mesh in units of square degrees. |
thespacedoctor/HMpTy | HMpTy/htm/htm.py | HTM.lookup_id | def lookup_id(
self,
ra,
dec):
"""*Lookup the ID of HTM trixel that a coordinate or lists of coordinates lie on*
**Key Arguments:**
- ``ra`` -- list, numpy array or single ra value (first coordinate set)
- ``dec`` -- list, numpy array or singl... | python | def lookup_id(
self,
ra,
dec):
"""*Lookup the ID of HTM trixel that a coordinate or lists of coordinates lie on*
**Key Arguments:**
- ``ra`` -- list, numpy array or single ra value (first coordinate set)
- ``dec`` -- list, numpy array or singl... | [
"def",
"lookup_id",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``lookup_id`` method'",
")",
"from",
"astrocalc",
".",
"coords",
"import",
"coordinates_to_array",
"raArray",
",",
"decArray",
"=",
"coordin... | *Lookup the ID of HTM trixel that a coordinate or lists of coordinates lie on*
**Key Arguments:**
- ``ra`` -- list, numpy array or single ra value (first coordinate set)
- ``dec`` -- list, numpy array or single dec value (first coordinate set - must match ra1 array length)
**Re... | [
"*",
"Lookup",
"the",
"ID",
"of",
"HTM",
"trixel",
"that",
"a",
"coordinate",
"or",
"lists",
"of",
"coordinates",
"lie",
"on",
"*"
] | 3ce2bdb7ce3351468962ab907ede9a6074c15912 | https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/htm/htm.py#L72-L109 | train | This method will return the ID of the HTM trixel that a set of coordinates lie on. |
thespacedoctor/HMpTy | HMpTy/htm/htm.py | HTM.intersect | def intersect(self, ra, dec, radius, inclusive=True, convertCoordinates=True):
"""*return IDs of all triangles contained within and/or intersecting a circle centered on a given ra and dec*
**Key Arguments:**
- ``ra`` -- RA of central point in decimal degrees or sexagesimal
- ``d... | python | def intersect(self, ra, dec, radius, inclusive=True, convertCoordinates=True):
"""*return IDs of all triangles contained within and/or intersecting a circle centered on a given ra and dec*
**Key Arguments:**
- ``ra`` -- RA of central point in decimal degrees or sexagesimal
- ``d... | [
"def",
"intersect",
"(",
"self",
",",
"ra",
",",
"dec",
",",
"radius",
",",
"inclusive",
"=",
"True",
",",
"convertCoordinates",
"=",
"True",
")",
":",
"# CONVERT RA AND DEC DECIMAL DEGREES",
"if",
"convertCoordinates",
"==",
"True",
":",
"converter",
"=",
"un... | *return IDs of all triangles contained within and/or intersecting a circle centered on a given ra and dec*
**Key Arguments:**
- ``ra`` -- RA of central point in decimal degrees or sexagesimal
- ``dec`` -- DEC of central point in decimal degrees or sexagesimal
- ``radius`` --... | [
"*",
"return",
"IDs",
"of",
"all",
"triangles",
"contained",
"within",
"and",
"/",
"or",
"intersecting",
"a",
"circle",
"centered",
"on",
"a",
"given",
"ra",
"and",
"dec",
"*"
] | 3ce2bdb7ce3351468962ab907ede9a6074c15912 | https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/htm/htm.py#L114-L169 | train | Returns the set of trixels that intersect the given point. |
thespacedoctor/HMpTy | HMpTy/htm/htm.py | HTM.match | def match(self, ra1, dec1, ra2, dec2, radius, maxmatch=1, convertToArray=True):
"""*Crossmatch two lists of ra/dec points*
This is very efficient for large search angles and large lists. Note, if you need to match against the same points many times, you should use a `Matcher` object
**Key Argu... | python | def match(self, ra1, dec1, ra2, dec2, radius, maxmatch=1, convertToArray=True):
"""*Crossmatch two lists of ra/dec points*
This is very efficient for large search angles and large lists. Note, if you need to match against the same points many times, you should use a `Matcher` object
**Key Argu... | [
"def",
"match",
"(",
"self",
",",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
",",
"radius",
",",
"maxmatch",
"=",
"1",
",",
"convertToArray",
"=",
"True",
")",
":",
"# CONVERT LISTS AND SINGLE VALUES TO ARRAYS OF FLOATS",
"ra1",
"=",
"numpy",
".",
"array",... | *Crossmatch two lists of ra/dec points*
This is very efficient for large search angles and large lists. Note, if you need to match against the same points many times, you should use a `Matcher` object
**Key Arguments:**
- ``ra1`` -- list, numpy array or single ra value (first coordinate se... | [
"*",
"Crossmatch",
"two",
"lists",
"of",
"ra",
"/",
"dec",
"points",
"*"
] | 3ce2bdb7ce3351468962ab907ede9a6074c15912 | https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/htm/htm.py#L171-L265 | train | Match two lists of ra and dec points. |
thespacedoctor/HMpTy | HMpTy/htm/htm.py | Matcher.match | def match(self, ra, dec, radius, maxmatch=1):
"""*match a corrdinate set against this Matcher object's coordinate set*
**Key Arguments:**
- ``ra`` -- list, numpy array or single ra value
- ``dec`` -- --list, numpy array or single dec value (must match ra array length)
... | python | def match(self, ra, dec, radius, maxmatch=1):
"""*match a corrdinate set against this Matcher object's coordinate set*
**Key Arguments:**
- ``ra`` -- list, numpy array or single ra value
- ``dec`` -- --list, numpy array or single dec value (must match ra array length)
... | [
"def",
"match",
"(",
"self",
",",
"ra",
",",
"dec",
",",
"radius",
",",
"maxmatch",
"=",
"1",
")",
":",
"if",
"self",
".",
"convertToArray",
"==",
"True",
":",
"from",
"astrocalc",
".",
"coords",
"import",
"coordinates_to_array",
"ra",
",",
"dec",
"=",... | *match a corrdinate set against this Matcher object's coordinate set*
**Key Arguments:**
- ``ra`` -- list, numpy array or single ra value
- ``dec`` -- --list, numpy array or single dec value (must match ra array length)
- ``radius`` -- radius of circle in degrees
... | [
"*",
"match",
"a",
"corrdinate",
"set",
"against",
"this",
"Matcher",
"object",
"s",
"coordinate",
"set",
"*"
] | 3ce2bdb7ce3351468962ab907ede9a6074c15912 | https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/htm/htm.py#L349-L414 | train | This method will match a corrdinate set against this Matcher object s coordinate set. |
Kortemme-Lab/klab | klab/box_backup.py | read_sha1 | def read_sha1(
file_path,
buf_size = None,
start_byte = 0,
read_size = None,
extra_hashers = [], # update(data) will be called on all of these
):
'''
Determines the sha1 hash of a file in chunks, to prevent loading the entire file at once into memory
'''
read_size = read_size or os.s... | python | def read_sha1(
file_path,
buf_size = None,
start_byte = 0,
read_size = None,
extra_hashers = [], # update(data) will be called on all of these
):
'''
Determines the sha1 hash of a file in chunks, to prevent loading the entire file at once into memory
'''
read_size = read_size or os.s... | [
"def",
"read_sha1",
"(",
"file_path",
",",
"buf_size",
"=",
"None",
",",
"start_byte",
"=",
"0",
",",
"read_size",
"=",
"None",
",",
"extra_hashers",
"=",
"[",
"]",
",",
"# update(data) will be called on all of these",
")",
":",
"read_size",
"=",
"read_size",
... | Determines the sha1 hash of a file in chunks, to prevent loading the entire file at once into memory | [
"Determines",
"the",
"sha1",
"hash",
"of",
"a",
"file",
"in",
"chunks",
"to",
"prevent",
"loading",
"the",
"entire",
"file",
"at",
"once",
"into",
"memory"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/box_backup.py#L665-L692 | train | Reads a file and returns the sha1 hash of the data. |
Kortemme-Lab/klab | klab/box_backup.py | BoxAPI.find_file | def find_file( self, folder_id, basename, limit = 500 ):
'''
Finds a file based on a box path
Returns a list of file IDs
Returns multiple file IDs if the file was split into parts with the extension '.partN' (where N is an integer)
'''
search_folder = self.client.folder( ... | python | def find_file( self, folder_id, basename, limit = 500 ):
'''
Finds a file based on a box path
Returns a list of file IDs
Returns multiple file IDs if the file was split into parts with the extension '.partN' (where N is an integer)
'''
search_folder = self.client.folder( ... | [
"def",
"find_file",
"(",
"self",
",",
"folder_id",
",",
"basename",
",",
"limit",
"=",
"500",
")",
":",
"search_folder",
"=",
"self",
".",
"client",
".",
"folder",
"(",
"folder_id",
"=",
"folder_id",
")",
"offset",
"=",
"0",
"search_items",
"=",
"search_... | Finds a file based on a box path
Returns a list of file IDs
Returns multiple file IDs if the file was split into parts with the extension '.partN' (where N is an integer) | [
"Finds",
"a",
"file",
"based",
"on",
"a",
"box",
"path",
"Returns",
"a",
"list",
"of",
"file",
"IDs",
"Returns",
"multiple",
"file",
"IDs",
"if",
"the",
"file",
"was",
"split",
"into",
"parts",
"with",
"the",
"extension",
".",
"partN",
"(",
"where",
"N... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/box_backup.py#L159-L181 | train | Find a file based on a box path |
Kortemme-Lab/klab | klab/box_backup.py | BoxAPI.verify_uploaded_file | def verify_uploaded_file(
self,
destination_folder_id,
source_path,
verbose = True,
):
'''
Verifies the integrity of a file uploaded to Box
'''
source_file_size = os.stat(source_path).st_size
total_part_size = 0
file_po... | python | def verify_uploaded_file(
self,
destination_folder_id,
source_path,
verbose = True,
):
'''
Verifies the integrity of a file uploaded to Box
'''
source_file_size = os.stat(source_path).st_size
total_part_size = 0
file_po... | [
"def",
"verify_uploaded_file",
"(",
"self",
",",
"destination_folder_id",
",",
"source_path",
",",
"verbose",
"=",
"True",
",",
")",
":",
"source_file_size",
"=",
"os",
".",
"stat",
"(",
"source_path",
")",
".",
"st_size",
"total_part_size",
"=",
"0",
"file_po... | Verifies the integrity of a file uploaded to Box | [
"Verifies",
"the",
"integrity",
"of",
"a",
"file",
"uploaded",
"to",
"Box"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/box_backup.py#L242-L280 | train | Verifies the integrity of a file uploaded to Box
|
Kortemme-Lab/klab | klab/box_backup.py | BoxAPI._upload_in_splits | def _upload_in_splits( self, destination_folder_id, source_path, preflight_check, verbose = True, chunked_upload_threads = 5 ):
'''
Since Box has a maximum file size limit (15 GB at time of writing),
we need to split files larger than this into smaller parts, and chunk upload each part
'... | python | def _upload_in_splits( self, destination_folder_id, source_path, preflight_check, verbose = True, chunked_upload_threads = 5 ):
'''
Since Box has a maximum file size limit (15 GB at time of writing),
we need to split files larger than this into smaller parts, and chunk upload each part
'... | [
"def",
"_upload_in_splits",
"(",
"self",
",",
"destination_folder_id",
",",
"source_path",
",",
"preflight_check",
",",
"verbose",
"=",
"True",
",",
"chunked_upload_threads",
"=",
"5",
")",
":",
"file_size",
"=",
"os",
".",
"stat",
"(",
"source_path",
")",
"."... | Since Box has a maximum file size limit (15 GB at time of writing),
we need to split files larger than this into smaller parts, and chunk upload each part | [
"Since",
"Box",
"has",
"a",
"maximum",
"file",
"size",
"limit",
"(",
"15",
"GB",
"at",
"time",
"of",
"writing",
")",
"we",
"need",
"to",
"split",
"files",
"larger",
"than",
"this",
"into",
"smaller",
"parts",
"and",
"chunk",
"upload",
"each",
"part"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/box_backup.py#L282-L321 | train | Uploads a file in a set of splits. |
ABI-Software/MeshParser | src/meshparser/base/parser.py | BaseParser.getPoints | def getPoints(self, pared=False):
"""
Get the points that make up the mesh.
:param pared: use the pared down list of points
:return: A list of points
"""
points = self._points[:]
if pared:
np = NodePare()
np.addPoints(points)
np... | python | def getPoints(self, pared=False):
"""
Get the points that make up the mesh.
:param pared: use the pared down list of points
:return: A list of points
"""
points = self._points[:]
if pared:
np = NodePare()
np.addPoints(points)
np... | [
"def",
"getPoints",
"(",
"self",
",",
"pared",
"=",
"False",
")",
":",
"points",
"=",
"self",
".",
"_points",
"[",
":",
"]",
"if",
"pared",
":",
"np",
"=",
"NodePare",
"(",
")",
"np",
".",
"addPoints",
"(",
"points",
")",
"np",
".",
"parePoints",
... | Get the points that make up the mesh.
:param pared: use the pared down list of points
:return: A list of points | [
"Get",
"the",
"points",
"that",
"make",
"up",
"the",
"mesh",
".",
":",
"param",
"pared",
":",
"use",
"the",
"pared",
"down",
"list",
"of",
"points",
":",
"return",
":",
"A",
"list",
"of",
"points"
] | 08dc0ce7c44d0149b443261ff6d3708e28a928e7 | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/base/parser.py#L26-L39 | train | Get the points that make up the mesh. |
ABI-Software/MeshParser | src/meshparser/base/parser.py | BaseParser.getElements | def getElements(self, zero_based=True, pared=False):
"""
Get the elements of the mesh as a list of point index list.
:param zero_based: use zero based index of points if true otherwise use 1-based index of points.
:param pared: use the pared down list of points
:return: A list of... | python | def getElements(self, zero_based=True, pared=False):
"""
Get the elements of the mesh as a list of point index list.
:param zero_based: use zero based index of points if true otherwise use 1-based index of points.
:param pared: use the pared down list of points
:return: A list of... | [
"def",
"getElements",
"(",
"self",
",",
"zero_based",
"=",
"True",
",",
"pared",
"=",
"False",
")",
":",
"points",
"=",
"self",
".",
"_points",
"[",
":",
"]",
"elements",
"=",
"self",
".",
"_elements",
"[",
":",
"]",
"offset",
"=",
"0",
"if",
"not"... | Get the elements of the mesh as a list of point index list.
:param zero_based: use zero based index of points if true otherwise use 1-based index of points.
:param pared: use the pared down list of points
:return: A list of point index lists | [
"Get",
"the",
"elements",
"of",
"the",
"mesh",
"as",
"a",
"list",
"of",
"point",
"index",
"list",
".",
":",
"param",
"zero_based",
":",
"use",
"zero",
"based",
"index",
"of",
"points",
"if",
"true",
"otherwise",
"use",
"1",
"-",
"based",
"index",
"of",... | 08dc0ce7c44d0149b443261ff6d3708e28a928e7 | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/base/parser.py#L41-L69 | train | Get the elements of the mesh as a list of point index lists. |
berkeley-cocosci/Wallace | examples/bartlett1932/experiment.py | WarOfTheGhostsSource._contents | def _contents(self):
"""Define the contents of new Infos.
transmit() -> _what() -> create_information() -> _contents().
"""
stories = [
"ghosts.md",
"cricket.md",
"moochi.md",
"outwit.md",
"raid.md",
"species.md",
... | python | def _contents(self):
"""Define the contents of new Infos.
transmit() -> _what() -> create_information() -> _contents().
"""
stories = [
"ghosts.md",
"cricket.md",
"moochi.md",
"outwit.md",
"raid.md",
"species.md",
... | [
"def",
"_contents",
"(",
"self",
")",
":",
"stories",
"=",
"[",
"\"ghosts.md\"",
",",
"\"cricket.md\"",
",",
"\"moochi.md\"",
",",
"\"outwit.md\"",
",",
"\"raid.md\"",
",",
"\"species.md\"",
",",
"\"tennis.md\"",
",",
"\"vagabond.md\"",
"]",
"story",
"=",
"rando... | Define the contents of new Infos.
transmit() -> _what() -> create_information() -> _contents(). | [
"Define",
"the",
"contents",
"of",
"new",
"Infos",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/bartlett1932/experiment.py#L61-L78 | train | Define the contents of new Infos. |
uogbuji/versa | tools/py/reader/md.py | handle_resourcelist | def handle_resourcelist(ltext, **kwargs):
'''
A helper that converts lists of resources from a textual format such as Markdown, including absolutizing relative IRIs
'''
base=kwargs.get('base', VERSA_BASEIRI)
model=kwargs.get('model')
iris = ltext.strip().split()
newlist = model.generate_reso... | python | def handle_resourcelist(ltext, **kwargs):
'''
A helper that converts lists of resources from a textual format such as Markdown, including absolutizing relative IRIs
'''
base=kwargs.get('base', VERSA_BASEIRI)
model=kwargs.get('model')
iris = ltext.strip().split()
newlist = model.generate_reso... | [
"def",
"handle_resourcelist",
"(",
"ltext",
",",
"*",
"*",
"kwargs",
")",
":",
"base",
"=",
"kwargs",
".",
"get",
"(",
"'base'",
",",
"VERSA_BASEIRI",
")",
"model",
"=",
"kwargs",
".",
"get",
"(",
"'model'",
")",
"iris",
"=",
"ltext",
".",
"strip",
"... | A helper that converts lists of resources from a textual format such as Markdown, including absolutizing relative IRIs | [
"A",
"helper",
"that",
"converts",
"lists",
"of",
"resources",
"from",
"a",
"textual",
"format",
"such",
"as",
"Markdown",
"including",
"absolutizing",
"relative",
"IRIs"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/reader/md.py#L63-L73 | train | A helper that converts a list of resources from a textual format such as Markdown including absolutizing relative IRIs |
uogbuji/versa | tools/py/reader/md.py | handle_resourceset | def handle_resourceset(ltext, **kwargs):
'''
A helper that converts sets of resources from a textual format such as Markdown, including absolutizing relative IRIs
'''
fullprop=kwargs.get('fullprop')
rid=kwargs.get('rid')
base=kwargs.get('base', VERSA_BASEIRI)
model=kwargs.get('model')
ir... | python | def handle_resourceset(ltext, **kwargs):
'''
A helper that converts sets of resources from a textual format such as Markdown, including absolutizing relative IRIs
'''
fullprop=kwargs.get('fullprop')
rid=kwargs.get('rid')
base=kwargs.get('base', VERSA_BASEIRI)
model=kwargs.get('model')
ir... | [
"def",
"handle_resourceset",
"(",
"ltext",
",",
"*",
"*",
"kwargs",
")",
":",
"fullprop",
"=",
"kwargs",
".",
"get",
"(",
"'fullprop'",
")",
"rid",
"=",
"kwargs",
".",
"get",
"(",
"'rid'",
")",
"base",
"=",
"kwargs",
".",
"get",
"(",
"'base'",
",",
... | A helper that converts sets of resources from a textual format such as Markdown, including absolutizing relative IRIs | [
"A",
"helper",
"that",
"converts",
"sets",
"of",
"resources",
"from",
"a",
"textual",
"format",
"such",
"as",
"Markdown",
"including",
"absolutizing",
"relative",
"IRIs"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/reader/md.py#L76-L87 | train | A helper that converts a list of resources from a textual format such as Markdown including absolutizing relative IRIs |
uogbuji/versa | tools/py/reader/md.py | parse | def parse(md, model, encoding='utf-8', config=None):
"""
Translate the Versa Markdown syntax into Versa model relationships
md -- markdown source text
model -- Versa model to take the output relationship
encoding -- character encoding (defaults to UTF-8)
Returns: The overall base URI (`@base`)... | python | def parse(md, model, encoding='utf-8', config=None):
"""
Translate the Versa Markdown syntax into Versa model relationships
md -- markdown source text
model -- Versa model to take the output relationship
encoding -- character encoding (defaults to UTF-8)
Returns: The overall base URI (`@base`)... | [
"def",
"parse",
"(",
"md",
",",
"model",
",",
"encoding",
"=",
"'utf-8'",
",",
"config",
"=",
"None",
")",
":",
"#Set up configuration to interpret the conventions for the Markdown",
"config",
"=",
"config",
"or",
"{",
"}",
"#This mapping takes syntactical elements such... | Translate the Versa Markdown syntax into Versa model relationships
md -- markdown source text
model -- Versa model to take the output relationship
encoding -- character encoding (defaults to UTF-8)
Returns: The overall base URI (`@base`) specified in the Markdown file, or None
>>> from versa.driv... | [
"Translate",
"the",
"Versa",
"Markdown",
"syntax",
"into",
"Versa",
"model",
"relationships"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/reader/md.py#L100-L355 | train | Translate the Versa Markdown source text into Versa model relationships |
Alveo/pyalveo | pyalveo/cache.py | Cache.to_dict | def to_dict(self):
"""
Returns a dict of all of it's necessary components.
Not the same as the __dict__ method
"""
data = dict()
data['max_age'] = self.max_age
data['cache_dir'] = self.cache_dir
return data | python | def to_dict(self):
"""
Returns a dict of all of it's necessary components.
Not the same as the __dict__ method
"""
data = dict()
data['max_age'] = self.max_age
data['cache_dir'] = self.cache_dir
return data | [
"def",
"to_dict",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'max_age'",
"]",
"=",
"self",
".",
"max_age",
"data",
"[",
"'cache_dir'",
"]",
"=",
"self",
".",
"cache_dir",
"return",
"data"
] | Returns a dict of all of it's necessary components.
Not the same as the __dict__ method | [
"Returns",
"a",
"dict",
"of",
"all",
"of",
"it",
"s",
"necessary",
"components",
".",
"Not",
"the",
"same",
"as",
"the",
"__dict__",
"method"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L48-L56 | train | Returns a dict of all of the necessary components. |
Alveo/pyalveo | pyalveo/cache.py | Cache.from_json | def from_json(json_data):
"""
Returns a pyalveo.OAuth2 given a json string built from the oauth.to_json() method.
"""
#If we have a string, then decode it, otherwise assume it's already decoded
if isinstance(json_data, str):
data = json.loads(json_data)
el... | python | def from_json(json_data):
"""
Returns a pyalveo.OAuth2 given a json string built from the oauth.to_json() method.
"""
#If we have a string, then decode it, otherwise assume it's already decoded
if isinstance(json_data, str):
data = json.loads(json_data)
el... | [
"def",
"from_json",
"(",
"json_data",
")",
":",
"#If we have a string, then decode it, otherwise assume it's already decoded",
"if",
"isinstance",
"(",
"json_data",
",",
"str",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"json_data",
")",
"else",
":",
"data",
... | Returns a pyalveo.OAuth2 given a json string built from the oauth.to_json() method. | [
"Returns",
"a",
"pyalveo",
".",
"OAuth2",
"given",
"a",
"json",
"string",
"built",
"from",
"the",
"oauth",
".",
"to_json",
"()",
"method",
"."
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L65-L75 | train | Returns a pyalveo. OAuth2 given a json string built from the oauth. to_json method. |
Alveo/pyalveo | pyalveo/cache.py | Cache.create_cache_database | def create_cache_database(self):
""" Create a new SQLite3 database for use with Cache objects
:raises: IOError if there is a problem creating the database file
"""
conn = sqlite3.connect(self.database)
conn.text_factory = str
c = conn.cursor()
c.execute("""CR... | python | def create_cache_database(self):
""" Create a new SQLite3 database for use with Cache objects
:raises: IOError if there is a problem creating the database file
"""
conn = sqlite3.connect(self.database)
conn.text_factory = str
c = conn.cursor()
c.execute("""CR... | [
"def",
"create_cache_database",
"(",
"self",
")",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"database",
")",
"conn",
".",
"text_factory",
"=",
"str",
"c",
"=",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"\"\"CREAT... | Create a new SQLite3 database for use with Cache objects
:raises: IOError if there is a problem creating the database file | [
"Create",
"a",
"new",
"SQLite3",
"database",
"for",
"use",
"with",
"Cache",
"objects"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L77-L96 | train | Create a SQLite3 database for use with Cache objects |
Alveo/pyalveo | pyalveo/cache.py | Cache.__exists_row_not_too_old | def __exists_row_not_too_old(self, row):
""" Check if the given row exists and is not too old """
if row is None:
return False
record_time = dateutil.parser.parse(row[2])
now = datetime.datetime.now(dateutil.tz.gettz())
age = (record_time - now).total_seconds()
... | python | def __exists_row_not_too_old(self, row):
""" Check if the given row exists and is not too old """
if row is None:
return False
record_time = dateutil.parser.parse(row[2])
now = datetime.datetime.now(dateutil.tz.gettz())
age = (record_time - now).total_seconds()
... | [
"def",
"__exists_row_not_too_old",
"(",
"self",
",",
"row",
")",
":",
"if",
"row",
"is",
"None",
":",
"return",
"False",
"record_time",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"row",
"[",
"2",
"]",
")",
"now",
"=",
"datetime",
".",
"datetime... | Check if the given row exists and is not too old | [
"Check",
"if",
"the",
"given",
"row",
"exists",
"and",
"is",
"not",
"too",
"old"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L135-L145 | train | Check if the given row exists and is not too old |
Alveo/pyalveo | pyalveo/cache.py | Cache.has_item | def has_item(self, item_url):
""" Check if the metadata for the given item is present in
the cache
If the max_age attribute of this Cache is set to a nonzero value,
entries older than the value of max_age in seconds will be ignored
:type item_url: String or Item
:param ... | python | def has_item(self, item_url):
""" Check if the metadata for the given item is present in
the cache
If the max_age attribute of this Cache is set to a nonzero value,
entries older than the value of max_age in seconds will be ignored
:type item_url: String or Item
:param ... | [
"def",
"has_item",
"(",
"self",
",",
"item_url",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"SELECT * FROM items WHERE url=?\"",
",",
"(",
"str",
"(",
"item_url",
")",
",",
")",
")",
"row",
"=",
"c",... | Check if the metadata for the given item is present in
the cache
If the max_age attribute of this Cache is set to a nonzero value,
entries older than the value of max_age in seconds will be ignored
:type item_url: String or Item
:param item_url: the URL of the item, or an Item ... | [
"Check",
"if",
"the",
"metadata",
"for",
"the",
"given",
"item",
"is",
"present",
"in",
"the",
"cache"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L153-L172 | train | Check if the item with the given URL is present in the cache. |
Alveo/pyalveo | pyalveo/cache.py | Cache.has_document | def has_document(self, doc_url):
""" Check if the content of the given document is present
in the cache
If the max_age attribute of this Cache is set to a nonzero value,
entries older than the value of max_age in seconds will be ignored
:type doc_url: String or Document
... | python | def has_document(self, doc_url):
""" Check if the content of the given document is present
in the cache
If the max_age attribute of this Cache is set to a nonzero value,
entries older than the value of max_age in seconds will be ignored
:type doc_url: String or Document
... | [
"def",
"has_document",
"(",
"self",
",",
"doc_url",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"SELECT * FROM documents WHERE url=?\"",
",",
"(",
"str",
"(",
"doc_url",
")",
",",
")",
")",
"row",
"=",
... | Check if the content of the given document is present
in the cache
If the max_age attribute of this Cache is set to a nonzero value,
entries older than the value of max_age in seconds will be ignored
:type doc_url: String or Document
:param doc_url: the URL of the document, or ... | [
"Check",
"if",
"the",
"content",
"of",
"the",
"given",
"document",
"is",
"present",
"in",
"the",
"cache"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L175-L194 | train | Check if the content of the given document is present in the cache. |
Alveo/pyalveo | pyalveo/cache.py | Cache.get_document | def get_document(self, doc_url):
""" Retrieve the content for the given document from the cache.
:type doc_url: String or Document
:param doc_url: the URL of the document, or a Document object
:rtype: String
:returns: the document data
:raises: ValueError if the item i... | python | def get_document(self, doc_url):
""" Retrieve the content for the given document from the cache.
:type doc_url: String or Document
:param doc_url: the URL of the document, or a Document object
:rtype: String
:returns: the document data
:raises: ValueError if the item i... | [
"def",
"get_document",
"(",
"self",
",",
"doc_url",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"SELECT * FROM documents WHERE url=?\"",
",",
"(",
"str",
"(",
"doc_url",
")",
",",
")",
")",
"row",
"=",
... | Retrieve the content for the given document from the cache.
:type doc_url: String or Document
:param doc_url: the URL of the document, or a Document object
:rtype: String
:returns: the document data
:raises: ValueError if the item is not in the cache | [
"Retrieve",
"the",
"content",
"for",
"the",
"given",
"document",
"from",
"the",
"cache",
"."
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L242-L268 | train | Retrieve the content for the given document from the cache. |
Alveo/pyalveo | pyalveo/cache.py | Cache.get_primary_text | def get_primary_text(self, item_url):
""" Retrieve the primary text for the given item from the cache.
:type item_url: String or Item
:param item_url: the URL of the item, or an Item object
:rtype: String
:returns: the primary text
:raises: ValueError if the primary te... | python | def get_primary_text(self, item_url):
""" Retrieve the primary text for the given item from the cache.
:type item_url: String or Item
:param item_url: the URL of the item, or an Item object
:rtype: String
:returns: the primary text
:raises: ValueError if the primary te... | [
"def",
"get_primary_text",
"(",
"self",
",",
"item_url",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"SELECT * FROM primary_texts WHERE item_url=?\"",
",",
"(",
"str",
"(",
"item_url",
")",
",",
")",
")",
... | Retrieve the primary text for the given item from the cache.
:type item_url: String or Item
:param item_url: the URL of the item, or an Item object
:rtype: String
:returns: the primary text
:raises: ValueError if the primary text is not in the cache | [
"Retrieve",
"the",
"primary",
"text",
"for",
"the",
"given",
"item",
"from",
"the",
"cache",
"."
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L271-L291 | train | Retrieve the primary text for the given item from the cache. |
Alveo/pyalveo | pyalveo/cache.py | Cache.add_item | def add_item(self, item_url, item_metadata):
""" Add the given item to the cache database, updating
the existing metadata if the item is already present
:type item_url: String or Item
:param item_url: the URL of the item, or an Item object
:type item_metadata: String
:pa... | python | def add_item(self, item_url, item_metadata):
""" Add the given item to the cache database, updating
the existing metadata if the item is already present
:type item_url: String or Item
:param item_url: the URL of the item, or an Item object
:type item_metadata: String
:pa... | [
"def",
"add_item",
"(",
"self",
",",
"item_url",
",",
"item_metadata",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"DELETE FROM items WHERE url=?\"",
",",
"(",
"str",
"(",
"item_url",
")",
",",
")",
")"... | Add the given item to the cache database, updating
the existing metadata if the item is already present
:type item_url: String or Item
:param item_url: the URL of the item, or an Item object
:type item_metadata: String
:param item_metadata: the item's metadata, as a JSON string | [
"Add",
"the",
"given",
"item",
"to",
"the",
"cache",
"database",
"updating",
"the",
"existing",
"metadata",
"if",
"the",
"item",
"is",
"already",
"present"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L294-L311 | train | Adds the given item to the cache database updating the existing metadata if the item is already present |
Alveo/pyalveo | pyalveo/cache.py | Cache.__generate_filepath | def __generate_filepath(self):
""" Generate a unique (absolute) file path within the file_dir directory
:rtype: String
:returns: a unique file path
"""
file_path = os.path.join(self.file_dir, str(uuid.uuid4()))
if os.path.exists(file_path):
warnings.warn("s... | python | def __generate_filepath(self):
""" Generate a unique (absolute) file path within the file_dir directory
:rtype: String
:returns: a unique file path
"""
file_path = os.path.join(self.file_dir, str(uuid.uuid4()))
if os.path.exists(file_path):
warnings.warn("s... | [
"def",
"__generate_filepath",
"(",
"self",
")",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"file_dir",
",",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_path"... | Generate a unique (absolute) file path within the file_dir directory
:rtype: String
:returns: a unique file path | [
"Generate",
"a",
"unique",
"(",
"absolute",
")",
"file",
"path",
"within",
"the",
"file_dir",
"directory"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L314-L326 | train | Generate a unique file path within the file_dir directory containing the unique ID of the current class. |
Alveo/pyalveo | pyalveo/cache.py | Cache.add_document | def add_document(self, doc_url, data):
""" Add the given document to the cache, updating
the existing content data if the document is already present
:type doc_url: String or Document
:param doc_url: the URL of the document, or a Document object
:type data: String
:param... | python | def add_document(self, doc_url, data):
""" Add the given document to the cache, updating
the existing content data if the document is already present
:type doc_url: String or Document
:param doc_url: the URL of the document, or a Document object
:type data: String
:param... | [
"def",
"add_document",
"(",
"self",
",",
"doc_url",
",",
"data",
")",
":",
"file_path",
"=",
"self",
".",
"__generate_filepath",
"(",
")",
"with",
"open",
"(",
"file_path",
",",
"'wb'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"data",
")",
"c",
... | Add the given document to the cache, updating
the existing content data if the document is already present
:type doc_url: String or Document
:param doc_url: the URL of the document, or a Document object
:type data: String
:param data: the document's content data | [
"Add",
"the",
"given",
"document",
"to",
"the",
"cache",
"updating",
"the",
"existing",
"content",
"data",
"if",
"the",
"document",
"is",
"already",
"present"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L329-L355 | train | Adds the given document to the cache updating the existing content data if the document is already present |
Alveo/pyalveo | pyalveo/cache.py | Cache.add_primary_text | def add_primary_text(self, item_url, primary_text):
""" Add the given primary text to the cache database, updating
the existing record if the primary text is already present
:type item_url: String or Item
:param item_url: the URL of the corresponding item, or an Item object
:typ... | python | def add_primary_text(self, item_url, primary_text):
""" Add the given primary text to the cache database, updating
the existing record if the primary text is already present
:type item_url: String or Item
:param item_url: the URL of the corresponding item, or an Item object
:typ... | [
"def",
"add_primary_text",
"(",
"self",
",",
"item_url",
",",
"primary_text",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"DELETE FROM primary_texts WHERE item_url=?\"",
",",
"(",
"str",
"(",
"item_url",
")",... | Add the given primary text to the cache database, updating
the existing record if the primary text is already present
:type item_url: String or Item
:param item_url: the URL of the corresponding item, or an Item object
:type primary_text: String
:param primary_text: the item's p... | [
"Add",
"the",
"given",
"primary",
"text",
"to",
"the",
"cache",
"database",
"updating",
"the",
"existing",
"record",
"if",
"the",
"primary",
"text",
"is",
"already",
"present"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/cache.py#L357-L375 | train | Adds the given primary text to the cache database updating the existing record if the primary text is already present |
cgrok/cr-async | examples/crcog.py | ClashCog.profile | async def profile(self, ctx, tag):
'''Example command for use inside a discord bot cog.'''
if not self.check_valid_tag(tag):
return await ctx.send('Invalid tag!')
profile = await self.cr.get_profile(tag)
em = discord.Embed(color=0x00FFFFF)
em.set_author(name=str(pro... | python | async def profile(self, ctx, tag):
'''Example command for use inside a discord bot cog.'''
if not self.check_valid_tag(tag):
return await ctx.send('Invalid tag!')
profile = await self.cr.get_profile(tag)
em = discord.Embed(color=0x00FFFFF)
em.set_author(name=str(pro... | [
"async",
"def",
"profile",
"(",
"self",
",",
"ctx",
",",
"tag",
")",
":",
"if",
"not",
"self",
".",
"check_valid_tag",
"(",
"tag",
")",
":",
"return",
"await",
"ctx",
".",
"send",
"(",
"'Invalid tag!'",
")",
"profile",
"=",
"await",
"self",
".",
"cr"... | Example command for use inside a discord bot cog. | [
"Example",
"command",
"for",
"use",
"inside",
"a",
"discord",
"bot",
"cog",
"."
] | f65a968e54704168706d137d1ba662f55f8ab852 | https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/examples/crcog.py#L22-L42 | train | Example command for use inside a discord bot cog. |
AtmaHou/atma | Metrics.py | load_dataset_items | def load_dataset_items(test_file, predict_file_lst, nonfeature_file):
"""
This function is used to read 3 kinds of data into list, 3 kinds of data are stored in files given by parameter
:param test_file: path string, the testing set used for SVm rank
:param predict_file_lst: filename lst, all predic... | python | def load_dataset_items(test_file, predict_file_lst, nonfeature_file):
"""
This function is used to read 3 kinds of data into list, 3 kinds of data are stored in files given by parameter
:param test_file: path string, the testing set used for SVm rank
:param predict_file_lst: filename lst, all predic... | [
"def",
"load_dataset_items",
"(",
"test_file",
",",
"predict_file_lst",
",",
"nonfeature_file",
")",
":",
"print",
"'Reading baseline feature & bleu...'",
"with",
"open",
"(",
"test_file",
",",
"'r'",
")",
"as",
"reader",
":",
"for",
"line",
"in",
"reader",
":",
... | This function is used to read 3 kinds of data into list, 3 kinds of data are stored in files given by parameter
:param test_file: path string, the testing set used for SVm rank
:param predict_file_lst: filename lst, all prediction file output by SVM rank
:param nonfeature_file: path string, contain all t... | [
"This",
"function",
"is",
"used",
"to",
"read",
"3",
"kinds",
"of",
"data",
"into",
"list",
"3",
"kinds",
"of",
"data",
"are",
"stored",
"in",
"files",
"given",
"by",
"parameter",
":",
"param",
"test_file",
":",
"path",
"string",
"the",
"testing",
"set",... | 41cd8ea9443a9c3b2dd71432f46f44a0f83093c7 | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L31-L67 | train | This function loads 3 kinds of data into list of 3 kinds of data. |
AtmaHou/atma | Metrics.py | get_item_metric_pair | def get_item_metric_pair(item_lst, metric_lst, id_lst):
"""
align bleu and specific score in item_lst, reconstruct the data as (rank_score, bleu) pairs, query_dic.
Detail:
query dict is input parameter used by metrics: top-x-bleu, kendall-tau
query dict is reconstructed dict type data c... | python | def get_item_metric_pair(item_lst, metric_lst, id_lst):
"""
align bleu and specific score in item_lst, reconstruct the data as (rank_score, bleu) pairs, query_dic.
Detail:
query dict is input parameter used by metrics: top-x-bleu, kendall-tau
query dict is reconstructed dict type data c... | [
"def",
"get_item_metric_pair",
"(",
"item_lst",
",",
"metric_lst",
",",
"id_lst",
")",
":",
"query_dic",
"=",
"{",
"}",
"# key is qid, value is list, whose elements are tuple eg: count of words, bleu score pairs\r",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"metric_... | align bleu and specific score in item_lst, reconstruct the data as (rank_score, bleu) pairs, query_dic.
Detail:
query dict is input parameter used by metrics: top-x-bleu, kendall-tau
query dict is reconstructed dict type data container,
query dict's key is qid and value is list type, who... | [
"align",
"bleu",
"and",
"specific",
"score",
"in",
"item_lst",
"reconstruct",
"the",
"data",
"as",
"(",
"rank_score",
"bleu",
")",
"pairs",
"query_dic",
".",
"Detail",
":",
"query",
"dict",
"is",
"input",
"parameter",
"used",
"by",
"metrics",
":",
"top",
"... | 41cd8ea9443a9c3b2dd71432f46f44a0f83093c7 | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L78-L99 | train | Returns a list of tuples where each element in the list is the score of the item in the list that is used to rank candidates and each element in the list is the score of the item in the list that is used to rank candidates. |
AtmaHou/atma | Metrics.py | top_x_bleu | def top_x_bleu(query_dic, mark, x=1):
"""
Calculate the top x average bleu value predictions ranking by item, x default is set above
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark:string, which indicates which method is evaluat... | python | def top_x_bleu(query_dic, mark, x=1):
"""
Calculate the top x average bleu value predictions ranking by item, x default is set above
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark:string, which indicates which method is evaluat... | [
"def",
"top_x_bleu",
"(",
"query_dic",
",",
"mark",
",",
"x",
"=",
"1",
")",
":",
"all_total",
"=",
"0.0",
"with",
"open",
"(",
"top_bleu_path",
"+",
"mark",
",",
"'w'",
")",
"as",
"writer",
":",
"for",
"k",
"in",
"query_dic",
":",
"candidate_lst",
"... | Calculate the top x average bleu value predictions ranking by item, x default is set above
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark:string, which indicates which method is evaluated, also used as output file name here.
:param ... | [
"Calculate",
"the",
"top",
"x",
"average",
"bleu",
"value",
"predictions",
"ranking",
"by",
"item",
"x",
"default",
"is",
"set",
"above",
":",
"param",
"query_dic",
":",
"dict",
"key",
"is",
"qid",
"value",
"is",
"(",
"item",
"bleu",
")",
"tuple",
"list"... | 41cd8ea9443a9c3b2dd71432f46f44a0f83093c7 | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L102-L130 | train | Calculates the top x average bleu value predictions ranking by item x default is set above |
AtmaHou/atma | Metrics.py | kendall_tau | def kendall_tau(query_dic, mark):
"""
Calculate kendall_tau metric result of a method
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark: string, which indicates which method is evaluated, also used as output file name here.
:... | python | def kendall_tau(query_dic, mark):
"""
Calculate kendall_tau metric result of a method
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark: string, which indicates which method is evaluated, also used as output file name here.
:... | [
"def",
"kendall_tau",
"(",
"query_dic",
",",
"mark",
")",
":",
"total",
"=",
"0.0",
"with",
"open",
"(",
"kendall_tau_path",
"+",
"mark",
",",
"'w'",
")",
"as",
"writer",
":",
"for",
"k",
"in",
"query_dic",
":",
"candidate_lst",
"=",
"query_dic",
"[",
... | Calculate kendall_tau metric result of a method
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark: string, which indicates which method is evaluated, also used as output file name here.
:return: average kendall score | [
"Calculate",
"kendall_tau",
"metric",
"result",
"of",
"a",
"method",
":",
"param",
"query_dic",
":",
"dict",
"key",
"is",
"qid",
"value",
"is",
"(",
"item",
"bleu",
")",
"tuple",
"list",
"which",
"will",
"be",
"ranked",
"by",
"item",
"as",
"key",
":",
... | 41cd8ea9443a9c3b2dd71432f46f44a0f83093c7 | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L152-L171 | train | Calculate kendall_tau metric result of a method
|
AtmaHou/atma | Metrics.py | top_x_meteor | def top_x_meteor(query_dic, mark, x=1):
"""
Calculate METEOR score of the top result
:param query_dic: dict, key is qid, value is (item, meteor) tuple list, which will be ranked by 'item' as key
:param mark: string, which indicates which method is evaluated, also used as output file name here.
... | python | def top_x_meteor(query_dic, mark, x=1):
"""
Calculate METEOR score of the top result
:param query_dic: dict, key is qid, value is (item, meteor) tuple list, which will be ranked by 'item' as key
:param mark: string, which indicates which method is evaluated, also used as output file name here.
... | [
"def",
"top_x_meteor",
"(",
"query_dic",
",",
"mark",
",",
"x",
"=",
"1",
")",
":",
"all_total",
"=",
"0.0",
"with",
"open",
"(",
"top_meteor_path",
"+",
"mark",
",",
"'w'",
")",
"as",
"writer",
":",
"for",
"k",
"in",
"query_dic",
":",
"candidate_lst",... | Calculate METEOR score of the top result
:param query_dic: dict, key is qid, value is (item, meteor) tuple list, which will be ranked by 'item' as key
:param mark: string, which indicates which method is evaluated, also used as output file name here.
:param x: int, define top x
:return: average mete... | [
"Calculate",
"METEOR",
"score",
"of",
"the",
"top",
"result",
":",
"param",
"query_dic",
":",
"dict",
"key",
"is",
"qid",
"value",
"is",
"(",
"item",
"meteor",
")",
"tuple",
"list",
"which",
"will",
"be",
"ranked",
"by",
"item",
"as",
"key",
":",
"para... | 41cd8ea9443a9c3b2dd71432f46f44a0f83093c7 | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L174-L204 | train | Calculates the METEOR score of the top x meteor of the list of items in query_dic |
TUNE-Archive/freight_forwarder | freight_forwarder/commercial_invoice/commercial_invoice.py | CommercialInvoice._create_container_ships | def _create_container_ships(self, hosts):
"""
:param hosts:
:return:
"""
container_ships = {}
if hosts:
if 'default' not in hosts:
default_container_ship = self._create_container_ship(None)
container_ships['default'] = {def... | python | def _create_container_ships(self, hosts):
"""
:param hosts:
:return:
"""
container_ships = {}
if hosts:
if 'default' not in hosts:
default_container_ship = self._create_container_ship(None)
container_ships['default'] = {def... | [
"def",
"_create_container_ships",
"(",
"self",
",",
"hosts",
")",
":",
"container_ships",
"=",
"{",
"}",
"if",
"hosts",
":",
"if",
"'default'",
"not",
"in",
"hosts",
":",
"default_container_ship",
"=",
"self",
".",
"_create_container_ship",
"(",
"None",
")",
... | :param hosts:
:return: | [
":",
"param",
"hosts",
":",
":",
"return",
":"
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/commercial_invoice/commercial_invoice.py#L182-L224 | train | Create a dict of container_ships that will be used to create the container_ships for the given hosts. |
TUNE-Archive/freight_forwarder | freight_forwarder/commercial_invoice/commercial_invoice.py | CommercialInvoice._create_container_ship | def _create_container_ship(self, host_data=None):
"""
# docker env vars. We use them if nothing is supplied.
DOCKER_HOST=fqdn:port
DOCKER_TLS_VERIFY=false
DOCKER_CERT_PATH=/path/
"""
if not host_data:
host_data = {}
path = o... | python | def _create_container_ship(self, host_data=None):
"""
# docker env vars. We use them if nothing is supplied.
DOCKER_HOST=fqdn:port
DOCKER_TLS_VERIFY=false
DOCKER_CERT_PATH=/path/
"""
if not host_data:
host_data = {}
path = o... | [
"def",
"_create_container_ship",
"(",
"self",
",",
"host_data",
"=",
"None",
")",
":",
"if",
"not",
"host_data",
":",
"host_data",
"=",
"{",
"}",
"path",
"=",
"os",
".",
"getenv",
"(",
"'DOCKER_CERT_PATH'",
")",
"host_data",
"[",
"'address'",
"]",
"=",
"... | # docker env vars. We use them if nothing is supplied.
DOCKER_HOST=fqdn:port
DOCKER_TLS_VERIFY=false
DOCKER_CERT_PATH=/path/ | [
"#",
"docker",
"env",
"vars",
".",
"We",
"use",
"them",
"if",
"nothing",
"is",
"supplied",
".",
"DOCKER_HOST",
"=",
"fqdn",
":",
"port",
"DOCKER_TLS_VERIFY",
"=",
"false",
"DOCKER_CERT_PATH",
"=",
"/",
"path",
"/"
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/commercial_invoice/commercial_invoice.py#L226-L262 | train | Create a new container ship object from the given host data. |
Kortemme-Lab/klab | klab/benchmarking/analysis/ddg_binding_affinity_analysis.py | DBBenchmarkRun.get_dataframe_row | def get_dataframe_row(self, dataset_cases, predicted_data, pdb_data, record_id, additional_prediction_data_columns):
'''Create a dataframe row for a prediction.'''
record = dataset_cases[record_id]
for m in record['PDBMutations']:
assert('DSSPSimpleSSType' not in m)
m['DS... | python | def get_dataframe_row(self, dataset_cases, predicted_data, pdb_data, record_id, additional_prediction_data_columns):
'''Create a dataframe row for a prediction.'''
record = dataset_cases[record_id]
for m in record['PDBMutations']:
assert('DSSPSimpleSSType' not in m)
m['DS... | [
"def",
"get_dataframe_row",
"(",
"self",
",",
"dataset_cases",
",",
"predicted_data",
",",
"pdb_data",
",",
"record_id",
",",
"additional_prediction_data_columns",
")",
":",
"record",
"=",
"dataset_cases",
"[",
"record_id",
"]",
"for",
"m",
"in",
"record",
"[",
... | Create a dataframe row for a prediction. | [
"Create",
"a",
"dataframe",
"row",
"for",
"a",
"prediction",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ddg_binding_affinity_analysis.py#L39-L50 | train | Create a dataframe row for a prediction. |
TheGhouls/oct | oct/results/stats_handler.py | init_stats | def init_stats(output_dir, config):
"""Init all required ressources for stats handling
:param str output_dir: the output directory for the results
:param dict config: the project configuration
"""
try:
os.makedirs(output_dir, 0o755)
except OSError as e:
print("ERROR: Can not cre... | python | def init_stats(output_dir, config):
"""Init all required ressources for stats handling
:param str output_dir: the output directory for the results
:param dict config: the project configuration
"""
try:
os.makedirs(output_dir, 0o755)
except OSError as e:
print("ERROR: Can not cre... | [
"def",
"init_stats",
"(",
"output_dir",
",",
"config",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"output_dir",
",",
"0o755",
")",
"except",
"OSError",
"as",
"e",
":",
"print",
"(",
"\"ERROR: Can not create output directory: %s\\n\"",
"%",
"e",
")",
"... | Init all required ressources for stats handling
:param str output_dir: the output directory for the results
:param dict config: the project configuration | [
"Init",
"all",
"required",
"ressources",
"for",
"stats",
"handling",
":",
"param",
"str",
"output_dir",
":",
"the",
"output",
"directory",
"for",
"the",
"results",
":",
"param",
"dict",
"config",
":",
"the",
"project",
"configuration"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/results/stats_handler.py#L8-L27 | train | Initialize all required stats handling
|
TheGhouls/oct | oct/results/stats_handler.py | StatsHandler.write_result | def write_result(self, data):
"""Write the results received to the database
:param dict data: the data to save in database
:return: None
"""
data['custom_timers'] = ujson.dumps(data['custom_timers'])
self.results.append(data)
if len(self.results) >= 150: # 150 r... | python | def write_result(self, data):
"""Write the results received to the database
:param dict data: the data to save in database
:return: None
"""
data['custom_timers'] = ujson.dumps(data['custom_timers'])
self.results.append(data)
if len(self.results) >= 150: # 150 r... | [
"def",
"write_result",
"(",
"self",
",",
"data",
")",
":",
"data",
"[",
"'custom_timers'",
"]",
"=",
"ujson",
".",
"dumps",
"(",
"data",
"[",
"'custom_timers'",
"]",
")",
"self",
".",
"results",
".",
"append",
"(",
"data",
")",
"if",
"len",
"(",
"sel... | Write the results received to the database
:param dict data: the data to save in database
:return: None | [
"Write",
"the",
"results",
"received",
"to",
"the",
"database",
":",
"param",
"dict",
"data",
":",
"the",
"data",
"to",
"save",
"in",
"database",
":",
"return",
":",
"None"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/results/stats_handler.py#L36-L48 | train | Write the results received to the database. |
TheGhouls/oct | oct/results/stats_handler.py | StatsHandler.write_remaining | def write_remaining(self):
"""Write the remaning stack content
"""
if not self.results:
return
with db.execution_context():
with db.atomic():
Result.insert_many(self.results).execute()
del self.results[:] | python | def write_remaining(self):
"""Write the remaning stack content
"""
if not self.results:
return
with db.execution_context():
with db.atomic():
Result.insert_many(self.results).execute()
del self.results[:] | [
"def",
"write_remaining",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"results",
":",
"return",
"with",
"db",
".",
"execution_context",
"(",
")",
":",
"with",
"db",
".",
"atomic",
"(",
")",
":",
"Result",
".",
"insert_many",
"(",
"self",
".",
"r... | Write the remaning stack content | [
"Write",
"the",
"remaning",
"stack",
"content"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/results/stats_handler.py#L50-L58 | train | Write the remaining content to the database. |
TheGhouls/oct | oct/utilities/configuration.py | configure | def configure(project_path, config_file=None):
"""Get the configuration of the test and return it as a config object
:return: the configured config object
:rtype: Object
"""
if config_file is None:
config_file = os.path.join(project_path, 'config.json')
try:
with open(config_fil... | python | def configure(project_path, config_file=None):
"""Get the configuration of the test and return it as a config object
:return: the configured config object
:rtype: Object
"""
if config_file is None:
config_file = os.path.join(project_path, 'config.json')
try:
with open(config_fil... | [
"def",
"configure",
"(",
"project_path",
",",
"config_file",
"=",
"None",
")",
":",
"if",
"config_file",
"is",
"None",
":",
"config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_path",
",",
"'config.json'",
")",
"try",
":",
"with",
"open",
"(... | Get the configuration of the test and return it as a config object
:return: the configured config object
:rtype: Object | [
"Get",
"the",
"configuration",
"of",
"the",
"test",
"and",
"return",
"it",
"as",
"a",
"config",
"object"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/configuration.py#L27-L43 | train | Get the configuration of the test and return it as a config object |
TheGhouls/oct | oct/utilities/configuration.py | configure_for_turret | def configure_for_turret(project_name, config_file):
"""Load the configuration file in python dict and check for keys that will be set to default value if not present
:param str project_name: the name of the project
:param str config_file: the path of the configuration file
:return: the loaded configur... | python | def configure_for_turret(project_name, config_file):
"""Load the configuration file in python dict and check for keys that will be set to default value if not present
:param str project_name: the name of the project
:param str config_file: the path of the configuration file
:return: the loaded configur... | [
"def",
"configure_for_turret",
"(",
"project_name",
",",
"config_file",
")",
":",
"config",
"=",
"configure",
"(",
"project_name",
",",
"config_file",
")",
"for",
"key",
"in",
"WARNING_CONFIG_KEYS",
":",
"if",
"key",
"not",
"in",
"config",
":",
"print",
"(",
... | Load the configuration file in python dict and check for keys that will be set to default value if not present
:param str project_name: the name of the project
:param str config_file: the path of the configuration file
:return: the loaded configuration
:rtype: dict | [
"Load",
"the",
"configuration",
"file",
"in",
"python",
"dict",
"and",
"check",
"for",
"keys",
"that",
"will",
"be",
"set",
"to",
"default",
"value",
"if",
"not",
"present"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/configuration.py#L56-L81 | train | Load the configuration file and check for keys that will be set to default value if not present |
TheGhouls/oct | oct/utilities/configuration.py | get_db_uri | def get_db_uri(config, output_dir):
"""Process results_database parameters in config to format them for
set database function
:param dict config: project configuration dict
:param str output_dir: output directory for results
:return: string for db uri
"""
db_config = config.get("results_dat... | python | def get_db_uri(config, output_dir):
"""Process results_database parameters in config to format them for
set database function
:param dict config: project configuration dict
:param str output_dir: output directory for results
:return: string for db uri
"""
db_config = config.get("results_dat... | [
"def",
"get_db_uri",
"(",
"config",
",",
"output_dir",
")",
":",
"db_config",
"=",
"config",
".",
"get",
"(",
"\"results_database\"",
",",
"{",
"\"db_uri\"",
":",
"\"default\"",
"}",
")",
"if",
"db_config",
"[",
"'db_uri'",
"]",
"==",
"'default'",
":",
"re... | Process results_database parameters in config to format them for
set database function
:param dict config: project configuration dict
:param str output_dir: output directory for results
:return: string for db uri | [
"Process",
"results_database",
"parameters",
"in",
"config",
"to",
"format",
"them",
"for",
"set",
"database",
"function"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/configuration.py#L98-L109 | train | Process results_database parameters in config to format them for
set database |
ethan92429/onshapepy | onshapepy/document.py | Document.update | def update(self):
"""All client calls to update this instance with Onshape."""
self.json = c.get_document(self.uri.did).json()
self.e_list = c.element_list(self.uri.as_dict()).json() | python | def update(self):
"""All client calls to update this instance with Onshape."""
self.json = c.get_document(self.uri.did).json()
self.e_list = c.element_list(self.uri.as_dict()).json() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"json",
"=",
"c",
".",
"get_document",
"(",
"self",
".",
"uri",
".",
"did",
")",
".",
"json",
"(",
")",
"self",
".",
"e_list",
"=",
"c",
".",
"element_list",
"(",
"self",
".",
"uri",
".",
"as... | All client calls to update this instance with Onshape. | [
"All",
"client",
"calls",
"to",
"update",
"this",
"instance",
"with",
"Onshape",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/document.py#L54-L57 | train | All client calls to update this instance with Onshape. |
ethan92429/onshapepy | onshapepy/document.py | Document.find_element | def find_element(self, name, type=ElementType.ANY):
"""Find an elemnent in the document with the given name - could be a PartStudio, Assembly or blob.
Args:
name: str
the name of the element.
Returns:
- onshapepy.uri of the element
"""
f... | python | def find_element(self, name, type=ElementType.ANY):
"""Find an elemnent in the document with the given name - could be a PartStudio, Assembly or blob.
Args:
name: str
the name of the element.
Returns:
- onshapepy.uri of the element
"""
f... | [
"def",
"find_element",
"(",
"self",
",",
"name",
",",
"type",
"=",
"ElementType",
".",
"ANY",
")",
":",
"for",
"e",
"in",
"self",
".",
"e_list",
":",
"# if a type is specified and this isn't it, move to the next loop.",
"if",
"type",
".",
"value",
"and",
"not",
... | Find an elemnent in the document with the given name - could be a PartStudio, Assembly or blob.
Args:
name: str
the name of the element.
Returns:
- onshapepy.uri of the element | [
"Find",
"an",
"elemnent",
"in",
"the",
"document",
"with",
"the",
"given",
"name",
"-",
"could",
"be",
"a",
"PartStudio",
"Assembly",
"or",
"blob",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/document.py#L63-L81 | train | Find an element in the document with the given name. |
DsixTools/python-smeftrunner | smeftrunner/beta.py | beta | def beta(C, HIGHSCALE, newphys=True):
"""Return the beta functions of all SM parameters and SMEFT Wilson
coefficients."""
g = C["g"]
gp = C["gp"]
gs = C["gs"]
m2 = C["m2"]
Lambda = C["Lambda"]
Gu = C["Gu"]
Gd = C["Gd"]
Ge = C["Ge"]
Eta1 = (3*np.trace(C["uphi"] @ Gu.conj().... | python | def beta(C, HIGHSCALE, newphys=True):
"""Return the beta functions of all SM parameters and SMEFT Wilson
coefficients."""
g = C["g"]
gp = C["gp"]
gs = C["gs"]
m2 = C["m2"]
Lambda = C["Lambda"]
Gu = C["Gu"]
Gd = C["Gd"]
Ge = C["Ge"]
Eta1 = (3*np.trace(C["uphi"] @ Gu.conj().... | [
"def",
"beta",
"(",
"C",
",",
"HIGHSCALE",
",",
"newphys",
"=",
"True",
")",
":",
"g",
"=",
"C",
"[",
"\"g\"",
"]",
"gp",
"=",
"C",
"[",
"\"gp\"",
"]",
"gs",
"=",
"C",
"[",
"\"gs\"",
"]",
"m2",
"=",
"C",
"[",
"\"m2\"",
"]",
"Lambda",
"=",
"... | Return the beta functions of all SM parameters and SMEFT Wilson
coefficients. | [
"Return",
"the",
"beta",
"functions",
"of",
"all",
"SM",
"parameters",
"and",
"SMEFT",
"Wilson",
"coefficients",
"."
] | 4c9130e53ad4f7bbb526657a82150ca9d57c4b37 | https://github.com/DsixTools/python-smeftrunner/blob/4c9130e53ad4f7bbb526657a82150ca9d57c4b37/smeftrunner/beta.py#L36-L1821 | train | Returns the beta functions of all SM parameters and SMEFT Wilson
coefficients. |
DsixTools/python-smeftrunner | smeftrunner/beta.py | beta_array | def beta_array(C, HIGHSCALE, *args, **kwargs):
"""Return the beta functions of all SM parameters and SMEFT Wilson
coefficients as a 1D numpy array."""
beta_odict = beta(C, HIGHSCALE, *args, **kwargs)
return np.hstack([np.asarray(b).ravel() for b in beta_odict.values()]) | python | def beta_array(C, HIGHSCALE, *args, **kwargs):
"""Return the beta functions of all SM parameters and SMEFT Wilson
coefficients as a 1D numpy array."""
beta_odict = beta(C, HIGHSCALE, *args, **kwargs)
return np.hstack([np.asarray(b).ravel() for b in beta_odict.values()]) | [
"def",
"beta_array",
"(",
"C",
",",
"HIGHSCALE",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"beta_odict",
"=",
"beta",
"(",
"C",
",",
"HIGHSCALE",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"np",
".",
"hstack",
"(",
"[",
... | Return the beta functions of all SM parameters and SMEFT Wilson
coefficients as a 1D numpy array. | [
"Return",
"the",
"beta",
"functions",
"of",
"all",
"SM",
"parameters",
"and",
"SMEFT",
"Wilson",
"coefficients",
"as",
"a",
"1D",
"numpy",
"array",
"."
] | 4c9130e53ad4f7bbb526657a82150ca9d57c4b37 | https://github.com/DsixTools/python-smeftrunner/blob/4c9130e53ad4f7bbb526657a82150ca9d57c4b37/smeftrunner/beta.py#L1823-L1827 | train | Return the beta functions of all SM parameters and SMEFT Wilson
coefficients as a 1D numpy array. |
peergradeio/flask-mongo-profiler | flask_mongo_profiler/contrib/flask_admin/views/base.py | RelationalSearchMixin._search | def _search(self, query, search_term):
"""
Improved search between words.
The original _search for MongoEngine dates back to November 12th, 2013 [1]_.
In this ref it's stated that there is a bug with complex Q queries preventing
multi-word searches. During this time, the MongoEn... | python | def _search(self, query, search_term):
"""
Improved search between words.
The original _search for MongoEngine dates back to November 12th, 2013 [1]_.
In this ref it's stated that there is a bug with complex Q queries preventing
multi-word searches. During this time, the MongoEn... | [
"def",
"_search",
"(",
"self",
",",
"query",
",",
"search_term",
")",
":",
"criterias",
"=",
"mongoengine",
".",
"Q",
"(",
")",
"rel_criterias",
"=",
"mongoengine",
".",
"Q",
"(",
")",
"terms",
"=",
"shlex",
".",
"split",
"(",
"search_term",
")",
"# If... | Improved search between words.
The original _search for MongoEngine dates back to November 12th, 2013 [1]_.
In this ref it's stated that there is a bug with complex Q queries preventing
multi-word searches. During this time, the MongoEngine version was earlier than
0.4 (predating PyPI) ... | [
"Improved",
"search",
"between",
"words",
"."
] | a267eeb49fea07c9a24fb370bd9d7a90ed313ccf | https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/contrib/flask_admin/views/base.py#L114-L195 | train | Search between words and returns a QuerySet containing the set of entries that match the search_term. |
DavidDoukhan/py_sonicvisualiser | py_sonicvisualiser/SVDataset.py | SVDataset2D.set_data_from_iterable | def set_data_from_iterable(self, frames, values, labels=None):
"""
Initialize a dataset structure from iterable parameters
:param x: The temporal indices of the dataset
:param y: The values of the dataset
:type x: iterable
:type y: iterable
"""
if not isi... | python | def set_data_from_iterable(self, frames, values, labels=None):
"""
Initialize a dataset structure from iterable parameters
:param x: The temporal indices of the dataset
:param y: The values of the dataset
:type x: iterable
:type y: iterable
"""
if not isi... | [
"def",
"set_data_from_iterable",
"(",
"self",
",",
"frames",
",",
"values",
",",
"labels",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"frames",
",",
"collections",
".",
"Iterable",
")",
":",
"raise",
"TypeError",
",",
"\"frames must be an iterable\... | Initialize a dataset structure from iterable parameters
:param x: The temporal indices of the dataset
:param y: The values of the dataset
:type x: iterable
:type y: iterable | [
"Initialize",
"a",
"dataset",
"structure",
"from",
"iterable",
"parameters"
] | ebe83bd7dffb0275393255dcbcc6671cf0ade4a5 | https://github.com/DavidDoukhan/py_sonicvisualiser/blob/ebe83bd7dffb0275393255dcbcc6671cf0ade4a5/py_sonicvisualiser/SVDataset.py#L50-L77 | train | Initialize a dataset structure from iterable parameters. |
DavidDoukhan/py_sonicvisualiser | py_sonicvisualiser/SVDataset.py | SVDataset2D.writexml | def writexml(self, writer, indent="", addindent="", newl=""):
"""
Write the continuous dataset using sonic visualiser xml conventions
"""
# dataset = self.data.appendChild(self.doc.createElement('dataset'))
# dataset.setAttribute('id', str(imodel))
# dataset.setAttribute... | python | def writexml(self, writer, indent="", addindent="", newl=""):
"""
Write the continuous dataset using sonic visualiser xml conventions
"""
# dataset = self.data.appendChild(self.doc.createElement('dataset'))
# dataset.setAttribute('id', str(imodel))
# dataset.setAttribute... | [
"def",
"writexml",
"(",
"self",
",",
"writer",
",",
"indent",
"=",
"\"\"",
",",
"addindent",
"=",
"\"\"",
",",
"newl",
"=",
"\"\"",
")",
":",
"# dataset = self.data.appendChild(self.doc.createElement('dataset'))",
"# dataset.setAttribute('id', str(imodel))",
"# dataset.se... | Write the continuous dataset using sonic visualiser xml conventions | [
"Write",
"the",
"continuous",
"dataset",
"using",
"sonic",
"visualiser",
"xml",
"conventions"
] | ebe83bd7dffb0275393255dcbcc6671cf0ade4a5 | https://github.com/DavidDoukhan/py_sonicvisualiser/blob/ebe83bd7dffb0275393255dcbcc6671cf0ade4a5/py_sonicvisualiser/SVDataset.py#L89-L100 | train | Writes the continuous dataset using sonic visualiser xml conventions
|
kata198/QueryableList | QueryableList/__init__.py | QueryableListMixed._get_item_value | def _get_item_value(item, fieldName):
'''
_get_item_value - Returns the value of a given field on #item, using either dict style (e.x. x['a']) aka __getitem__ access if possible,
otherwise attribute access (aka implements __getattribute__).
This allows you to pass a mix ... | python | def _get_item_value(item, fieldName):
'''
_get_item_value - Returns the value of a given field on #item, using either dict style (e.x. x['a']) aka __getitem__ access if possible,
otherwise attribute access (aka implements __getattribute__).
This allows you to pass a mix ... | [
"def",
"_get_item_value",
"(",
"item",
",",
"fieldName",
")",
":",
"if",
"hasattr",
"(",
"item",
",",
"'__getitem__'",
")",
":",
"return",
"QueryableListDicts",
".",
"_get_item_value",
"(",
"item",
",",
"fieldName",
")",
"return",
"QueryableListObjs",
".",
"_g... | _get_item_value - Returns the value of a given field on #item, using either dict style (e.x. x['a']) aka __getitem__ access if possible,
otherwise attribute access (aka implements __getattribute__).
This allows you to pass a mix of object types, or objects and dicts, in the same collection.... | [
"_get_item_value",
"-",
"Returns",
"the",
"value",
"of",
"a",
"given",
"field",
"on",
"#item",
"using",
"either",
"dict",
"style",
"(",
"e",
".",
"x",
".",
"x",
"[",
"a",
"]",
")",
"aka",
"__getitem__",
"access",
"if",
"possible",
"otherwise",
"attribute... | 279286d46205ce8268af42e03b75820a7483fddb | https://github.com/kata198/QueryableList/blob/279286d46205ce8268af42e03b75820a7483fddb/QueryableList/__init__.py#L87-L105 | train | Internal function that returns the value of a given field on an item. |
assamite/creamas | creamas/math.py | gaus_pdf | def gaus_pdf(x, mean, std):
'''Gaussian distribution's probability density function.
See, e.g. `Wikipedia <https://en.wikipedia.org/wiki/Normal_distribution>`_.
:param x: point in x-axis
:type x: float or numpy.ndarray
:param float mean: mean or expectation
:param float str: standard deviation... | python | def gaus_pdf(x, mean, std):
'''Gaussian distribution's probability density function.
See, e.g. `Wikipedia <https://en.wikipedia.org/wiki/Normal_distribution>`_.
:param x: point in x-axis
:type x: float or numpy.ndarray
:param float mean: mean or expectation
:param float str: standard deviation... | [
"def",
"gaus_pdf",
"(",
"x",
",",
"mean",
",",
"std",
")",
":",
"return",
"exp",
"(",
"-",
"(",
"(",
"x",
"-",
"mean",
")",
"/",
"std",
")",
"**",
"2",
"/",
"2",
")",
"/",
"sqrt",
"(",
"2",
"*",
"pi",
")",
"/",
"std"
] | Gaussian distribution's probability density function.
See, e.g. `Wikipedia <https://en.wikipedia.org/wiki/Normal_distribution>`_.
:param x: point in x-axis
:type x: float or numpy.ndarray
:param float mean: mean or expectation
:param float str: standard deviation
:returns: pdf(s) in point **x*... | [
"Gaussian",
"distribution",
"s",
"probability",
"density",
"function",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/math.py#L10-L22 | train | Gaussian distribution s probability density function. |
assamite/creamas | creamas/math.py | logistic | def logistic(x, x0, k, L):
'''Logistic function.
See, e.g `Wikipedia <https://en.wikipedia.org/wiki/Logistic_function>`_.
:param x: point in x-axis
:type x: float or numpy.ndarray
:param float x0: sigmoid's midpoint
:param float k: steepness of the curve
:param float L: maximum value of th... | python | def logistic(x, x0, k, L):
'''Logistic function.
See, e.g `Wikipedia <https://en.wikipedia.org/wiki/Logistic_function>`_.
:param x: point in x-axis
:type x: float or numpy.ndarray
:param float x0: sigmoid's midpoint
:param float k: steepness of the curve
:param float L: maximum value of th... | [
"def",
"logistic",
"(",
"x",
",",
"x0",
",",
"k",
",",
"L",
")",
":",
"return",
"L",
"/",
"(",
"1",
"+",
"exp",
"(",
"-",
"k",
"*",
"(",
"x",
"-",
"x0",
")",
")",
")"
] | Logistic function.
See, e.g `Wikipedia <https://en.wikipedia.org/wiki/Logistic_function>`_.
:param x: point in x-axis
:type x: float or numpy.ndarray
:param float x0: sigmoid's midpoint
:param float k: steepness of the curve
:param float L: maximum value of the curve
:returns: function's v... | [
"Logistic",
"function",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/math.py#L25-L38 | train | Logistic function. |
assamite/creamas | creamas/examples/grid/grid_node.py | create_grid_menv | def create_grid_menv(addr, slave_addrs, grid_size, origin, logger=logger,
extra_ser=None):
'''
:param addr: Address of the multi-environment
:param slave_addrs: Addresses for the slave environments.
:param tuple grid_size: Grid size for each slave environment, e.g. (4, 4)
:param... | python | def create_grid_menv(addr, slave_addrs, grid_size, origin, logger=logger,
extra_ser=None):
'''
:param addr: Address of the multi-environment
:param slave_addrs: Addresses for the slave environments.
:param tuple grid_size: Grid size for each slave environment, e.g. (4, 4)
:param... | [
"def",
"create_grid_menv",
"(",
"addr",
",",
"slave_addrs",
",",
"grid_size",
",",
"origin",
",",
"logger",
"=",
"logger",
",",
"extra_ser",
"=",
"None",
")",
":",
"env_kwargs",
"=",
"{",
"'codec'",
":",
"aiomas",
".",
"MsgPack",
",",
"'extra_serializers'",
... | :param addr: Address of the multi-environment
:param slave_addrs: Addresses for the slave environments.
:param tuple grid_size: Grid size for each slave environment, e.g. (4, 4)
:param origin:
Origin of the multi-environment (slave envs are stacked horizontally).
:param logger:
Root log... | [
":",
"param",
"addr",
":",
"Address",
"of",
"the",
"multi",
"-",
"environment",
":",
"param",
"slave_addrs",
":",
"Addresses",
"for",
"the",
"slave",
"environments",
".",
":",
"param",
"tuple",
"grid_size",
":",
"Grid",
"size",
"for",
"each",
"slave",
"env... | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/grid/grid_node.py#L35-L67 | train | Creates a multi - environment with the given addresses and grid size. |
assamite/creamas | creamas/examples/grid/grid_node.py | populate_menv | def populate_menv(menv, agent_cls_name, log_folder):
'''Populate given multiprocessing grid environment with agents.
:param menv: Instance of :py:class:`GridMultiEnvironment`
:param str agent_cls_name: Name of the agent class, e.g. 'grip_mp:GridAgent'
:param str log_folder: Root logging folder for the ... | python | def populate_menv(menv, agent_cls_name, log_folder):
'''Populate given multiprocessing grid environment with agents.
:param menv: Instance of :py:class:`GridMultiEnvironment`
:param str agent_cls_name: Name of the agent class, e.g. 'grip_mp:GridAgent'
:param str log_folder: Root logging folder for the ... | [
"def",
"populate_menv",
"(",
"menv",
",",
"agent_cls_name",
",",
"log_folder",
")",
":",
"gs",
"=",
"menv",
".",
"gs",
"n_agents",
"=",
"gs",
"[",
"0",
"]",
"*",
"gs",
"[",
"1",
"]",
"n_slaves",
"=",
"len",
"(",
"menv",
".",
"addrs",
")",
"logger",... | Populate given multiprocessing grid environment with agents.
:param menv: Instance of :py:class:`GridMultiEnvironment`
:param str agent_cls_name: Name of the agent class, e.g. 'grip_mp:GridAgent'
:param str log_folder: Root logging folder for the agents. | [
"Populate",
"given",
"multiprocessing",
"grid",
"environment",
"with",
"agents",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/grid/grid_node.py#L70-L82 | train | Populate given multiprocessing grid environment with agents. |
assamite/creamas | creamas/examples/grid/grid_node.py | get_slave_addrs | def get_slave_addrs(mgr_addr, N):
'''Get ports for the slave environments.
Currently the ports are not checked for availability.
'''
return [(HOST, p) for p in range(mgr_addr+1, mgr_addr+1+N)] | python | def get_slave_addrs(mgr_addr, N):
'''Get ports for the slave environments.
Currently the ports are not checked for availability.
'''
return [(HOST, p) for p in range(mgr_addr+1, mgr_addr+1+N)] | [
"def",
"get_slave_addrs",
"(",
"mgr_addr",
",",
"N",
")",
":",
"return",
"[",
"(",
"HOST",
",",
"p",
")",
"for",
"p",
"in",
"range",
"(",
"mgr_addr",
"+",
"1",
",",
"mgr_addr",
"+",
"1",
"+",
"N",
")",
"]"
] | Get ports for the slave environments.
Currently the ports are not checked for availability. | [
"Get",
"ports",
"for",
"the",
"slave",
"environments",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/grid/grid_node.py#L85-L90 | train | Get ports for the slave environments. |
assamite/creamas | creamas/rules/rule.py | weighted_average | def weighted_average(rule, artifact):
"""Evaluate artifact's value to be weighted average of values returned by
rule's subrules.
"""
e = 0
w = 0
for i in range(len(rule.R)):
r = rule.R[i](artifact)
if r is not None:
e += r * rule.W[i]
w += abs(rule.W[i])
... | python | def weighted_average(rule, artifact):
"""Evaluate artifact's value to be weighted average of values returned by
rule's subrules.
"""
e = 0
w = 0
for i in range(len(rule.R)):
r = rule.R[i](artifact)
if r is not None:
e += r * rule.W[i]
w += abs(rule.W[i])
... | [
"def",
"weighted_average",
"(",
"rule",
",",
"artifact",
")",
":",
"e",
"=",
"0",
"w",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"rule",
".",
"R",
")",
")",
":",
"r",
"=",
"rule",
".",
"R",
"[",
"i",
"]",
"(",
"artifact",
")",
"... | Evaluate artifact's value to be weighted average of values returned by
rule's subrules. | [
"Evaluate",
"artifact",
"s",
"value",
"to",
"be",
"weighted",
"average",
"of",
"values",
"returned",
"by",
"rule",
"s",
"subrules",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/rules/rule.py#L207-L220 | train | Evaluate artifact s value to be weighted average of values returned by
rule s subrules. |
assamite/creamas | creamas/rules/rule.py | minimum | def minimum(rule, artifact):
"""Evaluate artifact's value to be minimum of values returned by rule's
subrules.
This evaluation function ignores subrule weights.
"""
m = 1.0
for i in range(len(rule.R)):
e = rule.R[i](artifact)
if e is not None:
if e < m:
... | python | def minimum(rule, artifact):
"""Evaluate artifact's value to be minimum of values returned by rule's
subrules.
This evaluation function ignores subrule weights.
"""
m = 1.0
for i in range(len(rule.R)):
e = rule.R[i](artifact)
if e is not None:
if e < m:
... | [
"def",
"minimum",
"(",
"rule",
",",
"artifact",
")",
":",
"m",
"=",
"1.0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"rule",
".",
"R",
")",
")",
":",
"e",
"=",
"rule",
".",
"R",
"[",
"i",
"]",
"(",
"artifact",
")",
"if",
"e",
"is",
"not",... | Evaluate artifact's value to be minimum of values returned by rule's
subrules.
This evaluation function ignores subrule weights. | [
"Evaluate",
"artifact",
"s",
"value",
"to",
"be",
"minimum",
"of",
"values",
"returned",
"by",
"rule",
"s",
"subrules",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/rules/rule.py#L223-L235 | train | Evaluate artifact s value to be minimum of values returned by rule s
subrules. This evaluation function ignores subrule weights. |
assamite/creamas | creamas/rules/rule.py | Rule.add_subrule | def add_subrule(self, subrule, weight):
"""Add subrule to the rule.
:param subrule:
Subrule to add to this rule, an instance of :class:`Rule` or
:class:`RuleLeaf`.
:param float weight: Weight of the subrule
"""
if not issubclass(subrule.__class__, (Rule,... | python | def add_subrule(self, subrule, weight):
"""Add subrule to the rule.
:param subrule:
Subrule to add to this rule, an instance of :class:`Rule` or
:class:`RuleLeaf`.
:param float weight: Weight of the subrule
"""
if not issubclass(subrule.__class__, (Rule,... | [
"def",
"add_subrule",
"(",
"self",
",",
"subrule",
",",
"weight",
")",
":",
"if",
"not",
"issubclass",
"(",
"subrule",
".",
"__class__",
",",
"(",
"Rule",
",",
"RuleLeaf",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"Rule's class must be (subclass of) {} or {}... | Add subrule to the rule.
:param subrule:
Subrule to add to this rule, an instance of :class:`Rule` or
:class:`RuleLeaf`.
:param float weight: Weight of the subrule | [
"Add",
"subrule",
"to",
"the",
"rule",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/rules/rule.py#L153-L167 | train | Add a subrule to the rule. |
uogbuji/versa | tools/py/writer/csv.py | omap | def omap(m):
'''
Create a nested mapping from origin to property to values/attributes covering an entire Versa model
'''
om = {}
for s, p, o, a in m.match():
om.setdefault(s, {})
om[s].setdefault(p, []).append((o, a))
return om | python | def omap(m):
'''
Create a nested mapping from origin to property to values/attributes covering an entire Versa model
'''
om = {}
for s, p, o, a in m.match():
om.setdefault(s, {})
om[s].setdefault(p, []).append((o, a))
return om | [
"def",
"omap",
"(",
"m",
")",
":",
"om",
"=",
"{",
"}",
"for",
"s",
",",
"p",
",",
"o",
",",
"a",
"in",
"m",
".",
"match",
"(",
")",
":",
"om",
".",
"setdefault",
"(",
"s",
",",
"{",
"}",
")",
"om",
"[",
"s",
"]",
".",
"setdefault",
"("... | Create a nested mapping from origin to property to values/attributes covering an entire Versa model | [
"Create",
"a",
"nested",
"mapping",
"from",
"origin",
"to",
"property",
"to",
"values",
"/",
"attributes",
"covering",
"an",
"entire",
"Versa",
"model"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/writer/csv.py#L25-L33 | train | Create a nested mapping from origin to property to values / attributes covering an entire Versa model |
uogbuji/versa | tools/py/writer/csv.py | write | def write(models, csvout, rulelist, write_header, base=None, logger=logging):
'''
models - one or more input Versa models from which output is generated.
'''
properties = [ k for (k, v) in rulelist ]
numprops = len(properties)
headers = [ v for (k, v) in rulelist ]
if write_header:
c... | python | def write(models, csvout, rulelist, write_header, base=None, logger=logging):
'''
models - one or more input Versa models from which output is generated.
'''
properties = [ k for (k, v) in rulelist ]
numprops = len(properties)
headers = [ v for (k, v) in rulelist ]
if write_header:
c... | [
"def",
"write",
"(",
"models",
",",
"csvout",
",",
"rulelist",
",",
"write_header",
",",
"base",
"=",
"None",
",",
"logger",
"=",
"logging",
")",
":",
"properties",
"=",
"[",
"k",
"for",
"(",
"k",
",",
"v",
")",
"in",
"rulelist",
"]",
"numprops",
"... | models - one or more input Versa models from which output is generated. | [
"models",
"-",
"one",
"or",
"more",
"input",
"Versa",
"models",
"from",
"which",
"output",
"is",
"generated",
"."
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/writer/csv.py#L36-L62 | train | Writes a list of Versa models to CSV. |
Kortemme-Lab/klab | klab/chainsequence.py | ChainSequences.parse_seqres | def parse_seqres(self, pdb):
"""Parse the SEQRES entries into the object"""
seqresre = re.compile("SEQRES")
seqreslines = [line for line in pdb.lines if seqresre.match(line)]
for line in seqreslines:
chain = line[11]
resnames = line[19:70].strip()
self.setdefault(chain, ... | python | def parse_seqres(self, pdb):
"""Parse the SEQRES entries into the object"""
seqresre = re.compile("SEQRES")
seqreslines = [line for line in pdb.lines if seqresre.match(line)]
for line in seqreslines:
chain = line[11]
resnames = line[19:70].strip()
self.setdefault(chain, ... | [
"def",
"parse_seqres",
"(",
"self",
",",
"pdb",
")",
":",
"seqresre",
"=",
"re",
".",
"compile",
"(",
"\"SEQRES\"",
")",
"seqreslines",
"=",
"[",
"line",
"for",
"line",
"in",
"pdb",
".",
"lines",
"if",
"seqresre",
".",
"match",
"(",
"line",
")",
"]",... | Parse the SEQRES entries into the object | [
"Parse",
"the",
"SEQRES",
"entries",
"into",
"the",
"object"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/chainsequence.py#L44-L55 | train | Parse the SEQRES lines into the object |
Kortemme-Lab/klab | klab/chainsequence.py | ChainSequences.parse_atoms | def parse_atoms(self, pdb):
"""Parse the ATOM entries into the object"""
atomre = re.compile("ATOM")
atomlines = [line for line in pdb.lines if atomre.match(line)]
chainresnums = {}
for line in atomlines:
chain = line[21]
resname = line[17:20]
resnum = line[22:2... | python | def parse_atoms(self, pdb):
"""Parse the ATOM entries into the object"""
atomre = re.compile("ATOM")
atomlines = [line for line in pdb.lines if atomre.match(line)]
chainresnums = {}
for line in atomlines:
chain = line[21]
resname = line[17:20]
resnum = line[22:2... | [
"def",
"parse_atoms",
"(",
"self",
",",
"pdb",
")",
":",
"atomre",
"=",
"re",
".",
"compile",
"(",
"\"ATOM\"",
")",
"atomlines",
"=",
"[",
"line",
"for",
"line",
"in",
"pdb",
".",
"lines",
"if",
"atomre",
".",
"match",
"(",
"line",
")",
"]",
"chain... | Parse the ATOM entries into the object | [
"Parse",
"the",
"ATOM",
"entries",
"into",
"the",
"object"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/chainsequence.py#L57-L81 | train | Parse the ATOM entries into the object |
Kortemme-Lab/klab | klab/chainsequence.py | ChainSequences.seqres_lines | def seqres_lines(self):
"""Generate SEQRES lines representing the contents"""
lines = []
for chain in self.keys():
seq = self[chain]
serNum = 1
startidx = 0
while startidx < len(seq):
endidx = min(startidx+13, len(seq))
lines += ["SEQRES %2i %s %4i %s\n" % (se... | python | def seqres_lines(self):
"""Generate SEQRES lines representing the contents"""
lines = []
for chain in self.keys():
seq = self[chain]
serNum = 1
startidx = 0
while startidx < len(seq):
endidx = min(startidx+13, len(seq))
lines += ["SEQRES %2i %s %4i %s\n" % (se... | [
"def",
"seqres_lines",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"chain",
"in",
"self",
".",
"keys",
"(",
")",
":",
"seq",
"=",
"self",
"[",
"chain",
"]",
"serNum",
"=",
"1",
"startidx",
"=",
"0",
"while",
"startidx",
"<",
"len",
"(",... | Generate SEQRES lines representing the contents | [
"Generate",
"SEQRES",
"lines",
"representing",
"the",
"contents"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/chainsequence.py#L83-L98 | train | Generate SEQRES lines representing the contents of the sequence |
Kortemme-Lab/klab | klab/chainsequence.py | ChainSequences.replace_seqres | def replace_seqres(self, pdb, update_atoms = True):
"""Replace SEQRES lines with a new sequence, optionally removing
mutated sidechains"""
newpdb = PDB()
inserted_seqres = False
entries_before_seqres = set(["HEADER", "OBSLTE", "TITLE", "CAVEAT", "COMPND", "SOURCE",
... | python | def replace_seqres(self, pdb, update_atoms = True):
"""Replace SEQRES lines with a new sequence, optionally removing
mutated sidechains"""
newpdb = PDB()
inserted_seqres = False
entries_before_seqres = set(["HEADER", "OBSLTE", "TITLE", "CAVEAT", "COMPND", "SOURCE",
... | [
"def",
"replace_seqres",
"(",
"self",
",",
"pdb",
",",
"update_atoms",
"=",
"True",
")",
":",
"newpdb",
"=",
"PDB",
"(",
")",
"inserted_seqres",
"=",
"False",
"entries_before_seqres",
"=",
"set",
"(",
"[",
"\"HEADER\"",
",",
"\"OBSLTE\"",
",",
"\"TITLE\"",
... | Replace SEQRES lines with a new sequence, optionally removing
mutated sidechains | [
"Replace",
"SEQRES",
"lines",
"with",
"a",
"new",
"sequence",
"optionally",
"removing",
"mutated",
"sidechains"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/chainsequence.py#L100-L145 | train | Replace SEQRES lines with a new sequence. |
brunato/lograptor | lograptor/matcher.py | has_host_match | def has_host_match(log_data, hosts):
"""
Match the data with a list of hostname patterns. If the log line data
doesn't include host information considers the line as matched.
"""
hostname = getattr(log_data, 'host', None)
if hostname and hostname not in host_cache:
for host_pattern in ho... | python | def has_host_match(log_data, hosts):
"""
Match the data with a list of hostname patterns. If the log line data
doesn't include host information considers the line as matched.
"""
hostname = getattr(log_data, 'host', None)
if hostname and hostname not in host_cache:
for host_pattern in ho... | [
"def",
"has_host_match",
"(",
"log_data",
",",
"hosts",
")",
":",
"hostname",
"=",
"getattr",
"(",
"log_data",
",",
"'host'",
",",
"None",
")",
"if",
"hostname",
"and",
"hostname",
"not",
"in",
"host_cache",
":",
"for",
"host_pattern",
"in",
"hosts",
":",
... | Match the data with a list of hostname patterns. If the log line data
doesn't include host information considers the line as matched. | [
"Match",
"the",
"data",
"with",
"a",
"list",
"of",
"hostname",
"patterns",
".",
"If",
"the",
"log",
"line",
"data",
"doesn",
"t",
"include",
"host",
"information",
"considers",
"the",
"line",
"as",
"matched",
"."
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/matcher.py#L159-L172 | train | Returns True if the log line matches the given list of hostname patterns. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.