repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
base4sistemas/satcfe | satcfe/clientesathub.py | ClienteSATHub.atualizar_software_sat | def atualizar_software_sat(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT
"""
resp = self._http_post('atualizarsoftwaresat')
conteudo = resp.json()
return Res... | python | def atualizar_software_sat(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT
"""
resp = self._http_post('atualizarsoftwaresat')
conteudo = resp.json()
return Res... | [
"def",
"atualizar_software_sat",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_http_post",
"(",
"'atualizarsoftwaresat'",
")",
"conteudo",
"=",
"resp",
".",
"json",
"(",
")",
"return",
"RespostaSAT",
".",
"atualizar_software_sat",
"(",
"conteudo",
".",
"g... | Sobrepõe :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT | [
"Sobrepõe",
":",
"meth",
":",
"~satcfe",
".",
"base",
".",
"FuncoesSAT",
".",
"atualizar_software_sat",
"."
] | train | https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/clientesathub.py#L227-L235 |
base4sistemas/satcfe | satcfe/clientesathub.py | ClienteSATHub.extrair_logs | def extrair_logs(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.extrair_logs`.
:return: Uma resposta SAT especializada em ``ExtrairLogs``.
:rtype: satcfe.resposta.extrairlogs.RespostaExtrairLogs
"""
resp = self._http_post('extrairlogs')
conteudo = resp.json()
... | python | def extrair_logs(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.extrair_logs`.
:return: Uma resposta SAT especializada em ``ExtrairLogs``.
:rtype: satcfe.resposta.extrairlogs.RespostaExtrairLogs
"""
resp = self._http_post('extrairlogs')
conteudo = resp.json()
... | [
"def",
"extrair_logs",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_http_post",
"(",
"'extrairlogs'",
")",
"conteudo",
"=",
"resp",
".",
"json",
"(",
")",
"return",
"RespostaExtrairLogs",
".",
"analisar",
"(",
"conteudo",
".",
"get",
"(",
"'retorno'"... | Sobrepõe :meth:`~satcfe.base.FuncoesSAT.extrair_logs`.
:return: Uma resposta SAT especializada em ``ExtrairLogs``.
:rtype: satcfe.resposta.extrairlogs.RespostaExtrairLogs | [
"Sobrepõe",
":",
"meth",
":",
"~satcfe",
".",
"base",
".",
"FuncoesSAT",
".",
"extrair_logs",
"."
] | train | https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/clientesathub.py#L238-L246 |
base4sistemas/satcfe | satcfe/clientesathub.py | ClienteSATHub.bloquear_sat | def bloquear_sat(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT
"""
resp = self._http_post('bloquearsat')
conteudo = resp.json()
return RespostaSAT.bloquear_sat(conteud... | python | def bloquear_sat(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT
"""
resp = self._http_post('bloquearsat')
conteudo = resp.json()
return RespostaSAT.bloquear_sat(conteud... | [
"def",
"bloquear_sat",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_http_post",
"(",
"'bloquearsat'",
")",
"conteudo",
"=",
"resp",
".",
"json",
"(",
")",
"return",
"RespostaSAT",
".",
"bloquear_sat",
"(",
"conteudo",
".",
"get",
"(",
"'retorno'",
... | Sobrepõe :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT | [
"Sobrepõe",
":",
"meth",
":",
"~satcfe",
".",
"base",
".",
"FuncoesSAT",
".",
"bloquear_sat",
"."
] | train | https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/clientesathub.py#L249-L257 |
base4sistemas/satcfe | satcfe/clientesathub.py | ClienteSATHub.desbloquear_sat | def desbloquear_sat(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT
"""
resp = self._http_post('desbloquearsat')
conteudo = resp.json()
return RespostaSAT.desbloquear... | python | def desbloquear_sat(self):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT
"""
resp = self._http_post('desbloquearsat')
conteudo = resp.json()
return RespostaSAT.desbloquear... | [
"def",
"desbloquear_sat",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_http_post",
"(",
"'desbloquearsat'",
")",
"conteudo",
"=",
"resp",
".",
"json",
"(",
")",
"return",
"RespostaSAT",
".",
"desbloquear_sat",
"(",
"conteudo",
".",
"get",
"(",
"'reto... | Sobrepõe :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT | [
"Sobrepõe",
":",
"meth",
":",
"~satcfe",
".",
"base",
".",
"FuncoesSAT",
".",
"desbloquear_sat",
"."
] | train | https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/clientesathub.py#L260-L268 |
base4sistemas/satcfe | satcfe/clientesathub.py | ClienteSATHub.trocar_codigo_de_ativacao | def trocar_codigo_de_ativacao(self, novo_codigo_ativacao,
opcao=constantes.CODIGO_ATIVACAO_REGULAR,
codigo_emergencia=None):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSA... | python | def trocar_codigo_de_ativacao(self, novo_codigo_ativacao,
opcao=constantes.CODIGO_ATIVACAO_REGULAR,
codigo_emergencia=None):
"""Sobrepõe :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSA... | [
"def",
"trocar_codigo_de_ativacao",
"(",
"self",
",",
"novo_codigo_ativacao",
",",
"opcao",
"=",
"constantes",
".",
"CODIGO_ATIVACAO_REGULAR",
",",
"codigo_emergencia",
"=",
"None",
")",
":",
"resp",
"=",
"self",
".",
"_http_post",
"(",
"'trocarcodigodeativacao'",
"... | Sobrepõe :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`.
:return: Uma resposta SAT padrão.
:rtype: satcfe.resposta.padrao.RespostaSAT | [
"Sobrepõe",
":",
"meth",
":",
"~satcfe",
".",
"base",
".",
"FuncoesSAT",
".",
"trocar_codigo_de_ativacao",
"."
] | train | https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/clientesathub.py#L271-L284 |
nion-software/nionswift | nion/typeshed/API_1_0.py | Graphic.bounds | def bounds(self) -> typing.Tuple[typing.Tuple[float, float], typing.Tuple[float, float]]:
"""Return the bounds property in relative coordinates.
Bounds is a tuple ((top, left), (height, width))"""
... | python | def bounds(self) -> typing.Tuple[typing.Tuple[float, float], typing.Tuple[float, float]]:
"""Return the bounds property in relative coordinates.
Bounds is a tuple ((top, left), (height, width))"""
... | [
"def",
"bounds",
"(",
"self",
")",
"->",
"typing",
".",
"Tuple",
"[",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
",",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
"]",
":",
"..."
] | Return the bounds property in relative coordinates.
Bounds is a tuple ((top, left), (height, width)) | [
"Return",
"the",
"bounds",
"property",
"in",
"relative",
"coordinates",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L38-L42 |
nion-software/nionswift | nion/typeshed/API_1_0.py | Graphic.end | def end(self, value: typing.Union[float, typing.Tuple[float, float]]) -> None:
"""Set the end property in relative coordinates.
End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line."""
... | python | def end(self, value: typing.Union[float, typing.Tuple[float, float]]) -> None:
"""Set the end property in relative coordinates.
End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line."""
... | [
"def",
"end",
"(",
"self",
",",
"value",
":",
"typing",
".",
"Union",
"[",
"float",
",",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
"]",
")",
"->",
"None",
":",
"..."
] | Set the end property in relative coordinates.
End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line. | [
"Set",
"the",
"end",
"property",
"in",
"relative",
"coordinates",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L73-L77 |
nion-software/nionswift | nion/typeshed/API_1_0.py | Graphic.start | def start(self, value: typing.Union[float, typing.Tuple[float, float]]) -> None:
"""Set the end property in relative coordinates.
End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line."""
... | python | def start(self, value: typing.Union[float, typing.Tuple[float, float]]) -> None:
"""Set the end property in relative coordinates.
End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line."""
... | [
"def",
"start",
"(",
"self",
",",
"value",
":",
"typing",
".",
"Union",
"[",
"float",
",",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
"]",
")",
"->",
"None",
":",
"..."
] | Set the end property in relative coordinates.
End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line. | [
"Set",
"the",
"end",
"property",
"in",
"relative",
"coordinates",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L183-L187 |
nion-software/nionswift | nion/typeshed/API_1_0.py | Graphic.vector | def vector(self) -> typing.Tuple[typing.Tuple[float, float], typing.Tuple[float, float]]:
"""Return the vector property in relative coordinates.
Vector will be a tuple of tuples ((y_start, x_start), (y_end, x_end))."""
... | python | def vector(self) -> typing.Tuple[typing.Tuple[float, float], typing.Tuple[float, float]]:
"""Return the vector property in relative coordinates.
Vector will be a tuple of tuples ((y_start, x_start), (y_end, x_end))."""
... | [
"def",
"vector",
"(",
"self",
")",
"->",
"typing",
".",
"Tuple",
"[",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
",",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
"]",
":",
"..."
] | Return the vector property in relative coordinates.
Vector will be a tuple of tuples ((y_start, x_start), (y_end, x_end)). | [
"Return",
"the",
"vector",
"property",
"in",
"relative",
"coordinates",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L212-L216 |
nion-software/nionswift | nion/typeshed/API_1_0.py | Library.get_data_item_for_hardware_source | def get_data_item_for_hardware_source(self, hardware_source, channel_id: str=None, processor_id: str=None, create_if_needed: bool=False, large_format: bool=False) -> DataItem:
"""Get the data item associated with hardware source and (optional) channel id and processor_id. Optionally create if missing.
... | python | def get_data_item_for_hardware_source(self, hardware_source, channel_id: str=None, processor_id: str=None, create_if_needed: bool=False, large_format: bool=False) -> DataItem:
"""Get the data item associated with hardware source and (optional) channel id and processor_id. Optionally create if missing.
... | [
"def",
"get_data_item_for_hardware_source",
"(",
"self",
",",
"hardware_source",
",",
"channel_id",
":",
"str",
"=",
"None",
",",
"processor_id",
":",
"str",
"=",
"None",
",",
"create_if_needed",
":",
"bool",
"=",
"False",
",",
"large_format",
":",
"bool",
"="... | Get the data item associated with hardware source and (optional) channel id and processor_id. Optionally create if missing.
:param hardware_source: The hardware_source.
:param channel_id: The (optional) channel id.
:param processor_id: The (optional) processor id for the channel.
:param... | [
"Get",
"the",
"data",
"item",
"associated",
"with",
"hardware",
"source",
"and",
"(",
"optional",
")",
"channel",
"id",
"and",
"processor_id",
".",
"Optionally",
"create",
"if",
"missing",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L751-L765 |
nion-software/nionswift | nion/typeshed/API_1_0.py | Library.get_data_item_for_reference_key | def get_data_item_for_reference_key(self, data_item_reference_key: str=None, create_if_needed: bool=False, large_format: bool=False) -> DataItem:
"""Get the data item associated with data item reference key. Optionally create if missing.
:param data_item_reference_key: The data item reference key.
... | python | def get_data_item_for_reference_key(self, data_item_reference_key: str=None, create_if_needed: bool=False, large_format: bool=False) -> DataItem:
"""Get the data item associated with data item reference key. Optionally create if missing.
:param data_item_reference_key: The data item reference key.
... | [
"def",
"get_data_item_for_reference_key",
"(",
"self",
",",
"data_item_reference_key",
":",
"str",
"=",
"None",
",",
"create_if_needed",
":",
"bool",
"=",
"False",
",",
"large_format",
":",
"bool",
"=",
"False",
")",
"->",
"DataItem",
":",
"..."
] | Get the data item associated with data item reference key. Optionally create if missing.
:param data_item_reference_key: The data item reference key.
:param create_if_needed: Whether to create a new data item if none is found.
:return: The associated data item. May be None.
.. versiona... | [
"Get",
"the",
"data",
"item",
"associated",
"with",
"data",
"item",
"reference",
"key",
".",
"Optionally",
"create",
"if",
"missing",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L767-L779 |
nion-software/nionswift | nion/typeshed/API_1_0.py | DocumentWindow.show_get_string_message_box | def show_get_string_message_box(self, caption: str, text: str, accepted_fn, rejected_fn=None, accepted_text: str=None, rejected_text: str=None) -> None:
"""Show a dialog box and ask for a string.
Caption describes the user prompt. Text is the initial/default string.
Accepted function must be a... | python | def show_get_string_message_box(self, caption: str, text: str, accepted_fn, rejected_fn=None, accepted_text: str=None, rejected_text: str=None) -> None:
"""Show a dialog box and ask for a string.
Caption describes the user prompt. Text is the initial/default string.
Accepted function must be a... | [
"def",
"show_get_string_message_box",
"(",
"self",
",",
"caption",
":",
"str",
",",
"text",
":",
"str",
",",
"accepted_fn",
",",
"rejected_fn",
"=",
"None",
",",
"accepted_text",
":",
"str",
"=",
"None",
",",
"rejected_text",
":",
"str",
"=",
"None",
")",
... | Show a dialog box and ask for a string.
Caption describes the user prompt. Text is the initial/default string.
Accepted function must be a function taking one argument which is the resulting text if the user accepts the
message dialog. It will only be called if the user clicks OK.
Rej... | [
"Show",
"a",
"dialog",
"box",
"and",
"ask",
"for",
"a",
"string",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L987-L1001 |
nion-software/nionswift | nion/typeshed/API_1_0.py | API.create_calibration | def create_calibration(self, offset: float=None, scale: float=None, units: str=None) -> Calibration.Calibration:
"""Create a calibration object with offset, scale, and units.
:param offset: The offset of the calibration.
:param scale: The scale of the calibration.
:param units: The unit... | python | def create_calibration(self, offset: float=None, scale: float=None, units: str=None) -> Calibration.Calibration:
"""Create a calibration object with offset, scale, and units.
:param offset: The offset of the calibration.
:param scale: The scale of the calibration.
:param units: The unit... | [
"def",
"create_calibration",
"(",
"self",
",",
"offset",
":",
"float",
"=",
"None",
",",
"scale",
":",
"float",
"=",
"None",
",",
"units",
":",
"str",
"=",
"None",
")",
"->",
"Calibration",
".",
"Calibration",
":",
"..."
] | Create a calibration object with offset, scale, and units.
:param offset: The offset of the calibration.
:param scale: The scale of the calibration.
:param units: The units of the calibration as a string.
:return: The calibration object.
.. versionadded:: 1.0
Scriptabl... | [
"Create",
"a",
"calibration",
"object",
"with",
"offset",
"scale",
"and",
"units",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L1077-L1092 |
nion-software/nionswift | nion/typeshed/API_1_0.py | API.create_data_and_metadata | def create_data_and_metadata(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None, data_descriptor: DataAndMetadata.DataDescriptor=None) -> DataAndMetadata.DataAndMetadata:
""... | python | def create_data_and_metadata(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None, data_descriptor: DataAndMetadata.DataDescriptor=None) -> DataAndMetadata.DataAndMetadata:
""... | [
"def",
"create_data_and_metadata",
"(",
"self",
",",
"data",
":",
"numpy",
".",
"ndarray",
",",
"intensity_calibration",
":",
"Calibration",
".",
"Calibration",
"=",
"None",
",",
"dimensional_calibrations",
":",
"typing",
".",
"List",
"[",
"Calibration",
".",
"C... | Create a data_and_metadata object from data.
:param data: an ndarray of data.
:param intensity_calibration: An optional calibration object.
:param dimensional_calibrations: An optional list of calibration objects.
:param metadata: A dict of metadata.
:param timestamp: A datetime... | [
"Create",
"a",
"data_and_metadata",
"object",
"from",
"data",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L1094-L1108 |
nion-software/nionswift | nion/typeshed/API_1_0.py | API.create_data_and_metadata_from_data | def create_data_and_metadata_from_data(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None) -> DataAndMetadata.DataAndMetadata:
"""Create a data_and_metadata object from data... | python | def create_data_and_metadata_from_data(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None) -> DataAndMetadata.DataAndMetadata:
"""Create a data_and_metadata object from data... | [
"def",
"create_data_and_metadata_from_data",
"(",
"self",
",",
"data",
":",
"numpy",
".",
"ndarray",
",",
"intensity_calibration",
":",
"Calibration",
".",
"Calibration",
"=",
"None",
",",
"dimensional_calibrations",
":",
"typing",
".",
"List",
"[",
"Calibration",
... | Create a data_and_metadata object from data.
.. versionadded:: 1.0
.. deprecated:: 1.1
Use :py:meth:`~nion.swift.Facade.DataItem.create_data_and_metadata` instead.
Scriptable: No | [
"Create",
"a",
"data_and_metadata",
"object",
"from",
"data",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L1110-L1119 |
nion-software/nionswift | nion/typeshed/API_1_0.py | API.create_data_descriptor | def create_data_descriptor(self, is_sequence: bool, collection_dimension_count: int, datum_dimension_count: int) -> DataAndMetadata.DataDescriptor:
"""Create a data descriptor.
:param is_sequence: whether the descriptor describes a sequence of data.
:param collection_dimension_count: the number... | python | def create_data_descriptor(self, is_sequence: bool, collection_dimension_count: int, datum_dimension_count: int) -> DataAndMetadata.DataDescriptor:
"""Create a data descriptor.
:param is_sequence: whether the descriptor describes a sequence of data.
:param collection_dimension_count: the number... | [
"def",
"create_data_descriptor",
"(",
"self",
",",
"is_sequence",
":",
"bool",
",",
"collection_dimension_count",
":",
"int",
",",
"datum_dimension_count",
":",
"int",
")",
"->",
"DataAndMetadata",
".",
"DataDescriptor",
":",
"..."
] | Create a data descriptor.
:param is_sequence: whether the descriptor describes a sequence of data.
:param collection_dimension_count: the number of collection dimensions represented by the descriptor.
:param datum_dimension_count: the number of datum dimensions represented by the descriptor.
... | [
"Create",
"a",
"data",
"descriptor",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L1132-L1143 |
nion-software/nionswift | nion/swift/Inspector.py | make_calibration_row_widget | def make_calibration_row_widget(ui, calibration_observable, label: str=None):
"""Called when an item (calibration_observable) is inserted into the list widget. Returns a widget."""
calibration_row = ui.create_row_widget()
row_label = ui.create_label_widget(label, properties={"width": 60})
row_label.widg... | python | def make_calibration_row_widget(ui, calibration_observable, label: str=None):
"""Called when an item (calibration_observable) is inserted into the list widget. Returns a widget."""
calibration_row = ui.create_row_widget()
row_label = ui.create_label_widget(label, properties={"width": 60})
row_label.widg... | [
"def",
"make_calibration_row_widget",
"(",
"ui",
",",
"calibration_observable",
",",
"label",
":",
"str",
"=",
"None",
")",
":",
"calibration_row",
"=",
"ui",
".",
"create_row_widget",
"(",
")",
"row_label",
"=",
"ui",
".",
"create_label_widget",
"(",
"label",
... | Called when an item (calibration_observable) is inserted into the list widget. Returns a widget. | [
"Called",
"when",
"an",
"item",
"(",
"calibration_observable",
")",
"is",
"inserted",
"into",
"the",
"list",
"widget",
".",
"Returns",
"a",
"widget",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Inspector.py#L1067-L1091 |
nion-software/nionswift | nion/swift/Inspector.py | InspectorSection.add_widget_to_content | def add_widget_to_content(self, widget):
"""Subclasses should call this to add content in the section's top level column."""
self.__section_content_column.add_spacing(4)
self.__section_content_column.add(widget) | python | def add_widget_to_content(self, widget):
"""Subclasses should call this to add content in the section's top level column."""
self.__section_content_column.add_spacing(4)
self.__section_content_column.add(widget) | [
"def",
"add_widget_to_content",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"__section_content_column",
".",
"add_spacing",
"(",
"4",
")",
"self",
".",
"__section_content_column",
".",
"add",
"(",
"widget",
")"
] | Subclasses should call this to add content in the section's top level column. | [
"Subclasses",
"should",
"call",
"this",
"to",
"add",
"content",
"in",
"the",
"section",
"s",
"top",
"level",
"column",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Inspector.py#L218-L221 |
nion-software/nionswift | nion/swift/Inspector.py | CalibrationsInspectorSection.__create_list_item_widget | def __create_list_item_widget(self, ui, calibration_observable):
"""Called when an item (calibration_observable) is inserted into the list widget. Returns a widget."""
calibration_row = make_calibration_row_widget(ui, calibration_observable)
column = ui.create_column_widget()
column.add_... | python | def __create_list_item_widget(self, ui, calibration_observable):
"""Called when an item (calibration_observable) is inserted into the list widget. Returns a widget."""
calibration_row = make_calibration_row_widget(ui, calibration_observable)
column = ui.create_column_widget()
column.add_... | [
"def",
"__create_list_item_widget",
"(",
"self",
",",
"ui",
",",
"calibration_observable",
")",
":",
"calibration_row",
"=",
"make_calibration_row_widget",
"(",
"ui",
",",
"calibration_observable",
")",
"column",
"=",
"ui",
".",
"create_column_widget",
"(",
")",
"co... | Called when an item (calibration_observable) is inserted into the list widget. Returns a widget. | [
"Called",
"when",
"an",
"item",
"(",
"calibration_observable",
")",
"is",
"inserted",
"into",
"the",
"list",
"widget",
".",
"Returns",
"a",
"widget",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Inspector.py#L1211-L1217 |
nion-software/nionswift | nion/swift/HistogramPanel.py | AdornmentsCanvasItem._repaint | def _repaint(self, drawing_context):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size[1]
canvas_height = self.canvas_size[0]
left = self.display_limits[0]
right = self.display_limits[1]
# draw left displa... | python | def _repaint(self, drawing_context):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size[1]
canvas_height = self.canvas_size[0]
left = self.display_limits[0]
right = self.display_limits[1]
# draw left displa... | [
"def",
"_repaint",
"(",
"self",
",",
"drawing_context",
")",
":",
"# canvas size",
"canvas_width",
"=",
"self",
".",
"canvas_size",
"[",
"1",
"]",
"canvas_height",
"=",
"self",
".",
"canvas_size",
"[",
"0",
"]",
"left",
"=",
"self",
".",
"display_limits",
... | Repaint the canvas item. This will occur on a thread. | [
"Repaint",
"the",
"canvas",
"item",
".",
"This",
"will",
"occur",
"on",
"a",
"thread",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/HistogramPanel.py#L42-L79 |
nion-software/nionswift | nion/swift/HistogramPanel.py | SimpleLineGraphCanvasItem._repaint | def _repaint(self, drawing_context):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size[1]
canvas_height = self.canvas_size[0]
# draw background
if self.background_color:
with drawing_context.saver():
... | python | def _repaint(self, drawing_context):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size[1]
canvas_height = self.canvas_size[0]
# draw background
if self.background_color:
with drawing_context.saver():
... | [
"def",
"_repaint",
"(",
"self",
",",
"drawing_context",
")",
":",
"# canvas size",
"canvas_width",
"=",
"self",
".",
"canvas_size",
"[",
"1",
"]",
"canvas_height",
"=",
"self",
".",
"canvas_size",
"[",
"0",
"]",
"# draw background",
"if",
"self",
".",
"backg... | Repaint the canvas item. This will occur on a thread. | [
"Repaint",
"the",
"canvas",
"item",
".",
"This",
"will",
"occur",
"on",
"a",
"thread",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/HistogramPanel.py#L124-L155 |
nion-software/nionswift | nion/swift/HistogramPanel.py | ColorMapCanvasItem.color_map_data | def color_map_data(self, data: numpy.ndarray) -> None:
"""Set the data and mark the canvas item for updating.
Data should be an ndarray of shape (256, 3) with type uint8
"""
self.__color_map_data = data
self.update() | python | def color_map_data(self, data: numpy.ndarray) -> None:
"""Set the data and mark the canvas item for updating.
Data should be an ndarray of shape (256, 3) with type uint8
"""
self.__color_map_data = data
self.update() | [
"def",
"color_map_data",
"(",
"self",
",",
"data",
":",
"numpy",
".",
"ndarray",
")",
"->",
"None",
":",
"self",
".",
"__color_map_data",
"=",
"data",
"self",
".",
"update",
"(",
")"
] | Set the data and mark the canvas item for updating.
Data should be an ndarray of shape (256, 3) with type uint8 | [
"Set",
"the",
"data",
"and",
"mark",
"the",
"canvas",
"item",
"for",
"updating",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/HistogramPanel.py#L171-L177 |
nion-software/nionswift | nion/swift/HistogramPanel.py | ColorMapCanvasItem._repaint | def _repaint(self, drawing_context: DrawingContext.DrawingContext):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size.width
canvas_height = self.canvas_size.height
with drawing_context.saver():
if self.__color_... | python | def _repaint(self, drawing_context: DrawingContext.DrawingContext):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size.width
canvas_height = self.canvas_size.height
with drawing_context.saver():
if self.__color_... | [
"def",
"_repaint",
"(",
"self",
",",
"drawing_context",
":",
"DrawingContext",
".",
"DrawingContext",
")",
":",
"# canvas size",
"canvas_width",
"=",
"self",
".",
"canvas_size",
".",
"width",
"canvas_height",
"=",
"self",
".",
"canvas_size",
".",
"height",
"with... | Repaint the canvas item. This will occur on a thread. | [
"Repaint",
"the",
"canvas",
"item",
".",
"This",
"will",
"occur",
"on",
"a",
"thread",
"."
] | train | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/HistogramPanel.py#L179-L191 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.get_params | def get_params(self):
"Parameters used to initialize the class"
import inspect
a = inspect.getargspec(self.__init__)[0]
out = dict()
for key in a[1:]:
value = getattr(self, "_%s" % key, None)
out[key] = value
return out | python | def get_params(self):
"Parameters used to initialize the class"
import inspect
a = inspect.getargspec(self.__init__)[0]
out = dict()
for key in a[1:]:
value = getattr(self, "_%s" % key, None)
out[key] = value
return out | [
"def",
"get_params",
"(",
"self",
")",
":",
"import",
"inspect",
"a",
"=",
"inspect",
".",
"getargspec",
"(",
"self",
".",
"__init__",
")",
"[",
"0",
"]",
"out",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"a",
"[",
"1",
":",
"]",
":",
"value",
... | Parameters used to initialize the class | [
"Parameters",
"used",
"to",
"initialize",
"the",
"class"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L137-L145 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.signature | def signature(self):
"Instance file name"
kw = self.get_params()
keys = sorted(kw.keys())
l = []
for k in keys:
n = k[0] + k[-1]
v = kw[k]
if k == 'function_set':
v = "_".join([x.__name__[0] +
x.__n... | python | def signature(self):
"Instance file name"
kw = self.get_params()
keys = sorted(kw.keys())
l = []
for k in keys:
n = k[0] + k[-1]
v = kw[k]
if k == 'function_set':
v = "_".join([x.__name__[0] +
x.__n... | [
"def",
"signature",
"(",
"self",
")",
":",
"kw",
"=",
"self",
".",
"get_params",
"(",
")",
"keys",
"=",
"sorted",
"(",
"kw",
".",
"keys",
"(",
")",
")",
"l",
"=",
"[",
"]",
"for",
"k",
"in",
"keys",
":",
"n",
"=",
"k",
"[",
"0",
"]",
"+",
... | Instance file name | [
"Instance",
"file",
"name"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L157-L174 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.population | def population(self):
"Class containing the population and all the individuals generated"
try:
return self._p
except AttributeError:
self._p = self._population_class(base=self,
tournament_size=self._tournament_size,
... | python | def population(self):
"Class containing the population and all the individuals generated"
try:
return self._p
except AttributeError:
self._p = self._population_class(base=self,
tournament_size=self._tournament_size,
... | [
"def",
"population",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_p",
"except",
"AttributeError",
":",
"self",
".",
"_p",
"=",
"self",
".",
"_population_class",
"(",
"base",
"=",
"self",
",",
"tournament_size",
"=",
"self",
".",
"_tourname... | Class containing the population and all the individuals generated | [
"Class",
"containing",
"the",
"population",
"and",
"all",
"the",
"individuals",
"generated"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L262-L275 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.random_leaf | def random_leaf(self):
"Returns a random variable with the associated weight"
for i in range(self._number_tries_feasible_ind):
var = np.random.randint(self.nvar)
v = self._random_leaf(var)
if v is None:
continue
return v
raise Runti... | python | def random_leaf(self):
"Returns a random variable with the associated weight"
for i in range(self._number_tries_feasible_ind):
var = np.random.randint(self.nvar)
v = self._random_leaf(var)
if v is None:
continue
return v
raise Runti... | [
"def",
"random_leaf",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_number_tries_feasible_ind",
")",
":",
"var",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"self",
".",
"nvar",
")",
"v",
"=",
"self",
".",
"_random_leaf",
"... | Returns a random variable with the associated weight | [
"Returns",
"a",
"random",
"variable",
"with",
"the",
"associated",
"weight"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L300-L308 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.random_offspring | def random_offspring(self):
"Returns an offspring with the associated weight(s)"
function_set = self.function_set
function_selection = self._function_selection_ins
function_selection.density = self.population.density
function_selection.unfeasible_functions.clear()
for i i... | python | def random_offspring(self):
"Returns an offspring with the associated weight(s)"
function_set = self.function_set
function_selection = self._function_selection_ins
function_selection.density = self.population.density
function_selection.unfeasible_functions.clear()
for i i... | [
"def",
"random_offspring",
"(",
"self",
")",
":",
"function_set",
"=",
"self",
".",
"function_set",
"function_selection",
"=",
"self",
".",
"_function_selection_ins",
"function_selection",
".",
"density",
"=",
"self",
".",
"population",
".",
"density",
"function_sel... | Returns an offspring with the associated weight(s) | [
"Returns",
"an",
"offspring",
"with",
"the",
"associated",
"weight",
"(",
"s",
")"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L454-L476 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.stopping_criteria | def stopping_criteria(self):
"Test whether the stopping criteria has been achieved."
if self.stopping_criteria_tl():
return True
if self.generations < np.inf:
inds = self.popsize * self.generations
flag = inds <= len(self.population.hist)
else:
... | python | def stopping_criteria(self):
"Test whether the stopping criteria has been achieved."
if self.stopping_criteria_tl():
return True
if self.generations < np.inf:
inds = self.popsize * self.generations
flag = inds <= len(self.population.hist)
else:
... | [
"def",
"stopping_criteria",
"(",
"self",
")",
":",
"if",
"self",
".",
"stopping_criteria_tl",
"(",
")",
":",
"return",
"True",
"if",
"self",
".",
"generations",
"<",
"np",
".",
"inf",
":",
"inds",
"=",
"self",
".",
"popsize",
"*",
"self",
".",
"generat... | Test whether the stopping criteria has been achieved. | [
"Test",
"whether",
"the",
"stopping",
"criteria",
"has",
"been",
"achieved",
"."
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L488-L511 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.nclasses | def nclasses(self, v):
"Number of classes of v, also sets the labes"
if not self.classifier:
return 0
if isinstance(v, list):
self._labels = np.arange(len(v))
return
if not isinstance(v, np.ndarray):
v = tonparray(v)
self._labels = ... | python | def nclasses(self, v):
"Number of classes of v, also sets the labes"
if not self.classifier:
return 0
if isinstance(v, list):
self._labels = np.arange(len(v))
return
if not isinstance(v, np.ndarray):
v = tonparray(v)
self._labels = ... | [
"def",
"nclasses",
"(",
"self",
",",
"v",
")",
":",
"if",
"not",
"self",
".",
"classifier",
":",
"return",
"0",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
":",
"self",
".",
"_labels",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"v",
")",
")... | Number of classes of v, also sets the labes | [
"Number",
"of",
"classes",
"of",
"v",
"also",
"sets",
"the",
"labes"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L513-L523 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.fit | def fit(self, X, y, test_set=None):
"""Evolutive process"""
self._init_time = time.time()
self.X = X
if self._popsize == "nvar":
self._popsize = self.nvar + len(self._input_functions)
if isinstance(test_set, str) and test_set == 'shuffle':
test_set = self.... | python | def fit(self, X, y, test_set=None):
"""Evolutive process"""
self._init_time = time.time()
self.X = X
if self._popsize == "nvar":
self._popsize = self.nvar + len(self._input_functions)
if isinstance(test_set, str) and test_set == 'shuffle':
test_set = self.... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"test_set",
"=",
"None",
")",
":",
"self",
".",
"_init_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"X",
"=",
"X",
"if",
"self",
".",
"_popsize",
"==",
"\"nvar\"",
":",
"self",
".",... | Evolutive process | [
"Evolutive",
"process"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L537-L583 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.decision_function | def decision_function(self, v=None, X=None):
"Decision function i.e. the raw data of the prediction"
m = self.model(v=v)
return m.decision_function(X) | python | def decision_function(self, v=None, X=None):
"Decision function i.e. the raw data of the prediction"
m = self.model(v=v)
return m.decision_function(X) | [
"def",
"decision_function",
"(",
"self",
",",
"v",
"=",
"None",
",",
"X",
"=",
"None",
")",
":",
"m",
"=",
"self",
".",
"model",
"(",
"v",
"=",
"v",
")",
"return",
"m",
".",
"decision_function",
"(",
"X",
")"
] | Decision function i.e. the raw data of the prediction | [
"Decision",
"function",
"i",
".",
"e",
".",
"the",
"raw",
"data",
"of",
"the",
"prediction"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L593-L596 |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.predict | def predict(self, v=None, X=None):
"""In classification this returns the classes, in
regression it is equivalent to the decision function"""
if X is None:
X = v
v = None
m = self.model(v=v)
return m.predict(X) | python | def predict(self, v=None, X=None):
"""In classification this returns the classes, in
regression it is equivalent to the decision function"""
if X is None:
X = v
v = None
m = self.model(v=v)
return m.predict(X) | [
"def",
"predict",
"(",
"self",
",",
"v",
"=",
"None",
",",
"X",
"=",
"None",
")",
":",
"if",
"X",
"is",
"None",
":",
"X",
"=",
"v",
"v",
"=",
"None",
"m",
"=",
"self",
".",
"model",
"(",
"v",
"=",
"v",
")",
"return",
"m",
".",
"predict",
... | In classification this returns the classes, in
regression it is equivalent to the decision function | [
"In",
"classification",
"this",
"returns",
"the",
"classes",
"in",
"regression",
"it",
"is",
"equivalent",
"to",
"the",
"decision",
"function"
] | train | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L598-L605 |
marrow/WebCore | web/server/gevent_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""Gevent-based WSGI-HTTP server."""
# Instantiate the server with a host/port configuration and our application.
WSGIServer((host, int(port)), application).serve_forever() | python | def serve(application, host='127.0.0.1', port=8080):
"""Gevent-based WSGI-HTTP server."""
# Instantiate the server with a host/port configuration and our application.
WSGIServer((host, int(port)), application).serve_forever() | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a host/port configuration and our application.",
"WSGIServer",
"(",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
",",
"applic... | Gevent-based WSGI-HTTP server. | [
"Gevent",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/gevent_.py#L14-L18 |
bitlabstudio/django-subscribe | subscribe/templatetags/subscribe_tags.py | get_subscribers | def get_subscribers(obj):
"""
Returns the subscribers for a given object.
:param obj: Any object.
"""
ctype = ContentType.objects.get_for_model(obj)
return Subscription.objects.filter(content_type=ctype, object_id=obj.pk) | python | def get_subscribers(obj):
"""
Returns the subscribers for a given object.
:param obj: Any object.
"""
ctype = ContentType.objects.get_for_model(obj)
return Subscription.objects.filter(content_type=ctype, object_id=obj.pk) | [
"def",
"get_subscribers",
"(",
"obj",
")",
":",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"obj",
")",
"return",
"Subscription",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"ctype",
",",
"object_id",
"=",
"obj",
".... | Returns the subscribers for a given object.
:param obj: Any object. | [
"Returns",
"the",
"subscribers",
"for",
"a",
"given",
"object",
"."
] | train | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/templatetags/subscribe_tags.py#L23-L31 |
bitlabstudio/django-subscribe | subscribe/templatetags/subscribe_tags.py | is_subscribed | def is_subscribed(user, obj):
"""
Returns ``True`` if the user is subscribed to the given object.
:param user: A ``User`` instance.
:param obj: Any object.
"""
if not user.is_authenticated():
return False
ctype = ContentType.objects.get_for_model(obj)
try:
Subscriptio... | python | def is_subscribed(user, obj):
"""
Returns ``True`` if the user is subscribed to the given object.
:param user: A ``User`` instance.
:param obj: Any object.
"""
if not user.is_authenticated():
return False
ctype = ContentType.objects.get_for_model(obj)
try:
Subscriptio... | [
"def",
"is_subscribed",
"(",
"user",
",",
"obj",
")",
":",
"if",
"not",
"user",
".",
"is_authenticated",
"(",
")",
":",
"return",
"False",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"obj",
")",
"try",
":",
"Subscription",
"."... | Returns ``True`` if the user is subscribed to the given object.
:param user: A ``User`` instance.
:param obj: Any object. | [
"Returns",
"True",
"if",
"the",
"user",
"is",
"subscribed",
"to",
"the",
"given",
"object",
"."
] | train | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/templatetags/subscribe_tags.py#L35-L54 |
marrow/WebCore | web/core/context.py | Context._promote | def _promote(self, name, instantiate=True):
"""Create a new subclass of Context which incorporates instance attributes and new descriptors.
This promotes an instance and its instance attributes up to being a class with class attributes, then
returns an instance of that class.
"""
metaclass = type(self._... | python | def _promote(self, name, instantiate=True):
"""Create a new subclass of Context which incorporates instance attributes and new descriptors.
This promotes an instance and its instance attributes up to being a class with class attributes, then
returns an instance of that class.
"""
metaclass = type(self._... | [
"def",
"_promote",
"(",
"self",
",",
"name",
",",
"instantiate",
"=",
"True",
")",
":",
"metaclass",
"=",
"type",
"(",
"self",
".",
"__class__",
")",
"contents",
"=",
"self",
".",
"__dict__",
".",
"copy",
"(",
")",
"cls",
"=",
"metaclass",
"(",
"str"... | Create a new subclass of Context which incorporates instance attributes and new descriptors.
This promotes an instance and its instance attributes up to being a class with class attributes, then
returns an instance of that class. | [
"Create",
"a",
"new",
"subclass",
"of",
"Context",
"which",
"incorporates",
"instance",
"attributes",
"and",
"new",
"descriptors",
".",
"This",
"promotes",
"an",
"instance",
"and",
"its",
"instance",
"attributes",
"up",
"to",
"being",
"a",
"class",
"with",
"cl... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/context.py#L23-L37 |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLController.py | run_individual | def run_individual(sim_var,
reference,
neuroml_file,
nml_doc,
still_included,
generate_dir,
target,
sim_time,
dt,
simulator,
cl... | python | def run_individual(sim_var,
reference,
neuroml_file,
nml_doc,
still_included,
generate_dir,
target,
sim_time,
dt,
simulator,
cl... | [
"def",
"run_individual",
"(",
"sim_var",
",",
"reference",
",",
"neuroml_file",
",",
"nml_doc",
",",
"still_included",
",",
"generate_dir",
",",
"target",
",",
"sim_time",
",",
"dt",
",",
"simulator",
",",
"cleanup",
"=",
"True",
",",
"show",
"=",
"False",
... | Run an individual simulation.
The candidate data has been flattened into the sim_var dict. The
sim_var dict contains parameter:value key value pairs, which are
applied to the model before it is simulated. | [
"Run",
"an",
"individual",
"simulation",
"."
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLController.py#L154-L323 |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLController.py | NeuroMLController.run | def run(self,candidates,parameters):
"""
Run simulation for each candidate
This run method will loop through each candidate and run the simulation
corresponding to its parameter values. It will populate an array called
traces with the resulting voltage traces for the sim... | python | def run(self,candidates,parameters):
"""
Run simulation for each candidate
This run method will loop through each candidate and run the simulation
corresponding to its parameter values. It will populate an array called
traces with the resulting voltage traces for the sim... | [
"def",
"run",
"(",
"self",
",",
"candidates",
",",
"parameters",
")",
":",
"traces",
"=",
"[",
"]",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"self",
".",
"num_parallel_evaluations",
"==",
"1",
":",
"for",
"candidate_i",
"in",
"range",
"(... | Run simulation for each candidate
This run method will loop through each candidate and run the simulation
corresponding to its parameter values. It will populate an array called
traces with the resulting voltage traces for the simulation and return it. | [
"Run",
"simulation",
"for",
"each",
"candidate",
"This",
"run",
"method",
"will",
"loop",
"through",
"each",
"candidate",
"and",
"run",
"the",
"simulation",
"corresponding",
"to",
"its",
"parameter",
"values",
".",
"It",
"will",
"populate",
"an",
"array",
"cal... | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLController.py#L64-L135 |
marrow/WebCore | web/ext/local.py | ThreadLocalExtension.prepare | def prepare(self, context):
"""Executed prior to processing a request."""
if __debug__:
log.debug("Assigning thread local request context.")
self.local.context = context | python | def prepare(self, context):
"""Executed prior to processing a request."""
if __debug__:
log.debug("Assigning thread local request context.")
self.local.context = context | [
"def",
"prepare",
"(",
"self",
",",
"context",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Assigning thread local request context.\"",
")",
"self",
".",
"local",
".",
"context",
"=",
"context"
] | Executed prior to processing a request. | [
"Executed",
"prior",
"to",
"processing",
"a",
"request",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/local.py#L79-L84 |
marrow/WebCore | web/core/view.py | WebViews.register | def register(self, kind, handler):
"""Register a handler for a given type, class, interface, or abstract base class.
View registration should happen within the `start` callback of an extension. For example, to register the
previous `json` view example:
class JSONExtension:
def start(self, context):
... | python | def register(self, kind, handler):
"""Register a handler for a given type, class, interface, or abstract base class.
View registration should happen within the `start` callback of an extension. For example, to register the
previous `json` view example:
class JSONExtension:
def start(self, context):
... | [
"def",
"register",
"(",
"self",
",",
"kind",
",",
"handler",
")",
":",
"if",
"__debug__",
":",
"# In production this logging is completely skipped, regardless of logging level.",
"if",
"py3",
"and",
"not",
"pypy",
":",
"# Where possible, we shorten things to just the cannonic... | Register a handler for a given type, class, interface, or abstract base class.
View registration should happen within the `start` callback of an extension. For example, to register the
previous `json` view example:
class JSONExtension:
def start(self, context):
context.view.register(tuple, json)
... | [
"Register",
"a",
"handler",
"for",
"a",
"given",
"type",
"class",
"interface",
"or",
"abstract",
"base",
"class",
".",
"View",
"registration",
"should",
"happen",
"within",
"the",
"start",
"callback",
"of",
"an",
"extension",
".",
"For",
"example",
"to",
"re... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/view.py#L112-L144 |
marrow/WebCore | web/app/static.py | static | def static(base, mapping=None, far=('js', 'css', 'gif', 'jpg', 'jpeg', 'png', 'ttf', 'woff')):
"""Serve files from disk.
This utility endpoint factory is meant primarily for use in development environments; in production environments
it is better (more efficient, secure, etc.) to serve your static content using a ... | python | def static(base, mapping=None, far=('js', 'css', 'gif', 'jpg', 'jpeg', 'png', 'ttf', 'woff')):
"""Serve files from disk.
This utility endpoint factory is meant primarily for use in development environments; in production environments
it is better (more efficient, secure, etc.) to serve your static content using a ... | [
"def",
"static",
"(",
"base",
",",
"mapping",
"=",
"None",
",",
"far",
"=",
"(",
"'js'",
",",
"'css'",
",",
"'gif'",
",",
"'jpg'",
",",
"'jpeg'",
",",
"'png'",
",",
"'ttf'",
",",
"'woff'",
")",
")",
":",
"base",
"=",
"abspath",
"(",
"base",
")",
... | Serve files from disk.
This utility endpoint factory is meant primarily for use in development environments; in production environments
it is better (more efficient, secure, etc.) to serve your static content using a front end load balancer such as
Nginx.
The first argument, `base`, represents the base path to ... | [
"Serve",
"files",
"from",
"disk",
".",
"This",
"utility",
"endpoint",
"factory",
"is",
"meant",
"primarily",
"for",
"use",
"in",
"development",
"environments",
";",
"in",
"production",
"environments",
"it",
"is",
"better",
"(",
"more",
"efficient",
"secure",
"... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/app/static.py#L21-L76 |
marrow/WebCore | web/server/diesel_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""Diesel-based (greenlet) WSGI-HTTP server.
As a minor note, this is crazy. Diesel includes Flask, too.
"""
# Instantiate the server with a host/port configuration and our application.
WSGIApplication(application, port=int(port), iface=host).run() | python | def serve(application, host='127.0.0.1', port=8080):
"""Diesel-based (greenlet) WSGI-HTTP server.
As a minor note, this is crazy. Diesel includes Flask, too.
"""
# Instantiate the server with a host/port configuration and our application.
WSGIApplication(application, port=int(port), iface=host).run() | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a host/port configuration and our application.",
"WSGIApplication",
"(",
"application",
",",
"port",
"=",
"int",
"(",
"port",
")",
... | Diesel-based (greenlet) WSGI-HTTP server.
As a minor note, this is crazy. Diesel includes Flask, too. | [
"Diesel",
"-",
"based",
"(",
"greenlet",
")",
"WSGI",
"-",
"HTTP",
"server",
".",
"As",
"a",
"minor",
"note",
"this",
"is",
"crazy",
".",
"Diesel",
"includes",
"Flask",
"too",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/diesel_.py#L14-L21 |
NeuroML/pyNeuroML | pyneuroml/plot/PlotSpikes.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A script for plotting files containing spike time data")
parser.add_argument('spiketimeFiles',
type=str,
metavar='<spiketime file>',
... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A script for plotting files containing spike time data")
parser.add_argument('spiketimeFiles',
type=str,
metavar='<spiketime file>',
... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A script for plotting files containing spike time data\"",
")",
"parser",
".",
"add_argument",
"(",
"'spiketimeFiles'",
",",
"type",
"=",
"str",
",",
... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/plot/PlotSpikes.py#L56-L105 |
marrow/WebCore | web/server/stdlib.py | simple | def simple(application, host='127.0.0.1', port=8080):
"""Python-standard WSGI-HTTP server for testing purposes.
The additional work performed here is to match the default startup output of "waitress".
This is not a production quality interface and will be have badly under load.
"""
# Try to be handy as many ... | python | def simple(application, host='127.0.0.1', port=8080):
"""Python-standard WSGI-HTTP server for testing purposes.
The additional work performed here is to match the default startup output of "waitress".
This is not a production quality interface and will be have badly under load.
"""
# Try to be handy as many ... | [
"def",
"simple",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Try to be handy as many terminals allow clicking links.",
"print",
"(",
"\"serving on http://{0}:{1}\"",
".",
"format",
"(",
"host",
",",
"port",
")",
")",
... | Python-standard WSGI-HTTP server for testing purposes.
The additional work performed here is to match the default startup output of "waitress".
This is not a production quality interface and will be have badly under load. | [
"Python",
"-",
"standard",
"WSGI",
"-",
"HTTP",
"server",
"for",
"testing",
"purposes",
".",
"The",
"additional",
"work",
"performed",
"here",
"is",
"to",
"match",
"the",
"default",
"startup",
"output",
"of",
"waitress",
".",
"This",
"is",
"not",
"a",
"pro... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/stdlib.py#L23-L35 |
marrow/WebCore | web/server/stdlib.py | iiscgi | def iiscgi(application):
"""A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks.
This is not a production quality interface and will behave badly under load.
"""
try:
from wsgiref.handlers import IISCGIHandler
except ImportError:
print("Python 3.2 or newer is required.")
... | python | def iiscgi(application):
"""A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks.
This is not a production quality interface and will behave badly under load.
"""
try:
from wsgiref.handlers import IISCGIHandler
except ImportError:
print("Python 3.2 or newer is required.")
... | [
"def",
"iiscgi",
"(",
"application",
")",
":",
"try",
":",
"from",
"wsgiref",
".",
"handlers",
"import",
"IISCGIHandler",
"except",
"ImportError",
":",
"print",
"(",
"\"Python 3.2 or newer is required.\"",
")",
"if",
"not",
"__debug__",
":",
"warnings",
".",
"wa... | A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks.
This is not a production quality interface and will behave badly under load. | [
"A",
"specialized",
"version",
"of",
"the",
"reference",
"WSGI",
"-",
"CGI",
"server",
"to",
"adapt",
"to",
"Microsoft",
"IIS",
"quirks",
".",
"This",
"is",
"not",
"a",
"production",
"quality",
"interface",
"and",
"will",
"behave",
"badly",
"under",
"load",
... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/stdlib.py#L53-L66 |
marrow/WebCore | web/server/fcgi.py | serve | def serve(application, host='127.0.0.1', port=8080, socket=None, **options):
"""Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details.
"""
# Allow either on-disk socket (recommended) or TCP/IP socket use.
if not socket:
bindAddress = (ho... | python | def serve(application, host='127.0.0.1', port=8080, socket=None, **options):
"""Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details.
"""
# Allow either on-disk socket (recommended) or TCP/IP socket use.
if not socket:
bindAddress = (ho... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"socket",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"# Allow either on-disk socket (recommended) or TCP/IP socket use.",
"if",
"not",
"socket",
":",
"bindA... | Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details. | [
"Basic",
"FastCGI",
"support",
"via",
"flup",
".",
"This",
"web",
"server",
"has",
"many",
"many",
"options",
".",
"Please",
"see",
"the",
"Flup",
"project",
"documentation",
"for",
"details",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/fcgi.py#L18-L31 |
bitlabstudio/django-subscribe | subscribe/forms.py | SubscriptionCreateForm._get_method_kwargs | def _get_method_kwargs(self):
"""
Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object.
"""
method_kwargs = {
'user': self.user,
'content_type': self.ctype,
'object_id': self.content... | python | def _get_method_kwargs(self):
"""
Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object.
"""
method_kwargs = {
'user': self.user,
'content_type': self.ctype,
'object_id': self.content... | [
"def",
"_get_method_kwargs",
"(",
"self",
")",
":",
"method_kwargs",
"=",
"{",
"'user'",
":",
"self",
".",
"user",
",",
"'content_type'",
":",
"self",
".",
"ctype",
",",
"'object_id'",
":",
"self",
".",
"content_object",
".",
"pk",
",",
"}",
"return",
"m... | Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object. | [
"Helper",
"method",
".",
"Returns",
"kwargs",
"needed",
"to",
"filter",
"the",
"correct",
"object",
"."
] | train | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L15-L27 |
bitlabstudio/django-subscribe | subscribe/forms.py | SubscriptionCreateForm.save | def save(self, *args, **kwargs):
"""Adds a subscription for the given user to the given object."""
method_kwargs = self._get_method_kwargs()
try:
subscription = Subscription.objects.get(**method_kwargs)
except Subscription.DoesNotExist:
subscription = Subscription... | python | def save(self, *args, **kwargs):
"""Adds a subscription for the given user to the given object."""
method_kwargs = self._get_method_kwargs()
try:
subscription = Subscription.objects.get(**method_kwargs)
except Subscription.DoesNotExist:
subscription = Subscription... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method_kwargs",
"=",
"self",
".",
"_get_method_kwargs",
"(",
")",
"try",
":",
"subscription",
"=",
"Subscription",
".",
"objects",
".",
"get",
"(",
"*",
"*",
"method_kwar... | Adds a subscription for the given user to the given object. | [
"Adds",
"a",
"subscription",
"for",
"the",
"given",
"user",
"to",
"the",
"given",
"object",
"."
] | train | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L29-L36 |
marrow/WebCore | web/ext/base.py | BaseExtension.prepare | def prepare(self, context):
"""Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance.
"""
if __debug__:
log.debug("Preparing request context.", extra=dict(request=id(context)))
# Bridge in WebOb `Request` and `Response` objects.
# Ext... | python | def prepare(self, context):
"""Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance.
"""
if __debug__:
log.debug("Preparing request context.", extra=dict(request=id(context)))
# Bridge in WebOb `Request` and `Response` objects.
# Ext... | [
"def",
"prepare",
"(",
"self",
",",
"context",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Preparing request context.\"",
",",
"extra",
"=",
"dict",
"(",
"request",
"=",
"id",
"(",
"context",
")",
")",
")",
"# Bridge in WebOb `Request` and... | Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance. | [
"Add",
"the",
"usual",
"suspects",
"to",
"the",
"context",
".",
"This",
"adds",
"request",
"response",
"and",
"path",
"to",
"the",
"RequestContext",
"instance",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L83-L106 |
marrow/WebCore | web/ext/base.py | BaseExtension.dispatch | def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url".
"""
request = context.request
if __debug__:
log.debug("Handling dispatch event.", extra=dict(
request = id(context),
consum... | python | def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url".
"""
request = context.request
if __debug__:
log.debug("Handling dispatch event.", extra=dict(
request = id(context),
consum... | [
"def",
"dispatch",
"(",
"self",
",",
"context",
",",
"consumed",
",",
"handler",
",",
"is_endpoint",
")",
":",
"request",
"=",
"context",
".",
"request",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Handling dispatch event.\"",
",",
"extra",
"=",
"... | Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url". | [
"Called",
"as",
"dispatch",
"descends",
"into",
"a",
"tier",
".",
"The",
"base",
"extension",
"uses",
"this",
"to",
"maintain",
"the",
"current",
"url",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L108-L145 |
marrow/WebCore | web/ext/base.py | BaseExtension.render_none | def render_none(self, context, result):
"""Render empty responses."""
context.response.body = b''
del context.response.content_length
return True | python | def render_none(self, context, result):
"""Render empty responses."""
context.response.body = b''
del context.response.content_length
return True | [
"def",
"render_none",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"body",
"=",
"b''",
"del",
"context",
".",
"response",
".",
"content_length",
"return",
"True"
] | Render empty responses. | [
"Render",
"empty",
"responses",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L149-L153 |
marrow/WebCore | web/ext/base.py | BaseExtension.render_binary | def render_binary(self, context, result):
"""Return binary responses unmodified."""
context.response.app_iter = iter((result, )) # This wraps the binary string in a WSGI body iterable.
return True | python | def render_binary(self, context, result):
"""Return binary responses unmodified."""
context.response.app_iter = iter((result, )) # This wraps the binary string in a WSGI body iterable.
return True | [
"def",
"render_binary",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"app_iter",
"=",
"iter",
"(",
"(",
"result",
",",
")",
")",
"# This wraps the binary string in a WSGI body iterable.",
"return",
"True"
] | Return binary responses unmodified. | [
"Return",
"binary",
"responses",
"unmodified",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L160-L163 |
marrow/WebCore | web/ext/base.py | BaseExtension.render_file | def render_file(self, context, result):
"""Perform appropriate metadata wrangling for returned open file handles."""
if __debug__:
log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
response = context.response
response.conditional_response = True
modified ... | python | def render_file(self, context, result):
"""Perform appropriate metadata wrangling for returned open file handles."""
if __debug__:
log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
response = context.response
response.conditional_response = True
modified ... | [
"def",
"render_file",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Processing file-like object.\"",
",",
"extra",
"=",
"dict",
"(",
"request",
"=",
"id",
"(",
"context",
")",
",",
"result",
"=... | Perform appropriate metadata wrangling for returned open file handles. | [
"Perform",
"appropriate",
"metadata",
"wrangling",
"for",
"returned",
"open",
"file",
"handles",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L170-L192 |
marrow/WebCore | web/ext/base.py | BaseExtension.render_generator | def render_generator(self, context, result):
"""Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views.
"""
context.response.encoding = 'utf8'
context.response.app_iter = (
(i.encode('utf8') if isinst... | python | def render_generator(self, context, result):
"""Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views.
"""
context.response.encoding = 'utf8'
context.response.app_iter = (
(i.encode('utf8') if isinst... | [
"def",
"render_generator",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"encoding",
"=",
"'utf8'",
"context",
".",
"response",
".",
"app_iter",
"=",
"(",
"(",
"i",
".",
"encode",
"(",
"'utf8'",
")",
"if",
"isin... | Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views. | [
"Attempt",
"to",
"serve",
"generator",
"responses",
"through",
"stream",
"encoding",
".",
"This",
"allows",
"for",
"direct",
"use",
"of",
"cinje",
"template",
"functions",
"which",
"are",
"generators",
"as",
"returned",
"views",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L194-L204 |
marrow/WebCore | web/server/cherrypy_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""CherryPy-based WSGI-HTTP server."""
# Instantiate the server with our configuration and application.
server = CherryPyWSGIServer((host, int(port)), application, server_name=host)
# Try to be handy as many terminals allow clicking links.
print("serving on ... | python | def serve(application, host='127.0.0.1', port=8080):
"""CherryPy-based WSGI-HTTP server."""
# Instantiate the server with our configuration and application.
server = CherryPyWSGIServer((host, int(port)), application, server_name=host)
# Try to be handy as many terminals allow clicking links.
print("serving on ... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with our configuration and application.",
"server",
"=",
"CherryPyWSGIServer",
"(",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
... | CherryPy-based WSGI-HTTP server. | [
"CherryPy",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/cherrypy_.py#L14-L27 |
broadinstitute/xtermcolor | xtermcolor/ColorMap.py | TerminalColorMap.colorize | def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
'''Returns the colored string'''
if not isinstance(string, str):
string = str(string)
if rgb is None and ansi is None:
raise TerminalColorMapException(
'colorize: must specify one name... | python | def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
'''Returns the colored string'''
if not isinstance(string, str):
string = str(string)
if rgb is None and ansi is None:
raise TerminalColorMapException(
'colorize: must specify one name... | [
"def",
"colorize",
"(",
"self",
",",
"string",
",",
"rgb",
"=",
"None",
",",
"ansi",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"ansi_bg",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"string",
"=",
"str",... | Returns the colored string | [
"Returns",
"the",
"colored",
"string"
] | train | https://github.com/broadinstitute/xtermcolor/blob/2615100979eb59744597c9d01e6fd1b711b311e1/xtermcolor/ColorMap.py#L27-L54 |
marrow/WebCore | web/ext/serialize.py | SerializationExtension.render_serialization | def render_serialization(self, context, result):
"""Render serialized responses."""
resp = context.response
serial = context.serialize
match = context.request.accept.best_match(serial.types, default_match=self.default)
result = serial[match](result)
if isinstance(result, str):
result = result.decod... | python | def render_serialization(self, context, result):
"""Render serialized responses."""
resp = context.response
serial = context.serialize
match = context.request.accept.best_match(serial.types, default_match=self.default)
result = serial[match](result)
if isinstance(result, str):
result = result.decod... | [
"def",
"render_serialization",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"resp",
"=",
"context",
".",
"response",
"serial",
"=",
"context",
".",
"serialize",
"match",
"=",
"context",
".",
"request",
".",
"accept",
".",
"best_match",
"(",
"seria... | Render serialized responses. | [
"Render",
"serialized",
"responses",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/serialize.py#L91-L106 |
marrow/WebCore | web/server/eventlet_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/).
"""
# Instantiate the server with a bound port and with our application.
server(listen(host, int(port)), app... | python | def serve(application, host='127.0.0.1', port=8080):
"""Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/).
"""
# Instantiate the server with a bound port and with our application.
server(listen(host, int(port)), app... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a bound port and with our application.",
"server",
"(",
"listen",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
",",
"applic... | Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/). | [
"Eventlet",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
".",
"For",
"a",
"more",
"fully",
"-",
"featured",
"Eventlet",
"-",
"capable",
"interface",
"see",
"also",
"[",
"Spawning",
"]",
"(",
"http",
":",
"//",
"pypi",
".",
"python",
".",
"org",
"/",
... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/eventlet_.py#L15-L22 |
NeuroML/pyNeuroML | examples/component_evaluation.py | main | def main(args=None):
"""Main"""
vs = [(v-100)*0.001 for v in range(200)]
for f in ['IM.channel.nml','Kd.channel.nml']:
nml_doc = pynml.read_neuroml2_file(f)
for ct in nml_doc.ComponentType:
ys = []
for v in vs:
req_variables = {'v':'%sV'%v,... | python | def main(args=None):
"""Main"""
vs = [(v-100)*0.001 for v in range(200)]
for f in ['IM.channel.nml','Kd.channel.nml']:
nml_doc = pynml.read_neuroml2_file(f)
for ct in nml_doc.ComponentType:
ys = []
for v in vs:
req_variables = {'v':'%sV'%v,... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"vs",
"=",
"[",
"(",
"v",
"-",
"100",
")",
"*",
"0.001",
"for",
"v",
"in",
"range",
"(",
"200",
")",
"]",
"for",
"f",
"in",
"[",
"'IM.channel.nml'",
",",
"'Kd.channel.nml'",
"]",
":",
"nml_doc",
... | Main | [
"Main"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/examples/component_evaluation.py#L5-L33 |
NeuroML/pyNeuroML | pyneuroml/analysis/NML2ChannelAnalysis.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to generate a LEMS "
"file to analyse the behaviour of channels in "
"NeuroML 2"))
parser.ad... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to generate a LEMS "
"file to analyse the behaviour of channels in "
"NeuroML 2"))
parser.ad... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"A script which can be run to generate a LEMS \"",
"\"file to analyse the behaviour of channels in \"",
"\"NeuroML 2\"",
")",
")",
"parser",
".",
"add_arg... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/analysis/NML2ChannelAnalysis.py#L58-L185 |
NeuroML/pyNeuroML | pyneuroml/analysis/NML2ChannelAnalysis.py | plot_iv_curve | def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs):
"""A single IV curve"""
grid = plt_kwargs.pop('grid',True)
same_fig = plt_kwargs.pop('same_fig',False)
if not len(plt_args):
plt_args = ('ko-',)
if 'label' not in plt_kwargs:
plt_kwargs['label'] = 'Current'
if not sa... | python | def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs):
"""A single IV curve"""
grid = plt_kwargs.pop('grid',True)
same_fig = plt_kwargs.pop('same_fig',False)
if not len(plt_args):
plt_args = ('ko-',)
if 'label' not in plt_kwargs:
plt_kwargs['label'] = 'Current'
if not sa... | [
"def",
"plot_iv_curve",
"(",
"a",
",",
"hold_v",
",",
"i",
",",
"*",
"plt_args",
",",
"*",
"*",
"plt_kwargs",
")",
":",
"grid",
"=",
"plt_kwargs",
".",
"pop",
"(",
"'grid'",
",",
"True",
")",
"same_fig",
"=",
"plt_kwargs",
".",
"pop",
"(",
"'same_fig... | A single IV curve | [
"A",
"single",
"IV",
"curve"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/analysis/NML2ChannelAnalysis.py#L581-L594 |
marrow/WebCore | example/stream.py | root | def root(context):
"""Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html
"""
response = context.response
parts = []
for i in range(12):
for j in range(12):
parts.append(executor.submit(mul, i, j))
def stream(parts, timeout=None):
try:
for future in as_complete... | python | def root(context):
"""Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html
"""
response = context.response
parts = []
for i in range(12):
for j in range(12):
parts.append(executor.submit(mul, i, j))
def stream(parts, timeout=None):
try:
for future in as_complete... | [
"def",
"root",
"(",
"context",
")",
":",
"response",
"=",
"context",
".",
"response",
"parts",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"12",
")",
":",
"for",
"j",
"in",
"range",
"(",
"12",
")",
":",
"parts",
".",
"append",
"(",
"executor",... | Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html | [
"Multipart",
"AJAX",
"request",
"example",
".",
"See",
":",
"http",
":",
"//",
"test",
".",
"getify",
".",
"com",
"/",
"mpAjax",
"/",
"description",
".",
"html"
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/example/stream.py#L16-L49 |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | render_template_with_args_in_file | def render_template_with_args_in_file(file, template_file_name, **kwargs):
"""
Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in tem... | python | def render_template_with_args_in_file(file, template_file_name, **kwargs):
"""
Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in tem... | [
"def",
"render_template_with_args_in_file",
"(",
"file",
",",
"template_file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"template_file_content",
"=",
"\"\"",
".",
"join",
"(",
"codecs",
".",
"open",
"(",
"template_file_name",
",",
"encoding",
"=",
"'UTF-8'",
")",... | Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in template | [
"Get",
"a",
"file",
"and",
"render",
"the",
"content",
"of",
"the",
"template_file_name",
"with",
"kwargs",
"in",
"a",
"file",
":",
"param",
"file",
":",
"A",
"File",
"Stream",
"to",
"write",
":",
"param",
"template_file_name",
":",
"path",
"to",
"route",
... | train | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L20-L34 |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | create_or_open | def create_or_open(file_name, initial_template_file_name, args):
"""
Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files
... | python | def create_or_open(file_name, initial_template_file_name, args):
"""
Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files
... | [
"def",
"create_or_open",
"(",
"file_name",
",",
"initial_template_file_name",
",",
"args",
")",
":",
"file",
"=",
"None",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
"[",
"'django_application_folder'",
"... | Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files | [
"Creates",
"a",
"file",
"or",
"open",
"the",
"file",
"with",
"file_name",
"name",
":",
"param",
"file_name",
":",
"String",
"with",
"a",
"filename",
":",
"param",
"initial_template_file_name",
":",
"String",
"with",
"path",
"to",
"initial",
"template",
":",
... | train | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L37-L74 |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | generic_insert_module | def generic_insert_module(module_name, args, **kwargs):
"""
In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template
"""
file = create_or_open(
... | python | def generic_insert_module(module_name, args, **kwargs):
"""
In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template
"""
file = create_or_open(
... | [
"def",
"generic_insert_module",
"(",
"module_name",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"file",
"=",
"create_or_open",
"(",
"'{}.py'",
".",
"format",
"(",
"module_name",
")",
",",
"os",
".",
"path",
".",
"join",
"(",
"BASE_TEMPLATES_DIR",
",",
... | In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template | [
"In",
"general",
"we",
"have",
"a",
"initial",
"template",
"and",
"then",
"insert",
"new",
"data",
"so",
"we",
"dont",
"repeat",
"the",
"schema",
"for",
"each",
"module",
":",
"param",
"module_name",
":",
"String",
"with",
"module",
"name",
":",
"paran",
... | train | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L77-L100 |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | sanity_check | def sanity_check(args):
"""
Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None
"""
if not os.path.isfile(
os.path.join(
args['django_application_folder'],
'models.py'
)
):
print("django... | python | def sanity_check(args):
"""
Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None
"""
if not os.path.isfile(
os.path.join(
args['django_application_folder'],
'models.py'
)
):
print("django... | [
"def",
"sanity_check",
"(",
"args",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
"[",
"'django_application_folder'",
"]",
",",
"'models.py'",
")",
")",
":",
"print",
"(",
"\"django_application... | Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None | [
"Verify",
"if",
"the",
"work",
"folder",
"is",
"a",
"django",
"app",
".",
"A",
"valid",
"django",
"app",
"always",
"must",
"have",
"a",
"models",
".",
"py",
"file",
":",
"return",
":",
"None"
] | train | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L103-L116 |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | generic_insert_with_folder | def generic_insert_with_folder(folder_name, file_name, template_name, args):
"""
In general if we need to put a file on a folder, we use this method
"""
# First we make sure views are a package instead a file
if not os.path.isdir(
os.path.join(
args['django_application_folder'],
... | python | def generic_insert_with_folder(folder_name, file_name, template_name, args):
"""
In general if we need to put a file on a folder, we use this method
"""
# First we make sure views are a package instead a file
if not os.path.isdir(
os.path.join(
args['django_application_folder'],
... | [
"def",
"generic_insert_with_folder",
"(",
"folder_name",
",",
"file_name",
",",
"template_name",
",",
"args",
")",
":",
"# First we make sure views are a package instead a file",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(... | In general if we need to put a file on a folder, we use this method | [
"In",
"general",
"if",
"we",
"need",
"to",
"put",
"a",
"file",
"on",
"a",
"folder",
"we",
"use",
"this",
"method"
] | train | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L119-L160 |
marrow/WebCore | web/server/waitress_.py | serve | def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
"""The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks.
"""
# Bind and start the server; this is a blocking process.
serve_(application, host=host, port=int... | python | def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
"""The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks.
"""
# Bind and start the server; this is a blocking process.
serve_(application, host=host, port=int... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"threads",
"=",
"4",
",",
"*",
"*",
"kw",
")",
":",
"# Bind and start the server; this is a blocking process.",
"serve_",
"(",
"application",
",",
"host",
"=",
... | The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks. | [
"The",
"recommended",
"development",
"HTTP",
"server",
".",
"Note",
"that",
"this",
"server",
"performs",
"additional",
"buffering",
"and",
"will",
"not",
"honour",
"chunked",
"encoding",
"breaks",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/waitress_.py#L18-L25 |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLSimulation.py | NeuroMLSimulation.show | def show(self):
"""
Plot the result of the simulation once it's been intialized
"""
from matplotlib import pyplot as plt
if self.already_run:
for ref in self.volts.keys():
plt.plot(self.t, self.volts[ref], label=ref)
plt... | python | def show(self):
"""
Plot the result of the simulation once it's been intialized
"""
from matplotlib import pyplot as plt
if self.already_run:
for ref in self.volts.keys():
plt.plot(self.t, self.volts[ref], label=ref)
plt... | [
"def",
"show",
"(",
"self",
")",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"plt",
"if",
"self",
".",
"already_run",
":",
"for",
"ref",
"in",
"self",
".",
"volts",
".",
"keys",
"(",
")",
":",
"plt",
".",
"plot",
"(",
"self",
".",
"t",
"... | Plot the result of the simulation once it's been intialized | [
"Plot",
"the",
"result",
"of",
"the",
"simulation",
"once",
"it",
"s",
"been",
"intialized"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLSimulation.py#L58-L77 |
marrow/WebCore | example/annotation.py | Root.mul | def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to ex... | python | def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to ex... | [
"def",
"mul",
"(",
"self",
",",
"a",
":",
"int",
"=",
"None",
",",
"b",
":",
"int",
"=",
"None",
")",
"->",
"'json'",
":",
"if",
"not",
"a",
"or",
"not",
"b",
":",
"return",
"dict",
"(",
"message",
"=",
"\"Pass arguments a and b to multiply them togeth... | Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to execute this method:
* POST http://localhost:8080/mul
*... | [
"Multiply",
"two",
"values",
"together",
"and",
"return",
"the",
"result",
"via",
"JSON",
".",
"Python",
"3",
"function",
"annotations",
"are",
"used",
"to",
"ensure",
"that",
"the",
"arguments",
"are",
"integers",
".",
"This",
"requires",
"the",
"functionalit... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/example/annotation.py#L15-L42 |
broadinstitute/xtermcolor | xtermcolor/__init__.py | colorize | def colorize(string, rgb=None, ansi=None, bg=None, ansi_bg=None, fd=1):
'''Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will retur... | python | def colorize(string, rgb=None, ansi=None, bg=None, ansi_bg=None, fd=1):
'''Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will retur... | [
"def",
"colorize",
"(",
"string",
",",
"rgb",
"=",
"None",
",",
"ansi",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"ansi_bg",
"=",
"None",
",",
"fd",
"=",
"1",
")",
":",
"#Reinitializes if fd used is different",
"if",
"colorize",
".",
"fd",
"!=",
"fd",
... | Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will return the string without modifications.
string = the string to print. Only acc... | [
"Returns",
"the",
"colored",
"string",
"to",
"print",
"on",
"the",
"terminal",
"."
] | train | https://github.com/broadinstitute/xtermcolor/blob/2615100979eb59744597c9d01e6fd1b711b311e1/xtermcolor/__init__.py#L6-L45 |
marrow/WebCore | web/ext/annotation.py | AnnotationExtension.mutate | def mutate(self, context, handler, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
"""
def cast(arg, val):
if arg not in annotations:
return
cast = annotations[... | python | def mutate(self, context, handler, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
"""
def cast(arg, val):
if arg not in annotations:
return
cast = annotations[... | [
"def",
"mutate",
"(",
"self",
",",
"context",
",",
"handler",
",",
"args",
",",
"kw",
")",
":",
"def",
"cast",
"(",
"arg",
",",
"val",
")",
":",
"if",
"arg",
"not",
"in",
"annotations",
":",
"return",
"cast",
"=",
"annotations",
"[",
"key",
"]",
... | Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail. | [
"Inspect",
"and",
"potentially",
"mutate",
"the",
"given",
"handler",
"s",
"arguments",
".",
"The",
"args",
"list",
"and",
"kw",
"dictionary",
"may",
"be",
"freely",
"modified",
"though",
"invalid",
"arguments",
"to",
"the",
"handler",
"will",
"fail",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/annotation.py#L48-L87 |
marrow/WebCore | web/ext/annotation.py | AnnotationExtension.transform | def transform(self, context, handler, result):
"""Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation.
"""
handler = handler.__func__ if hasattr(handler, '__func__') else handler
annotation = getattr(handler, '__ann... | python | def transform(self, context, handler, result):
"""Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation.
"""
handler = handler.__func__ if hasattr(handler, '__func__') else handler
annotation = getattr(handler, '__ann... | [
"def",
"transform",
"(",
"self",
",",
"context",
",",
"handler",
",",
"result",
")",
":",
"handler",
"=",
"handler",
".",
"__func__",
"if",
"hasattr",
"(",
"handler",
",",
"'__func__'",
")",
"else",
"handler",
"annotation",
"=",
"getattr",
"(",
"handler",
... | Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation. | [
"Transform",
"the",
"value",
"returned",
"by",
"the",
"controller",
"endpoint",
".",
"This",
"extension",
"transforms",
"returned",
"values",
"if",
"the",
"endpoint",
"has",
"a",
"return",
"type",
"annotation",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/annotation.py#L89-L100 |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLTuner.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!"))
parser.add_argument('prefix',
... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!"))
parser.add_argument('prefix',
... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!\"",
")",
")",
"parser",
".",
"add_argument",
"... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLTuner.py#L52-L209 |
NeuroML/pyNeuroML | pyneuroml/povray/MakeMovie.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)")
parser.add_argument('prefix',
... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)")
parser.add_argument('prefix',
... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)\"",
")",
"parser"... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/povray/MakeMovie.py#L27-L92 |
marrow/WebCore | web/server/tornado_.py | serve | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | python | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"*",
"*",
"options",
")",
":",
"# Wrap our our WSGI application (potentially stack) in a Tornado adapter.",
"container",
"=",
"tornado",
".",
"wsgi",
".",
"WSGIContai... | Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server | [
"Tornado",
"s",
"HTTPServer",
".",
"This",
"is",
"a",
"high",
"quality",
"asynchronous",
"server",
"with",
"many",
"options",
".",
"For",
"details",
"please",
"visit",
":",
"http",
":",
"//",
"www",
".",
"tornadoweb",
".",
"org",
"/",
"en",
"/",
"stable"... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/tornado_.py#L18-L34 |
NeuroML/pyNeuroML | pyneuroml/pynml.py | parse_arguments | def parse_arguments():
"""Parse command line arguments"""
import argparse
parser = argparse.ArgumentParser(
description=('pyNeuroML v%s: Python utilities for NeuroML2' % __version__
+ "\n libNeuroML v%s"%(neuroml.__version__)
+ "\n jNe... | python | def parse_arguments():
"""Parse command line arguments"""
import argparse
parser = argparse.ArgumentParser(
description=('pyNeuroML v%s: Python utilities for NeuroML2' % __version__
+ "\n libNeuroML v%s"%(neuroml.__version__)
+ "\n jNe... | [
"def",
"parse_arguments",
"(",
")",
":",
"import",
"argparse",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"'pyNeuroML v%s: Python utilities for NeuroML2'",
"%",
"__version__",
"+",
"\"\\n libNeuroML v%s\"",
"%",
"(",
"neuroml",
... | Parse command line arguments | [
"Parse",
"command",
"line",
"arguments"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L43-L245 |
NeuroML/pyNeuroML | pyneuroml/pynml.py | quick_summary | def quick_summary(nml2_doc):
'''
Or better just use nml2_doc.summary(show_includes=False)
'''
info = 'Contents of NeuroML 2 document: %s\n'%nml2_doc.id
membs = inspect.getmembers(nml2_doc)
for memb in membs:
if isinstance(memb[1], list) and len(memb[1])>0 \
and not... | python | def quick_summary(nml2_doc):
'''
Or better just use nml2_doc.summary(show_includes=False)
'''
info = 'Contents of NeuroML 2 document: %s\n'%nml2_doc.id
membs = inspect.getmembers(nml2_doc)
for memb in membs:
if isinstance(memb[1], list) and len(memb[1])>0 \
and not... | [
"def",
"quick_summary",
"(",
"nml2_doc",
")",
":",
"info",
"=",
"'Contents of NeuroML 2 document: %s\\n'",
"%",
"nml2_doc",
".",
"id",
"membs",
"=",
"inspect",
".",
"getmembers",
"(",
"nml2_doc",
")",
"for",
"memb",
"in",
"membs",
":",
"if",
"isinstance",
"(",... | Or better just use nml2_doc.summary(show_includes=False) | [
"Or",
"better",
"just",
"use",
"nml2_doc",
".",
"summary",
"(",
"show_includes",
"=",
"False",
")"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L419-L441 |
NeuroML/pyNeuroML | pyneuroml/pynml.py | execute_command_in_dir | def execute_command_in_dir(command, directory, verbose=DEFAULTS['v'],
prefix="Output: ", env=None):
"""Execute a command in specific working directory"""
if os.name == 'nt':
directory = os.path.normpath(directory)
print_comment("Executing: (%s) in direc... | python | def execute_command_in_dir(command, directory, verbose=DEFAULTS['v'],
prefix="Output: ", env=None):
"""Execute a command in specific working directory"""
if os.name == 'nt':
directory = os.path.normpath(directory)
print_comment("Executing: (%s) in direc... | [
"def",
"execute_command_in_dir",
"(",
"command",
",",
"directory",
",",
"verbose",
"=",
"DEFAULTS",
"[",
"'v'",
"]",
",",
"prefix",
"=",
"\"Output: \"",
",",
"env",
"=",
"None",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"directory",
"=",
"o... | Execute a command in specific working directory | [
"Execute",
"a",
"command",
"in",
"specific",
"working",
"directory"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L1181-L1239 |
NeuroML/pyNeuroML | pyneuroml/pynml.py | evaluate_component | def evaluate_component(comp_type, req_variables={}, parameter_values={}):
print_comment('Evaluating %s with req:%s; params:%s'%(comp_type.name,req_variables,parameter_values))
exec_str = ''
return_vals = {}
from math import exp
for p in parameter_values:
exec_str+='%s = %s\n'%(p, get_va... | python | def evaluate_component(comp_type, req_variables={}, parameter_values={}):
print_comment('Evaluating %s with req:%s; params:%s'%(comp_type.name,req_variables,parameter_values))
exec_str = ''
return_vals = {}
from math import exp
for p in parameter_values:
exec_str+='%s = %s\n'%(p, get_va... | [
"def",
"evaluate_component",
"(",
"comp_type",
",",
"req_variables",
"=",
"{",
"}",
",",
"parameter_values",
"=",
"{",
"}",
")",
":",
"print_comment",
"(",
"'Evaluating %s with req:%s; params:%s'",
"%",
"(",
"comp_type",
".",
"name",
",",
"req_variables",
",",
"... | print_comment_v(exec_str) | [
"print_comment_v",
"(",
"exec_str",
")"
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L1431-L1462 |
marrow/WebCore | web/ext/analytics.py | AnalyticsExtension.after | def after(self, context, exc=None):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client."""
duration = context._duration = round((time.time() - context._start_time) * 1000) # Convert to ms.
delta = unicode(duration)
# Default response augmentatio... | python | def after(self, context, exc=None):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client."""
duration = context._duration = round((time.time() - context._start_time) * 1000) # Convert to ms.
delta = unicode(duration)
# Default response augmentatio... | [
"def",
"after",
"(",
"self",
",",
"context",
",",
"exc",
"=",
"None",
")",
":",
"duration",
"=",
"context",
".",
"_duration",
"=",
"round",
"(",
"(",
"time",
".",
"time",
"(",
")",
"-",
"context",
".",
"_start_time",
")",
"*",
"1000",
")",
"# Conve... | Executed after dispatch has returned and the response populated, prior to anything being sent to the client. | [
"Executed",
"after",
"dispatch",
"has",
"returned",
"and",
"the",
"response",
"populated",
"prior",
"to",
"anything",
"being",
"sent",
"to",
"the",
"client",
"."
] | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/analytics.py#L55-L69 |
marrow/WebCore | web/ext/args.py | ArgumentExtension._process_flat_kwargs | def _process_flat_kwargs(source, kwargs):
"""Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an arr... | python | def _process_flat_kwargs(source, kwargs):
"""Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an arr... | [
"def",
"_process_flat_kwargs",
"(",
"source",
",",
"kwargs",
")",
":",
"ordered_arrays",
"=",
"[",
"]",
"# Process arguments one at a time and apply them to the kwargs passed in.",
"for",
"name",
",",
"value",
"in",
"source",
".",
"items",
"(",
")",
":",
"container",
... | Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an array named `foo`
`foo[]`: define a simple value... | [
"Apply",
"a",
"flat",
"namespace",
"transformation",
"to",
"recreate",
"(",
"in",
"some",
"respects",
")",
"a",
"rich",
"structure",
".",
"This",
"applies",
"several",
"transformations",
"which",
"may",
"be",
"nested",
":",
"foo",
"(",
"singular",
")",
":",
... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/args.py#L22-L87 |
NeuroML/pyNeuroML | pyneuroml/povray/NeuroML2ToPOVRay.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for converting NeuroML v2 files into POVRay files for 3D rendering")
parser.add_argument('neuroml_file', type=str, metavar='<NeuroML file>',
help='NeuroML ... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for converting NeuroML v2 files into POVRay files for 3D rendering")
parser.add_argument('neuroml_file', type=str, metavar='<NeuroML file>',
help='NeuroML ... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A file for converting NeuroML v2 files into POVRay files for 3D rendering\"",
")",
"parser",
".",
"add_argument",
"(",
"'neuroml_file'",
",",
"type",
"=",
... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/povray/NeuroML2ToPOVRay.py#L27-L143 |
marrow/WebCore | web/core/application.py | Application._configure | def _configure(self, config):
"""Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config.
"""
config = config or dict()
# We really need this to be there.
if 'extensio... | python | def _configure(self, config):
"""Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config.
"""
config = config or dict()
# We really need this to be there.
if 'extensio... | [
"def",
"_configure",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"config",
"or",
"dict",
"(",
")",
"# We really need this to be there.",
"if",
"'extensions'",
"not",
"in",
"config",
":",
"config",
"[",
"'extensions'",
"]",
"=",
"list",
"(",
")",
"... | Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config. | [
"Prepare",
"the",
"incoming",
"configuration",
"and",
"ensure",
"certain",
"expected",
"values",
"are",
"present",
".",
"For",
"example",
"this",
"ensures",
"BaseExtension",
"is",
"included",
"in",
"the",
"extension",
"list",
"and",
"populates",
"the",
"logging",
... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L108-L147 |
marrow/WebCore | web/core/application.py | Application.serve | def serve(self, service='auto', **options): # pragma: no cover
"""Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any... | python | def serve(self, service='auto', **options): # pragma: no cover
"""Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any... | [
"def",
"serve",
"(",
"self",
",",
"service",
"=",
"'auto'",
",",
"*",
"*",
"options",
")",
":",
"# pragma: no cover",
"service",
"=",
"load",
"(",
"service",
",",
"'web.server'",
")",
"# We don't bother with a full registry for these one-time lookups.",
"try",
":",
... | Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any additional configuration options appropriate for that
service. Al... | [
"Initiate",
"a",
"web",
"server",
"service",
"to",
"serve",
"this",
"application",
".",
"You",
"can",
"always",
"use",
"the",
"Application",
"instance",
"as",
"a",
"bare",
"WSGI",
"application",
"of",
"course",
".",
"This",
"method",
"is",
"provided",
"as",
... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L151-L170 |
marrow/WebCore | web/core/application.py | Application.application | def application(self, environ, start_response):
"""Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
midd... | python | def application(self, environ, start_response):
"""Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
midd... | [
"def",
"application",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"context",
"=",
"environ",
"[",
"'wc.context'",
"]",
"=",
"self",
".",
"RequestContext",
"(",
"environ",
"=",
"environ",
")",
"signals",
"=",
"context",
".",
"extension",
"... | Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
middleware callable.
Most apps won't utilize middlew... | [
"Process",
"a",
"single",
"WSGI",
"request",
"/",
"response",
"cycle",
".",
"This",
"is",
"the",
"WSGI",
"handler",
"for",
"WebCore",
".",
"Depending",
"on",
"the",
"presence",
"of",
"extensions",
"providing",
"WSGI",
"middleware",
"the",
"__call__",
"attribut... | train | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L217-L280 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment._swap | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | python | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | [
"def",
"_swap",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
",",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_start",
",",
"self",
".",
"ref_start",
"self",
".",
"ref_end",
",",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_end",
",",
"self... | Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed | [
"Swaps",
"the",
"alignment",
"so",
"that",
"the",
"reference",
"becomes",
"the",
"query",
"and",
"vice",
"-",
"versa",
".",
"Swaps",
"their",
"names",
"coordinates",
"etc",
".",
"The",
"frame",
"is",
"not",
"changed"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L52-L58 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.qry_coords | def qry_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence'''
return pyfastaq.intervals.Interval(min(self.qry_start, self.qry_end), max(self.qry_start, self.qry_end)) | python | def qry_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence'''
return pyfastaq.intervals.Interval(min(self.qry_start, self.qry_end), max(self.qry_start, self.qry_end)) | [
"def",
"qry_coords",
"(",
"self",
")",
":",
"return",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"(",
"min",
"(",
"self",
".",
"qry_start",
",",
"self",
".",
"qry_end",
")",
",",
"max",
"(",
"self",
".",
"qry_start",
",",
"self",
".",
"qry_end",
... | Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence | [
"Returns",
"a",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"object",
"of",
"the",
"start",
"and",
"end",
"coordinates",
"in",
"the",
"query",
"sequence"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L61-L63 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.ref_coords | def ref_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence'''
return pyfastaq.intervals.Interval(min(self.ref_start, self.ref_end), max(self.ref_start, self.ref_end)) | python | def ref_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence'''
return pyfastaq.intervals.Interval(min(self.ref_start, self.ref_end), max(self.ref_start, self.ref_end)) | [
"def",
"ref_coords",
"(",
"self",
")",
":",
"return",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"(",
"min",
"(",
"self",
".",
"ref_start",
",",
"self",
".",
"ref_end",
")",
",",
"max",
"(",
"self",
".",
"ref_start",
",",
"self",
".",
"ref_end",
... | Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence | [
"Returns",
"a",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"object",
"of",
"the",
"start",
"and",
"end",
"coordinates",
"in",
"the",
"reference",
"sequence"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L66-L68 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.on_same_strand | def on_same_strand(self):
'''Returns true iff the direction of the alignment is the same in the reference and the query'''
return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end) | python | def on_same_strand(self):
'''Returns true iff the direction of the alignment is the same in the reference and the query'''
return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end) | [
"def",
"on_same_strand",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"ref_start",
"<",
"self",
".",
"ref_end",
")",
"==",
"(",
"self",
".",
"qry_start",
"<",
"self",
".",
"qry_end",
")"
] | Returns true iff the direction of the alignment is the same in the reference and the query | [
"Returns",
"true",
"iff",
"the",
"direction",
"of",
"the",
"alignment",
"is",
"the",
"same",
"in",
"the",
"reference",
"and",
"the",
"query"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L71-L73 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.is_self_hit | def is_self_hit(self):
'''Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity'''
return self.ref_name == self.qry_name \
and self.ref_start == self.qry_start \
and self.ref_end == self.qry_end \
... | python | def is_self_hit(self):
'''Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity'''
return self.ref_name == self.qry_name \
and self.ref_start == self.qry_start \
and self.ref_end == self.qry_end \
... | [
"def",
"is_self_hit",
"(",
"self",
")",
":",
"return",
"self",
".",
"ref_name",
"==",
"self",
".",
"qry_name",
"and",
"self",
".",
"ref_start",
"==",
"self",
".",
"qry_start",
"and",
"self",
".",
"ref_end",
"==",
"self",
".",
"qry_end",
"and",
"self",
... | Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity | [
"Returns",
"true",
"iff",
"the",
"alignment",
"is",
"of",
"a",
"sequence",
"to",
"itself",
":",
"names",
"and",
"all",
"coordinates",
"are",
"the",
"same",
"and",
"100",
"percent",
"identity"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L76-L81 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.reverse_query | def reverse_query(self):
'''Changes the coordinates as if the query sequence has been reverse complemented'''
self.qry_start = self.qry_length - self.qry_start - 1
self.qry_end = self.qry_length - self.qry_end - 1 | python | def reverse_query(self):
'''Changes the coordinates as if the query sequence has been reverse complemented'''
self.qry_start = self.qry_length - self.qry_start - 1
self.qry_end = self.qry_length - self.qry_end - 1 | [
"def",
"reverse_query",
"(",
"self",
")",
":",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_length",
"-",
"self",
".",
"qry_start",
"-",
"1",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_length",
"-",
"self",
".",
"qry_end",
"-",
"1"
] | Changes the coordinates as if the query sequence has been reverse complemented | [
"Changes",
"the",
"coordinates",
"as",
"if",
"the",
"query",
"sequence",
"has",
"been",
"reverse",
"complemented"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L84-L87 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.reverse_reference | def reverse_reference(self):
'''Changes the coordinates as if the reference sequence has been reverse complemented'''
self.ref_start = self.ref_length - self.ref_start - 1
self.ref_end = self.ref_length - self.ref_end - 1 | python | def reverse_reference(self):
'''Changes the coordinates as if the reference sequence has been reverse complemented'''
self.ref_start = self.ref_length - self.ref_start - 1
self.ref_end = self.ref_length - self.ref_end - 1 | [
"def",
"reverse_reference",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
"=",
"self",
".",
"ref_length",
"-",
"self",
".",
"ref_start",
"-",
"1",
"self",
".",
"ref_end",
"=",
"self",
".",
"ref_length",
"-",
"self",
".",
"ref_end",
"-",
"1"
] | Changes the coordinates as if the reference sequence has been reverse complemented | [
"Changes",
"the",
"coordinates",
"as",
"if",
"the",
"reference",
"sequence",
"has",
"been",
"reverse",
"complemented"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L90-L93 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.to_msp_crunch | def to_msp_crunch(self):
'''Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
... | python | def to_msp_crunch(self):
'''Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
... | [
"def",
"to_msp_crunch",
"(",
"self",
")",
":",
"# we don't know the alignment score. Estimate it. This approximates 1 for a match.",
"aln_score",
"=",
"int",
"(",
"self",
".",
"percent_identity",
"*",
"0.005",
"*",
"(",
"self",
".",
"hit_length_ref",
"+",
"self",
".",
... | Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
6. subject sequence start
... | [
"Returns",
"the",
"alignment",
"as",
"a",
"line",
"in",
"MSPcrunch",
"format",
".",
"The",
"columns",
"are",
"space",
"-",
"separated",
"and",
"are",
":",
"1",
".",
"score",
"2",
".",
"percent",
"identity",
"3",
".",
"match",
"start",
"in",
"the",
"que... | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L113-L136 |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.qry_coords_from_ref_coord | def qry_coords_from_ref_coord(self, ref_coord, variant_list):
'''Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
o... | python | def qry_coords_from_ref_coord(self, ref_coord, variant_list):
'''Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
o... | [
"def",
"qry_coords_from_ref_coord",
"(",
"self",
",",
"ref_coord",
",",
"variant_list",
")",
":",
"if",
"self",
".",
"ref_coords",
"(",
")",
".",
"distance_to_point",
"(",
"ref_coord",
")",
">",
"0",
":",
"raise",
"Error",
"(",
"'Cannot get query coord in qry_co... | Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
or not the ref_coord lies in an indel. If it is, then
returns t... | [
"Given",
"a",
"reference",
"position",
"and",
"a",
"list",
"of",
"variants",
"(",
"[",
"variant",
".",
"Variant",
"]",
")",
"works",
"out",
"the",
"position",
"in",
"the",
"query",
"sequence",
"accounting",
"for",
"indels",
".",
"Returns",
"a",
"tuple",
... | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L147-L181 |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._nucmer_command | def _nucmer_command(self, ref, qry, outprefix):
'''Construct the nucmer command'''
if self.use_promer:
command = 'promer'
else:
command = 'nucmer'
command += ' -p ' + outprefix
if self.breaklen is not None:
command += ' -b ' + str(self.breakl... | python | def _nucmer_command(self, ref, qry, outprefix):
'''Construct the nucmer command'''
if self.use_promer:
command = 'promer'
else:
command = 'nucmer'
command += ' -p ' + outprefix
if self.breaklen is not None:
command += ' -b ' + str(self.breakl... | [
"def",
"_nucmer_command",
"(",
"self",
",",
"ref",
",",
"qry",
",",
"outprefix",
")",
":",
"if",
"self",
".",
"use_promer",
":",
"command",
"=",
"'promer'",
"else",
":",
"command",
"=",
"'nucmer'",
"command",
"+=",
"' -p '",
"+",
"outprefix",
"if",
"self... | Construct the nucmer command | [
"Construct",
"the",
"nucmer",
"command"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L53-L83 |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._delta_filter_command | def _delta_filter_command(self, infile, outfile):
'''Construct delta-filter command'''
command = 'delta-filter'
if self.min_id is not None:
command += ' -i ' + str(self.min_id)
if self.min_length is not None:
command += ' -l ' + str(self.min_length)
ret... | python | def _delta_filter_command(self, infile, outfile):
'''Construct delta-filter command'''
command = 'delta-filter'
if self.min_id is not None:
command += ' -i ' + str(self.min_id)
if self.min_length is not None:
command += ' -l ' + str(self.min_length)
ret... | [
"def",
"_delta_filter_command",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"command",
"=",
"'delta-filter'",
"if",
"self",
".",
"min_id",
"is",
"not",
"None",
":",
"command",
"+=",
"' -i '",
"+",
"str",
"(",
"self",
".",
"min_id",
")",
"if",
... | Construct delta-filter command | [
"Construct",
"delta",
"-",
"filter",
"command"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L86-L96 |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._show_coords_command | def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
command = 'show-coords -dTlro'
if not self.coords_header:
command += ' -H'
return command + ' ' + infile + ' > ' + outfile | python | def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
command = 'show-coords -dTlro'
if not self.coords_header:
command += ' -H'
return command + ' ' + infile + ' > ' + outfile | [
"def",
"_show_coords_command",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"command",
"=",
"'show-coords -dTlro'",
"if",
"not",
"self",
".",
"coords_header",
":",
"command",
"+=",
"' -H'",
"return",
"command",
"+",
"' '",
"+",
"infile",
"+",
"' > '... | Construct show-coords command | [
"Construct",
"show",
"-",
"coords",
"command"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L99-L106 |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._write_script | def _write_script(self, script_name, ref, qry, outfile):
'''Write commands into a bash script'''
f = pyfastaq.utils.open_file_write(script_name)
print(self._nucmer_command(ref, qry, 'p'), file=f)
print(self._delta_filter_command('p.delta', 'p.delta.filter'), file=f)
print(self._s... | python | def _write_script(self, script_name, ref, qry, outfile):
'''Write commands into a bash script'''
f = pyfastaq.utils.open_file_write(script_name)
print(self._nucmer_command(ref, qry, 'p'), file=f)
print(self._delta_filter_command('p.delta', 'p.delta.filter'), file=f)
print(self._s... | [
"def",
"_write_script",
"(",
"self",
",",
"script_name",
",",
"ref",
",",
"qry",
",",
"outfile",
")",
":",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_write",
"(",
"script_name",
")",
"print",
"(",
"self",
".",
"_nucmer_command",
"(",
"ref",
",",... | Write commands into a bash script | [
"Write",
"commands",
"into",
"a",
"bash",
"script"
] | train | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L118-L126 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.