repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
gatkin/declxml | declxml.py | _Array.serialize_on_parent | def serialize_on_parent(
self,
parent, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value and append it to the parent element."""
if not value and self.required:
st... | python | def serialize_on_parent(
self,
parent, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value and append it to the parent element."""
if not value and self.required:
st... | [
"def",
"serialize_on_parent",
"(",
"self",
",",
"parent",
",",
"# type: ET.Element",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> None",
"if",
"not",
"value",
"and",
"self",
".",
"required",
":",
"state",
".",
"raise... | Serialize the value and append it to the parent element. | [
"Serialize",
"the",
"value",
"and",
"append",
"it",
"to",
"the",
"parent",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L846-L867 | train | Serialize the value and append it to the parent element. |
gatkin/declxml | declxml.py | _Array._parse | def _parse(
self,
item_iter, # type: Iterable[ET.Element]
state # type: _ProcessorState
):
# type: (...) -> List
"""Parse the array data using the provided iterator of XML elements."""
parsed_array = []
for i, item in enumerate(item_iter):
... | python | def _parse(
self,
item_iter, # type: Iterable[ET.Element]
state # type: _ProcessorState
):
# type: (...) -> List
"""Parse the array data using the provided iterator of XML elements."""
parsed_array = []
for i, item in enumerate(item_iter):
... | [
"def",
"_parse",
"(",
"self",
",",
"item_iter",
",",
"# type: Iterable[ET.Element]",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> List",
"parsed_array",
"=",
"[",
"]",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"item_iter",
")",
":",
"st... | Parse the array data using the provided iterator of XML elements. | [
"Parse",
"the",
"array",
"data",
"using",
"the",
"provided",
"iterator",
"of",
"XML",
"elements",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L869-L886 | train | Parses the array data using the provided iterator of XML elements. |
gatkin/declxml | declxml.py | _Array._serialize | def _serialize(
self,
array_parent, # type: ET.Element
value, # type: List
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the array value and add it to the array parent element."""
if not value:
# Nothing to ... | python | def _serialize(
self,
array_parent, # type: ET.Element
value, # type: List
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the array value and add it to the array parent element."""
if not value:
# Nothing to ... | [
"def",
"_serialize",
"(",
"self",
",",
"array_parent",
",",
"# type: ET.Element",
"value",
",",
"# type: List",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> None",
"if",
"not",
"value",
":",
"# Nothing to do. Avoid attempting to iterate over a possibly",
... | Serialize the array value and add it to the array parent element. | [
"Serialize",
"the",
"array",
"value",
"and",
"add",
"it",
"to",
"the",
"array",
"parent",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L888-L905 | train | Serialize the array value and add it to the array parent element. |
gatkin/declxml | declxml.py | _Dictionary.parse_at_element | def parse_at_element(
self,
element, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the provided element as a dictionary."""
parsed_dict = {}
for child in self._child_processors:
state.push_location... | python | def parse_at_element(
self,
element, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the provided element as a dictionary."""
parsed_dict = {}
for child in self._child_processors:
state.push_location... | [
"def",
"parse_at_element",
"(",
"self",
",",
"element",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"parsed_dict",
"=",
"{",
"}",
"for",
"child",
"in",
"self",
".",
"_child_processors",
":",
"state",
".",
"push_... | Parse the provided element as a dictionary. | [
"Parse",
"the",
"provided",
"element",
"as",
"a",
"dictionary",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L945-L959 | train | Parse the provided element as a dictionary. |
gatkin/declxml | declxml.py | _Dictionary.parse_at_root | def parse_at_root(
self,
root, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the root XML element as a dictionary."""
parsed_dict = {} # type: Dict
dict_element = _element_find_from_root(root, self.element_pa... | python | def parse_at_root(
self,
root, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the root XML element as a dictionary."""
parsed_dict = {} # type: Dict
dict_element = _element_find_from_root(root, self.element_pa... | [
"def",
"parse_at_root",
"(",
"self",
",",
"root",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"parsed_dict",
"=",
"{",
"}",
"# type: Dict",
"dict_element",
"=",
"_element_find_from_root",
"(",
"root",
",",
"self",
... | Parse the root XML element as a dictionary. | [
"Parse",
"the",
"root",
"XML",
"element",
"as",
"a",
"dictionary",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L961-L976 | train | Parse the root XML element as a dictionary. |
gatkin/declxml | declxml.py | _Dictionary.serialize | def serialize(
self,
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> ET.Element
"""Serialize the value to a new element and return the element."""
if not value and self.required:
state.raise_error(
Missing... | python | def serialize(
self,
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> ET.Element
"""Serialize the value to a new element and return the element."""
if not value and self.required:
state.raise_error(
Missing... | [
"def",
"serialize",
"(",
"self",
",",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> ET.Element",
"if",
"not",
"value",
"and",
"self",
".",
"required",
":",
"state",
".",
"raise_error",
"(",
"MissingValue",
",",
"'Mi... | Serialize the value to a new element and return the element. | [
"Serialize",
"the",
"value",
"to",
"a",
"new",
"element",
"and",
"return",
"the",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L996-L1010 | train | Serialize the value to a new element and return the element. |
gatkin/declxml | declxml.py | _Dictionary._serialize | def _serialize(
self,
element, # type: ET.Element
value, # type: Dict
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the dictionary and append all serialized children to the element."""
for child in self._child_processor... | python | def _serialize(
self,
element, # type: ET.Element
value, # type: Dict
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the dictionary and append all serialized children to the element."""
for child in self._child_processor... | [
"def",
"_serialize",
"(",
"self",
",",
"element",
",",
"# type: ET.Element",
"value",
",",
"# type: Dict",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> None",
"for",
"child",
"in",
"self",
".",
"_child_processors",
":",
"state",
".",
"push_locatio... | Serialize the dictionary and append all serialized children to the element. | [
"Serialize",
"the",
"dictionary",
"and",
"append",
"all",
"serialized",
"children",
"to",
"the",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1030-L1042 | train | Serialize the dictionary and append all serialized children to the element. |
gatkin/declxml | declxml.py | _HookedAggregate.parse_at_element | def parse_at_element(
self,
element, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the given element."""
xml_value = self._processor.parse_at_element(element, state)
return _hooks_apply_after_parse(self._hooks,... | python | def parse_at_element(
self,
element, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the given element."""
xml_value = self._processor.parse_at_element(element, state)
return _hooks_apply_after_parse(self._hooks,... | [
"def",
"parse_at_element",
"(",
"self",
",",
"element",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"xml_value",
"=",
"self",
".",
"_processor",
".",
"parse_at_element",
"(",
"element",
",",
"state",
")",
"return"... | Parse the given element. | [
"Parse",
"the",
"given",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1078-L1086 | train | Parse the given element and return the object. |
gatkin/declxml | declxml.py | _HookedAggregate.parse_at_root | def parse_at_root(
self,
root, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the given element as the root of the document."""
xml_value = self._processor.parse_at_root(root, state)
return _hooks_apply_after_pa... | python | def parse_at_root(
self,
root, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the given element as the root of the document."""
xml_value = self._processor.parse_at_root(root, state)
return _hooks_apply_after_pa... | [
"def",
"parse_at_root",
"(",
"self",
",",
"root",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"xml_value",
"=",
"self",
".",
"_processor",
".",
"parse_at_root",
"(",
"root",
",",
"state",
")",
"return",
"_hooks_... | Parse the given element as the root of the document. | [
"Parse",
"the",
"given",
"element",
"as",
"the",
"root",
"of",
"the",
"document",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1088-L1096 | train | Parse the given element as the root of the document. |
gatkin/declxml | declxml.py | _HookedAggregate.parse_from_parent | def parse_from_parent(
self,
parent, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the element from the given parent element."""
xml_value = self._processor.parse_from_parent(parent, state)
return _hooks_apply_... | python | def parse_from_parent(
self,
parent, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the element from the given parent element."""
xml_value = self._processor.parse_from_parent(parent, state)
return _hooks_apply_... | [
"def",
"parse_from_parent",
"(",
"self",
",",
"parent",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"xml_value",
"=",
"self",
".",
"_processor",
".",
"parse_from_parent",
"(",
"parent",
",",
"state",
")",
"return"... | Parse the element from the given parent element. | [
"Parse",
"the",
"element",
"from",
"the",
"given",
"parent",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1098-L1106 | train | Parse the element from the given parent element. |
gatkin/declxml | declxml.py | _HookedAggregate.serialize | def serialize(
self,
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> ET.Element
"""Serialize the value and returns it."""
xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
return self._processor.serialize(x... | python | def serialize(
self,
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> ET.Element
"""Serialize the value and returns it."""
xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
return self._processor.serialize(x... | [
"def",
"serialize",
"(",
"self",
",",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> ET.Element",
"xml_value",
"=",
"_hooks_apply_before_serialize",
"(",
"self",
".",
"_hooks",
",",
"state",
",",
"value",
")",
"return",
... | Serialize the value and returns it. | [
"Serialize",
"the",
"value",
"and",
"returns",
"it",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1108-L1116 | train | Serialize the value and returns it. |
gatkin/declxml | declxml.py | _HookedAggregate.serialize_on_parent | def serialize_on_parent(
self,
parent, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value directory on the parent."""
xml_value = _hooks_apply_before_serialize(self._hooks, sta... | python | def serialize_on_parent(
self,
parent, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value directory on the parent."""
xml_value = _hooks_apply_before_serialize(self._hooks, sta... | [
"def",
"serialize_on_parent",
"(",
"self",
",",
"parent",
",",
"# type: ET.Element",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> None",
"xml_value",
"=",
"_hooks_apply_before_serialize",
"(",
"self",
".",
"_hooks",
",",
... | Serialize the value directory on the parent. | [
"Serialize",
"the",
"value",
"directory",
"on",
"the",
"parent",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1118-L1127 | train | Serialize the value directory on the parent. |
gatkin/declxml | declxml.py | _PrimitiveValue.parse_at_element | def parse_at_element(
self,
element, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the primitive value at the XML element."""
if self._attribute:
parsed_value = self._parse_attribute(element, self._attribut... | python | def parse_at_element(
self,
element, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the primitive value at the XML element."""
if self._attribute:
parsed_value = self._parse_attribute(element, self._attribut... | [
"def",
"parse_at_element",
"(",
"self",
",",
"element",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"if",
"self",
".",
"_attribute",
":",
"parsed_value",
"=",
"self",
".",
"_parse_attribute",
"(",
"element",
",",
... | Parse the primitive value at the XML element. | [
"Parse",
"the",
"primitive",
"value",
"at",
"the",
"XML",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1202-L1214 | train | Parse the primitive value at the XML element. |
gatkin/declxml | declxml.py | _PrimitiveValue.parse_from_parent | def parse_from_parent(
self,
parent, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the primitive value under the parent XML element."""
element = parent.find(self.element_path)
if element is None and self.requ... | python | def parse_from_parent(
self,
parent, # type: ET.Element
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the primitive value under the parent XML element."""
element = parent.find(self.element_path)
if element is None and self.requ... | [
"def",
"parse_from_parent",
"(",
"self",
",",
"parent",
",",
"# type: ET.Element",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"element",
"=",
"parent",
".",
"find",
"(",
"self",
".",
"element_path",
")",
"if",
"element",
"is",
"None",
... | Parse the primitive value under the parent XML element. | [
"Parse",
"the",
"primitive",
"value",
"under",
"the",
"parent",
"XML",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1216-L1232 | train | Parse the primitive value under the parent XML element. |
gatkin/declxml | declxml.py | _PrimitiveValue.serialize | def serialize(
self,
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> ET.Element
"""
Serialize the value into a new element object and return the element.
If the omit_empty option was specified and the value is falsey, then t... | python | def serialize(
self,
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> ET.Element
"""
Serialize the value into a new element object and return the element.
If the omit_empty option was specified and the value is falsey, then t... | [
"def",
"serialize",
"(",
"self",
",",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> ET.Element",
"# For primitive values, this is only called when the value is part of an array,",
"# in which case we do not need to check for missing or omitt... | Serialize the value into a new element object and return the element.
If the omit_empty option was specified and the value is falsey, then this will return None. | [
"Serialize",
"the",
"value",
"into",
"a",
"new",
"element",
"object",
"and",
"return",
"the",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1234-L1249 | train | Serialize the value into a new element object and return the element. |
gatkin/declxml | declxml.py | _PrimitiveValue.serialize_on_parent | def serialize_on_parent(
self,
parent, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value and add it to the parent element."""
# Note that falsey values are not treated as miss... | python | def serialize_on_parent(
self,
parent, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value and add it to the parent element."""
# Note that falsey values are not treated as miss... | [
"def",
"serialize_on_parent",
"(",
"self",
",",
"parent",
",",
"# type: ET.Element",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> None",
"# Note that falsey values are not treated as missing, but they may be omitted.",
"if",
"value"... | Serialize the value and add it to the parent element. | [
"Serialize",
"the",
"value",
"and",
"add",
"it",
"to",
"the",
"parent",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1251-L1267 | train | Serialize the value and add it to the parent element. |
gatkin/declxml | declxml.py | _PrimitiveValue._missing_value_message | def _missing_value_message(self, parent):
# type: (ET.Element) -> Text
"""Return the message to report that the value needed for serialization is missing."""
if self._attribute is None:
message = 'Missing required value for element "{}"'.format(self.element_path)
else:
... | python | def _missing_value_message(self, parent):
# type: (ET.Element) -> Text
"""Return the message to report that the value needed for serialization is missing."""
if self._attribute is None:
message = 'Missing required value for element "{}"'.format(self.element_path)
else:
... | [
"def",
"_missing_value_message",
"(",
"self",
",",
"parent",
")",
":",
"# type: (ET.Element) -> Text",
"if",
"self",
".",
"_attribute",
"is",
"None",
":",
"message",
"=",
"'Missing required value for element \"{}\"'",
".",
"format",
"(",
"self",
".",
"element_path",
... | Return the message to report that the value needed for serialization is missing. | [
"Return",
"the",
"message",
"to",
"report",
"that",
"the",
"value",
"needed",
"for",
"serialization",
"is",
"missing",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1269-L1283 | train | Return the message to report that the value needed for serialization is missing. |
gatkin/declxml | declxml.py | _PrimitiveValue._parse_attribute | def _parse_attribute(
self,
element, # type: ET.Element
attribute, # type: Text
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the primitive value within the XML element's attribute."""
parsed_value = self._default
at... | python | def _parse_attribute(
self,
element, # type: ET.Element
attribute, # type: Text
state # type: _ProcessorState
):
# type: (...) -> Any
"""Parse the primitive value within the XML element's attribute."""
parsed_value = self._default
at... | [
"def",
"_parse_attribute",
"(",
"self",
",",
"element",
",",
"# type: ET.Element",
"attribute",
",",
"# type: Text",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> Any",
"parsed_value",
"=",
"self",
".",
"_default",
"attribute_value",
"=",
"element",
... | Parse the primitive value within the XML element's attribute. | [
"Parse",
"the",
"primitive",
"value",
"within",
"the",
"XML",
"element",
"s",
"attribute",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1285-L1305 | train | Parse the primitive value within the XML element s attribute. |
gatkin/declxml | declxml.py | _PrimitiveValue._serialize | def _serialize(
self,
element, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value to the element."""
xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
... | python | def _serialize(
self,
element, # type: ET.Element
value, # type: Any
state # type: _ProcessorState
):
# type: (...) -> None
"""Serialize the value to the element."""
xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
... | [
"def",
"_serialize",
"(",
"self",
",",
"element",
",",
"# type: ET.Element",
"value",
",",
"# type: Any",
"state",
"# type: _ProcessorState",
")",
":",
"# type: (...) -> None",
"xml_value",
"=",
"_hooks_apply_before_serialize",
"(",
"self",
".",
"_hooks",
",",
"state"... | Serialize the value to the element. | [
"Serialize",
"the",
"value",
"to",
"the",
"element",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1307-L1331 | train | Serialize the value to the element. |
gatkin/declxml | declxml.py | _ProcessorState.push_location | def push_location(
self,
element_path, # type: Text
array_index=None # type: Optional[int]
):
# type: (...) -> None
"""Push an item onto the state's stack of locations."""
location = ProcessorLocation(element_path=element_path, array_index=array_index)
... | python | def push_location(
self,
element_path, # type: Text
array_index=None # type: Optional[int]
):
# type: (...) -> None
"""Push an item onto the state's stack of locations."""
location = ProcessorLocation(element_path=element_path, array_index=array_index)
... | [
"def",
"push_location",
"(",
"self",
",",
"element_path",
",",
"# type: Text",
"array_index",
"=",
"None",
"# type: Optional[int]",
")",
":",
"# type: (...) -> None",
"location",
"=",
"ProcessorLocation",
"(",
"element_path",
"=",
"element_path",
",",
"array_index",
"... | Push an item onto the state's stack of locations. | [
"Push",
"an",
"item",
"onto",
"the",
"state",
"s",
"stack",
"of",
"locations",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1351-L1359 | train | Push an item onto the state s stack of locations. |
gatkin/declxml | declxml.py | _ProcessorState.raise_error | def raise_error(
self,
exception_type, # type: Type[Exception]
message # type: Text
):
# type: (...) -> NoReturn
"""Raise an exception with the current parser state information and error message."""
error_message = '{} at {}'.format(message, repr(self))
... | python | def raise_error(
self,
exception_type, # type: Type[Exception]
message # type: Text
):
# type: (...) -> NoReturn
"""Raise an exception with the current parser state information and error message."""
error_message = '{} at {}'.format(message, repr(self))
... | [
"def",
"raise_error",
"(",
"self",
",",
"exception_type",
",",
"# type: Type[Exception]",
"message",
"# type: Text",
")",
":",
"# type: (...) -> NoReturn",
"error_message",
"=",
"'{} at {}'",
".",
"format",
"(",
"message",
",",
"repr",
"(",
"self",
")",
")",
"rais... | Raise an exception with the current parser state information and error message. | [
"Raise",
"an",
"exception",
"with",
"the",
"current",
"parser",
"state",
"information",
"and",
"error",
"message",
"."
] | 3a2324b43aee943e82a04587fbb68932c6f392ba | https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1361-L1369 | train | Raise an exception with the current parser state information and error message. |
ponty/eagexp | eagexp/partlist.py | export_partlist_to_file | def export_partlist_to_file(input, output, timeout=20, showgui=False):
'''
call eagle and export sch or brd to partlist text file
:param input: .sch or .brd file name
:param output: text file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: None
'''
... | python | def export_partlist_to_file(input, output, timeout=20, showgui=False):
'''
call eagle and export sch or brd to partlist text file
:param input: .sch or .brd file name
:param output: text file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: None
'''
... | [
"def",
"export_partlist_to_file",
"(",
"input",
",",
"output",
",",
"timeout",
"=",
"20",
",",
"showgui",
"=",
"False",
")",
":",
"input",
"=",
"norm_path",
"(",
"input",
")",
"output",
"=",
"norm_path",
"(",
"output",
")",
"commands",
"=",
"export_command... | call eagle and export sch or brd to partlist text file
:param input: .sch or .brd file name
:param output: text file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: None | [
"call",
"eagle",
"and",
"export",
"sch",
"or",
"brd",
"to",
"partlist",
"text",
"file"
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/partlist.py#L16-L31 | train | call eagle and export sch or brd to partlist text file |
ponty/eagexp | eagexp/partlist.py | parse_partlist | def parse_partlist(str):
'''parse partlist text delivered by eagle.
header is converted to lowercase
:param str: input string
:rtype: tuple of header list and dict list: (['part','value',..], [{'part':'C1', 'value':'1n'}, ..])
'''
lines = str.strip().splitlines()
lines = filter(len, lines)... | python | def parse_partlist(str):
'''parse partlist text delivered by eagle.
header is converted to lowercase
:param str: input string
:rtype: tuple of header list and dict list: (['part','value',..], [{'part':'C1', 'value':'1n'}, ..])
'''
lines = str.strip().splitlines()
lines = filter(len, lines)... | [
"def",
"parse_partlist",
"(",
"str",
")",
":",
"lines",
"=",
"str",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
")",
"lines",
"=",
"filter",
"(",
"len",
",",
"lines",
")",
"hind",
"=",
"header_index",
"(",
"lines",
")",
"if",
"hind",
"is",
"Non... | parse partlist text delivered by eagle.
header is converted to lowercase
:param str: input string
:rtype: tuple of header list and dict list: (['part','value',..], [{'part':'C1', 'value':'1n'}, ..]) | [
"parse",
"partlist",
"text",
"delivered",
"by",
"eagle",
"."
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/partlist.py#L40-L69 | train | parse partlist text delivered by eagle. |
ponty/eagexp | eagexp/partlist.py | raw_partlist | def raw_partlist(input, timeout=20, showgui=False):
'''export partlist by eagle, then return it
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: string
'''
output = tempfile.NamedTemporaryFile(
prefix='eagexp_', su... | python | def raw_partlist(input, timeout=20, showgui=False):
'''export partlist by eagle, then return it
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: string
'''
output = tempfile.NamedTemporaryFile(
prefix='eagexp_', su... | [
"def",
"raw_partlist",
"(",
"input",
",",
"timeout",
"=",
"20",
",",
"showgui",
"=",
"False",
")",
":",
"output",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"'eagexp_'",
",",
"suffix",
"=",
"'.partlist'",
",",
"delete",
"=",
"0",
")"... | export partlist by eagle, then return it
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: string | [
"export",
"partlist",
"by",
"eagle",
"then",
"return",
"it"
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/partlist.py#L72-L87 | train | export partlist by eagle then return it
|
ponty/eagexp | eagexp/partlist.py | structured_partlist | def structured_partlist(input, timeout=20, showgui=False):
'''export partlist by eagle, then parse it
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: tuple of header list and dict list: (['part','value',..], [{'part':'C1', 'value'... | python | def structured_partlist(input, timeout=20, showgui=False):
'''export partlist by eagle, then parse it
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: tuple of header list and dict list: (['part','value',..], [{'part':'C1', 'value'... | [
"def",
"structured_partlist",
"(",
"input",
",",
"timeout",
"=",
"20",
",",
"showgui",
"=",
"False",
")",
":",
"s",
"=",
"raw_partlist",
"(",
"input",
"=",
"input",
",",
"timeout",
"=",
"timeout",
",",
"showgui",
"=",
"showgui",
")",
"return",
"parse_par... | export partlist by eagle, then parse it
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: tuple of header list and dict list: (['part','value',..], [{'part':'C1', 'value':'1n'}, ..]) | [
"export",
"partlist",
"by",
"eagle",
"then",
"parse",
"it"
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/partlist.py#L90-L100 | train | export partlist by eagle then parse it
|
ponty/eagexp | eagexp/partlist.py | print_partlist | def print_partlist(input, timeout=20, showgui=False):
'''print partlist text delivered by eagle
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: None
'''
print raw_partlist(input=input, timeout=timeout, showgui=showgui) | python | def print_partlist(input, timeout=20, showgui=False):
'''print partlist text delivered by eagle
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: None
'''
print raw_partlist(input=input, timeout=timeout, showgui=showgui) | [
"def",
"print_partlist",
"(",
"input",
",",
"timeout",
"=",
"20",
",",
"showgui",
"=",
"False",
")",
":",
"print",
"raw_partlist",
"(",
"input",
"=",
"input",
",",
"timeout",
"=",
"timeout",
",",
"showgui",
"=",
"showgui",
")"
] | print partlist text delivered by eagle
:param input: .sch or .brd file name
:param timeout: int
:param showgui: Bool, True -> do not hide eagle GUI
:rtype: None | [
"print",
"partlist",
"text",
"delivered",
"by",
"eagle"
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/partlist.py#L104-L112 | train | print partlist text delivered by eagle
|
xflr6/bitsets | bitsets/visualize.py | bitset | def bitset(bs, member_label=None, filename=None, directory=None, format=None,
render=False, view=False):
"""Graphviz source for the Hasse diagram of the domains' Boolean algebra."""
if member_label is None:
member_label = MEMBER_LABEL
if filename is None:
kind = 'members' if memb... | python | def bitset(bs, member_label=None, filename=None, directory=None, format=None,
render=False, view=False):
"""Graphviz source for the Hasse diagram of the domains' Boolean algebra."""
if member_label is None:
member_label = MEMBER_LABEL
if filename is None:
kind = 'members' if memb... | [
"def",
"bitset",
"(",
"bs",
",",
"member_label",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"directory",
"=",
"None",
",",
"format",
"=",
"None",
",",
"render",
"=",
"False",
",",
"view",
"=",
"False",
")",
":",
"if",
"member_label",
"is",
"None... | Graphviz source for the Hasse diagram of the domains' Boolean algebra. | [
"Graphviz",
"source",
"for",
"the",
"Hasse",
"diagram",
"of",
"the",
"domains",
"Boolean",
"algebra",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/visualize.py#L34-L68 | train | Graphviz source for the Hasse diagram of the domains Boolean algebra. |
druids/django-chamber | chamber/patch.py | field_init | def field_init(self, *args, **kwargs):
"""
Patches a Django Field's `__init__` method for easier usage of optional `kwargs`. It defines a `humanized` attribute
on a field for better display of its value.
"""
humanize_func = kwargs.pop('humanized', None)
if humanize_func:
def humanize(val... | python | def field_init(self, *args, **kwargs):
"""
Patches a Django Field's `__init__` method for easier usage of optional `kwargs`. It defines a `humanized` attribute
on a field for better display of its value.
"""
humanize_func = kwargs.pop('humanized', None)
if humanize_func:
def humanize(val... | [
"def",
"field_init",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"humanize_func",
"=",
"kwargs",
".",
"pop",
"(",
"'humanized'",
",",
"None",
")",
"if",
"humanize_func",
":",
"def",
"humanize",
"(",
"val",
",",
"inst",
",",
"*",... | Patches a Django Field's `__init__` method for easier usage of optional `kwargs`. It defines a `humanized` attribute
on a field for better display of its value. | [
"Patches",
"a",
"Django",
"Field",
"s",
"__init__",
"method",
"for",
"easier",
"usage",
"of",
"optional",
"kwargs",
".",
"It",
"defines",
"a",
"humanized",
"attribute",
"on",
"a",
"field",
"for",
"better",
"display",
"of",
"its",
"value",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/patch.py#L50-L62 | train | Patches a Django Field s __init__ method for easier usage of optional kwargs. |
kyzima-spb/flask-pony | flask_pony/orm.py | FormBuilder._get_field_method | def _get_field_method(self, tp):
"""Returns a reference to the form element's constructor method."""
method = self.field_constructor.get(tp)
if method and hasattr(self, method.__name__):
return getattr(self, method.__name__)
return method | python | def _get_field_method(self, tp):
"""Returns a reference to the form element's constructor method."""
method = self.field_constructor.get(tp)
if method and hasattr(self, method.__name__):
return getattr(self, method.__name__)
return method | [
"def",
"_get_field_method",
"(",
"self",
",",
"tp",
")",
":",
"method",
"=",
"self",
".",
"field_constructor",
".",
"get",
"(",
"tp",
")",
"if",
"method",
"and",
"hasattr",
"(",
"self",
",",
"method",
".",
"__name__",
")",
":",
"return",
"getattr",
"("... | Returns a reference to the form element's constructor method. | [
"Returns",
"a",
"reference",
"to",
"the",
"form",
"element",
"s",
"constructor",
"method",
"."
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/orm.py#L66-L71 | train | Returns a reference to the form element s constructor method. |
kyzima-spb/flask-pony | flask_pony/orm.py | FormBuilder._create_plain_field | def _create_plain_field(self, attr, options):
"""Creates the form element."""
method = self._get_field_method(attr.py_type) or self._create_other_field
klass, options = method(attr, options)
if attr.is_unique:
options['validators'].append(validators.UniqueEntityValidator(att... | python | def _create_plain_field(self, attr, options):
"""Creates the form element."""
method = self._get_field_method(attr.py_type) or self._create_other_field
klass, options = method(attr, options)
if attr.is_unique:
options['validators'].append(validators.UniqueEntityValidator(att... | [
"def",
"_create_plain_field",
"(",
"self",
",",
"attr",
",",
"options",
")",
":",
"method",
"=",
"self",
".",
"_get_field_method",
"(",
"attr",
".",
"py_type",
")",
"or",
"self",
".",
"_create_other_field",
"klass",
",",
"options",
"=",
"method",
"(",
"att... | Creates the form element. | [
"Creates",
"the",
"form",
"element",
"."
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/orm.py#L77-L85 | train | Creates the form element. |
kyzima-spb/flask-pony | flask_pony/orm.py | FormBuilder._create_relational_field | def _create_relational_field(self, attr, options):
"""Creates the form element for working with entity relationships."""
options['entity_class'] = attr.py_type
options['allow_empty'] = not attr.is_required
return EntityField, options | python | def _create_relational_field(self, attr, options):
"""Creates the form element for working with entity relationships."""
options['entity_class'] = attr.py_type
options['allow_empty'] = not attr.is_required
return EntityField, options | [
"def",
"_create_relational_field",
"(",
"self",
",",
"attr",
",",
"options",
")",
":",
"options",
"[",
"'entity_class'",
"]",
"=",
"attr",
".",
"py_type",
"options",
"[",
"'allow_empty'",
"]",
"=",
"not",
"attr",
".",
"is_required",
"return",
"EntityField",
... | Creates the form element for working with entity relationships. | [
"Creates",
"the",
"form",
"element",
"for",
"working",
"with",
"entity",
"relationships",
"."
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/orm.py#L92-L96 | train | Creates the form element for working with entity relationships. |
kyzima-spb/flask-pony | flask_pony/orm.py | FormBuilder.add | def add(self, attr, field_class=None, **options):
"""Adds an element to the form based on the entity attribute."""
# print(attr.name, attr.py_type, getattr(attr, 'set', None))
# print(dir(attr))
# print(attr, attr.is_relation, attr.is_collection)
# print(attr.is_pk, attr.auto, at... | python | def add(self, attr, field_class=None, **options):
"""Adds an element to the form based on the entity attribute."""
# print(attr.name, attr.py_type, getattr(attr, 'set', None))
# print(dir(attr))
# print(attr, attr.is_relation, attr.is_collection)
# print(attr.is_pk, attr.auto, at... | [
"def",
"add",
"(",
"self",
",",
"attr",
",",
"field_class",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"# print(attr.name, attr.py_type, getattr(attr, 'set', None))",
"# print(dir(attr))",
"# print(attr, attr.is_relation, attr.is_collection)",
"# print(attr.is_pk, attr.au... | Adds an element to the form based on the entity attribute. | [
"Adds",
"an",
"element",
"to",
"the",
"form",
"based",
"on",
"the",
"entity",
"attribute",
"."
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/orm.py#L102-L133 | train | Adds an element to the form based on the entity attribute. |
kyzima-spb/flask-pony | flask_pony/orm.py | FormBuilder.add_button | def add_button(self, name, button_class=wtf_fields.SubmitField, **options):
"""Adds a button to the form."""
self._buttons[name] = button_class(**options) | python | def add_button(self, name, button_class=wtf_fields.SubmitField, **options):
"""Adds a button to the form."""
self._buttons[name] = button_class(**options) | [
"def",
"add_button",
"(",
"self",
",",
"name",
",",
"button_class",
"=",
"wtf_fields",
".",
"SubmitField",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_buttons",
"[",
"name",
"]",
"=",
"button_class",
"(",
"*",
"*",
"options",
")"
] | Adds a button to the form. | [
"Adds",
"a",
"button",
"to",
"the",
"form",
"."
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/orm.py#L135-L137 | train | Adds a button to the form. |
kyzima-spb/flask-pony | flask_pony/orm.py | FormBuilder.field_uuid | def field_uuid(self, attr, options):
"""Creates a form element for the UUID type."""
options['validators'].append(validators.UUIDValidator(attr.entity))
return wtf_fields.StringField, options | python | def field_uuid(self, attr, options):
"""Creates a form element for the UUID type."""
options['validators'].append(validators.UUIDValidator(attr.entity))
return wtf_fields.StringField, options | [
"def",
"field_uuid",
"(",
"self",
",",
"attr",
",",
"options",
")",
":",
"options",
"[",
"'validators'",
"]",
".",
"append",
"(",
"validators",
".",
"UUIDValidator",
"(",
"attr",
".",
"entity",
")",
")",
"return",
"wtf_fields",
".",
"StringField",
",",
"... | Creates a form element for the UUID type. | [
"Creates",
"a",
"form",
"element",
"for",
"the",
"UUID",
"type",
"."
] | 6cf28d70b7ebf415d58fa138fcc70b8dd57432c7 | https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/orm.py#L198-L201 | train | Creates a form element for the UUID type. |
ponty/eagexp | eagexp/image.py | export_image | def export_image(input, output, timeout=20, palette='white', resolution=150, layers=None, command=None, mirror=False, showgui=False):
'''
Exporting eagle .sch or .brd file into image file.
GUI is not displayed if ``pyvirtualdisplay`` is installed.
If export is blocked somehow (e.g. popup window is displ... | python | def export_image(input, output, timeout=20, palette='white', resolution=150, layers=None, command=None, mirror=False, showgui=False):
'''
Exporting eagle .sch or .brd file into image file.
GUI is not displayed if ``pyvirtualdisplay`` is installed.
If export is blocked somehow (e.g. popup window is displ... | [
"def",
"export_image",
"(",
"input",
",",
"output",
",",
"timeout",
"=",
"20",
",",
"palette",
"=",
"'white'",
",",
"resolution",
"=",
"150",
",",
"layers",
"=",
"None",
",",
"command",
"=",
"None",
",",
"mirror",
"=",
"False",
",",
"showgui",
"=",
"... | Exporting eagle .sch or .brd file into image file.
GUI is not displayed if ``pyvirtualdisplay`` is installed.
If export is blocked somehow (e.g. popup window is displayed) then after timeout operation is canceled with exception.
Problem can be investigated by setting 'showgui' flag.
Exporting generates... | [
"Exporting",
"eagle",
".",
"sch",
"or",
".",
"brd",
"file",
"into",
"image",
"file",
".",
"GUI",
"is",
"not",
"displayed",
"if",
"pyvirtualdisplay",
"is",
"installed",
".",
"If",
"export",
"is",
"blocked",
"somehow",
"(",
"e",
".",
"g",
".",
"popup",
"... | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/image.py#L15-L88 | train | Export an image file from one of the available formats. |
PaulMcMillan/tasa | tasa/cli.py | runm | def runm():
""" This is super minimal and pretty hacky, but it counts as a first pass.
"""
signal.signal(signal.SIGINT, signal_handler)
count = int(sys.argv.pop(1))
processes = [Process(target=run, args=()) for x in range(count)]
try:
for p in processes:
p.start()
except ... | python | def runm():
""" This is super minimal and pretty hacky, but it counts as a first pass.
"""
signal.signal(signal.SIGINT, signal_handler)
count = int(sys.argv.pop(1))
processes = [Process(target=run, args=()) for x in range(count)]
try:
for p in processes:
p.start()
except ... | [
"def",
"runm",
"(",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal_handler",
")",
"count",
"=",
"int",
"(",
"sys",
".",
"argv",
".",
"pop",
"(",
"1",
")",
")",
"processes",
"=",
"[",
"Process",
"(",
"target",
"=",
"... | This is super minimal and pretty hacky, but it counts as a first pass. | [
"This",
"is",
"super",
"minimal",
"and",
"pretty",
"hacky",
"but",
"it",
"counts",
"as",
"a",
"first",
"pass",
"."
] | fd548d97fd08e61c0e71296b08ffedb7d949e06a | https://github.com/PaulMcMillan/tasa/blob/fd548d97fd08e61c0e71296b08ffedb7d949e06a/tasa/cli.py#L79-L93 | train | This is a hacky method that counts as a first pass. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.identify | def identify(self, request):
"""Establish what identity this user claims to have from request.
:param request: Request to extract identity information from.
:type request: :class:`morepath.Request`.
:returns: :class:`morepath.Identity` instance or
:attr:`morepath.NO_IDENTITY` ... | python | def identify(self, request):
"""Establish what identity this user claims to have from request.
:param request: Request to extract identity information from.
:type request: :class:`morepath.Request`.
:returns: :class:`morepath.Identity` instance or
:attr:`morepath.NO_IDENTITY` ... | [
"def",
"identify",
"(",
"self",
",",
"request",
")",
":",
"token",
"=",
"self",
".",
"get_jwt",
"(",
"request",
")",
"if",
"token",
"is",
"None",
":",
"return",
"NO_IDENTITY",
"try",
":",
"claims_set",
"=",
"self",
".",
"decode_jwt",
"(",
"token",
")",... | Establish what identity this user claims to have from request.
:param request: Request to extract identity information from.
:type request: :class:`morepath.Request`.
:returns: :class:`morepath.Identity` instance or
:attr:`morepath.NO_IDENTITY` if identity cannot
be establis... | [
"Establish",
"what",
"identity",
"this",
"user",
"claims",
"to",
"have",
"from",
"request",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L150-L173 | train | Establish what identity this user claims to have from request. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.remember | def remember(self, response, request, identity):
"""Remember identity on response.
Implements ``morepath.App.remember_identity``, which is called
from user login code.
Create a JWT token and return it as the Authorization field of the
response header.
:param response: ... | python | def remember(self, response, request, identity):
"""Remember identity on response.
Implements ``morepath.App.remember_identity``, which is called
from user login code.
Create a JWT token and return it as the Authorization field of the
response header.
:param response: ... | [
"def",
"remember",
"(",
"self",
",",
"response",
",",
"request",
",",
"identity",
")",
":",
"claims",
"=",
"identity",
".",
"as_dict",
"(",
")",
"userid",
"=",
"claims",
".",
"pop",
"(",
"'userid'",
")",
"claims_set",
"=",
"self",
".",
"create_claims_set... | Remember identity on response.
Implements ``morepath.App.remember_identity``, which is called
from user login code.
Create a JWT token and return it as the Authorization field of the
response header.
:param response: response object on which to store identity.
:type re... | [
"Remember",
"identity",
"on",
"response",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L175-L196 | train | Remember identity on response. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.decode_jwt | def decode_jwt(self, token, verify_expiration=True):
"""Decode a JWTAuth token into its claims set.
This method decodes the given JWT to provide the claims set. The JWT
can fail if the token has expired (with appropriate leeway) or if the
token won't validate due to the secret (key) be... | python | def decode_jwt(self, token, verify_expiration=True):
"""Decode a JWTAuth token into its claims set.
This method decodes the given JWT to provide the claims set. The JWT
can fail if the token has expired (with appropriate leeway) or if the
token won't validate due to the secret (key) be... | [
"def",
"decode_jwt",
"(",
"self",
",",
"token",
",",
"verify_expiration",
"=",
"True",
")",
":",
"options",
"=",
"{",
"'verify_exp'",
":",
"verify_expiration",
",",
"}",
"return",
"jwt",
".",
"decode",
"(",
"token",
",",
"self",
".",
"public_key",
",",
"... | Decode a JWTAuth token into its claims set.
This method decodes the given JWT to provide the claims set. The JWT
can fail if the token has expired (with appropriate leeway) or if the
token won't validate due to the secret (key) being wrong.
If private_key/public key is set then the pu... | [
"Decode",
"a",
"JWTAuth",
"token",
"into",
"its",
"claims",
"set",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L214-L239 | train | Decode a JWTAuth token into its claims set. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.create_claims_set | def create_claims_set(self, request, userid, extra_claims=None):
"""Create the claims set based on the userid of the claimed identity,
the settings and the extra_claims dictionary.
The userid will be stored in settings.jwtauth.userid_claim
(default: "sub").
If settings.jwtauth.e... | python | def create_claims_set(self, request, userid, extra_claims=None):
"""Create the claims set based on the userid of the claimed identity,
the settings and the extra_claims dictionary.
The userid will be stored in settings.jwtauth.userid_claim
(default: "sub").
If settings.jwtauth.e... | [
"def",
"create_claims_set",
"(",
"self",
",",
"request",
",",
"userid",
",",
"extra_claims",
"=",
"None",
")",
":",
"claims_set",
"=",
"{",
"self",
".",
"userid_claim",
":",
"userid",
"}",
"now",
"=",
"timegm",
"(",
"datetime",
".",
"utcnow",
"(",
")",
... | Create the claims set based on the userid of the claimed identity,
the settings and the extra_claims dictionary.
The userid will be stored in settings.jwtauth.userid_claim
(default: "sub").
If settings.jwtauth.expiration_delta is set it will be added
to the current time and stor... | [
"Create",
"the",
"claims",
"set",
"based",
"on",
"the",
"userid",
"of",
"the",
"claimed",
"identity",
"the",
"settings",
"and",
"the",
"extra_claims",
"dictionary",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L241-L280 | train | Create the claims set based on the userid of the claimed identity. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.encode_jwt | def encode_jwt(self, claims_set):
"""Encode a JWT token based on the claims_set and the settings.
If available, registry.settings.jwtauth.private_key is used as key.
In this case the algorithm must be an RS* or EC* algorithm.
If registry.settings.jwtauth.private_key is not set,
... | python | def encode_jwt(self, claims_set):
"""Encode a JWT token based on the claims_set and the settings.
If available, registry.settings.jwtauth.private_key is used as key.
In this case the algorithm must be an RS* or EC* algorithm.
If registry.settings.jwtauth.private_key is not set,
... | [
"def",
"encode_jwt",
"(",
"self",
",",
"claims_set",
")",
":",
"token",
"=",
"jwt",
".",
"encode",
"(",
"claims_set",
",",
"self",
".",
"private_key",
",",
"self",
".",
"algorithm",
")",
"if",
"PY3",
":",
"token",
"=",
"token",
".",
"decode",
"(",
"e... | Encode a JWT token based on the claims_set and the settings.
If available, registry.settings.jwtauth.private_key is used as key.
In this case the algorithm must be an RS* or EC* algorithm.
If registry.settings.jwtauth.private_key is not set,
registry.settings.jwtauth.master_secret is us... | [
"Encode",
"a",
"JWT",
"token",
"based",
"on",
"the",
"claims_set",
"and",
"the",
"settings",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L282-L299 | train | Encode a JWT token based on the claims_set and the settings. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.get_extra_claims | def get_extra_claims(self, claims_set):
"""Get claims holding extra identity info from the claims set.
Returns a dictionary of extra claims or None if there are none.
:param claims_set: set of claims, which was included in the received
token.
"""
reserved_claims = (
... | python | def get_extra_claims(self, claims_set):
"""Get claims holding extra identity info from the claims set.
Returns a dictionary of extra claims or None if there are none.
:param claims_set: set of claims, which was included in the received
token.
"""
reserved_claims = (
... | [
"def",
"get_extra_claims",
"(",
"self",
",",
"claims_set",
")",
":",
"reserved_claims",
"=",
"(",
"self",
".",
"userid_claim",
",",
"\"iss\"",
",",
"\"aud\"",
",",
"\"exp\"",
",",
"\"nbf\"",
",",
"\"iat\"",
",",
"\"jti\"",
",",
"\"refresh_until\"",
",",
"\"n... | Get claims holding extra identity info from the claims set.
Returns a dictionary of extra claims or None if there are none.
:param claims_set: set of claims, which was included in the received
token. | [
"Get",
"claims",
"holding",
"extra",
"identity",
"info",
"from",
"the",
"claims",
"set",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L314-L333 | train | Returns a dictionary of extra claims holding extra identity info from the claims set. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.get_jwt | def get_jwt(self, request):
"""Extract the JWT token from the authorisation header of the request.
Returns the JWT token or None, if the token cannot be extracted.
:param request: request object.
:type request: :class:`morepath.Request`
"""
try:
authorizatio... | python | def get_jwt(self, request):
"""Extract the JWT token from the authorisation header of the request.
Returns the JWT token or None, if the token cannot be extracted.
:param request: request object.
:type request: :class:`morepath.Request`
"""
try:
authorizatio... | [
"def",
"get_jwt",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"authorization",
"=",
"request",
".",
"authorization",
"except",
"ValueError",
":",
"return",
"None",
"if",
"authorization",
"is",
"None",
":",
"return",
"None",
"authtype",
",",
"token",
... | Extract the JWT token from the authorisation header of the request.
Returns the JWT token or None, if the token cannot be extracted.
:param request: request object.
:type request: :class:`morepath.Request` | [
"Extract",
"the",
"JWT",
"token",
"from",
"the",
"authorisation",
"header",
"of",
"the",
"request",
"."
] | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L335-L352 | train | Extract the JWT token from the authorisation header of the request. |
morepath/more.jwtauth | more/jwtauth/main.py | JWTIdentityPolicy.verify_refresh | def verify_refresh(self, request):
"""
Verify if the request to refresh the token is valid.
If valid it returns the userid which can be used to create
an updated identity with ``remember_identity``.
Otherwise it raises an exception based on InvalidTokenError.
:param requ... | python | def verify_refresh(self, request):
"""
Verify if the request to refresh the token is valid.
If valid it returns the userid which can be used to create
an updated identity with ``remember_identity``.
Otherwise it raises an exception based on InvalidTokenError.
:param requ... | [
"def",
"verify_refresh",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"self",
".",
"allow_refresh",
":",
"raise",
"InvalidTokenError",
"(",
"'Token refresh is disabled'",
")",
"token",
"=",
"self",
".",
"get_jwt",
"(",
"request",
")",
"if",
"token",
"... | Verify if the request to refresh the token is valid.
If valid it returns the userid which can be used to create
an updated identity with ``remember_identity``.
Otherwise it raises an exception based on InvalidTokenError.
:param request: current request object
:type request: :cla... | [
"Verify",
"if",
"the",
"request",
"to",
"refresh",
"the",
"token",
"is",
"valid",
".",
"If",
"valid",
"it",
"returns",
"the",
"userid",
"which",
"can",
"be",
"used",
"to",
"create",
"an",
"updated",
"identity",
"with",
"remember_identity",
".",
"Otherwise",
... | 1c3c5731612069a092e44cf612641c05edf1f083 | https://github.com/morepath/more.jwtauth/blob/1c3c5731612069a092e44cf612641c05edf1f083/more/jwtauth/main.py#L354-L404 | train | Verify if the request to refresh the token is valid. |
guaix-ucm/numina | numina/array/robustfit.py | fit_theil_sen | def fit_theil_sen(x, y):
"""Compute a robust linear fit using the Theil-Sen method.
See http://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator for details.
This function "pairs up sample points by the rank of their x-coordinates
(the point with the smallest coordinate being paired with the first poin... | python | def fit_theil_sen(x, y):
"""Compute a robust linear fit using the Theil-Sen method.
See http://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator for details.
This function "pairs up sample points by the rank of their x-coordinates
(the point with the smallest coordinate being paired with the first poin... | [
"def",
"fit_theil_sen",
"(",
"x",
",",
"y",
")",
":",
"xx",
"=",
"numpy",
".",
"asarray",
"(",
"x",
")",
"y1",
"=",
"numpy",
".",
"asarray",
"(",
"y",
")",
"n",
"=",
"len",
"(",
"xx",
")",
"if",
"n",
"<",
"5",
":",
"raise",
"ValueError",
"(",... | Compute a robust linear fit using the Theil-Sen method.
See http://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator for details.
This function "pairs up sample points by the rank of their x-coordinates
(the point with the smallest coordinate being paired with the first point
above the median coordinat... | [
"Compute",
"a",
"robust",
"linear",
"fit",
"using",
"the",
"Theil",
"-",
"Sen",
"method",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/robustfit.py#L15-L80 | train | Compute a robust linear fit using the Theil - Sen method. |
guaix-ucm/numina | numina/user/cli.py | main | def main(args=None):
"""Entry point for the Numina CLI."""
# Configuration args from a text file
config = configparser.SafeConfigParser()
# Building programatically
config.add_section('numina')
config.set('numina', 'format', 'yaml')
# Custom values
config.read([
os.path.join(x... | python | def main(args=None):
"""Entry point for the Numina CLI."""
# Configuration args from a text file
config = configparser.SafeConfigParser()
# Building programatically
config.add_section('numina')
config.set('numina', 'format', 'yaml')
# Custom values
config.read([
os.path.join(x... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"# Configuration args from a text file",
"config",
"=",
"configparser",
".",
"SafeConfigParser",
"(",
")",
"# Building programatically",
"config",
".",
"add_section",
"(",
"'numina'",
")",
"config",
".",
"set",
"(... | Entry point for the Numina CLI. | [
"Entry",
"point",
"for",
"the",
"Numina",
"CLI",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/cli.py#L33-L149 | train | Entry point for the Numina CLI. |
guaix-ucm/numina | numina/user/cli.py | process_unknown_arguments | def process_unknown_arguments(unknowns):
"""Process arguments unknown to the parser"""
result = argparse.Namespace()
result.extra_control = {}
# It would be interesting to use argparse internal
# machinery for this
for unknown in unknowns:
# Check prefixes
prefix = '--parameter-... | python | def process_unknown_arguments(unknowns):
"""Process arguments unknown to the parser"""
result = argparse.Namespace()
result.extra_control = {}
# It would be interesting to use argparse internal
# machinery for this
for unknown in unknowns:
# Check prefixes
prefix = '--parameter-... | [
"def",
"process_unknown_arguments",
"(",
"unknowns",
")",
":",
"result",
"=",
"argparse",
".",
"Namespace",
"(",
")",
"result",
".",
"extra_control",
"=",
"{",
"}",
"# It would be interesting to use argparse internal",
"# machinery for this",
"for",
"unknown",
"in",
"... | Process arguments unknown to the parser | [
"Process",
"arguments",
"unknown",
"to",
"the",
"parser"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/cli.py#L152-L170 | train | Process unknown arguments to the parser |
rfk/playitagainsam | playitagainsam/util.py | get_fd | def get_fd(file_or_fd, default=None):
"""Helper function for getting a file descriptor."""
fd = file_or_fd
if fd is None:
fd = default
if hasattr(fd, "fileno"):
fd = fd.fileno()
return fd | python | def get_fd(file_or_fd, default=None):
"""Helper function for getting a file descriptor."""
fd = file_or_fd
if fd is None:
fd = default
if hasattr(fd, "fileno"):
fd = fd.fileno()
return fd | [
"def",
"get_fd",
"(",
"file_or_fd",
",",
"default",
"=",
"None",
")",
":",
"fd",
"=",
"file_or_fd",
"if",
"fd",
"is",
"None",
":",
"fd",
"=",
"default",
"if",
"hasattr",
"(",
"fd",
",",
"\"fileno\"",
")",
":",
"fd",
"=",
"fd",
".",
"fileno",
"(",
... | Helper function for getting a file descriptor. | [
"Helper",
"function",
"for",
"getting",
"a",
"file",
"descriptor",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L65-L72 | train | Helper function for getting a file descriptor. |
rfk/playitagainsam | playitagainsam/util.py | forkexec | def forkexec(argv, env=None):
"""Fork a child process."""
child_pid = os.fork()
if child_pid == 0:
os.closerange(3, MAXFD)
environ = os.environ.copy()
if env is not None:
environ.update(env)
os.execve(argv[0], argv, environ)
return child_pid | python | def forkexec(argv, env=None):
"""Fork a child process."""
child_pid = os.fork()
if child_pid == 0:
os.closerange(3, MAXFD)
environ = os.environ.copy()
if env is not None:
environ.update(env)
os.execve(argv[0], argv, environ)
return child_pid | [
"def",
"forkexec",
"(",
"argv",
",",
"env",
"=",
"None",
")",
":",
"child_pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"child_pid",
"==",
"0",
":",
"os",
".",
"closerange",
"(",
"3",
",",
"MAXFD",
")",
"environ",
"=",
"os",
".",
"environ",
".",
... | Fork a child process. | [
"Fork",
"a",
"child",
"process",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L75-L84 | train | Fork a child process. |
rfk/playitagainsam | playitagainsam/util.py | forkexec_pty | def forkexec_pty(argv, env=None, size=None):
"""Fork a child process attached to a pty."""
child_pid, child_fd = pty.fork()
if child_pid == 0:
os.closerange(3, MAXFD)
environ = os.environ.copy()
if env is not None:
environ.update(env)
os.execve(argv[0], argv, envi... | python | def forkexec_pty(argv, env=None, size=None):
"""Fork a child process attached to a pty."""
child_pid, child_fd = pty.fork()
if child_pid == 0:
os.closerange(3, MAXFD)
environ = os.environ.copy()
if env is not None:
environ.update(env)
os.execve(argv[0], argv, envi... | [
"def",
"forkexec_pty",
"(",
"argv",
",",
"env",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"child_pid",
",",
"child_fd",
"=",
"pty",
".",
"fork",
"(",
")",
"if",
"child_pid",
"==",
"0",
":",
"os",
".",
"closerange",
"(",
"3",
",",
"MAXFD",
... | Fork a child process attached to a pty. | [
"Fork",
"a",
"child",
"process",
"attached",
"to",
"a",
"pty",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L87-L102 | train | Fork a child process attached to a pty. |
rfk/playitagainsam | playitagainsam/util.py | find_executable | def find_executable(filename, environ=None):
"""Find an executable by searching the user's $PATH."""
if environ is None:
environ = os.environ
path = environ.get("PATH", "/usr/local/bin:/usr/bin:/bin").split(":")
for dirpath in path:
dirpath = os.path.abspath(dirpath.strip())
file... | python | def find_executable(filename, environ=None):
"""Find an executable by searching the user's $PATH."""
if environ is None:
environ = os.environ
path = environ.get("PATH", "/usr/local/bin:/usr/bin:/bin").split(":")
for dirpath in path:
dirpath = os.path.abspath(dirpath.strip())
file... | [
"def",
"find_executable",
"(",
"filename",
",",
"environ",
"=",
"None",
")",
":",
"if",
"environ",
"is",
"None",
":",
"environ",
"=",
"os",
".",
"environ",
"path",
"=",
"environ",
".",
"get",
"(",
"\"PATH\"",
",",
"\"/usr/local/bin:/usr/bin:/bin\"",
")",
"... | Find an executable by searching the user's $PATH. | [
"Find",
"an",
"executable",
"by",
"searching",
"the",
"user",
"s",
"$PATH",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L105-L115 | train | Find an executable by searching the user s PATH. |
rfk/playitagainsam | playitagainsam/util.py | get_ancestor_processes | def get_ancestor_processes():
"""Get a list of the executables of all ancestor processes."""
if not _ANCESTOR_PROCESSES and psutil is not None:
proc = psutil.Process(os.getpid())
while proc.parent() is not None:
try:
_ANCESTOR_PROCESSES.append(proc.parent().exe())
... | python | def get_ancestor_processes():
"""Get a list of the executables of all ancestor processes."""
if not _ANCESTOR_PROCESSES and psutil is not None:
proc = psutil.Process(os.getpid())
while proc.parent() is not None:
try:
_ANCESTOR_PROCESSES.append(proc.parent().exe())
... | [
"def",
"get_ancestor_processes",
"(",
")",
":",
"if",
"not",
"_ANCESTOR_PROCESSES",
"and",
"psutil",
"is",
"not",
"None",
":",
"proc",
"=",
"psutil",
".",
"Process",
"(",
"os",
".",
"getpid",
"(",
")",
")",
"while",
"proc",
".",
"parent",
"(",
")",
"is... | Get a list of the executables of all ancestor processes. | [
"Get",
"a",
"list",
"of",
"the",
"executables",
"of",
"all",
"ancestor",
"processes",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L121-L131 | train | Get a list of the executables of all ancestor processes. |
rfk/playitagainsam | playitagainsam/util.py | get_default_shell | def get_default_shell(environ=None, fallback=_UNSPECIFIED):
"""Get the user's default shell program."""
if environ is None:
environ = os.environ
# If the option is specified in the environment, respect it.
if "PIAS_OPT_SHELL" in environ:
return environ["PIAS_OPT_SHELL"]
# Find all ca... | python | def get_default_shell(environ=None, fallback=_UNSPECIFIED):
"""Get the user's default shell program."""
if environ is None:
environ = os.environ
# If the option is specified in the environment, respect it.
if "PIAS_OPT_SHELL" in environ:
return environ["PIAS_OPT_SHELL"]
# Find all ca... | [
"def",
"get_default_shell",
"(",
"environ",
"=",
"None",
",",
"fallback",
"=",
"_UNSPECIFIED",
")",
":",
"if",
"environ",
"is",
"None",
":",
"environ",
"=",
"os",
".",
"environ",
"# If the option is specified in the environment, respect it.",
"if",
"\"PIAS_OPT_SHELL\"... | Get the user's default shell program. | [
"Get",
"the",
"user",
"s",
"default",
"shell",
"program",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L134-L158 | train | Get the user s default shell program. |
rfk/playitagainsam | playitagainsam/util.py | get_default_terminal | def get_default_terminal(environ=None, fallback=_UNSPECIFIED):
"""Get the user's default terminal program."""
if environ is None:
environ = os.environ
# If the option is specified in the environment, respect it.
if "PIAS_OPT_TERMINAL" in environ:
return environ["PIAS_OPT_TERMINAL"]
#... | python | def get_default_terminal(environ=None, fallback=_UNSPECIFIED):
"""Get the user's default terminal program."""
if environ is None:
environ = os.environ
# If the option is specified in the environment, respect it.
if "PIAS_OPT_TERMINAL" in environ:
return environ["PIAS_OPT_TERMINAL"]
#... | [
"def",
"get_default_terminal",
"(",
"environ",
"=",
"None",
",",
"fallback",
"=",
"_UNSPECIFIED",
")",
":",
"if",
"environ",
"is",
"None",
":",
"environ",
"=",
"os",
".",
"environ",
"# If the option is specified in the environment, respect it.",
"if",
"\"PIAS_OPT_TERM... | Get the user's default terminal program. | [
"Get",
"the",
"user",
"s",
"default",
"terminal",
"program",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L161-L186 | train | Get the user s default terminal program. |
rfk/playitagainsam | playitagainsam/util.py | get_pias_script | def get_pias_script(environ=None):
"""Get the path to the playitagainsam command-line script."""
if os.path.basename(sys.argv[0]) == "pias":
return sys.argv[0]
filepath = find_executable("pias", environ)
if filepath is not None:
return filepath
filepath = os.path.join(os.path.dirname... | python | def get_pias_script(environ=None):
"""Get the path to the playitagainsam command-line script."""
if os.path.basename(sys.argv[0]) == "pias":
return sys.argv[0]
filepath = find_executable("pias", environ)
if filepath is not None:
return filepath
filepath = os.path.join(os.path.dirname... | [
"def",
"get_pias_script",
"(",
"environ",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
"==",
"\"pias\"",
":",
"return",
"sys",
".",
"argv",
"[",
"0",
"]",
"filepath",
"=",
"find_execu... | Get the path to the playitagainsam command-line script. | [
"Get",
"the",
"path",
"to",
"the",
"playitagainsam",
"command",
"-",
"line",
"script",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L189-L200 | train | Get the path to the playitagainsam command - line script. |
rfk/playitagainsam | playitagainsam/util.py | get_terminal_size | def get_terminal_size(fd):
"""Get the (width, height) size tuple for the given pty fd."""
sizebuf = array.array('h', [0, 0])
fcntl.ioctl(fd, termios.TIOCGWINSZ, sizebuf, True)
return tuple(reversed(sizebuf)) | python | def get_terminal_size(fd):
"""Get the (width, height) size tuple for the given pty fd."""
sizebuf = array.array('h', [0, 0])
fcntl.ioctl(fd, termios.TIOCGWINSZ, sizebuf, True)
return tuple(reversed(sizebuf)) | [
"def",
"get_terminal_size",
"(",
"fd",
")",
":",
"sizebuf",
"=",
"array",
".",
"array",
"(",
"'h'",
",",
"[",
"0",
",",
"0",
"]",
")",
"fcntl",
".",
"ioctl",
"(",
"fd",
",",
"termios",
".",
"TIOCGWINSZ",
",",
"sizebuf",
",",
"True",
")",
"return",
... | Get the (width, height) size tuple for the given pty fd. | [
"Get",
"the",
"(",
"width",
"height",
")",
"size",
"tuple",
"for",
"the",
"given",
"pty",
"fd",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L203-L207 | train | Get the width height tuple for the given pty fd. |
rfk/playitagainsam | playitagainsam/util.py | set_terminal_size | def set_terminal_size(fd, size):
"""Set the (width, height) size tuple for the given pty fd."""
sizebuf = array.array('h', reversed(size))
fcntl.ioctl(fd, termios.TIOCSWINSZ, sizebuf) | python | def set_terminal_size(fd, size):
"""Set the (width, height) size tuple for the given pty fd."""
sizebuf = array.array('h', reversed(size))
fcntl.ioctl(fd, termios.TIOCSWINSZ, sizebuf) | [
"def",
"set_terminal_size",
"(",
"fd",
",",
"size",
")",
":",
"sizebuf",
"=",
"array",
".",
"array",
"(",
"'h'",
",",
"reversed",
"(",
"size",
")",
")",
"fcntl",
".",
"ioctl",
"(",
"fd",
",",
"termios",
".",
"TIOCSWINSZ",
",",
"sizebuf",
")"
] | Set the (width, height) size tuple for the given pty fd. | [
"Set",
"the",
"(",
"width",
"height",
")",
"size",
"tuple",
"for",
"the",
"given",
"pty",
"fd",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/util.py#L210-L213 | train | Set the width and height of the terminal. |
ponty/eagexp | eagexp/airwires.py | airwires | def airwires(board, showgui=0):
'search for airwires in eagle board'
board = Path(board).expand().abspath()
file_out = tempfile.NamedTemporaryFile(suffix='.txt', delete=0)
file_out.close()
ulp = ulp_templ.replace('FILE_NAME', file_out.name)
file_ulp = tempfile.NamedTemporaryFile(suffix='.ulp'... | python | def airwires(board, showgui=0):
'search for airwires in eagle board'
board = Path(board).expand().abspath()
file_out = tempfile.NamedTemporaryFile(suffix='.txt', delete=0)
file_out.close()
ulp = ulp_templ.replace('FILE_NAME', file_out.name)
file_ulp = tempfile.NamedTemporaryFile(suffix='.ulp'... | [
"def",
"airwires",
"(",
"board",
",",
"showgui",
"=",
"0",
")",
":",
"board",
"=",
"Path",
"(",
"board",
")",
".",
"expand",
"(",
")",
".",
"abspath",
"(",
")",
"file_out",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"'.txt'",
","... | search for airwires in eagle board | [
"search",
"for",
"airwires",
"in",
"eagle",
"board"
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/airwires.py#L27-L51 | train | search for airwires in eagle board |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite._initialize | def _initialize(self, con):
"""Set up tables in SQL"""
if self.initialized:
return
SQLite3Database()._initialize(con) # ASE db initialization
cur = con.execute(
'SELECT COUNT(*) FROM sqlite_master WHERE name="reaction"')
if cur.fetchone()[0] == 0: # n... | python | def _initialize(self, con):
"""Set up tables in SQL"""
if self.initialized:
return
SQLite3Database()._initialize(con) # ASE db initialization
cur = con.execute(
'SELECT COUNT(*) FROM sqlite_master WHERE name="reaction"')
if cur.fetchone()[0] == 0: # n... | [
"def",
"_initialize",
"(",
"self",
",",
"con",
")",
":",
"if",
"self",
".",
"initialized",
":",
"return",
"SQLite3Database",
"(",
")",
".",
"_initialize",
"(",
"con",
")",
"# ASE db initialization",
"cur",
"=",
"con",
".",
"execute",
"(",
"'SELECT COUNT(*) F... | Set up tables in SQL | [
"Set",
"up",
"tables",
"in",
"SQL"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L118-L133 | train | Initialize tables in SQL |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.read | def read(self, id, table='reaction'):
""" Return an entire row of a table
Parameters
---------
id: int
row integer
table: str
'reaction', 'publication', 'publication_system', 'reaction_system'
"""
con = self.connection or self._connect()
... | python | def read(self, id, table='reaction'):
""" Return an entire row of a table
Parameters
---------
id: int
row integer
table: str
'reaction', 'publication', 'publication_system', 'reaction_system'
"""
con = self.connection or self._connect()
... | [
"def",
"read",
"(",
"self",
",",
"id",
",",
"table",
"=",
"'reaction'",
")",
":",
"con",
"=",
"self",
".",
"connection",
"or",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_initialize",
"(",
"con",
")",
"cur",
"=",
"con",
".",
"cursor",
"(",
... | Return an entire row of a table
Parameters
---------
id: int
row integer
table: str
'reaction', 'publication', 'publication_system', 'reaction_system' | [
"Return",
"an",
"entire",
"row",
"of",
"a",
"table",
"Parameters",
"---------"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L135-L155 | train | Return an entire row of a table with the given id |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.write_publication | def write_publication(self, values):
"""
Write publication info to db
Parameters
----------
values: dict with entries
{'pub_id': str (short name for publication),
'authors': list of str ()
'journal': str,
'volume': str,
... | python | def write_publication(self, values):
"""
Write publication info to db
Parameters
----------
values: dict with entries
{'pub_id': str (short name for publication),
'authors': list of str ()
'journal': str,
'volume': str,
... | [
"def",
"write_publication",
"(",
"self",
",",
"values",
")",
":",
"con",
"=",
"self",
".",
"connection",
"or",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_initialize",
"(",
"con",
")",
"cur",
"=",
"con",
".",
"cursor",
"(",
")",
"values",
"=",
... | Write publication info to db
Parameters
----------
values: dict with entries
{'pub_id': str (short name for publication),
'authors': list of str ()
'journal': str,
'volume': str,
'number': str,
'pages': 'str'
'y... | [
"Write",
"publication",
"info",
"to",
"db"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L157-L201 | train | Writes publication info to db |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.write | def write(self, values, data=None):
"""
Write reaction info to db file
Parameters
----------
values: dict
The values dict can include:
{'chemical_composition': str (chemical composition on empty slab) ,
'surface_composition': str (reduced chemical compos... | python | def write(self, values, data=None):
"""
Write reaction info to db file
Parameters
----------
values: dict
The values dict can include:
{'chemical_composition': str (chemical composition on empty slab) ,
'surface_composition': str (reduced chemical compos... | [
"def",
"write",
"(",
"self",
",",
"values",
",",
"data",
"=",
"None",
")",
":",
"con",
"=",
"self",
".",
"connection",
"or",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_initialize",
"(",
"con",
")",
"cur",
"=",
"con",
".",
"cursor",
"(",
")... | Write reaction info to db file
Parameters
----------
values: dict
The values dict can include:
{'chemical_composition': str (chemical composition on empty slab) ,
'surface_composition': str (reduced chemical composition or
shortn... | [
"Write",
"reaction",
"info",
"to",
"db",
"file"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L203-L291 | train | Writes the reaction info to the database. |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.update | def update(self, id, values, key_names='all'):
"""
Update reaction info for a selected row
Parameters
----------
id: int
row integer
values: dict
See write() method for details
key_names: list or 'all'
list with name of columns... | python | def update(self, id, values, key_names='all'):
"""
Update reaction info for a selected row
Parameters
----------
id: int
row integer
values: dict
See write() method for details
key_names: list or 'all'
list with name of columns... | [
"def",
"update",
"(",
"self",
",",
"id",
",",
"values",
",",
"key_names",
"=",
"'all'",
")",
":",
"con",
"=",
"self",
".",
"connection",
"or",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_initialize",
"(",
"con",
")",
"cur",
"=",
"con",
".",
... | Update reaction info for a selected row
Parameters
----------
id: int
row integer
values: dict
See write() method for details
key_names: list or 'all'
list with name of columns to update. Should match the keys-value
pairs in values... | [
"Update",
"reaction",
"info",
"for",
"a",
"selected",
"row"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L293-L351 | train | Update the reaction info for a selected row. |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.get_last_id | def get_last_id(self, cur, table='reaction'):
"""
Get the id of the last written row in table
Parameters
----------
cur: database connection().cursor() object
table: str
'reaction', 'publication', 'publication_system', 'reaction_system'
Returns: id
... | python | def get_last_id(self, cur, table='reaction'):
"""
Get the id of the last written row in table
Parameters
----------
cur: database connection().cursor() object
table: str
'reaction', 'publication', 'publication_system', 'reaction_system'
Returns: id
... | [
"def",
"get_last_id",
"(",
"self",
",",
"cur",
",",
"table",
"=",
"'reaction'",
")",
":",
"cur",
".",
"execute",
"(",
"\"SELECT seq FROM sqlite_sequence WHERE name='{0}'\"",
".",
"format",
"(",
"table",
")",
")",
"result",
"=",
"cur",
".",
"fetchone",
"(",
"... | Get the id of the last written row in table
Parameters
----------
cur: database connection().cursor() object
table: str
'reaction', 'publication', 'publication_system', 'reaction_system'
Returns: id | [
"Get",
"the",
"id",
"of",
"the",
"last",
"written",
"row",
"in",
"table"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L353-L372 | train | Get the last written row in table
|
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.check | def check(self, chemical_composition, reaction_energy):
"""
Check if entry with same surface and energy is allready written
to database file
Parameters
----------
chemcial_composition: str
reaction_energy: str
Returns id or None
"""
con = ... | python | def check(self, chemical_composition, reaction_energy):
"""
Check if entry with same surface and energy is allready written
to database file
Parameters
----------
chemcial_composition: str
reaction_energy: str
Returns id or None
"""
con = ... | [
"def",
"check",
"(",
"self",
",",
"chemical_composition",
",",
"reaction_energy",
")",
":",
"con",
"=",
"self",
".",
"connection",
"or",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_initialize",
"(",
"con",
")",
"cur",
"=",
"con",
".",
"cursor",
"... | Check if entry with same surface and energy is allready written
to database file
Parameters
----------
chemcial_composition: str
reaction_energy: str
Returns id or None | [
"Check",
"if",
"entry",
"with",
"same",
"surface",
"and",
"energy",
"is",
"allready",
"written",
"to",
"database",
"file",
"Parameters",
"----------",
"chemcial_composition",
":",
"str",
"reaction_energy",
":",
"str"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L374-L398 | train | Checks if entry with same surface and energy is allready written
to database file. Returns id or None if no entry with same surface and energy is allready written
to database file. |
SUNCAT-Center/CatHub | cathub/cathubsqlite.py | CathubSQLite.check_reaction_on_surface | def check_reaction_on_surface(self, chemical_composition, reactants,
products):
"""
Check if entry with same surface and reaction is allready written
to database file
Parameters
----------
chemcial_composition: str
reactants: dic... | python | def check_reaction_on_surface(self, chemical_composition, reactants,
products):
"""
Check if entry with same surface and reaction is allready written
to database file
Parameters
----------
chemcial_composition: str
reactants: dic... | [
"def",
"check_reaction_on_surface",
"(",
"self",
",",
"chemical_composition",
",",
"reactants",
",",
"products",
")",
":",
"con",
"=",
"self",
".",
"connection",
"or",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_initialize",
"(",
"con",
")",
"cur",
"... | Check if entry with same surface and reaction is allready written
to database file
Parameters
----------
chemcial_composition: str
reactants: dict
products: dict
Returns id or None | [
"Check",
"if",
"entry",
"with",
"same",
"surface",
"and",
"reaction",
"is",
"allready",
"written",
"to",
"database",
"file"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/cathubsqlite.py#L400-L429 | train | Checks if entry with same surface and reaction is allready written
to database file. |
guaix-ucm/numina | numina/array/wavecalib/__main__.py | collapsed_spectrum | def collapsed_spectrum(fitsfile, ns1, ns2,
method='mean', nwin_background=0,
reverse=False, out_sp=None, debugplot=0):
"""Compute a collapsed spectrum from a 2D image using scans in [ns1,ns2].
Parameters
----------
fitsfile : file object
File name o... | python | def collapsed_spectrum(fitsfile, ns1, ns2,
method='mean', nwin_background=0,
reverse=False, out_sp=None, debugplot=0):
"""Compute a collapsed spectrum from a 2D image using scans in [ns1,ns2].
Parameters
----------
fitsfile : file object
File name o... | [
"def",
"collapsed_spectrum",
"(",
"fitsfile",
",",
"ns1",
",",
"ns2",
",",
"method",
"=",
"'mean'",
",",
"nwin_background",
"=",
"0",
",",
"reverse",
"=",
"False",
",",
"out_sp",
"=",
"None",
",",
"debugplot",
"=",
"0",
")",
":",
"# read FITS file",
"wit... | Compute a collapsed spectrum from a 2D image using scans in [ns1,ns2].
Parameters
----------
fitsfile : file object
File name of FITS file containing the spectra to be calibrated.
ns1 : int
First scan (from 1 to NAXIS2).
ns2 : int
Last scan (from 1 to NAXIS2).
method : s... | [
"Compute",
"a",
"collapsed",
"spectrum",
"from",
"a",
"2D",
"image",
"using",
"scans",
"in",
"[",
"ns1",
"ns2",
"]",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/__main__.py#L35-L111 | train | Compute a collapsed spectrum from a 2D image using scans in ns1 ns2. |
guaix-ucm/numina | numina/array/wavecalib/__main__.py | read_wv_master_from_array | def read_wv_master_from_array(master_table, lines='brightest', debugplot=0):
"""read arc line wavelengths from numpy array
Parameters
----------
master_table : Numpy array
Numpy array containing the wavelength database.
lines : string
Indicates which lines to read. For files with a ... | python | def read_wv_master_from_array(master_table, lines='brightest', debugplot=0):
"""read arc line wavelengths from numpy array
Parameters
----------
master_table : Numpy array
Numpy array containing the wavelength database.
lines : string
Indicates which lines to read. For files with a ... | [
"def",
"read_wv_master_from_array",
"(",
"master_table",
",",
"lines",
"=",
"'brightest'",
",",
"debugplot",
"=",
"0",
")",
":",
"# protection",
"if",
"lines",
"not",
"in",
"[",
"'brightest'",
",",
"'all'",
"]",
":",
"raise",
"ValueError",
"(",
"'Unexpected li... | read arc line wavelengths from numpy array
Parameters
----------
master_table : Numpy array
Numpy array containing the wavelength database.
lines : string
Indicates which lines to read. For files with a single column
or two columns this parameter is irrelevant. For files with
... | [
"read",
"arc",
"line",
"wavelengths",
"from",
"numpy",
"array"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/__main__.py#L114-L164 | train | read arc line wavelengths from numpy array |
guaix-ucm/numina | numina/array/wavecalib/__main__.py | read_wv_master_file | def read_wv_master_file(wv_master_file, lines='brightest', debugplot=0):
"""read arc line wavelengths from external file.
Parameters
----------
wv_master_file : string
File name of txt file containing the wavelength database.
lines : string
Indicates which lines to read. For files w... | python | def read_wv_master_file(wv_master_file, lines='brightest', debugplot=0):
"""read arc line wavelengths from external file.
Parameters
----------
wv_master_file : string
File name of txt file containing the wavelength database.
lines : string
Indicates which lines to read. For files w... | [
"def",
"read_wv_master_file",
"(",
"wv_master_file",
",",
"lines",
"=",
"'brightest'",
",",
"debugplot",
"=",
"0",
")",
":",
"# protection",
"if",
"lines",
"not",
"in",
"[",
"'brightest'",
",",
"'all'",
"]",
":",
"raise",
"ValueError",
"(",
"'Unexpected lines=... | read arc line wavelengths from external file.
Parameters
----------
wv_master_file : string
File name of txt file containing the wavelength database.
lines : string
Indicates which lines to read. For files with a single column
or two columns this parameter is irrelevant. For fil... | [
"read",
"arc",
"line",
"wavelengths",
"from",
"external",
"file",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/__main__.py#L167-L205 | train | read arc line wavelengths from external file. |
guaix-ucm/numina | numina/array/wavecalib/__main__.py | find_fxpeaks | def find_fxpeaks(sp,
times_sigma_threshold,
minimum_threshold,
nwinwidth_initial,
nwinwidth_refined,
npix_avoid_border,
nbrightlines,
sigma_gaussian_filtering,
minimum_gaussian_filteri... | python | def find_fxpeaks(sp,
times_sigma_threshold,
minimum_threshold,
nwinwidth_initial,
nwinwidth_refined,
npix_avoid_border,
nbrightlines,
sigma_gaussian_filtering,
minimum_gaussian_filteri... | [
"def",
"find_fxpeaks",
"(",
"sp",
",",
"times_sigma_threshold",
",",
"minimum_threshold",
",",
"nwinwidth_initial",
",",
"nwinwidth_refined",
",",
"npix_avoid_border",
",",
"nbrightlines",
",",
"sigma_gaussian_filtering",
",",
"minimum_gaussian_filtering",
",",
"plottitle",... | Locate line peaks in array coordinates (from 0 to naxis1-1).
Parameters
----------
sp : 1d numpy array
Spectrum to be wavelength calibrated.
times_sigma_threshold : float
Times robust sigma above the median to detect line peaks.
minimum_threshold : float or None
Minimum ... | [
"Locate",
"line",
"peaks",
"in",
"array",
"coordinates",
"(",
"from",
"0",
"to",
"naxis1",
"-",
"1",
")",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/__main__.py#L208-L379 | train | Find the line peaks in the given spectrum. |
guaix-ucm/numina | numina/array/wavecalib/__main__.py | wvcal_spectrum | def wvcal_spectrum(sp, fxpeaks, poly_degree_wfit, wv_master,
wv_ini_search=None, wv_end_search=None,
wvmin_useful=None, wvmax_useful=None,
geometry=None, debugplot=0):
"""Execute wavelength calibration of a spectrum using fixed line peaks.
Parameters
... | python | def wvcal_spectrum(sp, fxpeaks, poly_degree_wfit, wv_master,
wv_ini_search=None, wv_end_search=None,
wvmin_useful=None, wvmax_useful=None,
geometry=None, debugplot=0):
"""Execute wavelength calibration of a spectrum using fixed line peaks.
Parameters
... | [
"def",
"wvcal_spectrum",
"(",
"sp",
",",
"fxpeaks",
",",
"poly_degree_wfit",
",",
"wv_master",
",",
"wv_ini_search",
"=",
"None",
",",
"wv_end_search",
"=",
"None",
",",
"wvmin_useful",
"=",
"None",
",",
"wvmax_useful",
"=",
"None",
",",
"geometry",
"=",
"No... | Execute wavelength calibration of a spectrum using fixed line peaks.
Parameters
----------
sp : 1d numpy array
Spectrum to be wavelength calibrated.
fxpeaks : 1d numpy array
Refined location of peaks in array index scale, i.e, from 0
to naxis1 - 1. The wavelength calibration is ... | [
"Execute",
"wavelength",
"calibration",
"of",
"a",
"spectrum",
"using",
"fixed",
"line",
"peaks",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/__main__.py#L382-L499 | train | Execute wavelength calibration of a spectrum using fixed line peaks. |
chhantyal/sorl-thumbnail-async | thumbnail/__init__.py | get_thumbnail | def get_thumbnail(file_, name):
"""
get_thumbnail version that uses aliasses defined in THUMBNAIL_OPTIONS_DICT
"""
options = settings.OPTIONS_DICT[name]
opt = copy(options)
geometry = opt.pop('geometry')
return original_get_thumbnail(file_, geometry, **opt) | python | def get_thumbnail(file_, name):
"""
get_thumbnail version that uses aliasses defined in THUMBNAIL_OPTIONS_DICT
"""
options = settings.OPTIONS_DICT[name]
opt = copy(options)
geometry = opt.pop('geometry')
return original_get_thumbnail(file_, geometry, **opt) | [
"def",
"get_thumbnail",
"(",
"file_",
",",
"name",
")",
":",
"options",
"=",
"settings",
".",
"OPTIONS_DICT",
"[",
"name",
"]",
"opt",
"=",
"copy",
"(",
"options",
")",
"geometry",
"=",
"opt",
".",
"pop",
"(",
"'geometry'",
")",
"return",
"original_get_t... | get_thumbnail version that uses aliasses defined in THUMBNAIL_OPTIONS_DICT | [
"get_thumbnail",
"version",
"that",
"uses",
"aliasses",
"defined",
"in",
"THUMBNAIL_OPTIONS_DICT"
] | 023d20aac79090a691d563dc26f558bb87239811 | https://github.com/chhantyal/sorl-thumbnail-async/blob/023d20aac79090a691d563dc26f558bb87239811/thumbnail/__init__.py#L9-L17 | train | get_thumbnail version that uses aliasses defined in THUMBNAIL_OPTIONS_DICT |
pylp/pylp | pylp/cli/colors.py | foreground | def foreground(color):
"""Set the foreground color."""
if color not in foreground_colors:
return
if is_win32:
last_fg = foreground_colors[color][1]
set_color_win32(last_fg | last_bg)
else:
set_color_ansi(foreground_colors[color][0]) | python | def foreground(color):
"""Set the foreground color."""
if color not in foreground_colors:
return
if is_win32:
last_fg = foreground_colors[color][1]
set_color_win32(last_fg | last_bg)
else:
set_color_ansi(foreground_colors[color][0]) | [
"def",
"foreground",
"(",
"color",
")",
":",
"if",
"color",
"not",
"in",
"foreground_colors",
":",
"return",
"if",
"is_win32",
":",
"last_fg",
"=",
"foreground_colors",
"[",
"color",
"]",
"[",
"1",
"]",
"set_color_win32",
"(",
"last_fg",
"|",
"last_bg",
")... | Set the foreground color. | [
"Set",
"the",
"foreground",
"color",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/colors.py#L69-L78 | train | Set the foreground color. |
pylp/pylp | pylp/cli/colors.py | background | def background(color):
"""Set the background color."""
if color not in background_colors:
return
if is_win32:
last_bg = background_colors[color][1]
set_color_win32(last_fg | last_bg)
else:
set_color_ansi(background_colors[color][0]) | python | def background(color):
"""Set the background color."""
if color not in background_colors:
return
if is_win32:
last_bg = background_colors[color][1]
set_color_win32(last_fg | last_bg)
else:
set_color_ansi(background_colors[color][0]) | [
"def",
"background",
"(",
"color",
")",
":",
"if",
"color",
"not",
"in",
"background_colors",
":",
"return",
"if",
"is_win32",
":",
"last_bg",
"=",
"background_colors",
"[",
"color",
"]",
"[",
"1",
"]",
"set_color_win32",
"(",
"last_fg",
"|",
"last_bg",
")... | Set the background color. | [
"Set",
"the",
"background",
"color",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/colors.py#L81-L90 | train | Set the background color. |
xflr6/bitsets | bitsets/__init__.py | bitset | def bitset(name, members, base=bases.BitSet, list=False, tuple=False):
"""Return a new bitset class with given name and members.
Args:
name: Name of the class to be created.
members: Hashable sequence of allowed bitset members.
base: Base class to derive the returned class from.
... | python | def bitset(name, members, base=bases.BitSet, list=False, tuple=False):
"""Return a new bitset class with given name and members.
Args:
name: Name of the class to be created.
members: Hashable sequence of allowed bitset members.
base: Base class to derive the returned class from.
... | [
"def",
"bitset",
"(",
"name",
",",
"members",
",",
"base",
"=",
"bases",
".",
"BitSet",
",",
"list",
"=",
"False",
",",
"tuple",
"=",
"False",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"'empty bitset name: %r'",
"%",
"name",
")",
... | Return a new bitset class with given name and members.
Args:
name: Name of the class to be created.
members: Hashable sequence of allowed bitset members.
base: Base class to derive the returned class from.
list (bool): Include a custom class for bitset lists.
tuple (bool): I... | [
"Return",
"a",
"new",
"bitset",
"class",
"with",
"given",
"name",
"and",
"members",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/__init__.py#L16-L51 | train | Return a new bitset class with given name and members. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._extrapolation | def _extrapolation(self, extrapolate):
"""Check permited values of extrapolation."""
modes = ['extrapolate',
'raise',
'const',
'border']
if extrapolate not in modes:
msg = 'invalid extrapolation mode {}'.format(extrapolate)
... | python | def _extrapolation(self, extrapolate):
"""Check permited values of extrapolation."""
modes = ['extrapolate',
'raise',
'const',
'border']
if extrapolate not in modes:
msg = 'invalid extrapolation mode {}'.format(extrapolate)
... | [
"def",
"_extrapolation",
"(",
"self",
",",
"extrapolate",
")",
":",
"modes",
"=",
"[",
"'extrapolate'",
",",
"'raise'",
",",
"'const'",
",",
"'border'",
"]",
"if",
"extrapolate",
"not",
"in",
"modes",
":",
"msg",
"=",
"'invalid extrapolation mode {}'",
".",
... | Check permited values of extrapolation. | [
"Check",
"permited",
"values",
"of",
"extrapolation",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L104-L120 | train | Check permited values of extrapolation. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._create_s | def _create_s(y, h):
"""Estimate secants"""
s = np.zeros_like(y)
s[:-1] = (y[1:] - y[:-1]) / h[:-1]
s[-1] = 0.0
return s | python | def _create_s(y, h):
"""Estimate secants"""
s = np.zeros_like(y)
s[:-1] = (y[1:] - y[:-1]) / h[:-1]
s[-1] = 0.0
return s | [
"def",
"_create_s",
"(",
"y",
",",
"h",
")",
":",
"s",
"=",
"np",
".",
"zeros_like",
"(",
"y",
")",
"s",
"[",
":",
"-",
"1",
"]",
"=",
"(",
"y",
"[",
"1",
":",
"]",
"-",
"y",
"[",
":",
"-",
"1",
"]",
")",
"/",
"h",
"[",
":",
"-",
"1... | Estimate secants | [
"Estimate",
"secants"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L123-L128 | train | Estimate secants |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._create_h | def _create_h(x):
"""increase between samples"""
h = np.zeros_like(x)
h[:-1] = x[1:] - x[:-1]
# border
h[-1] = h[-2]
return h | python | def _create_h(x):
"""increase between samples"""
h = np.zeros_like(x)
h[:-1] = x[1:] - x[:-1]
# border
h[-1] = h[-2]
return h | [
"def",
"_create_h",
"(",
"x",
")",
":",
"h",
"=",
"np",
".",
"zeros_like",
"(",
"x",
")",
"h",
"[",
":",
"-",
"1",
"]",
"=",
"x",
"[",
"1",
":",
"]",
"-",
"x",
"[",
":",
"-",
"1",
"]",
"# border",
"h",
"[",
"-",
"1",
"]",
"=",
"h",
"[... | increase between samples | [
"increase",
"between",
"samples"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L131-L137 | train | create a hash table for the given samples |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._create_p | def _create_p(s, h):
"""Parabolic derivative"""
p = np.zeros_like(s)
p[1:] = (s[:-1]*h[1:] + s[1:] * h[:-1]) / (h[1:] + h[:-1])
return p | python | def _create_p(s, h):
"""Parabolic derivative"""
p = np.zeros_like(s)
p[1:] = (s[:-1]*h[1:] + s[1:] * h[:-1]) / (h[1:] + h[:-1])
return p | [
"def",
"_create_p",
"(",
"s",
",",
"h",
")",
":",
"p",
"=",
"np",
".",
"zeros_like",
"(",
"s",
")",
"p",
"[",
"1",
":",
"]",
"=",
"(",
"s",
"[",
":",
"-",
"1",
"]",
"*",
"h",
"[",
"1",
":",
"]",
"+",
"s",
"[",
"1",
":",
"]",
"*",
"h... | Parabolic derivative | [
"Parabolic",
"derivative"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L140-L144 | train | Create a parabolic derivative of the logarithm |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._eval | def _eval(self, v, in_bounds, der):
"""Eval polynomial inside bounds."""
result = np.zeros_like(v, dtype='float')
x_indices = np.searchsorted(self._x, v, side='rigth')
ids = x_indices[in_bounds] - 1
u = v[in_bounds] - self._x[ids]
result[in_bounds] = self._poly_eval(u, id... | python | def _eval(self, v, in_bounds, der):
"""Eval polynomial inside bounds."""
result = np.zeros_like(v, dtype='float')
x_indices = np.searchsorted(self._x, v, side='rigth')
ids = x_indices[in_bounds] - 1
u = v[in_bounds] - self._x[ids]
result[in_bounds] = self._poly_eval(u, id... | [
"def",
"_eval",
"(",
"self",
",",
"v",
",",
"in_bounds",
",",
"der",
")",
":",
"result",
"=",
"np",
".",
"zeros_like",
"(",
"v",
",",
"dtype",
"=",
"'float'",
")",
"x_indices",
"=",
"np",
".",
"searchsorted",
"(",
"self",
".",
"_x",
",",
"v",
","... | Eval polynomial inside bounds. | [
"Eval",
"polynomial",
"inside",
"bounds",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L146-L153 | train | Eval polynomial inside bounds. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._extrapolate | def _extrapolate(self, result, v, below_bounds, above_bounds, der):
"""Extrapolate result based on extrapolation mode."""
if self.extrapolate_mode == 'const':
fill_b = fill_a = self.fill_value
elif self.extrapolate_mode == 'border':
fill_b = self._poly_eval(0, 0, der)
... | python | def _extrapolate(self, result, v, below_bounds, above_bounds, der):
"""Extrapolate result based on extrapolation mode."""
if self.extrapolate_mode == 'const':
fill_b = fill_a = self.fill_value
elif self.extrapolate_mode == 'border':
fill_b = self._poly_eval(0, 0, der)
... | [
"def",
"_extrapolate",
"(",
"self",
",",
"result",
",",
"v",
",",
"below_bounds",
",",
"above_bounds",
",",
"der",
")",
":",
"if",
"self",
".",
"extrapolate_mode",
"==",
"'const'",
":",
"fill_b",
"=",
"fill_a",
"=",
"self",
".",
"fill_value",
"elif",
"se... | Extrapolate result based on extrapolation mode. | [
"Extrapolate",
"result",
"based",
"on",
"extrapolation",
"mode",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L155-L171 | train | Extrapolate the result of a set of values. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._poly_eval | def _poly_eval(self, u, ids, der=0):
"""Evaluate internal polynomial."""
if der == 0:
return self._poly_eval_0(u, ids)
elif der == 1:
return self._poly_eval_1(u, ids)
elif der == 2:
return self._poly_eval_2(u, ids)
elif der == 3:
re... | python | def _poly_eval(self, u, ids, der=0):
"""Evaluate internal polynomial."""
if der == 0:
return self._poly_eval_0(u, ids)
elif der == 1:
return self._poly_eval_1(u, ids)
elif der == 2:
return self._poly_eval_2(u, ids)
elif der == 3:
re... | [
"def",
"_poly_eval",
"(",
"self",
",",
"u",
",",
"ids",
",",
"der",
"=",
"0",
")",
":",
"if",
"der",
"==",
"0",
":",
"return",
"self",
".",
"_poly_eval_0",
"(",
"u",
",",
"ids",
")",
"elif",
"der",
"==",
"1",
":",
"return",
"self",
".",
"_poly_... | Evaluate internal polynomial. | [
"Evaluate",
"internal",
"polynomial",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L203-L216 | train | Evaluate internal polynomial. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._poly_eval_0 | def _poly_eval_0(self, u, ids):
"""Evaluate internal polynomial."""
return u * (u * (self._a[ids] * u + self._b[ids]) + self._c[ids]) + self._d[ids] | python | def _poly_eval_0(self, u, ids):
"""Evaluate internal polynomial."""
return u * (u * (self._a[ids] * u + self._b[ids]) + self._c[ids]) + self._d[ids] | [
"def",
"_poly_eval_0",
"(",
"self",
",",
"u",
",",
"ids",
")",
":",
"return",
"u",
"*",
"(",
"u",
"*",
"(",
"self",
".",
"_a",
"[",
"ids",
"]",
"*",
"u",
"+",
"self",
".",
"_b",
"[",
"ids",
"]",
")",
"+",
"self",
".",
"_c",
"[",
"ids",
"]... | Evaluate internal polynomial. | [
"Evaluate",
"internal",
"polynomial",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L218-L220 | train | Evaluate internal polynomial. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._poly_eval_1 | def _poly_eval_1(self, u, ids):
"""Evaluate internal polynomial."""
return (u * (3*self._a[ids] * u + 2*self._b[ids]) + self._c[ids]) | python | def _poly_eval_1(self, u, ids):
"""Evaluate internal polynomial."""
return (u * (3*self._a[ids] * u + 2*self._b[ids]) + self._c[ids]) | [
"def",
"_poly_eval_1",
"(",
"self",
",",
"u",
",",
"ids",
")",
":",
"return",
"(",
"u",
"*",
"(",
"3",
"*",
"self",
".",
"_a",
"[",
"ids",
"]",
"*",
"u",
"+",
"2",
"*",
"self",
".",
"_b",
"[",
"ids",
"]",
")",
"+",
"self",
".",
"_c",
"[",... | Evaluate internal polynomial. | [
"Evaluate",
"internal",
"polynomial",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L222-L224 | train | Evaluate internal polynomial. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._poly_eval_2 | def _poly_eval_2(self, u, ids):
"""Evaluate internal polynomial."""
return 6 * self._a[ids] * u + 2*self._b[ids] | python | def _poly_eval_2(self, u, ids):
"""Evaluate internal polynomial."""
return 6 * self._a[ids] * u + 2*self._b[ids] | [
"def",
"_poly_eval_2",
"(",
"self",
",",
"u",
",",
"ids",
")",
":",
"return",
"6",
"*",
"self",
".",
"_a",
"[",
"ids",
"]",
"*",
"u",
"+",
"2",
"*",
"self",
".",
"_b",
"[",
"ids",
"]"
] | Evaluate internal polynomial. | [
"Evaluate",
"internal",
"polynomial",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L226-L228 | train | Evaluate internal polynomial. |
guaix-ucm/numina | numina/array/interpolation.py | SteffenInterpolator._check_bounds | def _check_bounds(self, v):
"""Check which values are out of bounds.
Raises
------
ValueError:
"""
below_bounds = v < self._x[0]
above_bounds = v > self._x[-1]
if self.bounds_error and below_bounds.any():
raise ValueError("A value in x_new i... | python | def _check_bounds(self, v):
"""Check which values are out of bounds.
Raises
------
ValueError:
"""
below_bounds = v < self._x[0]
above_bounds = v > self._x[-1]
if self.bounds_error and below_bounds.any():
raise ValueError("A value in x_new i... | [
"def",
"_check_bounds",
"(",
"self",
",",
"v",
")",
":",
"below_bounds",
"=",
"v",
"<",
"self",
".",
"_x",
"[",
"0",
"]",
"above_bounds",
"=",
"v",
">",
"self",
".",
"_x",
"[",
"-",
"1",
"]",
"if",
"self",
".",
"bounds_error",
"and",
"below_bounds"... | Check which values are out of bounds.
Raises
------
ValueError: | [
"Check",
"which",
"values",
"are",
"out",
"of",
"bounds",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/interpolation.py#L238-L256 | train | Check which values are out of bounds. |
guaix-ucm/numina | numina/dal/utils.py | tags_are_valid | def tags_are_valid(subset, superset):
"""Validate tags"""
for key, val in subset.items():
if key in superset and superset[key] != val:
return False
return True | python | def tags_are_valid(subset, superset):
"""Validate tags"""
for key, val in subset.items():
if key in superset and superset[key] != val:
return False
return True | [
"def",
"tags_are_valid",
"(",
"subset",
",",
"superset",
")",
":",
"for",
"key",
",",
"val",
"in",
"subset",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"superset",
"and",
"superset",
"[",
"key",
"]",
"!=",
"val",
":",
"return",
"False",
"return"... | Validate tags | [
"Validate",
"tags"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/utils.py#L14-L19 | train | Validate tags. |
guaix-ucm/numina | numina/array/wavecalib/crosscorrelation.py | filtmask | def filtmask(sp, fmin=0.02, fmax=0.15, debugplot=0):
"""Filter spectrum in Fourier space and apply cosine bell.
Parameters
----------
sp : numpy array
Spectrum to be filtered and masked.
fmin : float
Minimum frequency to be employed.
fmax : float
Maximum frequency to be ... | python | def filtmask(sp, fmin=0.02, fmax=0.15, debugplot=0):
"""Filter spectrum in Fourier space and apply cosine bell.
Parameters
----------
sp : numpy array
Spectrum to be filtered and masked.
fmin : float
Minimum frequency to be employed.
fmax : float
Maximum frequency to be ... | [
"def",
"filtmask",
"(",
"sp",
",",
"fmin",
"=",
"0.02",
",",
"fmax",
"=",
"0.15",
",",
"debugplot",
"=",
"0",
")",
":",
"# Fourier filtering",
"xf",
"=",
"np",
".",
"fft",
".",
"fftfreq",
"(",
"sp",
".",
"size",
")",
"yf",
"=",
"np",
".",
"fft",
... | Filter spectrum in Fourier space and apply cosine bell.
Parameters
----------
sp : numpy array
Spectrum to be filtered and masked.
fmin : float
Minimum frequency to be employed.
fmax : float
Maximum frequency to be employed.
debugplot : int
Debugging level for me... | [
"Filter",
"spectrum",
"in",
"Fourier",
"space",
"and",
"apply",
"cosine",
"bell",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/crosscorrelation.py#L24-L80 | train | Filter spectrum in Fourier space and apply cosine bell. |
guaix-ucm/numina | numina/array/wavecalib/crosscorrelation.py | cosinebell | def cosinebell(n, fraction):
"""Return a cosine bell spanning n pixels, masking a fraction of pixels
Parameters
----------
n : int
Number of pixels.
fraction : float
Length fraction over which the data will be masked.
"""
mask = np.ones(n)
nmasked = int(fraction * n)
... | python | def cosinebell(n, fraction):
"""Return a cosine bell spanning n pixels, masking a fraction of pixels
Parameters
----------
n : int
Number of pixels.
fraction : float
Length fraction over which the data will be masked.
"""
mask = np.ones(n)
nmasked = int(fraction * n)
... | [
"def",
"cosinebell",
"(",
"n",
",",
"fraction",
")",
":",
"mask",
"=",
"np",
".",
"ones",
"(",
"n",
")",
"nmasked",
"=",
"int",
"(",
"fraction",
"*",
"n",
")",
"for",
"i",
"in",
"range",
"(",
"nmasked",
")",
":",
"yval",
"=",
"0.5",
"*",
"(",
... | Return a cosine bell spanning n pixels, masking a fraction of pixels
Parameters
----------
n : int
Number of pixels.
fraction : float
Length fraction over which the data will be masked. | [
"Return",
"a",
"cosine",
"bell",
"spanning",
"n",
"pixels",
"masking",
"a",
"fraction",
"of",
"pixels"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/crosscorrelation.py#L83-L102 | train | Return a cosine bell spanning n pixels masking a fraction of pixels. |
guaix-ucm/numina | numina/array/wavecalib/crosscorrelation.py | convolve_comb_lines | def convolve_comb_lines(lines_wave, lines_flux, sigma,
crpix1, crval1, cdelt1, naxis1):
"""Convolve a set of lines of known wavelengths and flux.
Parameters
----------
lines_wave : array like
Input array with wavelengths
lines_flux : array like
Input array wi... | python | def convolve_comb_lines(lines_wave, lines_flux, sigma,
crpix1, crval1, cdelt1, naxis1):
"""Convolve a set of lines of known wavelengths and flux.
Parameters
----------
lines_wave : array like
Input array with wavelengths
lines_flux : array like
Input array wi... | [
"def",
"convolve_comb_lines",
"(",
"lines_wave",
",",
"lines_flux",
",",
"sigma",
",",
"crpix1",
",",
"crval1",
",",
"cdelt1",
",",
"naxis1",
")",
":",
"# generate wavelengths for output spectrum",
"xwave",
"=",
"crval1",
"+",
"(",
"np",
".",
"arange",
"(",
"n... | Convolve a set of lines of known wavelengths and flux.
Parameters
----------
lines_wave : array like
Input array with wavelengths
lines_flux : array like
Input array with fluxes
sigma : float
Sigma of the broadening gaussian to be applied.
crpix1 : float
CRPIX1 o... | [
"Convolve",
"a",
"set",
"of",
"lines",
"of",
"known",
"wavelengths",
"and",
"flux",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/crosscorrelation.py#L105-L147 | train | Convolve a set of lines of known wavelengths and fluxes. |
guaix-ucm/numina | numina/array/wavecalib/crosscorrelation.py | periodic_corr1d | def periodic_corr1d(sp_reference, sp_offset,
fminmax=None,
naround_zero=None,
norm_spectra=False,
plottitle=None,
pdf=None,
debugplot=0):
"""Periodic correlation between two spectra, implemented u... | python | def periodic_corr1d(sp_reference, sp_offset,
fminmax=None,
naround_zero=None,
norm_spectra=False,
plottitle=None,
pdf=None,
debugplot=0):
"""Periodic correlation between two spectra, implemented u... | [
"def",
"periodic_corr1d",
"(",
"sp_reference",
",",
"sp_offset",
",",
"fminmax",
"=",
"None",
",",
"naround_zero",
"=",
"None",
",",
"norm_spectra",
"=",
"False",
",",
"plottitle",
"=",
"None",
",",
"pdf",
"=",
"None",
",",
"debugplot",
"=",
"0",
")",
":... | Periodic correlation between two spectra, implemented using FFT.
Parameters
----------
sp_reference : numpy array
Reference spectrum.
sp_offset : numpy array
Spectrum which offset is going to be measured relative to the
reference spectrum.
fminmax : tuple of floats or None
... | [
"Periodic",
"correlation",
"between",
"two",
"spectra",
"implemented",
"using",
"FFT",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/crosscorrelation.py#L150-L370 | train | This function computes the 1D correlation between two spectra. |
guaix-ucm/numina | numina/array/wavecalib/crosscorrelation.py | compute_broadening | def compute_broadening(wv_obj, sp_obj, wv_ref, sp_ref,
sigmalist, fpixminmax=None, naround_zero=None,
ax1=None, ax2=None,
debugplot=0):
"""Compute broadening to match 'sp_obj' with 'sp_ref'.
The reference spectrum 'sp_ref' should have a bette... | python | def compute_broadening(wv_obj, sp_obj, wv_ref, sp_ref,
sigmalist, fpixminmax=None, naround_zero=None,
ax1=None, ax2=None,
debugplot=0):
"""Compute broadening to match 'sp_obj' with 'sp_ref'.
The reference spectrum 'sp_ref' should have a bette... | [
"def",
"compute_broadening",
"(",
"wv_obj",
",",
"sp_obj",
",",
"wv_ref",
",",
"sp_ref",
",",
"sigmalist",
",",
"fpixminmax",
"=",
"None",
",",
"naround_zero",
"=",
"None",
",",
"ax1",
"=",
"None",
",",
"ax2",
"=",
"None",
",",
"debugplot",
"=",
"0",
"... | Compute broadening to match 'sp_obj' with 'sp_ref'.
The reference spectrum 'sp_ref' should have a better spectral
resolution than the object spectrum 'sp_obj'.
It is assumed that the wavelength arrays are provided in
ascending order.
The wavelength sampling 'wv_ref' and 'wv_ref' can be different.... | [
"Compute",
"broadening",
"to",
"match",
"sp_obj",
"with",
"sp_ref",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/crosscorrelation.py#L373-L531 | train | Compute the broadening of the object spectrum with the given wavelengths and reference spectrum. |
inspirehep/inspire-schemas | inspire_schemas/builders/references.py | _split_refextract_authors_str | def _split_refextract_authors_str(authors_str):
"""Extract author names out of refextract authors output."""
author_seq = (x.strip() for x in RE_SPLIT_AUTH.split(authors_str) if x)
res = []
current = ''
for author in author_seq:
if not isinstance(author, six.text_type):
author =... | python | def _split_refextract_authors_str(authors_str):
"""Extract author names out of refextract authors output."""
author_seq = (x.strip() for x in RE_SPLIT_AUTH.split(authors_str) if x)
res = []
current = ''
for author in author_seq:
if not isinstance(author, six.text_type):
author =... | [
"def",
"_split_refextract_authors_str",
"(",
"authors_str",
")",
":",
"author_seq",
"=",
"(",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"RE_SPLIT_AUTH",
".",
"split",
"(",
"authors_str",
")",
"if",
"x",
")",
"res",
"=",
"[",
"]",
"current",
"=",
"... | Extract author names out of refextract authors output. | [
"Extract",
"author",
"names",
"out",
"of",
"refextract",
"authors",
"output",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/references.py#L57-L97 | train | Extract author names out of refextract authors output. |
inspirehep/inspire-schemas | inspire_schemas/builders/references.py | ReferenceBuilder._set_publication_info_field | def _set_publication_info_field(self, field_name, value):
"""Put a value in the publication info of the reference."""
self._ensure_reference_field('publication_info', {})
self.obj['reference']['publication_info'][field_name] = value | python | def _set_publication_info_field(self, field_name, value):
"""Put a value in the publication info of the reference."""
self._ensure_reference_field('publication_info', {})
self.obj['reference']['publication_info'][field_name] = value | [
"def",
"_set_publication_info_field",
"(",
"self",
",",
"field_name",
",",
"value",
")",
":",
"self",
".",
"_ensure_reference_field",
"(",
"'publication_info'",
",",
"{",
"}",
")",
"self",
".",
"obj",
"[",
"'reference'",
"]",
"[",
"'publication_info'",
"]",
"[... | Put a value in the publication info of the reference. | [
"Put",
"a",
"value",
"in",
"the",
"publication",
"info",
"of",
"the",
"reference",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/references.py#L148-L151 | train | Put a value in the publication info of the reference. |
inspirehep/inspire-schemas | inspire_schemas/builders/references.py | ReferenceBuilder.set_pubnote | def set_pubnote(self, pubnote):
"""Parse pubnote and populate correct fields."""
if 'publication_info' in self.obj.get('reference', {}):
self.add_misc(u'Additional pubnote: {}'.format(pubnote))
return
if self.RE_VALID_PUBNOTE.match(pubnote):
pubnote = split_p... | python | def set_pubnote(self, pubnote):
"""Parse pubnote and populate correct fields."""
if 'publication_info' in self.obj.get('reference', {}):
self.add_misc(u'Additional pubnote: {}'.format(pubnote))
return
if self.RE_VALID_PUBNOTE.match(pubnote):
pubnote = split_p... | [
"def",
"set_pubnote",
"(",
"self",
",",
"pubnote",
")",
":",
"if",
"'publication_info'",
"in",
"self",
".",
"obj",
".",
"get",
"(",
"'reference'",
",",
"{",
"}",
")",
":",
"self",
".",
"add_misc",
"(",
"u'Additional pubnote: {}'",
".",
"format",
"(",
"pu... | Parse pubnote and populate correct fields. | [
"Parse",
"pubnote",
"and",
"populate",
"correct",
"fields",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/references.py#L228-L239 | train | Parse pubnote and populate correct fields. |
inspirehep/inspire-schemas | inspire_schemas/builders/references.py | ReferenceBuilder._add_uid | def _add_uid(self, uid, skip_handle=False):
"""Add unique identifier in correct field.
The ``skip_handle`` flag is used when adding a uid through the add_url function
since urls can be easily confused with handle elements.
"""
# We might add None values from wherever. Kill them ... | python | def _add_uid(self, uid, skip_handle=False):
"""Add unique identifier in correct field.
The ``skip_handle`` flag is used when adding a uid through the add_url function
since urls can be easily confused with handle elements.
"""
# We might add None values from wherever. Kill them ... | [
"def",
"_add_uid",
"(",
"self",
",",
"uid",
",",
"skip_handle",
"=",
"False",
")",
":",
"# We might add None values from wherever. Kill them here.",
"uid",
"=",
"uid",
"or",
"''",
"if",
"is_arxiv",
"(",
"uid",
")",
":",
"self",
".",
"_ensure_reference_field",
"(... | Add unique identifier in correct field.
The ``skip_handle`` flag is used when adding a uid through the add_url function
since urls can be easily confused with handle elements. | [
"Add",
"unique",
"identifier",
"in",
"correct",
"field",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/references.py#L271-L318 | train | Add unique identifier in correct field. |
inspirehep/inspire-schemas | inspire_schemas/builders/references.py | ReferenceBuilder.set_page_artid | def set_page_artid(self, page_start=None, page_end=None, artid=None):
"""Add artid, start, end pages to publication info of a reference.
Args:
page_start(Optional[string]): value for the field page_start
page_end(Optional[string]): value for the field page_end
artid(... | python | def set_page_artid(self, page_start=None, page_end=None, artid=None):
"""Add artid, start, end pages to publication info of a reference.
Args:
page_start(Optional[string]): value for the field page_start
page_end(Optional[string]): value for the field page_end
artid(... | [
"def",
"set_page_artid",
"(",
"self",
",",
"page_start",
"=",
"None",
",",
"page_end",
"=",
"None",
",",
"artid",
"=",
"None",
")",
":",
"if",
"page_end",
"and",
"not",
"page_start",
":",
"raise",
"ValueError",
"(",
"'End_page provided without start_page'",
")... | Add artid, start, end pages to publication info of a reference.
Args:
page_start(Optional[string]): value for the field page_start
page_end(Optional[string]): value for the field page_end
artid(Optional[string]): value for the field artid
Raises:
ValueEr... | [
"Add",
"artid",
"start",
"end",
"pages",
"to",
"publication",
"info",
"of",
"a",
"reference",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/references.py#L336-L357 | train | Add artid start end pages to publication info of a reference. |
pylp/pylp | pylp/utils/glob.py | separate_globs | def separate_globs(globs):
"""Separate include and exclude globs."""
exclude = []
include = []
for path in globs:
if path.startswith("!"):
exclude.append(path[1:])
else:
include.append(path)
return (exclude, include) | python | def separate_globs(globs):
"""Separate include and exclude globs."""
exclude = []
include = []
for path in globs:
if path.startswith("!"):
exclude.append(path[1:])
else:
include.append(path)
return (exclude, include) | [
"def",
"separate_globs",
"(",
"globs",
")",
":",
"exclude",
"=",
"[",
"]",
"include",
"=",
"[",
"]",
"for",
"path",
"in",
"globs",
":",
"if",
"path",
".",
"startswith",
"(",
"\"!\"",
")",
":",
"exclude",
".",
"append",
"(",
"path",
"[",
"1",
":",
... | Separate include and exclude globs. | [
"Separate",
"include",
"and",
"exclude",
"globs",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/glob.py#L15-L26 | train | Separate include and exclude globs. |
pylp/pylp | pylp/utils/glob.py | parse_glob | def parse_glob(path, included):
"""Parse a glob."""
files = glob.glob(path, recursive=True)
array = []
for file in files:
file = os.path.abspath(file)
if file not in included:
array.append(file)
included += array
return array | python | def parse_glob(path, included):
"""Parse a glob."""
files = glob.glob(path, recursive=True)
array = []
for file in files:
file = os.path.abspath(file)
if file not in included:
array.append(file)
included += array
return array | [
"def",
"parse_glob",
"(",
"path",
",",
"included",
")",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"path",
",",
"recursive",
"=",
"True",
")",
"array",
"=",
"[",
"]",
"for",
"file",
"in",
"files",
":",
"file",
"=",
"os",
".",
"path",
".",
"absp... | Parse a glob. | [
"Parse",
"a",
"glob",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/glob.py#L30-L42 | train | Parse a glob. |
pylp/pylp | pylp/utils/glob.py | find_base | def find_base(path):
"""Find the base of a glob."""
result = _pattern.match(path)
if result:
base = result.group(0)
else:
base = "./"
if base.endswith('/') or base.endswith('\\'):
return os.path.abspath(base)
else:
return os.path.dirname(os.path.abspath(base)) | python | def find_base(path):
"""Find the base of a glob."""
result = _pattern.match(path)
if result:
base = result.group(0)
else:
base = "./"
if base.endswith('/') or base.endswith('\\'):
return os.path.abspath(base)
else:
return os.path.dirname(os.path.abspath(base)) | [
"def",
"find_base",
"(",
"path",
")",
":",
"result",
"=",
"_pattern",
".",
"match",
"(",
"path",
")",
"if",
"result",
":",
"base",
"=",
"result",
".",
"group",
"(",
"0",
")",
"else",
":",
"base",
"=",
"\"./\"",
"if",
"base",
".",
"endswith",
"(",
... | Find the base of a glob. | [
"Find",
"the",
"base",
"of",
"a",
"glob",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/glob.py#L49-L61 | train | Find the base of a glob. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.