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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
inveniosoftware/invenio-pidrelations | invenio_pidrelations/serializers/schemas.py | RelationSchema.dump_previous | def dump_previous(self, obj):
"""Dump the parent of a PID."""
if self._is_child(obj) and obj.index(self.context['pid']) > 0:
return self._dump_relative(obj.previous_child(self.context['pid'])) | python | def dump_previous(self, obj):
"""Dump the parent of a PID."""
if self._is_child(obj) and obj.index(self.context['pid']) > 0:
return self._dump_relative(obj.previous_child(self.context['pid'])) | [
"def",
"dump_previous",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"_is_child",
"(",
"obj",
")",
"and",
"obj",
".",
"index",
"(",
"self",
".",
"context",
"[",
"'pid'",
"]",
")",
">",
"0",
":",
"return",
"self",
".",
"_dump_relative",
"("... | Dump the parent of a PID. | [
"Dump",
"the",
"parent",
"of",
"a",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L68-L71 | train | Dump the previous child of a PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/serializers/schemas.py | RelationSchema.dump_index | def dump_index(self, obj):
"""Dump the index of the child in the relation."""
if isinstance(obj, PIDNodeOrdered) and self._is_child(obj):
return obj.index(self.context['pid'])
else:
return None | python | def dump_index(self, obj):
"""Dump the index of the child in the relation."""
if isinstance(obj, PIDNodeOrdered) and self._is_child(obj):
return obj.index(self.context['pid'])
else:
return None | [
"def",
"dump_index",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"PIDNodeOrdered",
")",
"and",
"self",
".",
"_is_child",
"(",
"obj",
")",
":",
"return",
"obj",
".",
"index",
"(",
"self",
".",
"context",
"[",
"'pid'",
"]",
... | Dump the index of the child in the relation. | [
"Dump",
"the",
"index",
"of",
"the",
"child",
"in",
"the",
"relation",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L73-L78 | train | Dump the index of the child in the relation. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/serializers/schemas.py | RelationSchema.dump_is_last | def dump_is_last(self, obj):
"""Dump the boolean stating if the child in the relation is last.
Dumps `None` for parent serialization.
"""
if self._is_child(obj) and isinstance(obj, PIDNodeOrdered):
if obj.children.count() > 0:
return obj.children.ordered('asc... | python | def dump_is_last(self, obj):
"""Dump the boolean stating if the child in the relation is last.
Dumps `None` for parent serialization.
"""
if self._is_child(obj) and isinstance(obj, PIDNodeOrdered):
if obj.children.count() > 0:
return obj.children.ordered('asc... | [
"def",
"dump_is_last",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"_is_child",
"(",
"obj",
")",
"and",
"isinstance",
"(",
"obj",
",",
"PIDNodeOrdered",
")",
":",
"if",
"obj",
".",
"children",
".",
"count",
"(",
")",
">",
"0",
":",
"retur... | Dump the boolean stating if the child in the relation is last.
Dumps `None` for parent serialization. | [
"Dump",
"the",
"boolean",
"stating",
"if",
"the",
"child",
"in",
"the",
"relation",
"is",
"last",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L88-L102 | train | Dump the boolean stating if the child in the relation is last. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/serializers/schemas.py | RelationSchema.dump_type | def dump_type(self, obj):
"""Dump the text name of the relation."""
if not isinstance(obj.relation_type, RelationType):
return resolve_relation_type_config(obj.relation_type).name
else:
return obj.relation_type.name | python | def dump_type(self, obj):
"""Dump the text name of the relation."""
if not isinstance(obj.relation_type, RelationType):
return resolve_relation_type_config(obj.relation_type).name
else:
return obj.relation_type.name | [
"def",
"dump_type",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
".",
"relation_type",
",",
"RelationType",
")",
":",
"return",
"resolve_relation_type_config",
"(",
"obj",
".",
"relation_type",
")",
".",
"name",
"else",
":",
"r... | Dump the text name of the relation. | [
"Dump",
"the",
"text",
"name",
"of",
"the",
"relation",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L104-L109 | train | Dump the text name of the relation. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/serializers/schemas.py | RelationSchema.dump_parent | def dump_parent(self, obj):
"""Dump the parent of a PID."""
if not self._is_parent(obj):
return self._dump_relative(obj.pid)
return None | python | def dump_parent(self, obj):
"""Dump the parent of a PID."""
if not self._is_parent(obj):
return self._dump_relative(obj.pid)
return None | [
"def",
"dump_parent",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"self",
".",
"_is_parent",
"(",
"obj",
")",
":",
"return",
"self",
".",
"_dump_relative",
"(",
"obj",
".",
"pid",
")",
"return",
"None"
] | Dump the parent of a PID. | [
"Dump",
"the",
"parent",
"of",
"a",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L111-L115 | train | Dump the parent of a PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/serializers/schemas.py | RelationSchema.dump_children | def dump_children(self, obj):
"""Dump the siblings of a PID."""
data, errors = PIDSchema(many=True).dump(
obj.children.ordered('asc').all())
return data | python | def dump_children(self, obj):
"""Dump the siblings of a PID."""
data, errors = PIDSchema(many=True).dump(
obj.children.ordered('asc').all())
return data | [
"def",
"dump_children",
"(",
"self",
",",
"obj",
")",
":",
"data",
",",
"errors",
"=",
"PIDSchema",
"(",
"many",
"=",
"True",
")",
".",
"dump",
"(",
"obj",
".",
"children",
".",
"ordered",
"(",
"'asc'",
")",
".",
"all",
"(",
")",
")",
"return",
"... | Dump the siblings of a PID. | [
"Dump",
"the",
"siblings",
"of",
"a",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L117-L121 | train | Dump the siblings of a PID. |
projectshift/shift-boiler | boiler/__init__.py | load_dotenvs | def load_dotenvs():
"""
Load dotenvs
Loads .env and .flaskenv files from project root directory.
:return:
"""
if not os.getenv('DOTENVS_LOADED'):
envs = ['.env', '.flaskenv']
for env in envs:
path = os.path.join(os.getcwd(), env)
if os.path.isfile(path):
... | python | def load_dotenvs():
"""
Load dotenvs
Loads .env and .flaskenv files from project root directory.
:return:
"""
if not os.getenv('DOTENVS_LOADED'):
envs = ['.env', '.flaskenv']
for env in envs:
path = os.path.join(os.getcwd(), env)
if os.path.isfile(path):
... | [
"def",
"load_dotenvs",
"(",
")",
":",
"if",
"not",
"os",
".",
"getenv",
"(",
"'DOTENVS_LOADED'",
")",
":",
"envs",
"=",
"[",
"'.env'",
",",
"'.flaskenv'",
"]",
"for",
"env",
"in",
"envs",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",... | Load dotenvs
Loads .env and .flaskenv files from project root directory.
:return: | [
"Load",
"dotenvs",
"Loads",
".",
"env",
"and",
".",
"flaskenv",
"files",
"from",
"project",
"root",
"directory",
".",
":",
"return",
":"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/__init__.py#L4-L16 | train | Load dotenvs from project root directory. |
sopoforic/gamest | gamest/app.py | identify_window | def identify_window(pid, text):
"""Identify the app associated with a window."""
proc = None
path = None
uas = Session.query(UserApp).filter(UserApp.window_text == text)
nontext = Session.query(UserApp).filter(UserApp.window_text == None)
if uas.count():
proc = psutil.Process(pid)
... | python | def identify_window(pid, text):
"""Identify the app associated with a window."""
proc = None
path = None
uas = Session.query(UserApp).filter(UserApp.window_text == text)
nontext = Session.query(UserApp).filter(UserApp.window_text == None)
if uas.count():
proc = psutil.Process(pid)
... | [
"def",
"identify_window",
"(",
"pid",
",",
"text",
")",
":",
"proc",
"=",
"None",
"path",
"=",
"None",
"uas",
"=",
"Session",
".",
"query",
"(",
"UserApp",
")",
".",
"filter",
"(",
"UserApp",
".",
"window_text",
"==",
"text",
")",
"nontext",
"=",
"Se... | Identify the app associated with a window. | [
"Identify",
"the",
"app",
"associated",
"with",
"a",
"window",
"."
] | 2129a6b7ce9976c40347d7232525878a76915eea | https://github.com/sopoforic/gamest/blob/2129a6b7ce9976c40347d7232525878a76915eea/gamest/app.py#L43-L66 | train | Identify the app associated with a window. |
saxix/drf-api-checker | src/drf_api_checker/recorder.py | Recorder._assertCALL | def _assertCALL(self, url, *, allow_empty=False, check_headers=True, check_status=True,
expect_errors=False, name=None, method='get', data=None):
"""
check url for response changes
:param url: url to check
:param allow_empty: if True ignore empty response and 404 err... | python | def _assertCALL(self, url, *, allow_empty=False, check_headers=True, check_status=True,
expect_errors=False, name=None, method='get', data=None):
"""
check url for response changes
:param url: url to check
:param allow_empty: if True ignore empty response and 404 err... | [
"def",
"_assertCALL",
"(",
"self",
",",
"url",
",",
"*",
",",
"allow_empty",
"=",
"False",
",",
"check_headers",
"=",
"True",
",",
"check_status",
"=",
"True",
",",
"expect_errors",
"=",
"False",
",",
"name",
"=",
"None",
",",
"method",
"=",
"'get'",
"... | check url for response changes
:param url: url to check
:param allow_empty: if True ignore empty response and 404 errors
:param check_headers: check response headers
:param check_status: check response status code
:raises: ValueError
:raises: AssertionError | [
"check",
"url",
"for",
"response",
"changes"
] | c84e598f3a95b5b63cf758dcaced89c02b53d772 | https://github.com/saxix/drf-api-checker/blob/c84e598f3a95b5b63cf758dcaced89c02b53d772/src/drf_api_checker/recorder.py#L102-L137 | train | Check that the response from the API is OK. |
ludeeus/GHLocalApi | examples/reboot.py | reboot | async def reboot():
"""Reboot a Google Home unit."""
async with aiohttp.ClientSession() as session:
ghlocalapi = DeviceSettings(LOOP, session, IPADDRESS)
result = await ghlocalapi.reboot()
print("Reboot info:", result) | python | async def reboot():
"""Reboot a Google Home unit."""
async with aiohttp.ClientSession() as session:
ghlocalapi = DeviceSettings(LOOP, session, IPADDRESS)
result = await ghlocalapi.reboot()
print("Reboot info:", result) | [
"async",
"def",
"reboot",
"(",
")",
":",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"session",
":",
"ghlocalapi",
"=",
"DeviceSettings",
"(",
"LOOP",
",",
"session",
",",
"IPADDRESS",
")",
"result",
"=",
"await",
"ghlocalapi",
".",
... | Reboot a Google Home unit. | [
"Reboot",
"a",
"Google",
"Home",
"unit",
"."
] | 93abdee299c4a4b65aa9dd03c77ec34e174e3c56 | https://github.com/ludeeus/GHLocalApi/blob/93abdee299c4a4b65aa9dd03c77ec34e174e3c56/examples/reboot.py#L9-L15 | train | Reboot a Google Home unit. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/logging.py | RequestFilter.filter | def filter(self, record):
"""
Adds user and remote_addr to the record.
"""
request = get_request()
if request:
user = getattr(request, 'user', None)
if user and not user.is_anonymous():
record.username = user.username
else:
... | python | def filter(self, record):
"""
Adds user and remote_addr to the record.
"""
request = get_request()
if request:
user = getattr(request, 'user', None)
if user and not user.is_anonymous():
record.username = user.username
else:
... | [
"def",
"filter",
"(",
"self",
",",
"record",
")",
":",
"request",
"=",
"get_request",
"(",
")",
"if",
"request",
":",
"user",
"=",
"getattr",
"(",
"request",
",",
"'user'",
",",
"None",
")",
"if",
"user",
"and",
"not",
"user",
".",
"is_anonymous",
"(... | Adds user and remote_addr to the record. | [
"Adds",
"user",
"and",
"remote_addr",
"to",
"the",
"record",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/logging.py#L39-L59 | train | Adds user and remote_addr to the record. |
PostmonAPI/postmon-python | postmon.py | _parse_area_km2 | def _parse_area_km2(valor):
"""O campo ``area_km2`` é uma string com um número em formato pt-br, com
casas decimais que representam m2.
Exemplos: "331,401", "248.222,801"
"""
if valor is None:
return None
elif isinstance(valor, Decimal):
return valor
try:
int_, dec =... | python | def _parse_area_km2(valor):
"""O campo ``area_km2`` é uma string com um número em formato pt-br, com
casas decimais que representam m2.
Exemplos: "331,401", "248.222,801"
"""
if valor is None:
return None
elif isinstance(valor, Decimal):
return valor
try:
int_, dec =... | [
"def",
"_parse_area_km2",
"(",
"valor",
")",
":",
"if",
"valor",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"valor",
",",
"Decimal",
")",
":",
"return",
"valor",
"try",
":",
"int_",
",",
"dec",
"=",
"valor",
".",
"split",
"(",
"'... | O campo ``area_km2`` é uma string com um número em formato pt-br, com
casas decimais que representam m2.
Exemplos: "331,401", "248.222,801" | [
"O",
"campo",
"area_km2",
"é",
"uma",
"string",
"com",
"um",
"número",
"em",
"formato",
"pt",
"-",
"br",
"com",
"casas",
"decimais",
"que",
"representam",
"m2",
"."
] | bfd3a38a8aec5e069536a0bc36440946d1981e37 | https://github.com/PostmonAPI/postmon-python/blob/bfd3a38a8aec5e069536a0bc36440946d1981e37/postmon.py#L291-L310 | train | O campo area_km2 é uma string com um número em formato pt - br com
casas decimais que representam m2. |
PostmonAPI/postmon-python | postmon.py | PostmonModel.user_agent | def user_agent(self):
"""
User-Agent para as requisições feitas para o Postmon.
Retorna o ``base_user_agent`` concatenado com o ``User-Agent`` padrão
do requests.
"""
if not self._user_agent:
session = requests.Session()
user_agent = session.heade... | python | def user_agent(self):
"""
User-Agent para as requisições feitas para o Postmon.
Retorna o ``base_user_agent`` concatenado com o ``User-Agent`` padrão
do requests.
"""
if not self._user_agent:
session = requests.Session()
user_agent = session.heade... | [
"def",
"user_agent",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_user_agent",
":",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"user_agent",
"=",
"session",
".",
"headers",
"[",
"'User-Agent'",
"]",
"self",
".",
"_user_agent",
"=",
"'%s ... | User-Agent para as requisições feitas para o Postmon.
Retorna o ``base_user_agent`` concatenado com o ``User-Agent`` padrão
do requests. | [
"User",
"-",
"Agent",
"para",
"as",
"requisições",
"feitas",
"para",
"o",
"Postmon",
"."
] | bfd3a38a8aec5e069536a0bc36440946d1981e37 | https://github.com/PostmonAPI/postmon-python/blob/bfd3a38a8aec5e069536a0bc36440946d1981e37/postmon.py#L31-L42 | train | Return a user - agent string para as requisições feitas para o Postmon. |
PostmonAPI/postmon-python | postmon.py | PostmonModel.buscar | def buscar(self):
"""Faz a busca das informações do objeto no Postmon.
Retorna um ``bool`` indicando se a busca foi bem sucedida.
"""
headers = {'User-Agent': self.user_agent}
try:
self._response = requests.get(self.url, headers=headers)
except requests.Reque... | python | def buscar(self):
"""Faz a busca das informações do objeto no Postmon.
Retorna um ``bool`` indicando se a busca foi bem sucedida.
"""
headers = {'User-Agent': self.user_agent}
try:
self._response = requests.get(self.url, headers=headers)
except requests.Reque... | [
"def",
"buscar",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"self",
".",
"user_agent",
"}",
"try",
":",
"self",
".",
"_response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"url",
",",
"headers",
"=",
"headers",
")",
"except... | Faz a busca das informações do objeto no Postmon.
Retorna um ``bool`` indicando se a busca foi bem sucedida. | [
"Faz",
"a",
"busca",
"das",
"informações",
"do",
"objeto",
"no",
"Postmon",
"."
] | bfd3a38a8aec5e069536a0bc36440946d1981e37 | https://github.com/PostmonAPI/postmon-python/blob/bfd3a38a8aec5e069536a0bc36440946d1981e37/postmon.py#L44-L59 | train | Retorna um bool indicando se a busca foi bem sucedida. |
PostmonAPI/postmon-python | postmon.py | PostmonModel.status | def status(self):
"""Status da resposta recebida do Postmon.
Os status previstos pelo Postmon são:
* ``200 OK``
* ``404 CEP NAO ENCONTRADO``
* ``503 SERVICO INDISPONIVEL``
Além dos status listados, outros status HTTP podem ocorrer, como
em qualquer chamada H... | python | def status(self):
"""Status da resposta recebida do Postmon.
Os status previstos pelo Postmon são:
* ``200 OK``
* ``404 CEP NAO ENCONTRADO``
* ``503 SERVICO INDISPONIVEL``
Além dos status listados, outros status HTTP podem ocorrer, como
em qualquer chamada H... | [
"def",
"status",
"(",
"self",
")",
":",
"try",
":",
"r",
"=",
"self",
".",
"_response",
"except",
"AttributeError",
":",
"return",
"None",
"else",
":",
"return",
"r",
".",
"status_code",
",",
"r",
".",
"reason"
] | Status da resposta recebida do Postmon.
Os status previstos pelo Postmon são:
* ``200 OK``
* ``404 CEP NAO ENCONTRADO``
* ``503 SERVICO INDISPONIVEL``
Além dos status listados, outros status HTTP podem ocorrer, como
em qualquer chamada HTTP.
O único caso de... | [
"Status",
"da",
"resposta",
"recebida",
"do",
"Postmon",
"."
] | bfd3a38a8aec5e069536a0bc36440946d1981e37 | https://github.com/PostmonAPI/postmon-python/blob/bfd3a38a8aec5e069536a0bc36440946d1981e37/postmon.py#L72-L92 | train | Status da resposta recebida do Postmon. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/themes.py | package_theme | def package_theme(app_name, build_dir,
excludes=None, includes=None, path_prefix=None,
template_dirs=None):
"""
Package resources and templates for a multi-tier environment
into a zip file.
Templates are pre-compiled into ``*build_dir*/*app_name*/templates``.
Com... | python | def package_theme(app_name, build_dir,
excludes=None, includes=None, path_prefix=None,
template_dirs=None):
"""
Package resources and templates for a multi-tier environment
into a zip file.
Templates are pre-compiled into ``*build_dir*/*app_name*/templates``.
Com... | [
"def",
"package_theme",
"(",
"app_name",
",",
"build_dir",
",",
"excludes",
"=",
"None",
",",
"includes",
"=",
"None",
",",
"path_prefix",
"=",
"None",
",",
"template_dirs",
"=",
"None",
")",
":",
"#pylint:disable=too-many-locals,too-many-arguments",
"templates_dest... | Package resources and templates for a multi-tier environment
into a zip file.
Templates are pre-compiled into ``*build_dir*/*app_name*/templates``.
Compilation means {% assets '*path*' %} and {% static '*path*' %} tags
are replaced by their compiled expression. | [
"Package",
"resources",
"and",
"templates",
"for",
"a",
"multi",
"-",
"tier",
"environment",
"into",
"a",
"zip",
"file",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/themes.py#L276-L304 | train | Package resources and templates for a multi - tier environment. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/themes.py | fill_package | def fill_package(app_name, build_dir=None, install_dir=None):
"""
Creates the theme package (.zip) from templates and optionally
assets installed in the ``build_dir``.
"""
zip_path = os.path.join(install_dir, '%s.zip' % app_name)
with zipfile.ZipFile(zip_path, 'w') as zip_file:
fill_pack... | python | def fill_package(app_name, build_dir=None, install_dir=None):
"""
Creates the theme package (.zip) from templates and optionally
assets installed in the ``build_dir``.
"""
zip_path = os.path.join(install_dir, '%s.zip' % app_name)
with zipfile.ZipFile(zip_path, 'w') as zip_file:
fill_pack... | [
"def",
"fill_package",
"(",
"app_name",
",",
"build_dir",
"=",
"None",
",",
"install_dir",
"=",
"None",
")",
":",
"zip_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"install_dir",
",",
"'%s.zip'",
"%",
"app_name",
")",
"with",
"zipfile",
".",
"ZipFile... | Creates the theme package (.zip) from templates and optionally
assets installed in the ``build_dir``. | [
"Creates",
"the",
"theme",
"package",
"(",
".",
"zip",
")",
"from",
"templates",
"and",
"optionally",
"assets",
"installed",
"in",
"the",
"build_dir",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/themes.py#L307-L315 | train | Creates the theme package. zip from templates and optionally a theme package. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/themes.py | install_templates | def install_templates(srcroot, destroot, prefix='', excludes=None,
includes=None, path_prefix=None):
#pylint:disable=too-many-arguments,too-many-statements
"""
Expand link to compiled assets all templates in *srcroot*
and its subdirectories.
"""
#pylint: disable=too-many-lo... | python | def install_templates(srcroot, destroot, prefix='', excludes=None,
includes=None, path_prefix=None):
#pylint:disable=too-many-arguments,too-many-statements
"""
Expand link to compiled assets all templates in *srcroot*
and its subdirectories.
"""
#pylint: disable=too-many-lo... | [
"def",
"install_templates",
"(",
"srcroot",
",",
"destroot",
",",
"prefix",
"=",
"''",
",",
"excludes",
"=",
"None",
",",
"includes",
"=",
"None",
",",
"path_prefix",
"=",
"None",
")",
":",
"#pylint:disable=too-many-arguments,too-many-statements",
"#pylint: disable=... | Expand link to compiled assets all templates in *srcroot*
and its subdirectories. | [
"Expand",
"link",
"to",
"compiled",
"assets",
"all",
"templates",
"in",
"*",
"srcroot",
"*",
"and",
"its",
"subdirectories",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/themes.py#L328-L449 | train | Installs all templates in srcroot to destroot. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/redirects.py | _insert_url | def _insert_url(request, redirect_field_name=REDIRECT_FIELD_NAME,
inserted_url=None):
'''Redirects to the *inserted_url* before going to the orginal
request path.'''
# This code is pretty much straightforward
# from contrib.auth.user_passes_test
path = request.build_absolute_uri()
... | python | def _insert_url(request, redirect_field_name=REDIRECT_FIELD_NAME,
inserted_url=None):
'''Redirects to the *inserted_url* before going to the orginal
request path.'''
# This code is pretty much straightforward
# from contrib.auth.user_passes_test
path = request.build_absolute_uri()
... | [
"def",
"_insert_url",
"(",
"request",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"inserted_url",
"=",
"None",
")",
":",
"# This code is pretty much straightforward",
"# from contrib.auth.user_passes_test",
"path",
"=",
"request",
".",
"build_absolute_uri",
... | Redirects to the *inserted_url* before going to the orginal
request path. | [
"Redirects",
"to",
"the",
"*",
"inserted_url",
"*",
"before",
"going",
"to",
"the",
"orginal",
"request",
"path",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/redirects.py#L44-L62 | train | Redirects to the inserted_url before going to the orginal
request path. |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | AjaxResponseMixin.json_to_response | def json_to_response(self, action=None, json_status=None, success_url=None,
json_data=None, **response_kwargs):
""" Valid response with next action to be followed by the JS """
data = {
"status": self.get_status(json_status),
"action": self.get_action(act... | python | def json_to_response(self, action=None, json_status=None, success_url=None,
json_data=None, **response_kwargs):
""" Valid response with next action to be followed by the JS """
data = {
"status": self.get_status(json_status),
"action": self.get_action(act... | [
"def",
"json_to_response",
"(",
"self",
",",
"action",
"=",
"None",
",",
"json_status",
"=",
"None",
",",
"success_url",
"=",
"None",
",",
"json_data",
"=",
"None",
",",
"*",
"*",
"response_kwargs",
")",
":",
"data",
"=",
"{",
"\"status\"",
":",
"self",
... | Valid response with next action to be followed by the JS | [
"Valid",
"response",
"with",
"next",
"action",
"to",
"be",
"followed",
"by",
"the",
"JS"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L39-L50 | train | Return a JsonResponse object with the JSON data. |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | AjaxResponseMixin.get_action | def get_action(self, action=None):
""" Returns action to take after call """
if action:
self.action = action
if self.action not in AjaxResponseAction.choices:
raise ValueError(
"Invalid action selected: '{}'".format(self.action))
return self.acti... | python | def get_action(self, action=None):
""" Returns action to take after call """
if action:
self.action = action
if self.action not in AjaxResponseAction.choices:
raise ValueError(
"Invalid action selected: '{}'".format(self.action))
return self.acti... | [
"def",
"get_action",
"(",
"self",
",",
"action",
"=",
"None",
")",
":",
"if",
"action",
":",
"self",
".",
"action",
"=",
"action",
"if",
"self",
".",
"action",
"not",
"in",
"AjaxResponseAction",
".",
"choices",
":",
"raise",
"ValueError",
"(",
"\"Invalid... | Returns action to take after call | [
"Returns",
"action",
"to",
"take",
"after",
"call"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L52-L61 | train | Returns the action to take after call |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | AjaxResponseMixin.get_status | def get_status(self, json_status=None):
""" Returns status of for json """
if json_status:
self.json_status = json_status
if self.json_status not in AjaxResponseStatus.choices:
raise ValueError(
"Invalid status selected: '{}'".format(self.json_status))
... | python | def get_status(self, json_status=None):
""" Returns status of for json """
if json_status:
self.json_status = json_status
if self.json_status not in AjaxResponseStatus.choices:
raise ValueError(
"Invalid status selected: '{}'".format(self.json_status))
... | [
"def",
"get_status",
"(",
"self",
",",
"json_status",
"=",
"None",
")",
":",
"if",
"json_status",
":",
"self",
".",
"json_status",
"=",
"json_status",
"if",
"self",
".",
"json_status",
"not",
"in",
"AjaxResponseStatus",
".",
"choices",
":",
"raise",
"ValueEr... | Returns status of for json | [
"Returns",
"status",
"of",
"for",
"json"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L63-L72 | train | Returns status of for json |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | FormAjaxMixin.form_invalid | def form_invalid(self, form, prefix=None):
""" If form invalid return error list in JSON response """
response = super(FormAjaxMixin, self).form_invalid(form)
if self.request.is_ajax():
data = {
"errors_list": self.add_prefix(form.errors, prefix),
}
... | python | def form_invalid(self, form, prefix=None):
""" If form invalid return error list in JSON response """
response = super(FormAjaxMixin, self).form_invalid(form)
if self.request.is_ajax():
data = {
"errors_list": self.add_prefix(form.errors, prefix),
}
... | [
"def",
"form_invalid",
"(",
"self",
",",
"form",
",",
"prefix",
"=",
"None",
")",
":",
"response",
"=",
"super",
"(",
"FormAjaxMixin",
",",
"self",
")",
".",
"form_invalid",
"(",
"form",
")",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":... | If form invalid return error list in JSON response | [
"If",
"form",
"invalid",
"return",
"error",
"list",
"in",
"JSON",
"response"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L82-L91 | train | Return error list in JSON response |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | FormAjaxMixin.form_valid | def form_valid(self, form):
""" If form valid return response with action """
response = super(FormAjaxMixin, self).form_valid(form)
if self.request.is_ajax():
return self.json_to_response()
return response | python | def form_valid(self, form):
""" If form valid return response with action """
response = super(FormAjaxMixin, self).form_valid(form)
if self.request.is_ajax():
return self.json_to_response()
return response | [
"def",
"form_valid",
"(",
"self",
",",
"form",
")",
":",
"response",
"=",
"super",
"(",
"FormAjaxMixin",
",",
"self",
")",
".",
"form_valid",
"(",
"form",
")",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":",
"return",
"self",
".",
"json_... | If form valid return response with action | [
"If",
"form",
"valid",
"return",
"response",
"with",
"action"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L99-L104 | train | Returns response with action if form valid |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | FormAjaxMixin.add_prefix | def add_prefix(self, errors, prefix):
"""Add form prefix to errors"""
if not prefix:
prefix = self.get_prefix()
if prefix:
return {"%s-%s" % (prefix, k): v for k, v in errors.items()}
return errors | python | def add_prefix(self, errors, prefix):
"""Add form prefix to errors"""
if not prefix:
prefix = self.get_prefix()
if prefix:
return {"%s-%s" % (prefix, k): v for k, v in errors.items()}
return errors | [
"def",
"add_prefix",
"(",
"self",
",",
"errors",
",",
"prefix",
")",
":",
"if",
"not",
"prefix",
":",
"prefix",
"=",
"self",
".",
"get_prefix",
"(",
")",
"if",
"prefix",
":",
"return",
"{",
"\"%s-%s\"",
"%",
"(",
"prefix",
",",
"k",
")",
":",
"v",
... | Add form prefix to errors | [
"Add",
"form",
"prefix",
"to",
"errors"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L106-L112 | train | Add form prefix to errors |
dipcode-software/django-ajax-cbv | ajax_cbv/mixins.py | PartialAjaxMixin.render_to_response | def render_to_response(self, context, **response_kwargs):
""" Returns the rendered template in JSON format """
if self.request.is_ajax():
data = {
"content": render_to_string(
self.get_template_names(), context, request=self.request)
}
... | python | def render_to_response(self, context, **response_kwargs):
""" Returns the rendered template in JSON format """
if self.request.is_ajax():
data = {
"content": render_to_string(
self.get_template_names(), context, request=self.request)
}
... | [
"def",
"render_to_response",
"(",
"self",
",",
"context",
",",
"*",
"*",
"response_kwargs",
")",
":",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":",
"data",
"=",
"{",
"\"content\"",
":",
"render_to_string",
"(",
"self",
".",
"get_template_nam... | Returns the rendered template in JSON format | [
"Returns",
"the",
"rendered",
"template",
"in",
"JSON",
"format"
] | a723eaa90490e57f1b2dfbd8d10905b9e2541f88 | https://github.com/dipcode-software/django-ajax-cbv/blob/a723eaa90490e57f1b2dfbd8d10905b9e2541f88/ajax_cbv/mixins.py#L131-L142 | train | Returns the rendered template in JSON format |
romanorac/discomll | discomll/clustering/kmeans.py | random_init_map | def random_init_map(interface, state, label, inp):
"""Assign datapoint `e` randomly to one of the `k` clusters."""
import random
out = interface.output(0)
centers = {}
for row in inp:
row = row.strip().split(state["delimiter"])
if len(row) > 1:
x = [(0 if row[i] in state... | python | def random_init_map(interface, state, label, inp):
"""Assign datapoint `e` randomly to one of the `k` clusters."""
import random
out = interface.output(0)
centers = {}
for row in inp:
row = row.strip().split(state["delimiter"])
if len(row) > 1:
x = [(0 if row[i] in state... | [
"def",
"random_init_map",
"(",
"interface",
",",
"state",
",",
"label",
",",
"inp",
")",
":",
"import",
"random",
"out",
"=",
"interface",
".",
"output",
"(",
"0",
")",
"centers",
"=",
"{",
"}",
"for",
"row",
"in",
"inp",
":",
"row",
"=",
"row",
".... | Assign datapoint `e` randomly to one of the `k` clusters. | [
"Assign",
"datapoint",
"e",
"randomly",
"to",
"one",
"of",
"the",
"k",
"clusters",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/clustering/kmeans.py#L31-L45 | train | Assign datapoint e randomly to one of the k clusters. |
romanorac/discomll | discomll/clustering/kmeans.py | estimate_map | def estimate_map(interface, state, label, inp):
"""Find the cluster `i` that is closest to the datapoint `e`."""
out = interface.output(0)
centers = {}
for row in inp:
row = row.strip().split(state["delimiter"])
if len(row) > 1:
x = [(0 if row[i] in state["missing_vals"] else... | python | def estimate_map(interface, state, label, inp):
"""Find the cluster `i` that is closest to the datapoint `e`."""
out = interface.output(0)
centers = {}
for row in inp:
row = row.strip().split(state["delimiter"])
if len(row) > 1:
x = [(0 if row[i] in state["missing_vals"] else... | [
"def",
"estimate_map",
"(",
"interface",
",",
"state",
",",
"label",
",",
"inp",
")",
":",
"out",
"=",
"interface",
".",
"output",
"(",
"0",
")",
"centers",
"=",
"{",
"}",
"for",
"row",
"in",
"inp",
":",
"row",
"=",
"row",
".",
"strip",
"(",
")",... | Find the cluster `i` that is closest to the datapoint `e`. | [
"Find",
"the",
"cluster",
"i",
"that",
"is",
"closest",
"to",
"the",
"datapoint",
"e",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/clustering/kmeans.py#L48-L61 | train | Estimate the map of the i - th cluster that is closest to the datapoint e. |
romanorac/discomll | discomll/clustering/kmeans.py | estimate_reduce | def estimate_reduce(interface, state, label, inp):
"""Estimate the cluster centers for each cluster."""
centers = {}
for i, c in inp:
centers[i] = c if i not in centers else state['update'](centers[i], c)
out = interface.output(0)
for i, c in centers.items():
out.add(i, state['final... | python | def estimate_reduce(interface, state, label, inp):
"""Estimate the cluster centers for each cluster."""
centers = {}
for i, c in inp:
centers[i] = c if i not in centers else state['update'](centers[i], c)
out = interface.output(0)
for i, c in centers.items():
out.add(i, state['final... | [
"def",
"estimate_reduce",
"(",
"interface",
",",
"state",
",",
"label",
",",
"inp",
")",
":",
"centers",
"=",
"{",
"}",
"for",
"i",
",",
"c",
"in",
"inp",
":",
"centers",
"[",
"i",
"]",
"=",
"c",
"if",
"i",
"not",
"in",
"centers",
"else",
"state"... | Estimate the cluster centers for each cluster. | [
"Estimate",
"the",
"cluster",
"centers",
"for",
"each",
"cluster",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/clustering/kmeans.py#L64-L72 | train | Estimate the cluster centers for each cluster. |
romanorac/discomll | discomll/clustering/kmeans.py | predict_map | def predict_map(interface, state, label, inp):
"""Determine the closest cluster for the datapoint `e`."""
out = interface.output(0)
for row in inp:
if len(row) > 1:
row = row.strip().split(state["delimiter"])
x_id = "" if state["id_index"] == -1 else row[state["id_index"]]
... | python | def predict_map(interface, state, label, inp):
"""Determine the closest cluster for the datapoint `e`."""
out = interface.output(0)
for row in inp:
if len(row) > 1:
row = row.strip().split(state["delimiter"])
x_id = "" if state["id_index"] == -1 else row[state["id_index"]]
... | [
"def",
"predict_map",
"(",
"interface",
",",
"state",
",",
"label",
",",
"inp",
")",
":",
"out",
"=",
"interface",
".",
"output",
"(",
"0",
")",
"for",
"row",
"in",
"inp",
":",
"if",
"len",
"(",
"row",
")",
">",
"1",
":",
"row",
"=",
"row",
"."... | Determine the closest cluster for the datapoint `e`. | [
"Determine",
"the",
"closest",
"cluster",
"for",
"the",
"datapoint",
"e",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/clustering/kmeans.py#L75-L83 | train | Determine the closest cluster for the datapoint e. |
romanorac/discomll | discomll/clustering/kmeans.py | fit | def fit(dataset, n_clusters=5, max_iterations=10, random_state=None, save_results=True, show=False):
"""
Optimize k-clustering for `iterations` iterations with cluster
center definitions as given in `center`.
"""
from disco.job import Job
from disco.worker.pipeline.worker import Worker, Stage
... | python | def fit(dataset, n_clusters=5, max_iterations=10, random_state=None, save_results=True, show=False):
"""
Optimize k-clustering for `iterations` iterations with cluster
center definitions as given in `center`.
"""
from disco.job import Job
from disco.worker.pipeline.worker import Worker, Stage
... | [
"def",
"fit",
"(",
"dataset",
",",
"n_clusters",
"=",
"5",
",",
"max_iterations",
"=",
"10",
",",
"random_state",
"=",
"None",
",",
"save_results",
"=",
"True",
",",
"show",
"=",
"False",
")",
":",
"from",
"disco",
".",
"job",
"import",
"Job",
"from",
... | Optimize k-clustering for `iterations` iterations with cluster
center definitions as given in `center`. | [
"Optimize",
"k",
"-",
"clustering",
"for",
"iterations",
"iterations",
"with",
"cluster",
"center",
"definitions",
"as",
"given",
"in",
"center",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/clustering/kmeans.py#L86-L135 | train | Optimize k - clustering for iterations with k - clustering for max_iterations iterations with cluster
center definitions as given in center. |
romanorac/discomll | discomll/clustering/kmeans.py | predict | def predict(dataset, fitmodel_url, save_results=True, show=False):
"""
Predict the closest clusters for the datapoints in input.
"""
from disco.job import Job
from disco.worker.pipeline.worker import Worker, Stage
from disco.core import result_iterator
if "kmeans_fitmodel" not in fitmodel_... | python | def predict(dataset, fitmodel_url, save_results=True, show=False):
"""
Predict the closest clusters for the datapoints in input.
"""
from disco.job import Job
from disco.worker.pipeline.worker import Worker, Stage
from disco.core import result_iterator
if "kmeans_fitmodel" not in fitmodel_... | [
"def",
"predict",
"(",
"dataset",
",",
"fitmodel_url",
",",
"save_results",
"=",
"True",
",",
"show",
"=",
"False",
")",
":",
"from",
"disco",
".",
"job",
"import",
"Job",
"from",
"disco",
".",
"worker",
".",
"pipeline",
".",
"worker",
"import",
"Worker"... | Predict the closest clusters for the datapoints in input. | [
"Predict",
"the",
"closest",
"clusters",
"for",
"the",
"datapoints",
"in",
"input",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/clustering/kmeans.py#L138-L159 | train | Predict closest clusters for the datapoints in input. |
tweekmonster/moult | moult/utils.py | load_stdlib | def load_stdlib():
'''Scans sys.path for standard library modules.
'''
if _stdlib:
return _stdlib
prefixes = tuple({os.path.abspath(p) for p in (
sys.prefix,
getattr(sys, 'real_prefix', sys.prefix),
getattr(sys, 'base_prefix', sys.prefix),
)})
for sp in sys.path... | python | def load_stdlib():
'''Scans sys.path for standard library modules.
'''
if _stdlib:
return _stdlib
prefixes = tuple({os.path.abspath(p) for p in (
sys.prefix,
getattr(sys, 'real_prefix', sys.prefix),
getattr(sys, 'base_prefix', sys.prefix),
)})
for sp in sys.path... | [
"def",
"load_stdlib",
"(",
")",
":",
"if",
"_stdlib",
":",
"return",
"_stdlib",
"prefixes",
"=",
"tuple",
"(",
"{",
"os",
".",
"path",
".",
"abspath",
"(",
"p",
")",
"for",
"p",
"in",
"(",
"sys",
".",
"prefix",
",",
"getattr",
"(",
"sys",
",",
"'... | Scans sys.path for standard library modules. | [
"Scans",
"sys",
".",
"path",
"for",
"standard",
"library",
"modules",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L18-L54 | train | Scans sys. path for standard library modules. |
tweekmonster/moult | moult/utils.py | import_path_from_file | def import_path_from_file(filename, as_list=False):
'''Returns a tuple of the import path and root module directory for the
supplied file.
'''
module_path = []
basename = os.path.splitext(os.path.basename(filename))[0]
if basename != '__init__':
module_path.append(basename)
dirname ... | python | def import_path_from_file(filename, as_list=False):
'''Returns a tuple of the import path and root module directory for the
supplied file.
'''
module_path = []
basename = os.path.splitext(os.path.basename(filename))[0]
if basename != '__init__':
module_path.append(basename)
dirname ... | [
"def",
"import_path_from_file",
"(",
"filename",
",",
"as_list",
"=",
"False",
")",
":",
"module_path",
"=",
"[",
"]",
"basename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
")",
"[",
"0",
... | Returns a tuple of the import path and root module directory for the
supplied file. | [
"Returns",
"a",
"tuple",
"of",
"the",
"import",
"path",
"and",
"root",
"module",
"directory",
"for",
"the",
"supplied",
"file",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L69-L85 | train | Returns a tuple of the import path and root module directory for the
supplied file. |
tweekmonster/moult | moult/utils.py | file_containing_import | def file_containing_import(import_path, import_root):
'''Finds the file that might contain the import_path.
'''
if not _import_paths:
load_stdlib()
if os.path.isfile(import_root):
import_root = os.path.dirname(import_root)
search_paths = [import_root] + _import_paths
module_par... | python | def file_containing_import(import_path, import_root):
'''Finds the file that might contain the import_path.
'''
if not _import_paths:
load_stdlib()
if os.path.isfile(import_root):
import_root = os.path.dirname(import_root)
search_paths = [import_root] + _import_paths
module_par... | [
"def",
"file_containing_import",
"(",
"import_path",
",",
"import_root",
")",
":",
"if",
"not",
"_import_paths",
":",
"load_stdlib",
"(",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"import_root",
")",
":",
"import_root",
"=",
"os",
".",
"path",
".",... | Finds the file that might contain the import_path. | [
"Finds",
"the",
"file",
"that",
"might",
"contain",
"the",
"import_path",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L88-L107 | train | Finds the file that might contain the import_path. |
tweekmonster/moult | moult/utils.py | resolve_import | def resolve_import(import_path, from_module):
'''Resolves relative imports from a module.
'''
if not import_path or not import_path.startswith('.'):
return import_path
from_module = from_module.split('.')
dots = 0
for c in import_path:
if c == '.':
dots += 1
... | python | def resolve_import(import_path, from_module):
'''Resolves relative imports from a module.
'''
if not import_path or not import_path.startswith('.'):
return import_path
from_module = from_module.split('.')
dots = 0
for c in import_path:
if c == '.':
dots += 1
... | [
"def",
"resolve_import",
"(",
"import_path",
",",
"from_module",
")",
":",
"if",
"not",
"import_path",
"or",
"not",
"import_path",
".",
"startswith",
"(",
"'.'",
")",
":",
"return",
"import_path",
"from_module",
"=",
"from_module",
".",
"split",
"(",
"'.'",
... | Resolves relative imports from a module. | [
"Resolves",
"relative",
"imports",
"from",
"a",
"module",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L110-L131 | train | Resolves relative imports from a module. |
tweekmonster/moult | moult/utils.py | find_package | def find_package(name, installed, package=False):
'''Finds a package in the installed list.
If `package` is true, match package names, otherwise, match import paths.
'''
if package:
name = name.lower()
tests = (
lambda x: x.user and name == x.name.lower(),
lambda... | python | def find_package(name, installed, package=False):
'''Finds a package in the installed list.
If `package` is true, match package names, otherwise, match import paths.
'''
if package:
name = name.lower()
tests = (
lambda x: x.user and name == x.name.lower(),
lambda... | [
"def",
"find_package",
"(",
"name",
",",
"installed",
",",
"package",
"=",
"False",
")",
":",
"if",
"package",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"tests",
"=",
"(",
"lambda",
"x",
":",
"x",
".",
"user",
"and",
"name",
"==",
"x",
".... | Finds a package in the installed list.
If `package` is true, match package names, otherwise, match import paths. | [
"Finds",
"a",
"package",
"in",
"the",
"installed",
"list",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L134-L160 | train | Finds a package in the installed list. |
tweekmonster/moult | moult/utils.py | is_script | def is_script(filename):
'''Checks if a file has a hashbang.
'''
if not os.path.isfile(filename):
return False
try:
with open(filename, 'rb') as fp:
return fp.read(2) == b'#!'
except IOError:
pass
return False | python | def is_script(filename):
'''Checks if a file has a hashbang.
'''
if not os.path.isfile(filename):
return False
try:
with open(filename, 'rb') as fp:
return fp.read(2) == b'#!'
except IOError:
pass
return False | [
"def",
"is_script",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"return",
"False",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"return",
"fp",
".",
"read",... | Checks if a file has a hashbang. | [
"Checks",
"if",
"a",
"file",
"has",
"a",
"hashbang",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L163-L175 | train | Checks if a file has a hashbang.
|
tweekmonster/moult | moult/utils.py | is_python_script | def is_python_script(filename):
'''Checks a file to see if it's a python script of some sort.
'''
if filename.lower().endswith('.py'):
return True
if not os.path.isfile(filename):
return False
try:
with open(filename, 'rb') as fp:
if fp.read(2) != b'#!':
... | python | def is_python_script(filename):
'''Checks a file to see if it's a python script of some sort.
'''
if filename.lower().endswith('.py'):
return True
if not os.path.isfile(filename):
return False
try:
with open(filename, 'rb') as fp:
if fp.read(2) != b'#!':
... | [
"def",
"is_python_script",
"(",
"filename",
")",
":",
"if",
"filename",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"'.py'",
")",
":",
"return",
"True",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"return",
"False",
"t... | Checks a file to see if it's a python script of some sort. | [
"Checks",
"a",
"file",
"to",
"see",
"if",
"it",
"s",
"a",
"python",
"script",
"of",
"some",
"sort",
"."
] | 38d3a3b9002336219897ebe263ca1d8dcadbecf5 | https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/utils.py#L178-L195 | train | Checks a file to see if it s a python script of some sort. |
catch22/pw | pw/store.py | Store.search | def search(self, key_pattern: str, user_pattern: str) -> List[Entry]:
"""Search database for given key and user pattern."""
# normalize key
key_pattern = _normalized_key(key_pattern)
# search
results = []
for entry in self.entries:
if key_pattern in entry.key... | python | def search(self, key_pattern: str, user_pattern: str) -> List[Entry]:
"""Search database for given key and user pattern."""
# normalize key
key_pattern = _normalized_key(key_pattern)
# search
results = []
for entry in self.entries:
if key_pattern in entry.key... | [
"def",
"search",
"(",
"self",
",",
"key_pattern",
":",
"str",
",",
"user_pattern",
":",
"str",
")",
"->",
"List",
"[",
"Entry",
"]",
":",
"# normalize key",
"key_pattern",
"=",
"_normalized_key",
"(",
"key_pattern",
")",
"# search",
"results",
"=",
"[",
"]... | Search database for given key and user pattern. | [
"Search",
"database",
"for",
"given",
"key",
"and",
"user",
"pattern",
"."
] | 2452924bbdccad28b21290b6ce062809c3d1c5f2 | https://github.com/catch22/pw/blob/2452924bbdccad28b21290b6ce062809c3d1c5f2/pw/store.py#L23-L35 | train | Search database for given key and user pattern. |
catch22/pw | pw/store.py | Store.load | def load(path: str) -> "Store":
"""Load password store from file."""
# load source (decrypting if necessary)
if _gpg.is_encrypted(path):
src_bytes = _gpg.decrypt(path)
else:
src_bytes = open(path, "rb").read()
src = src_bytes.decode("utf-8")
# par... | python | def load(path: str) -> "Store":
"""Load password store from file."""
# load source (decrypting if necessary)
if _gpg.is_encrypted(path):
src_bytes = _gpg.decrypt(path)
else:
src_bytes = open(path, "rb").read()
src = src_bytes.decode("utf-8")
# par... | [
"def",
"load",
"(",
"path",
":",
"str",
")",
"->",
"\"Store\"",
":",
"# load source (decrypting if necessary)",
"if",
"_gpg",
".",
"is_encrypted",
"(",
"path",
")",
":",
"src_bytes",
"=",
"_gpg",
".",
"decrypt",
"(",
"path",
")",
"else",
":",
"src_bytes",
... | Load password store from file. | [
"Load",
"password",
"store",
"from",
"file",
"."
] | 2452924bbdccad28b21290b6ce062809c3d1c5f2 | https://github.com/catch22/pw/blob/2452924bbdccad28b21290b6ce062809c3d1c5f2/pw/store.py#L38-L55 | train | Load a password store from a file. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | only_passed_and_wait | def only_passed_and_wait(result):
"""Returns PASS and WAIT results only, skips everything else."""
verdict = result.get("verdict", "").strip().lower()
if verdict in Verdicts.PASS + Verdicts.WAIT:
return result
return None | python | def only_passed_and_wait(result):
"""Returns PASS and WAIT results only, skips everything else."""
verdict = result.get("verdict", "").strip().lower()
if verdict in Verdicts.PASS + Verdicts.WAIT:
return result
return None | [
"def",
"only_passed_and_wait",
"(",
"result",
")",
":",
"verdict",
"=",
"result",
".",
"get",
"(",
"\"verdict\"",
",",
"\"\"",
")",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"if",
"verdict",
"in",
"Verdicts",
".",
"PASS",
"+",
"Verdicts",
".",
... | Returns PASS and WAIT results only, skips everything else. | [
"Returns",
"PASS",
"and",
"WAIT",
"results",
"only",
"skips",
"everything",
"else",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L23-L28 | train | Returns PASS and WAIT results only skips everything else. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | insert_source_info | def insert_source_info(result):
"""Adds info about source of test result if available."""
comment = result.get("comment")
# don't change comment if it already exists
if comment:
return
source = result.get("source")
job_name = result.get("job_name")
run = result.get("run")
source... | python | def insert_source_info(result):
"""Adds info about source of test result if available."""
comment = result.get("comment")
# don't change comment if it already exists
if comment:
return
source = result.get("source")
job_name = result.get("job_name")
run = result.get("run")
source... | [
"def",
"insert_source_info",
"(",
"result",
")",
":",
"comment",
"=",
"result",
".",
"get",
"(",
"\"comment\"",
")",
"# don't change comment if it already exists",
"if",
"comment",
":",
"return",
"source",
"=",
"result",
".",
"get",
"(",
"\"source\"",
")",
"job_... | Adds info about source of test result if available. | [
"Adds",
"info",
"about",
"source",
"of",
"test",
"result",
"if",
"available",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L31-L47 | train | Adds info about source of test result if available. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | setup_parametrization | def setup_parametrization(result, parametrize):
"""Modifies result's data according to the parametrization settings."""
if parametrize:
# remove parameters from title
title = result.get("title")
if title:
result["title"] = TEST_PARAM_RE.sub("", title)
else:
# don'... | python | def setup_parametrization(result, parametrize):
"""Modifies result's data according to the parametrization settings."""
if parametrize:
# remove parameters from title
title = result.get("title")
if title:
result["title"] = TEST_PARAM_RE.sub("", title)
else:
# don'... | [
"def",
"setup_parametrization",
"(",
"result",
",",
"parametrize",
")",
":",
"if",
"parametrize",
":",
"# remove parameters from title",
"title",
"=",
"result",
".",
"get",
"(",
"\"title\"",
")",
"if",
"title",
":",
"result",
"[",
"\"title\"",
"]",
"=",
"TEST_... | Modifies result's data according to the parametrization settings. | [
"Modifies",
"result",
"s",
"data",
"according",
"to",
"the",
"parametrization",
"settings",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L50-L60 | train | Modifies the result s data according to the parametrization settings. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | include_class_in_title | def include_class_in_title(result):
"""Makes sure that test class is included in "title".
e.g. "TestServiceRESTAPI.test_power_parent_service"
>>> result = {"title": "test_foo", "classname": "foo.bar.baz.TestFoo",
... "file": "foo/bar/baz.py"}
>>> include_class_in_title(result)
>>> str(resul... | python | def include_class_in_title(result):
"""Makes sure that test class is included in "title".
e.g. "TestServiceRESTAPI.test_power_parent_service"
>>> result = {"title": "test_foo", "classname": "foo.bar.baz.TestFoo",
... "file": "foo/bar/baz.py"}
>>> include_class_in_title(result)
>>> str(resul... | [
"def",
"include_class_in_title",
"(",
"result",
")",
":",
"classname",
"=",
"result",
".",
"get",
"(",
"\"classname\"",
",",
"\"\"",
")",
"if",
"classname",
":",
"filepath",
"=",
"result",
".",
"get",
"(",
"\"file\"",
",",
"\"\"",
")",
"title",
"=",
"res... | Makes sure that test class is included in "title".
e.g. "TestServiceRESTAPI.test_power_parent_service"
>>> result = {"title": "test_foo", "classname": "foo.bar.baz.TestFoo",
... "file": "foo/bar/baz.py"}
>>> include_class_in_title(result)
>>> str(result.get("title"))
'TestFoo.test_foo'
... | [
"Makes",
"sure",
"that",
"test",
"class",
"is",
"included",
"in",
"title",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L63-L86 | train | Makes sure that test class is included in title. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | parse_rst_description | def parse_rst_description(testcase):
"""Creates an HTML version of the RST formatted description."""
description = testcase.get("description")
if not description:
return
try:
with open(os.devnull, "w") as devnull:
testcase["description"] = publish_parts(
des... | python | def parse_rst_description(testcase):
"""Creates an HTML version of the RST formatted description."""
description = testcase.get("description")
if not description:
return
try:
with open(os.devnull, "w") as devnull:
testcase["description"] = publish_parts(
des... | [
"def",
"parse_rst_description",
"(",
"testcase",
")",
":",
"description",
"=",
"testcase",
".",
"get",
"(",
"\"description\"",
")",
"if",
"not",
"description",
":",
"return",
"try",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"as",
... | Creates an HTML version of the RST formatted description. | [
"Creates",
"an",
"HTML",
"version",
"of",
"the",
"RST",
"formatted",
"description",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L119-L136 | train | Creates an HTML version of the RST formatted description. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | preformat_plain_description | def preformat_plain_description(testcase):
"""Creates a preformatted HTML version of the description."""
description = testcase.get("description")
if not description:
return
# naive approach to removing indent from pytest docstrings
nodeid = testcase.get("nodeid") or ""
indent = None
... | python | def preformat_plain_description(testcase):
"""Creates a preformatted HTML version of the description."""
description = testcase.get("description")
if not description:
return
# naive approach to removing indent from pytest docstrings
nodeid = testcase.get("nodeid") or ""
indent = None
... | [
"def",
"preformat_plain_description",
"(",
"testcase",
")",
":",
"description",
"=",
"testcase",
".",
"get",
"(",
"\"description\"",
")",
"if",
"not",
"description",
":",
"return",
"# naive approach to removing indent from pytest docstrings",
"nodeid",
"=",
"testcase",
... | Creates a preformatted HTML version of the description. | [
"Creates",
"a",
"preformatted",
"HTML",
"version",
"of",
"the",
"description",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L139-L163 | train | Creates a preformatted HTML version of the description. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | add_unique_runid | def add_unique_runid(testcase, run_id=None):
"""Adds run id to the test description.
The `run_id` runs makes the descriptions unique between imports and force Polarion
to update every testcase every time.
"""
testcase["description"] = '{}<br id="{}"/>'.format(
testcase.get("description") or... | python | def add_unique_runid(testcase, run_id=None):
"""Adds run id to the test description.
The `run_id` runs makes the descriptions unique between imports and force Polarion
to update every testcase every time.
"""
testcase["description"] = '{}<br id="{}"/>'.format(
testcase.get("description") or... | [
"def",
"add_unique_runid",
"(",
"testcase",
",",
"run_id",
"=",
"None",
")",
":",
"testcase",
"[",
"\"description\"",
"]",
"=",
"'{}<br id=\"{}\"/>'",
".",
"format",
"(",
"testcase",
".",
"get",
"(",
"\"description\"",
")",
"or",
"\"\"",
",",
"run_id",
"or",... | Adds run id to the test description.
The `run_id` runs makes the descriptions unique between imports and force Polarion
to update every testcase every time. | [
"Adds",
"run",
"id",
"to",
"the",
"test",
"description",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L166-L174 | train | Adds run id to the test description. |
mkoura/dump2polarion | dump2polarion/exporters/transform.py | add_automation_link | def add_automation_link(testcase):
"""Appends link to automation script to the test description."""
automation_link = (
'<a href="{}">Test Source</a>'.format(testcase["automation_script"])
if testcase.get("automation_script")
else ""
)
testcase["description"] = "{}<br/>{}".format... | python | def add_automation_link(testcase):
"""Appends link to automation script to the test description."""
automation_link = (
'<a href="{}">Test Source</a>'.format(testcase["automation_script"])
if testcase.get("automation_script")
else ""
)
testcase["description"] = "{}<br/>{}".format... | [
"def",
"add_automation_link",
"(",
"testcase",
")",
":",
"automation_link",
"=",
"(",
"'<a href=\"{}\">Test Source</a>'",
".",
"format",
"(",
"testcase",
"[",
"\"automation_script\"",
"]",
")",
"if",
"testcase",
".",
"get",
"(",
"\"automation_script\"",
")",
"else",... | Appends link to automation script to the test description. | [
"Appends",
"link",
"to",
"automation",
"script",
"to",
"the",
"test",
"description",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform.py#L177-L184 | train | Appends link to automation script to the test description. |
marcosfelt/cheminventory_python | cheminventory/objects.py | Container.image | def image(self):
'''Return an image of the structure of the compound'''
r = requests.get(self.image_url, stream=True)
r.raise_for_status()
return r.raw.read() | python | def image(self):
'''Return an image of the structure of the compound'''
r = requests.get(self.image_url, stream=True)
r.raise_for_status()
return r.raw.read() | [
"def",
"image",
"(",
"self",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"image_url",
",",
"stream",
"=",
"True",
")",
"r",
".",
"raise_for_status",
"(",
")",
"return",
"r",
".",
"raw",
".",
"read",
"(",
")"
] | Return an image of the structure of the compound | [
"Return",
"an",
"image",
"of",
"the",
"structure",
"of",
"the",
"compound"
] | fa7d67a3741ba7095b30377ac52842997a649012 | https://github.com/marcosfelt/cheminventory_python/blob/fa7d67a3741ba7095b30377ac52842997a649012/cheminventory/objects.py#L52-L56 | train | Return an image of the structure of the compound |
oz123/blogit | media/uploads/ajax_bottle_files/ajax_bottle.py | add_numbers | def add_numbers():
"""Add two numbers server side, ridiculous but well..."""
a = request.params.get('a', 0, type=int)
b = request.params.get('b', 0, type=int)
return json.dumps({'result': a+b}) | python | def add_numbers():
"""Add two numbers server side, ridiculous but well..."""
a = request.params.get('a', 0, type=int)
b = request.params.get('b', 0, type=int)
return json.dumps({'result': a+b}) | [
"def",
"add_numbers",
"(",
")",
":",
"a",
"=",
"request",
".",
"params",
".",
"get",
"(",
"'a'",
",",
"0",
",",
"type",
"=",
"int",
")",
"b",
"=",
"request",
".",
"params",
".",
"get",
"(",
"'b'",
",",
"0",
",",
"type",
"=",
"int",
")",
"retu... | Add two numbers server side, ridiculous but well... | [
"Add",
"two",
"numbers",
"server",
"side",
"ridiculous",
"but",
"well",
"..."
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/media/uploads/ajax_bottle_files/ajax_bottle.py#L16-L20 | train | Add two numbers server side ridiculous but well... |
DeV1doR/aioethereum | aioethereum/management/db.py | DbMixin.db_putString | def db_putString(self, db_name, key, value):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_putstring
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
return (yield from self.rpc_call('db_putString',
[db_name, key, val... | python | def db_putString(self, db_name, key, value):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_putstring
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
return (yield from self.rpc_call('db_putString',
[db_name, key, val... | [
"def",
"db_putString",
"(",
"self",
",",
"db_name",
",",
"key",
",",
"value",
")",
":",
"warnings",
".",
"warn",
"(",
"'deprecated'",
",",
"DeprecationWarning",
")",
"return",
"(",
"yield",
"from",
"self",
".",
"rpc_call",
"(",
"'db_putString'",
",",
"[",
... | https://github.com/ethereum/wiki/wiki/JSON-RPC#db_putstring
DEPRECATED | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"ethereum",
"/",
"wiki",
"/",
"wiki",
"/",
"JSON",
"-",
"RPC#db_putstring"
] | 85eb46550d862b3ccc309914ea871ca1c7b42157 | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/db.py#L10-L17 | train | Store a string value in the specified database. |
DeV1doR/aioethereum | aioethereum/management/db.py | DbMixin.db_getString | def db_getString(self, db_name, key):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_getstring
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
return (yield from self.rpc_call('db_getString', [db_name, key])) | python | def db_getString(self, db_name, key):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_getstring
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
return (yield from self.rpc_call('db_getString', [db_name, key])) | [
"def",
"db_getString",
"(",
"self",
",",
"db_name",
",",
"key",
")",
":",
"warnings",
".",
"warn",
"(",
"'deprecated'",
",",
"DeprecationWarning",
")",
"return",
"(",
"yield",
"from",
"self",
".",
"rpc_call",
"(",
"'db_getString'",
",",
"[",
"db_name",
","... | https://github.com/ethereum/wiki/wiki/JSON-RPC#db_getstring
DEPRECATED | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"ethereum",
"/",
"wiki",
"/",
"wiki",
"/",
"JSON",
"-",
"RPC#db_getstring"
] | 85eb46550d862b3ccc309914ea871ca1c7b42157 | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/db.py#L20-L26 | train | Get a string from the database. |
DeV1doR/aioethereum | aioethereum/management/db.py | DbMixin.db_putHex | def db_putHex(self, db_name, key, value):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_puthex
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
if not value.startswith('0x'):
value = add_0x(value)
return (yield from self.rpc_call('db_putH... | python | def db_putHex(self, db_name, key, value):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_puthex
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
if not value.startswith('0x'):
value = add_0x(value)
return (yield from self.rpc_call('db_putH... | [
"def",
"db_putHex",
"(",
"self",
",",
"db_name",
",",
"key",
",",
"value",
")",
":",
"warnings",
".",
"warn",
"(",
"'deprecated'",
",",
"DeprecationWarning",
")",
"if",
"not",
"value",
".",
"startswith",
"(",
"'0x'",
")",
":",
"value",
"=",
"add_0x",
"... | https://github.com/ethereum/wiki/wiki/JSON-RPC#db_puthex
DEPRECATED | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"ethereum",
"/",
"wiki",
"/",
"wiki",
"/",
"JSON",
"-",
"RPC#db_puthex"
] | 85eb46550d862b3ccc309914ea871ca1c7b42157 | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/db.py#L29-L37 | train | Put a hex key in the database. |
DeV1doR/aioethereum | aioethereum/management/db.py | DbMixin.db_getHex | def db_getHex(self, db_name, key):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_gethex
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
return (yield from self.rpc_call('db_getHex', [db_name, key])) | python | def db_getHex(self, db_name, key):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#db_gethex
DEPRECATED
"""
warnings.warn('deprecated', DeprecationWarning)
return (yield from self.rpc_call('db_getHex', [db_name, key])) | [
"def",
"db_getHex",
"(",
"self",
",",
"db_name",
",",
"key",
")",
":",
"warnings",
".",
"warn",
"(",
"'deprecated'",
",",
"DeprecationWarning",
")",
"return",
"(",
"yield",
"from",
"self",
".",
"rpc_call",
"(",
"'db_getHex'",
",",
"[",
"db_name",
",",
"k... | https://github.com/ethereum/wiki/wiki/JSON-RPC#db_gethex
DEPRECATED | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"ethereum",
"/",
"wiki",
"/",
"wiki",
"/",
"JSON",
"-",
"RPC#db_gethex"
] | 85eb46550d862b3ccc309914ea871ca1c7b42157 | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/db.py#L39-L45 | train | Get a hex value from a database. |
chemreac/block_diag_ilu | python_prototype/fakelu.py | FakeLU.solve | def solve(self, b):
"""
LUx = b:
Ly = b
Ux = y
"""
#b = self.permute_vec(b)
y = []
for bri in range(self.N): # block row index
for li in range(self.n): # local row index
s = 0.0
for lci in range(li): # lo... | python | def solve(self, b):
"""
LUx = b:
Ly = b
Ux = y
"""
#b = self.permute_vec(b)
y = []
for bri in range(self.N): # block row index
for li in range(self.n): # local row index
s = 0.0
for lci in range(li): # lo... | [
"def",
"solve",
"(",
"self",
",",
"b",
")",
":",
"#b = self.permute_vec(b)",
"y",
"=",
"[",
"]",
"for",
"bri",
"in",
"range",
"(",
"self",
".",
"N",
")",
":",
"# block row index",
"for",
"li",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"# loca... | LUx = b:
Ly = b
Ux = y | [
"LUx",
"=",
"b",
":",
"Ly",
"=",
"b",
"Ux",
"=",
"y"
] | 3be507f3f90c4c6e6c9576d56f83f84167ce3b52 | https://github.com/chemreac/block_diag_ilu/blob/3be507f3f90c4c6e6c9576d56f83f84167ce3b52/python_prototype/fakelu.py#L237-L268 | train | Solve the problem with the given set of entries. |
bradmontgomery/django-blargg | blargg/templatetags/blargg_tags.py | entry_archive_year_url | def entry_archive_year_url():
"""Renders the ``entry_archive_year`` URL for the latest ``Entry``."""
entry = Entry.objects.filter(published=True).latest()
arg_list = [entry.published_on.strftime("%Y")]
return reverse('blargg:entry_archive_year', args=arg_list) | python | def entry_archive_year_url():
"""Renders the ``entry_archive_year`` URL for the latest ``Entry``."""
entry = Entry.objects.filter(published=True).latest()
arg_list = [entry.published_on.strftime("%Y")]
return reverse('blargg:entry_archive_year', args=arg_list) | [
"def",
"entry_archive_year_url",
"(",
")",
":",
"entry",
"=",
"Entry",
".",
"objects",
".",
"filter",
"(",
"published",
"=",
"True",
")",
".",
"latest",
"(",
")",
"arg_list",
"=",
"[",
"entry",
".",
"published_on",
".",
"strftime",
"(",
"\"%Y\"",
")",
... | Renders the ``entry_archive_year`` URL for the latest ``Entry``. | [
"Renders",
"the",
"entry_archive_year",
"URL",
"for",
"the",
"latest",
"Entry",
"."
] | 5d683e04723889a0d1c6d6cf1a67a3d431a2e617 | https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/templatetags/blargg_tags.py#L9-L13 | train | Renders the entry_archive_year URL for the latest Entry. |
mkoura/dump2polarion | dump2polarion/results/junittools.py | _extract_parameters_from_properties | def _extract_parameters_from_properties(properties):
"""Extracts parameters from properties."""
new_properties = {}
parameters = []
for key, value in six.iteritems(properties):
if key.startswith(_PARAMETER_PREFIX):
parameters.append((key.replace(_PARAMETER_PREFIX, ""), value))
... | python | def _extract_parameters_from_properties(properties):
"""Extracts parameters from properties."""
new_properties = {}
parameters = []
for key, value in six.iteritems(properties):
if key.startswith(_PARAMETER_PREFIX):
parameters.append((key.replace(_PARAMETER_PREFIX, ""), value))
... | [
"def",
"_extract_parameters_from_properties",
"(",
"properties",
")",
":",
"new_properties",
"=",
"{",
"}",
"parameters",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"properties",
")",
":",
"if",
"key",
".",
"startswith",
... | Extracts parameters from properties. | [
"Extracts",
"parameters",
"from",
"properties",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/junittools.py#L58-L68 | train | Extracts parameters from properties. |
mkoura/dump2polarion | dump2polarion/results/junittools.py | import_junit | def import_junit(junit_file, **kwargs):
"""Reads the content of the junit-results file produced by pytest and returns imported data."""
xml_root = _get_xml_root(junit_file)
results = []
for test_data in xml_root:
if test_data.tag != "testcase":
continue
verdict, comment, pr... | python | def import_junit(junit_file, **kwargs):
"""Reads the content of the junit-results file produced by pytest and returns imported data."""
xml_root = _get_xml_root(junit_file)
results = []
for test_data in xml_root:
if test_data.tag != "testcase":
continue
verdict, comment, pr... | [
"def",
"import_junit",
"(",
"junit_file",
",",
"*",
"*",
"kwargs",
")",
":",
"xml_root",
"=",
"_get_xml_root",
"(",
"junit_file",
")",
"results",
"=",
"[",
"]",
"for",
"test_data",
"in",
"xml_root",
":",
"if",
"test_data",
".",
"tag",
"!=",
"\"testcase\"",... | Reads the content of the junit-results file produced by pytest and returns imported data. | [
"Reads",
"the",
"content",
"of",
"the",
"junit",
"-",
"results",
"file",
"produced",
"by",
"pytest",
"and",
"returns",
"imported",
"data",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/junittools.py#L72-L104 | train | Reads the content of the junit - results file produced by pytest and returns imported data. |
klen/zeta-library | zetalibrary/main.py | libs | def libs():
" Show zeta libs "
for name, description, version, url in gen_frameworks():
print name
print ''.join('-' for _ in xrange(len(name)))
print description.strip('/*\n ')
print version.strip('/*\n ')
print url.strip('/*\n ')
print | python | def libs():
" Show zeta libs "
for name, description, version, url in gen_frameworks():
print name
print ''.join('-' for _ in xrange(len(name)))
print description.strip('/*\n ')
print version.strip('/*\n ')
print url.strip('/*\n ')
print | [
"def",
"libs",
"(",
")",
":",
"for",
"name",
",",
"description",
",",
"version",
",",
"url",
"in",
"gen_frameworks",
"(",
")",
":",
"print",
"name",
"print",
"''",
".",
"join",
"(",
"'-'",
"for",
"_",
"in",
"xrange",
"(",
"len",
"(",
"name",
")",
... | Show zeta libs | [
"Show",
"zeta",
"libs"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/main.py#L23-L31 | train | Show zeta libs |
klen/zeta-library | zetalibrary/main.py | watch | def watch(args):
" Watch directory for changes and auto pack sources "
assert op.isdir(args.source), "Watch mode allowed only for directories."
print 'Zeta-library v. %s watch mode' % VERSION
print '================================'
print 'Ctrl+C for exit\n'
observer = Observer()
handler = Z... | python | def watch(args):
" Watch directory for changes and auto pack sources "
assert op.isdir(args.source), "Watch mode allowed only for directories."
print 'Zeta-library v. %s watch mode' % VERSION
print '================================'
print 'Ctrl+C for exit\n'
observer = Observer()
handler = Z... | [
"def",
"watch",
"(",
"args",
")",
":",
"assert",
"op",
".",
"isdir",
"(",
"args",
".",
"source",
")",
",",
"\"Watch mode allowed only for directories.\"",
"print",
"'Zeta-library v. %s watch mode'",
"%",
"VERSION",
"print",
"'================================'",
"print",... | Watch directory for changes and auto pack sources | [
"Watch",
"directory",
"for",
"changes",
"and",
"auto",
"pack",
"sources"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/main.py#L42-L58 | train | Watch directory for changes and auto pack sources |
klen/zeta-library | zetalibrary/main.py | pack | def pack(args):
" Parse file or dir, import css, js code and save with prefix "
assert op.exists(args.source), "Does not exists: %s" % args.source
zeta_pack(args) | python | def pack(args):
" Parse file or dir, import css, js code and save with prefix "
assert op.exists(args.source), "Does not exists: %s" % args.source
zeta_pack(args) | [
"def",
"pack",
"(",
"args",
")",
":",
"assert",
"op",
".",
"exists",
"(",
"args",
".",
"source",
")",
",",
"\"Does not exists: %s\"",
"%",
"args",
".",
"source",
"zeta_pack",
"(",
"args",
")"
] | Parse file or dir, import css, js code and save with prefix | [
"Parse",
"file",
"or",
"dir",
"import",
"css",
"js",
"code",
"and",
"save",
"with",
"prefix"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/main.py#L69-L72 | train | Parse file or dir import css js code and save with prefix |
Genida/dependenpy | src/dependenpy/structures.py | Matrix.cast | def cast(keys, data):
"""Cast a set of keys and an array to a Matrix object."""
matrix = Matrix()
matrix.keys = keys
matrix.data = data
return matrix | python | def cast(keys, data):
"""Cast a set of keys and an array to a Matrix object."""
matrix = Matrix()
matrix.keys = keys
matrix.data = data
return matrix | [
"def",
"cast",
"(",
"keys",
",",
"data",
")",
":",
"matrix",
"=",
"Matrix",
"(",
")",
"matrix",
".",
"keys",
"=",
"keys",
"matrix",
".",
"data",
"=",
"data",
"return",
"matrix"
] | Cast a set of keys and an array to a Matrix object. | [
"Cast",
"a",
"set",
"of",
"keys",
"and",
"an",
"array",
"to",
"a",
"Matrix",
"object",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/structures.py#L82-L87 | train | Cast a set of keys and an array to a Matrix object. |
Genida/dependenpy | src/dependenpy/structures.py | Vertex.connect_to | def connect_to(self, vertex, weight=1):
"""
Connect this vertex to another one.
Args:
vertex (Vertex): vertex to connect to.
weight (int): weight of the edge.
Returns:
Edge: the newly created edge.
"""
for edge in self.edges_out:
... | python | def connect_to(self, vertex, weight=1):
"""
Connect this vertex to another one.
Args:
vertex (Vertex): vertex to connect to.
weight (int): weight of the edge.
Returns:
Edge: the newly created edge.
"""
for edge in self.edges_out:
... | [
"def",
"connect_to",
"(",
"self",
",",
"vertex",
",",
"weight",
"=",
"1",
")",
":",
"for",
"edge",
"in",
"self",
".",
"edges_out",
":",
"if",
"vertex",
"==",
"edge",
".",
"vertex_in",
":",
"return",
"edge",
"return",
"Edge",
"(",
"self",
",",
"vertex... | Connect this vertex to another one.
Args:
vertex (Vertex): vertex to connect to.
weight (int): weight of the edge.
Returns:
Edge: the newly created edge. | [
"Connect",
"this",
"vertex",
"to",
"another",
"one",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/structures.py#L201-L215 | train | Connect this edge to another edge. |
Genida/dependenpy | src/dependenpy/structures.py | Vertex.connect_from | def connect_from(self, vertex, weight=1):
"""
Connect another vertex to this one.
Args:
vertex (Vertex): vertex to connect from.
weight (int): weight of the edge.
Returns:
Edge: the newly created edge.
"""
for edge in self.edges_in:
... | python | def connect_from(self, vertex, weight=1):
"""
Connect another vertex to this one.
Args:
vertex (Vertex): vertex to connect from.
weight (int): weight of the edge.
Returns:
Edge: the newly created edge.
"""
for edge in self.edges_in:
... | [
"def",
"connect_from",
"(",
"self",
",",
"vertex",
",",
"weight",
"=",
"1",
")",
":",
"for",
"edge",
"in",
"self",
".",
"edges_in",
":",
"if",
"vertex",
"==",
"edge",
".",
"vertex_out",
":",
"return",
"edge",
"return",
"Edge",
"(",
"vertex",
",",
"se... | Connect another vertex to this one.
Args:
vertex (Vertex): vertex to connect from.
weight (int): weight of the edge.
Returns:
Edge: the newly created edge. | [
"Connect",
"another",
"vertex",
"to",
"this",
"one",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/structures.py#L217-L231 | train | Connect another vertex to this one. |
Genida/dependenpy | src/dependenpy/structures.py | Edge.go_from | def go_from(self, vertex):
"""
Tell the edge to go out from this vertex.
Args:
vertex (Vertex): vertex to go from.
"""
if self.vertex_out:
self.vertex_out.edges_out.remove(self)
self.vertex_out = vertex
vertex.edges_out.add(self) | python | def go_from(self, vertex):
"""
Tell the edge to go out from this vertex.
Args:
vertex (Vertex): vertex to go from.
"""
if self.vertex_out:
self.vertex_out.edges_out.remove(self)
self.vertex_out = vertex
vertex.edges_out.add(self) | [
"def",
"go_from",
"(",
"self",
",",
"vertex",
")",
":",
"if",
"self",
".",
"vertex_out",
":",
"self",
".",
"vertex_out",
".",
"edges_out",
".",
"remove",
"(",
"self",
")",
"self",
".",
"vertex_out",
"=",
"vertex",
"vertex",
".",
"edges_out",
".",
"add"... | Tell the edge to go out from this vertex.
Args:
vertex (Vertex): vertex to go from. | [
"Tell",
"the",
"edge",
"to",
"go",
"out",
"from",
"this",
"vertex",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/structures.py#L256-L266 | train | Tells the edge to go out from this one. |
Genida/dependenpy | src/dependenpy/structures.py | Edge.go_in | def go_in(self, vertex):
"""
Tell the edge to go into this vertex.
Args:
vertex (Vertex): vertex to go into.
"""
if self.vertex_in:
self.vertex_in.edges_in.remove(self)
self.vertex_in = vertex
vertex.edges_in.add(self) | python | def go_in(self, vertex):
"""
Tell the edge to go into this vertex.
Args:
vertex (Vertex): vertex to go into.
"""
if self.vertex_in:
self.vertex_in.edges_in.remove(self)
self.vertex_in = vertex
vertex.edges_in.add(self) | [
"def",
"go_in",
"(",
"self",
",",
"vertex",
")",
":",
"if",
"self",
".",
"vertex_in",
":",
"self",
".",
"vertex_in",
".",
"edges_in",
".",
"remove",
"(",
"self",
")",
"self",
".",
"vertex_in",
"=",
"vertex",
"vertex",
".",
"edges_in",
".",
"add",
"("... | Tell the edge to go into this vertex.
Args:
vertex (Vertex): vertex to go into. | [
"Tell",
"the",
"edge",
"to",
"go",
"into",
"this",
"vertex",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/structures.py#L268-L278 | train | Tells the edge to go into this vertex. |
ludeeus/GHLocalApi | ghlocalapi/utils/convert.py | get_device_type | def get_device_type(device_type=0):
"""Return the device type from a device_type list."""
device_types = {
0: "Unknown",
1: "Classic - BR/EDR devices",
2: "Low Energy - LE-only",
3: "Dual Mode - BR/EDR/LE"
}
if device_type in [0, 1, 2, 3]:
return_value = device_ty... | python | def get_device_type(device_type=0):
"""Return the device type from a device_type list."""
device_types = {
0: "Unknown",
1: "Classic - BR/EDR devices",
2: "Low Energy - LE-only",
3: "Dual Mode - BR/EDR/LE"
}
if device_type in [0, 1, 2, 3]:
return_value = device_ty... | [
"def",
"get_device_type",
"(",
"device_type",
"=",
"0",
")",
":",
"device_types",
"=",
"{",
"0",
":",
"\"Unknown\"",
",",
"1",
":",
"\"Classic - BR/EDR devices\"",
",",
"2",
":",
"\"Low Energy - LE-only\"",
",",
"3",
":",
"\"Dual Mode - BR/EDR/LE\"",
"}",
"if",
... | Return the device type from a device_type list. | [
"Return",
"the",
"device",
"type",
"from",
"a",
"device_type",
"list",
"."
] | 93abdee299c4a4b65aa9dd03c77ec34e174e3c56 | https://github.com/ludeeus/GHLocalApi/blob/93abdee299c4a4b65aa9dd03c77ec34e174e3c56/ghlocalapi/utils/convert.py#L9-L21 | train | Return the device type from a device_type list. |
djaodjin/djaodjin-deployutils | deployutils/apps/flask/templates.py | site_prefixed | def site_prefixed(path):
"""
*Mockup*: adds the path prefix when required.
"""
if path is None:
path = ''
if settings.DEBUG and hasattr(settings, 'APP_NAME'):
path_prefix = '/%s' % settings.APP_NAME
else:
path_prefix = ''
if path:
# We have an actual path inst... | python | def site_prefixed(path):
"""
*Mockup*: adds the path prefix when required.
"""
if path is None:
path = ''
if settings.DEBUG and hasattr(settings, 'APP_NAME'):
path_prefix = '/%s' % settings.APP_NAME
else:
path_prefix = ''
if path:
# We have an actual path inst... | [
"def",
"site_prefixed",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"''",
"if",
"settings",
".",
"DEBUG",
"and",
"hasattr",
"(",
"settings",
",",
"'APP_NAME'",
")",
":",
"path_prefix",
"=",
"'/%s'",
"%",
"settings",
".",
"APP_N... | *Mockup*: adds the path prefix when required. | [
"*",
"Mockup",
"*",
":",
"adds",
"the",
"path",
"prefix",
"when",
"required",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/flask/templates.py#L31-L48 | train | Returns the path prefix for the current site. |
romanorac/discomll | discomll/classification/logistic_regression.py | map_fit | def map_fit(interface, state, label, inp):
"""
Function calculates sigmoid function (g) for every sample. With g it calculates part of Hessian matrix and gradient, aggregates and output them. It also calculates J function which is needed for checking the convergence of parameters theta.
"""
import numpy... | python | def map_fit(interface, state, label, inp):
"""
Function calculates sigmoid function (g) for every sample. With g it calculates part of Hessian matrix and gradient, aggregates and output them. It also calculates J function which is needed for checking the convergence of parameters theta.
"""
import numpy... | [
"def",
"map_fit",
"(",
"interface",
",",
"state",
",",
"label",
",",
"inp",
")",
":",
"import",
"numpy",
"as",
"np",
"out",
"=",
"interface",
".",
"output",
"(",
"0",
")",
"H",
",",
"J",
",",
"grad",
"=",
"0",
",",
"0",
",",
"0",
"for",
"row",
... | Function calculates sigmoid function (g) for every sample. With g it calculates part of Hessian matrix and gradient, aggregates and output them. It also calculates J function which is needed for checking the convergence of parameters theta. | [
"Function",
"calculates",
"sigmoid",
"function",
"(",
"g",
")",
"for",
"every",
"sample",
".",
"With",
"g",
"it",
"calculates",
"part",
"of",
"Hessian",
"matrix",
"and",
"gradient",
"aggregates",
"and",
"output",
"them",
".",
"It",
"also",
"calculates",
"J",... | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/logistic_regression.py#L15-L40 | train | Function calculates sigmoid function for every sample and calculates gradient for each sample. |
romanorac/discomll | discomll/classification/logistic_regression.py | fit | def fit(dataset, alpha=1e-8, max_iterations=10, save_results=True, show=False):
"""
Function starts a job for calculation of theta parameters
Parameters
----------
input - dataset object with input urls and other parameters
alpha - convergence value
max_iterations - define maximum number of... | python | def fit(dataset, alpha=1e-8, max_iterations=10, save_results=True, show=False):
"""
Function starts a job for calculation of theta parameters
Parameters
----------
input - dataset object with input urls and other parameters
alpha - convergence value
max_iterations - define maximum number of... | [
"def",
"fit",
"(",
"dataset",
",",
"alpha",
"=",
"1e-8",
",",
"max_iterations",
"=",
"10",
",",
"save_results",
"=",
"True",
",",
"show",
"=",
"False",
")",
":",
"from",
"disco",
".",
"worker",
".",
"pipeline",
".",
"worker",
"import",
"Worker",
",",
... | Function starts a job for calculation of theta parameters
Parameters
----------
input - dataset object with input urls and other parameters
alpha - convergence value
max_iterations - define maximum number of iterations
save_results - save results to ddfs
show - show info about job execution... | [
"Function",
"starts",
"a",
"job",
"for",
"calculation",
"of",
"theta",
"parameters"
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/logistic_regression.py#L82-L138 | train | Function for fitting a logistic regression model on a single dataset object. |
davidfokkema/artist | artist/plot.py | BasePlotContainer.render | def render(self, template=None):
"""Render the plot using a template.
Once the plot is complete, it needs to be rendered. Artist uses
the Jinja2 templating engine. The default template results in a
LaTeX file which can be included in your document.
:param template: a user-sup... | python | def render(self, template=None):
"""Render the plot using a template.
Once the plot is complete, it needs to be rendered. Artist uses
the Jinja2 templating engine. The default template results in a
LaTeX file which can be included in your document.
:param template: a user-sup... | [
"def",
"render",
"(",
"self",
",",
"template",
"=",
"None",
")",
":",
"if",
"not",
"template",
":",
"template",
"=",
"self",
".",
"template",
"response",
"=",
"template",
".",
"render",
"(",
")",
"return",
"response"
] | Render the plot using a template.
Once the plot is complete, it needs to be rendered. Artist uses
the Jinja2 templating engine. The default template results in a
LaTeX file which can be included in your document.
:param template: a user-supplied template or None.
:type templa... | [
"Render",
"the",
"plot",
"using",
"a",
"template",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L64-L83 | train | Render the plot using a template. |
davidfokkema/artist | artist/plot.py | BasePlotContainer.save | def save(self, dest_path):
r"""Save the plot as a LaTeX file.
The output file can be included (using \input) in your LaTeX document.
It can also be compiled as a standalone document to generate a
(cropped) pdf version of the plot.
:param dest_path: path of the file.
""... | python | def save(self, dest_path):
r"""Save the plot as a LaTeX file.
The output file can be included (using \input) in your LaTeX document.
It can also be compiled as a standalone document to generate a
(cropped) pdf version of the plot.
:param dest_path: path of the file.
""... | [
"def",
"save",
"(",
"self",
",",
"dest_path",
")",
":",
"self",
".",
"save_assets",
"(",
"dest_path",
")",
"self",
".",
"external_filename",
"=",
"'externalized-%s'",
"%",
"os",
".",
"path",
".",
"basename",
"(",
"dest_path",
")",
".",
"replace",
"(",
"'... | r"""Save the plot as a LaTeX file.
The output file can be included (using \input) in your LaTeX document.
It can also be compiled as a standalone document to generate a
(cropped) pdf version of the plot.
:param dest_path: path of the file. | [
"r",
"Save",
"the",
"plot",
"as",
"a",
"LaTeX",
"file",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L96-L111 | train | r Save the plot as a LaTeX file. |
davidfokkema/artist | artist/plot.py | BasePlotContainer.save_as_pdf | def save_as_pdf(self, dest_path):
"""Save the plot as a PDF file.
Save and render the plot using LaTeX to create a PDF file.
:param dest_path: path of the file.
"""
dest_path = self._add_extension('pdf', dest_path)
build_dir = tempfile.mkdtemp()
build_path = os... | python | def save_as_pdf(self, dest_path):
"""Save the plot as a PDF file.
Save and render the plot using LaTeX to create a PDF file.
:param dest_path: path of the file.
"""
dest_path = self._add_extension('pdf', dest_path)
build_dir = tempfile.mkdtemp()
build_path = os... | [
"def",
"save_as_pdf",
"(",
"self",
",",
"dest_path",
")",
":",
"dest_path",
"=",
"self",
".",
"_add_extension",
"(",
"'pdf'",
",",
"dest_path",
")",
"build_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"build_path",
"=",
"os",
".",
"path",
".",
"join"... | Save the plot as a PDF file.
Save and render the plot using LaTeX to create a PDF file.
:param dest_path: path of the file. | [
"Save",
"the",
"plot",
"as",
"a",
"PDF",
"file",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L113-L129 | train | Save the plot as a PDF file. |
davidfokkema/artist | artist/plot.py | SubPlot.plot | def plot(self, x, y, xerr=[], yerr=[], mark='o',
linestyle='solid', use_steps=False, markstyle=None, legend=None):
"""Add a data series to the plot.
:param x: array containing x-values.
:param y: array containing y-values.
:param xerr: (optional) array containing errors on ... | python | def plot(self, x, y, xerr=[], yerr=[], mark='o',
linestyle='solid', use_steps=False, markstyle=None, legend=None):
"""Add a data series to the plot.
:param x: array containing x-values.
:param y: array containing y-values.
:param xerr: (optional) array containing errors on ... | [
"def",
"plot",
"(",
"self",
",",
"x",
",",
"y",
",",
"xerr",
"=",
"[",
"]",
",",
"yerr",
"=",
"[",
"]",
",",
"mark",
"=",
"'o'",
",",
"linestyle",
"=",
"'solid'",
",",
"use_steps",
"=",
"False",
",",
"markstyle",
"=",
"None",
",",
"legend",
"="... | Add a data series to the plot.
:param x: array containing x-values.
:param y: array containing y-values.
:param xerr: (optional) array containing errors on the x-values.
:param yerr: (optional) array containing errors on the y-values.
:param mark: the symbol used to mark the dat... | [
"Add",
"a",
"data",
"series",
"to",
"the",
"plot",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L231-L271 | train | Add a data series to the plot. |
davidfokkema/artist | artist/plot.py | SubPlot.histogram | def histogram(self, counts, bin_edges, linestyle='solid'):
"""Plot a histogram.
The user needs to supply the histogram. This method only plots
the results. You can use NumPy's histogram function.
:param counts: array containing the count values.
:param bin_edges: array contai... | python | def histogram(self, counts, bin_edges, linestyle='solid'):
"""Plot a histogram.
The user needs to supply the histogram. This method only plots
the results. You can use NumPy's histogram function.
:param counts: array containing the count values.
:param bin_edges: array contai... | [
"def",
"histogram",
"(",
"self",
",",
"counts",
",",
"bin_edges",
",",
"linestyle",
"=",
"'solid'",
")",
":",
"if",
"len",
"(",
"bin_edges",
")",
"-",
"1",
"!=",
"len",
"(",
"counts",
")",
":",
"raise",
"RuntimeError",
"(",
"'The length of bin_edges should... | Plot a histogram.
The user needs to supply the histogram. This method only plots
the results. You can use NumPy's histogram function.
:param counts: array containing the count values.
:param bin_edges: array containing the bin edges.
:param linestyle: the line style used to c... | [
"Plot",
"a",
"histogram",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L289-L315 | train | Plots a histogram of the count values and bin edges. |
davidfokkema/artist | artist/plot.py | SubPlot.histogram2d | def histogram2d(self, counts, x_edges, y_edges, type='bw', style=None,
bitmap=False, colormap=None):
"""Plot a two-dimensional histogram.
The user needs to supply the histogram. This method only plots
the results. You can use NumPy's histogram2d function.
:param c... | python | def histogram2d(self, counts, x_edges, y_edges, type='bw', style=None,
bitmap=False, colormap=None):
"""Plot a two-dimensional histogram.
The user needs to supply the histogram. This method only plots
the results. You can use NumPy's histogram2d function.
:param c... | [
"def",
"histogram2d",
"(",
"self",
",",
"counts",
",",
"x_edges",
",",
"y_edges",
",",
"type",
"=",
"'bw'",
",",
"style",
"=",
"None",
",",
"bitmap",
"=",
"False",
",",
"colormap",
"=",
"None",
")",
":",
"if",
"counts",
".",
"shape",
"!=",
"(",
"le... | Plot a two-dimensional histogram.
The user needs to supply the histogram. This method only plots
the results. You can use NumPy's histogram2d function.
:param counts: array containing the count values.
:param x_edges: array containing the x-axis bin edges.
:param y_edges: arr... | [
"Plot",
"a",
"two",
"-",
"dimensional",
"histogram",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L317-L431 | train | Plot a two - dimensional histogram of the count values. |
davidfokkema/artist | artist/plot.py | SubPlot.scatter | def scatter(self, x, y, xerr=[], yerr=[], mark='o', markstyle=None):
"""Plot a series of points.
Plot a series of points (marks) that are not connected by a
line. Shortcut for plot with linestyle=None.
:param x: array containing x-values.
:param y: array containing y-values.
... | python | def scatter(self, x, y, xerr=[], yerr=[], mark='o', markstyle=None):
"""Plot a series of points.
Plot a series of points (marks) that are not connected by a
line. Shortcut for plot with linestyle=None.
:param x: array containing x-values.
:param y: array containing y-values.
... | [
"def",
"scatter",
"(",
"self",
",",
"x",
",",
"y",
",",
"xerr",
"=",
"[",
"]",
",",
"yerr",
"=",
"[",
"]",
",",
"mark",
"=",
"'o'",
",",
"markstyle",
"=",
"None",
")",
":",
"self",
".",
"plot",
"(",
"x",
",",
"y",
",",
"xerr",
"=",
"xerr",
... | Plot a series of points.
Plot a series of points (marks) that are not connected by a
line. Shortcut for plot with linestyle=None.
:param x: array containing x-values.
:param y: array containing y-values.
:param xerr: array containing errors on the x-values.
:param yerr:... | [
"Plot",
"a",
"series",
"of",
"points",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L433-L458 | train | Plot a series of points. |
davidfokkema/artist | artist/plot.py | SubPlot.scatter_table | def scatter_table(self, x, y, c, s, mark='*'):
"""Add a data series to the plot.
:param x: array containing x-values.
:param y: array containing y-values.
:param c: array containing values for the color of the mark.
:param s: array containing values for the size of the mark.
... | python | def scatter_table(self, x, y, c, s, mark='*'):
"""Add a data series to the plot.
:param x: array containing x-values.
:param y: array containing y-values.
:param c: array containing values for the color of the mark.
:param s: array containing values for the size of the mark.
... | [
"def",
"scatter_table",
"(",
"self",
",",
"x",
",",
"y",
",",
"c",
",",
"s",
",",
"mark",
"=",
"'*'",
")",
":",
"# clear the background of the marks",
"# self._clear_plot_mark_background(x, y, mark, markstyle)",
"# draw the plot series over the background",
"options",
"="... | Add a data series to the plot.
:param x: array containing x-values.
:param y: array containing y-values.
:param c: array containing values for the color of the mark.
:param s: array containing values for the size of the mark.
:param mark: the symbol used to mark the data point. ... | [
"Add",
"a",
"data",
"series",
"to",
"the",
"plot",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L460-L481 | train | Add a data series to the plot. |
davidfokkema/artist | artist/plot.py | SubPlot.set_label | def set_label(self, text, location='upper right', style=None):
"""Set a label for the plot.
:param text: the label text.
:param location: the location of the label inside the plot. May
be one of 'center', 'upper right', 'lower right', 'upper
left', 'lower left'.
... | python | def set_label(self, text, location='upper right', style=None):
"""Set a label for the plot.
:param text: the label text.
:param location: the location of the label inside the plot. May
be one of 'center', 'upper right', 'lower right', 'upper
left', 'lower left'.
... | [
"def",
"set_label",
"(",
"self",
",",
"text",
",",
"location",
"=",
"'upper right'",
",",
"style",
"=",
"None",
")",
":",
"if",
"location",
"in",
"RELATIVE_NODE_LOCATIONS",
":",
"label",
"=",
"RELATIVE_NODE_LOCATIONS",
"[",
"location",
"]",
".",
"copy",
"(",... | Set a label for the plot.
:param text: the label text.
:param location: the location of the label inside the plot. May
be one of 'center', 'upper right', 'lower right', 'upper
left', 'lower left'.
:param style: any TikZ style to style the text. | [
"Set",
"a",
"label",
"for",
"the",
"plot",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L494-L510 | train | Set the label for the current plot. |
davidfokkema/artist | artist/plot.py | SubPlot.add_pin | def add_pin(self, text, location='left', x=None, use_arrow=False,
relative_position=None, style=None):
"""Add pin to most recent data series.
The location of the pin is interpolated if necessary, while correcting
for logarithmic x and/or y axes.
:param text: the text of... | python | def add_pin(self, text, location='left', x=None, use_arrow=False,
relative_position=None, style=None):
"""Add pin to most recent data series.
The location of the pin is interpolated if necessary, while correcting
for logarithmic x and/or y axes.
:param text: the text of... | [
"def",
"add_pin",
"(",
"self",
",",
"text",
",",
"location",
"=",
"'left'",
",",
"x",
"=",
"None",
",",
"use_arrow",
"=",
"False",
",",
"relative_position",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"try",
":",
"series",
"=",
"self",
".",
"... | Add pin to most recent data series.
The location of the pin is interpolated if necessary, while correcting
for logarithmic x and/or y axes.
:param text: the text of the pin label.
:param location: the location of the pin relative to the data
point. Any location accepted by... | [
"Add",
"pin",
"to",
"most",
"recent",
"data",
"series",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L512-L560 | train | Add a pin to the most recent data series. |
davidfokkema/artist | artist/plot.py | SubPlot.add_pin_at_xy | def add_pin_at_xy(self, x, y, text, location='above right',
relative_position=.9, use_arrow=True, style=None):
"""Add pin at x, y location.
:param x: array, list or float, specifying the location of the
pin.
:param y: array, list or float, specifying the locati... | python | def add_pin_at_xy(self, x, y, text, location='above right',
relative_position=.9, use_arrow=True, style=None):
"""Add pin at x, y location.
:param x: array, list or float, specifying the location of the
pin.
:param y: array, list or float, specifying the locati... | [
"def",
"add_pin_at_xy",
"(",
"self",
",",
"x",
",",
"y",
",",
"text",
",",
"location",
"=",
"'above right'",
",",
"relative_position",
"=",
".9",
",",
"use_arrow",
"=",
"True",
",",
"style",
"=",
"None",
")",
":",
"if",
"relative_position",
"is",
"None",... | Add pin at x, y location.
:param x: array, list or float, specifying the location of the
pin.
:param y: array, list or float, specifying the location of the
pin.
:param text: the text of the pin label.
:param location: the location of the pin relative to the data... | [
"Add",
"pin",
"at",
"x",
"y",
"location",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L562-L597 | train | Adds a pin at x y location. |
davidfokkema/artist | artist/plot.py | SubPlot.shade_region | def shade_region(self, x, lower, upper, color='lightgray'):
"""Shade a region between upper and lower bounds.
:param x: array containing x-values
:param lower: array containing y-values of lower bounds
:param upper: array containing y-values of upper bounds
:param color: TikZ st... | python | def shade_region(self, x, lower, upper, color='lightgray'):
"""Shade a region between upper and lower bounds.
:param x: array containing x-values
:param lower: array containing y-values of lower bounds
:param upper: array containing y-values of upper bounds
:param color: TikZ st... | [
"def",
"shade_region",
"(",
"self",
",",
"x",
",",
"lower",
",",
"upper",
",",
"color",
"=",
"'lightgray'",
")",
":",
"self",
".",
"shaded_regions_list",
".",
"append",
"(",
"{",
"'data'",
":",
"list",
"(",
"zip",
"(",
"x",
",",
"lower",
",",
"upper"... | Shade a region between upper and lower bounds.
:param x: array containing x-values
:param lower: array containing y-values of lower bounds
:param upper: array containing y-values of upper bounds
:param color: TikZ style to color the region | [
"Shade",
"a",
"region",
"between",
"upper",
"and",
"lower",
"bounds",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L599-L609 | train | Shade a region between upper and lower bounds. |
davidfokkema/artist | artist/plot.py | SubPlot.draw_image | def draw_image(self, image, xmin=0, ymin=0, xmax=None, ymax=None):
"""Draw an image.
Do not forget to use :meth:`set_axis_equal` to preserve the
aspect ratio of the image, or change the aspect ratio of the
plot to the aspect ratio of the image.
:param image: Pillow Image object... | python | def draw_image(self, image, xmin=0, ymin=0, xmax=None, ymax=None):
"""Draw an image.
Do not forget to use :meth:`set_axis_equal` to preserve the
aspect ratio of the image, or change the aspect ratio of the
plot to the aspect ratio of the image.
:param image: Pillow Image object... | [
"def",
"draw_image",
"(",
"self",
",",
"image",
",",
"xmin",
"=",
"0",
",",
"ymin",
"=",
"0",
",",
"xmax",
"=",
"None",
",",
"ymax",
"=",
"None",
")",
":",
"if",
"xmax",
"is",
"None",
":",
"xmax",
"=",
"xmin",
"+",
"image",
".",
"size",
"[",
... | Draw an image.
Do not forget to use :meth:`set_axis_equal` to preserve the
aspect ratio of the image, or change the aspect ratio of the
plot to the aspect ratio of the image.
:param image: Pillow Image object.
:param xmin,ymin,xmax,ymax: the x, y image bounds.
Example:... | [
"Draw",
"an",
"image",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L611-L649 | train | Draw an image. |
davidfokkema/artist | artist/plot.py | SubPlot.set_xlimits | def set_xlimits(self, min=None, max=None):
"""Set limits for the x-axis.
:param min: minimum value to be displayed. If None, it will be
calculated.
:param max: maximum value to be displayed. If None, it will be
calculated.
"""
self.limits['xmin'] = min... | python | def set_xlimits(self, min=None, max=None):
"""Set limits for the x-axis.
:param min: minimum value to be displayed. If None, it will be
calculated.
:param max: maximum value to be displayed. If None, it will be
calculated.
"""
self.limits['xmin'] = min... | [
"def",
"set_xlimits",
"(",
"self",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"self",
".",
"limits",
"[",
"'xmin'",
"]",
"=",
"min",
"self",
".",
"limits",
"[",
"'xmax'",
"]",
"=",
"max"
] | Set limits for the x-axis.
:param min: minimum value to be displayed. If None, it will be
calculated.
:param max: maximum value to be displayed. If None, it will be
calculated. | [
"Set",
"limits",
"for",
"the",
"x",
"-",
"axis",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L695-L705 | train | Set limits for the x - axis. |
davidfokkema/artist | artist/plot.py | SubPlot.set_ylimits | def set_ylimits(self, min=None, max=None):
"""Set limits for the y-axis.
:param min: minimum value to be displayed. If None, it will be
calculated.
:param max: maximum value to be displayed. If None, it will be
calculated.
"""
self.limits['ymin'] = min... | python | def set_ylimits(self, min=None, max=None):
"""Set limits for the y-axis.
:param min: minimum value to be displayed. If None, it will be
calculated.
:param max: maximum value to be displayed. If None, it will be
calculated.
"""
self.limits['ymin'] = min... | [
"def",
"set_ylimits",
"(",
"self",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"self",
".",
"limits",
"[",
"'ymin'",
"]",
"=",
"min",
"self",
".",
"limits",
"[",
"'ymax'",
"]",
"=",
"max"
] | Set limits for the y-axis.
:param min: minimum value to be displayed. If None, it will be
calculated.
:param max: maximum value to be displayed. If None, it will be
calculated. | [
"Set",
"limits",
"for",
"the",
"y",
"-",
"axis",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L707-L717 | train | Set limits for the y - axis. |
davidfokkema/artist | artist/plot.py | SubPlot.set_mlimits | def set_mlimits(self, min=None, max=None):
"""Set limits for the point meta (colormap).
Point meta values outside this range will be clipped.
:param min: value corresponding to the start of the colormap.
If None, it will be calculated.
:param max: value corresponding to the... | python | def set_mlimits(self, min=None, max=None):
"""Set limits for the point meta (colormap).
Point meta values outside this range will be clipped.
:param min: value corresponding to the start of the colormap.
If None, it will be calculated.
:param max: value corresponding to the... | [
"def",
"set_mlimits",
"(",
"self",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"self",
".",
"limits",
"[",
"'mmin'",
"]",
"=",
"min",
"self",
".",
"limits",
"[",
"'mmax'",
"]",
"=",
"max"
] | Set limits for the point meta (colormap).
Point meta values outside this range will be clipped.
:param min: value corresponding to the start of the colormap.
If None, it will be calculated.
:param max: value corresponding to the end of the colormap.
If None, it will be ... | [
"Set",
"limits",
"for",
"the",
"point",
"meta",
"(",
"colormap",
")",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L745-L757 | train | Set limits for the point meta values outside this range will be clipped. |
davidfokkema/artist | artist/plot.py | SubPlot.set_slimits | def set_slimits(self, min, max):
"""Set limits for the size of points in :meth:`scatter_table`.
If both are None, the size will be the given values.
:param min: point size for the lowest value.
:param max: point size for the highest value.
"""
self.limits['smin'] = sqr... | python | def set_slimits(self, min, max):
"""Set limits for the size of points in :meth:`scatter_table`.
If both are None, the size will be the given values.
:param min: point size for the lowest value.
:param max: point size for the highest value.
"""
self.limits['smin'] = sqr... | [
"def",
"set_slimits",
"(",
"self",
",",
"min",
",",
"max",
")",
":",
"self",
".",
"limits",
"[",
"'smin'",
"]",
"=",
"sqrt",
"(",
"min",
")",
"self",
".",
"limits",
"[",
"'smax'",
"]",
"=",
"sqrt",
"(",
"max",
")"
] | Set limits for the size of points in :meth:`scatter_table`.
If both are None, the size will be the given values.
:param min: point size for the lowest value.
:param max: point size for the highest value. | [
"Set",
"limits",
"for",
"the",
"size",
"of",
"points",
"in",
":",
"meth",
":",
"scatter_table",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L759-L769 | train | Set limits for the size of points in scatter table. |
davidfokkema/artist | artist/plot.py | SubPlot.set_xtick_labels | def set_xtick_labels(self, labels, style=None):
"""Set tick labels for the x-axis.
Also set the x-ticks positions to ensure the labels end up on
the correct place.
:param labels: list of labels for the ticks along the axis.
"""
self.ticks['xlabels'] = labels
se... | python | def set_xtick_labels(self, labels, style=None):
"""Set tick labels for the x-axis.
Also set the x-ticks positions to ensure the labels end up on
the correct place.
:param labels: list of labels for the ticks along the axis.
"""
self.ticks['xlabels'] = labels
se... | [
"def",
"set_xtick_labels",
"(",
"self",
",",
"labels",
",",
"style",
"=",
"None",
")",
":",
"self",
".",
"ticks",
"[",
"'xlabels'",
"]",
"=",
"labels",
"self",
".",
"ticks",
"[",
"'xlabel_style'",
"]",
"=",
"style"
] | Set tick labels for the x-axis.
Also set the x-ticks positions to ensure the labels end up on
the correct place.
:param labels: list of labels for the ticks along the axis. | [
"Set",
"tick",
"labels",
"for",
"the",
"x",
"-",
"axis",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L811-L821 | train | Set the tick labels for the x - axis. |
davidfokkema/artist | artist/plot.py | SubPlot.set_ytick_labels | def set_ytick_labels(self, labels, style=None):
"""Set tick labels for the y-axis.
Also set the y-ticks positions to ensure the labels end up on
the correct place.
:param labels: list of labels for the ticks along the axis.
"""
self.ticks['ylabels'] = labels
se... | python | def set_ytick_labels(self, labels, style=None):
"""Set tick labels for the y-axis.
Also set the y-ticks positions to ensure the labels end up on
the correct place.
:param labels: list of labels for the ticks along the axis.
"""
self.ticks['ylabels'] = labels
se... | [
"def",
"set_ytick_labels",
"(",
"self",
",",
"labels",
",",
"style",
"=",
"None",
")",
":",
"self",
".",
"ticks",
"[",
"'ylabels'",
"]",
"=",
"labels",
"self",
".",
"ticks",
"[",
"'ylabel_style'",
"]",
"=",
"style"
] | Set tick labels for the y-axis.
Also set the y-ticks positions to ensure the labels end up on
the correct place.
:param labels: list of labels for the ticks along the axis. | [
"Set",
"tick",
"labels",
"for",
"the",
"y",
"-",
"axis",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L823-L833 | train | Set the tick labels for the y - axis. |
davidfokkema/artist | artist/plot.py | SubPlot.set_xtick_suffix | def set_xtick_suffix(self, suffix):
"""Set the suffix for the ticks of the x-axis.
:param suffix: string added after each tick. If the value is
`degree` or `precent` the corresponding symbols
will be added.
"""
if suffix == 'degree':
... | python | def set_xtick_suffix(self, suffix):
"""Set the suffix for the ticks of the x-axis.
:param suffix: string added after each tick. If the value is
`degree` or `precent` the corresponding symbols
will be added.
"""
if suffix == 'degree':
... | [
"def",
"set_xtick_suffix",
"(",
"self",
",",
"suffix",
")",
":",
"if",
"suffix",
"==",
"'degree'",
":",
"suffix",
"=",
"r'^\\circ'",
"elif",
"suffix",
"==",
"'percent'",
":",
"suffix",
"=",
"r'\\%'",
"self",
".",
"ticks",
"[",
"'xsuffix'",
"]",
"=",
"suf... | Set the suffix for the ticks of the x-axis.
:param suffix: string added after each tick. If the value is
`degree` or `precent` the corresponding symbols
will be added. | [
"Set",
"the",
"suffix",
"for",
"the",
"ticks",
"of",
"the",
"x",
"-",
"axis",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L835-L848 | train | Set the suffix for the ticks of the x - axis. |
davidfokkema/artist | artist/plot.py | SubPlot.set_ytick_suffix | def set_ytick_suffix(self, suffix):
"""Set ticks for the y-axis.
:param suffix: string added after each tick. If the value is
`degree` or `precent` the corresponding symbols
will be added.
"""
if suffix == 'degree':
suffix = r'^... | python | def set_ytick_suffix(self, suffix):
"""Set ticks for the y-axis.
:param suffix: string added after each tick. If the value is
`degree` or `precent` the corresponding symbols
will be added.
"""
if suffix == 'degree':
suffix = r'^... | [
"def",
"set_ytick_suffix",
"(",
"self",
",",
"suffix",
")",
":",
"if",
"suffix",
"==",
"'degree'",
":",
"suffix",
"=",
"r'^\\circ'",
"elif",
"suffix",
"==",
"'percent'",
":",
"suffix",
"=",
"r'\\%'",
"self",
".",
"ticks",
"[",
"'ysuffix'",
"]",
"=",
"suf... | Set ticks for the y-axis.
:param suffix: string added after each tick. If the value is
`degree` or `precent` the corresponding symbols
will be added. | [
"Set",
"ticks",
"for",
"the",
"y",
"-",
"axis",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L850-L863 | train | Set the ticks for the y - axis. |
davidfokkema/artist | artist/plot.py | SubPlot.set_scalebar | def set_scalebar(self, location='lower right'):
"""Show marker area scale.
:param location: the location of the label inside the plot. May
be one of 'center', 'upper right', 'lower right', 'upper
left', 'lower left'.
"""
if location in RELATIVE_NODE_LOCATIONS:
... | python | def set_scalebar(self, location='lower right'):
"""Show marker area scale.
:param location: the location of the label inside the plot. May
be one of 'center', 'upper right', 'lower right', 'upper
left', 'lower left'.
"""
if location in RELATIVE_NODE_LOCATIONS:
... | [
"def",
"set_scalebar",
"(",
"self",
",",
"location",
"=",
"'lower right'",
")",
":",
"if",
"location",
"in",
"RELATIVE_NODE_LOCATIONS",
":",
"scalebar",
"=",
"RELATIVE_NODE_LOCATIONS",
"[",
"location",
"]",
".",
"copy",
"(",
")",
"self",
".",
"scalebar",
"=",
... | Show marker area scale.
:param location: the location of the label inside the plot. May
be one of 'center', 'upper right', 'lower right', 'upper
left', 'lower left'. | [
"Show",
"marker",
"area",
"scale",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L870-L882 | train | Set marker area scale. |
davidfokkema/artist | artist/plot.py | SubPlot._calc_position_for_pin | def _calc_position_for_pin(self, x, y, relative_position):
"""Determine position at fraction of x, y path.
:param x,y: two equal length lists of values describing a path.
:param relative_position: value between 0 and 1
:returns: the x, y position of the fraction (relative_position)
... | python | def _calc_position_for_pin(self, x, y, relative_position):
"""Determine position at fraction of x, y path.
:param x,y: two equal length lists of values describing a path.
:param relative_position: value between 0 and 1
:returns: the x, y position of the fraction (relative_position)
... | [
"def",
"_calc_position_for_pin",
"(",
"self",
",",
"x",
",",
"y",
",",
"relative_position",
")",
":",
"try",
":",
"max_idx_x",
"=",
"len",
"(",
"x",
")",
"-",
"1",
"max_idx_y",
"=",
"len",
"(",
"y",
")",
"-",
"1",
"except",
"TypeError",
":",
"return"... | Determine position at fraction of x, y path.
:param x,y: two equal length lists of values describing a path.
:param relative_position: value between 0 and 1
:returns: the x, y position of the fraction (relative_position)
of the path length. | [
"Determine",
"position",
"at",
"fraction",
"of",
"x",
"y",
"path",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L952-L993 | train | Calculates the position at fraction of x y for pin. |
davidfokkema/artist | artist/plot.py | SubPlot._calc_relative_path_lengths | def _calc_relative_path_lengths(self, x, y):
"""Determine the relative path length at each x,y position."""
path_lengths = np.sqrt(np.diff(x) ** 2 + np.diff(y) ** 2)
total_length = np.sum(path_lengths)
cummulative_lengths = np.cumsum(path_lengths)
relative_path_lengths = cummula... | python | def _calc_relative_path_lengths(self, x, y):
"""Determine the relative path length at each x,y position."""
path_lengths = np.sqrt(np.diff(x) ** 2 + np.diff(y) ** 2)
total_length = np.sum(path_lengths)
cummulative_lengths = np.cumsum(path_lengths)
relative_path_lengths = cummula... | [
"def",
"_calc_relative_path_lengths",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"path_lengths",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"diff",
"(",
"x",
")",
"**",
"2",
"+",
"np",
".",
"diff",
"(",
"y",
")",
"**",
"2",
")",
"total_length",
"=",... | Determine the relative path length at each x,y position. | [
"Determine",
"the",
"relative",
"path",
"length",
"at",
"each",
"x",
"y",
"position",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L995-L1002 | train | Determine the relative path length at each x y position. |
davidfokkema/artist | artist/plot.py | SubPlot._normalize_histogram2d | def _normalize_histogram2d(self, counts, type):
"""Normalize the values of the counts for a 2D histogram.
This normalizes the values of a numpy array to the range 0-255.
:param counts: a NumPy array which is to be rescaled.
:param type: either 'bw' or 'reverse_bw'.
"""
... | python | def _normalize_histogram2d(self, counts, type):
"""Normalize the values of the counts for a 2D histogram.
This normalizes the values of a numpy array to the range 0-255.
:param counts: a NumPy array which is to be rescaled.
:param type: either 'bw' or 'reverse_bw'.
"""
... | [
"def",
"_normalize_histogram2d",
"(",
"self",
",",
"counts",
",",
"type",
")",
":",
"counts",
"=",
"(",
"255",
"*",
"(",
"counts",
"-",
"np",
".",
"nanmin",
"(",
"counts",
")",
")",
"/",
"(",
"np",
".",
"nanmax",
"(",
"counts",
")",
"-",
"np",
".... | Normalize the values of the counts for a 2D histogram.
This normalizes the values of a numpy array to the range 0-255.
:param counts: a NumPy array which is to be rescaled.
:param type: either 'bw' or 'reverse_bw'. | [
"Normalize",
"the",
"values",
"of",
"the",
"counts",
"for",
"a",
"2D",
"histogram",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L1004-L1019 | train | Normalize the values of the counts for a 2D histogram. |
davidfokkema/artist | artist/plot.py | SubPlot._write_bitmaps | def _write_bitmaps(self, path, suffix=''):
"""Write bitmap file assets.
:param path: path of the plot file.
:param suffix: optional suffix to add to asset names.
The path parameter is used for the dirname, and the filename.
So if :meth:`save` is called with '/foo/myplot.tex', y... | python | def _write_bitmaps(self, path, suffix=''):
"""Write bitmap file assets.
:param path: path of the plot file.
:param suffix: optional suffix to add to asset names.
The path parameter is used for the dirname, and the filename.
So if :meth:`save` is called with '/foo/myplot.tex', y... | [
"def",
"_write_bitmaps",
"(",
"self",
",",
"path",
",",
"suffix",
"=",
"''",
")",
":",
"dir",
",",
"prefix",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"if",
"'.'",
"in",
"prefix",
":",
"prefix",
"=",
"prefix",
".",
"split",
"(",
"'.... | Write bitmap file assets.
:param path: path of the plot file.
:param suffix: optional suffix to add to asset names.
The path parameter is used for the dirname, and the filename.
So if :meth:`save` is called with '/foo/myplot.tex', you can call
this method with that same path. T... | [
"Write",
"bitmap",
"file",
"assets",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L1021-L1046 | train | Write bitmap files. |
davidfokkema/artist | artist/plot.py | SubPlot._prepare_data | def _prepare_data(self):
"""Prepare data before rendering
When plotting very large datasets, we don't want to include data points
which are outside the x-axis limits. LaTeX is very slow and consumes a
lot of memory otherwise. Limiting the data points is only (easily)
possible wh... | python | def _prepare_data(self):
"""Prepare data before rendering
When plotting very large datasets, we don't want to include data points
which are outside the x-axis limits. LaTeX is very slow and consumes a
lot of memory otherwise. Limiting the data points is only (easily)
possible wh... | [
"def",
"_prepare_data",
"(",
"self",
")",
":",
"xmin",
",",
"xmax",
"=",
"self",
".",
"limits",
"[",
"'xmin'",
"]",
",",
"self",
".",
"limits",
"[",
"'xmax'",
"]",
"self",
".",
"prepared_plot_series_list",
"=",
"[",
"]",
"for",
"series",
"in",
"self",
... | Prepare data before rendering
When plotting very large datasets, we don't want to include data points
which are outside the x-axis limits. LaTeX is very slow and consumes a
lot of memory otherwise. Limiting the data points is only (easily)
possible when the data are sorted. | [
"Prepare",
"data",
"before",
"rendering"
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L1048-L1103 | train | Prepare data before rendering a new object. |
davidfokkema/artist | artist/plot.py | Plot.render | def render(self, template=None):
"""Render the plot using a template.
Once the plot is complete, it needs to be rendered. Artist uses
the Jinja2 templating engine. The default template results in a
LaTeX file which can be included in your document.
:param template: a user-sup... | python | def render(self, template=None):
"""Render the plot using a template.
Once the plot is complete, it needs to be rendered. Artist uses
the Jinja2 templating engine. The default template results in a
LaTeX file which can be included in your document.
:param template: a user-sup... | [
"def",
"render",
"(",
"self",
",",
"template",
"=",
"None",
")",
":",
"if",
"not",
"template",
":",
"template",
"=",
"self",
".",
"template",
"self",
".",
"_prepare_data",
"(",
")",
"response",
"=",
"template",
".",
"render",
"(",
"axis_background",
"=",... | Render the plot using a template.
Once the plot is complete, it needs to be rendered. Artist uses
the Jinja2 templating engine. The default template results in a
LaTeX file which can be included in your document.
:param template: a user-supplied template or None.
:type templa... | [
"Render",
"the",
"plot",
"using",
"a",
"template",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L1131-L1171 | train | Render the plot using a Jinja2 template. |
davidfokkema/artist | artist/plot.py | PolarPlot.plot | def plot(self, phi, r, **kwargs):
"""Add a data series to the plot.
:param phi: array containing phi-values, should be in degrees
(or radians).
:param r: array containing r-values.
For further options see the plot function of the super class.
"""
if... | python | def plot(self, phi, r, **kwargs):
"""Add a data series to the plot.
:param phi: array containing phi-values, should be in degrees
(or radians).
:param r: array containing r-values.
For further options see the plot function of the super class.
"""
if... | [
"def",
"plot",
"(",
"self",
",",
"phi",
",",
"r",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"use_radians",
":",
"phi",
"=",
"np",
".",
"degrees",
"(",
"phi",
")",
"super",
"(",
"PolarPlot",
",",
"self",
")",
".",
"plot",
"(",
"phi",... | Add a data series to the plot.
:param phi: array containing phi-values, should be in degrees
(or radians).
:param r: array containing r-values.
For further options see the plot function of the super class. | [
"Add",
"a",
"data",
"series",
"to",
"the",
"plot",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/plot.py#L1206-L1218 | train | Add a data series to the plot. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.