repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
meraki-analytics/datapipelines-python | datapipelines/pipelines.py | DataPipeline.put_many | def put_many(self, type: Type[T], items: Iterable[T]) -> None:
"""Puts multiple objects of the same type into the data sink. The objects may be transformed into a new type for insertion if necessary.
Args:
items: An iterable (e.g. list) of objects to be inserted into the data pipeline.
... | python | def put_many(self, type: Type[T], items: Iterable[T]) -> None:
"""Puts multiple objects of the same type into the data sink. The objects may be transformed into a new type for insertion if necessary.
Args:
items: An iterable (e.g. list) of objects to be inserted into the data pipeline.
... | [
"def",
"put_many",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T",
"]",
",",
"items",
":",
"Iterable",
"[",
"T",
"]",
")",
"->",
"None",
":",
"LOGGER",
".",
"info",
"(",
"\"Getting SinkHandlers for \\\"{type}\\\"\"",
".",
"format",
"(",
"type",
"=",
"... | Puts multiple objects of the same type into the data sink. The objects may be transformed into a new type for insertion if necessary.
Args:
items: An iterable (e.g. list) of objects to be inserted into the data pipeline. | [
"Puts",
"multiple",
"objects",
"of",
"the",
"same",
"type",
"into",
"the",
"data",
"sink",
".",
"The",
"objects",
"may",
"be",
"transformed",
"into",
"a",
"new",
"type",
"for",
"insertion",
"if",
"necessary",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/pipelines.py#L532-L556 |
jmvrbanac/Specter | specter/reporting/dots.py | DotsReporter.print_error | def print_error(self, wrapper):
""" A crude way of output the errors for now. This needs to be
cleaned up into something better.
"""
level = 0
parent = wrapper.parent
while parent:
print_test_msg(parent.name, level, TestStatus.FAIL, self.use_color)
... | python | def print_error(self, wrapper):
""" A crude way of output the errors for now. This needs to be
cleaned up into something better.
"""
level = 0
parent = wrapper.parent
while parent:
print_test_msg(parent.name, level, TestStatus.FAIL, self.use_color)
... | [
"def",
"print_error",
"(",
"self",
",",
"wrapper",
")",
":",
"level",
"=",
"0",
"parent",
"=",
"wrapper",
".",
"parent",
"while",
"parent",
":",
"print_test_msg",
"(",
"parent",
".",
"name",
",",
"level",
",",
"TestStatus",
".",
"FAIL",
",",
"self",
".... | A crude way of output the errors for now. This needs to be
cleaned up into something better. | [
"A",
"crude",
"way",
"of",
"output",
"the",
"errors",
"for",
"now",
".",
"This",
"needs",
"to",
"be",
"cleaned",
"up",
"into",
"something",
"better",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/reporting/dots.py#L29-L53 |
kylef/refract.py | refract/refraction.py | refract | def refract(structure) -> Element:
"""
Refracts the given value.
>>> refract('string')
String(content='string')
>>> refract(1)
Number(content=1)
>>> refract(True)
Boolean(content=True)
>>> refract(None)
Null()
>>> refract([1, 2])
Array(content=[Number(content=1), Num... | python | def refract(structure) -> Element:
"""
Refracts the given value.
>>> refract('string')
String(content='string')
>>> refract(1)
Number(content=1)
>>> refract(True)
Boolean(content=True)
>>> refract(None)
Null()
>>> refract([1, 2])
Array(content=[Number(content=1), Num... | [
"def",
"refract",
"(",
"structure",
")",
"->",
"Element",
":",
"if",
"isinstance",
"(",
"structure",
",",
"Element",
")",
":",
"return",
"structure",
"elif",
"isinstance",
"(",
"structure",
",",
"str",
")",
":",
"return",
"String",
"(",
"content",
"=",
"... | Refracts the given value.
>>> refract('string')
String(content='string')
>>> refract(1)
Number(content=1)
>>> refract(True)
Boolean(content=True)
>>> refract(None)
Null()
>>> refract([1, 2])
Array(content=[Number(content=1), Number(content=2)])
>>> refract({'name': 'Doe... | [
"Refracts",
"the",
"given",
"value",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/refraction.py#L8-L50 |
kylef/refract.py | refract/json.py | JSONSerialiser.serialise | def serialise(self, element: Element, **kwargs) -> str:
"""
Serialises the given element into JSON.
>>> JSONSerialiser().serialise(String(content='Hello'))
'{"element": "string", "content": "Hello"}'
"""
return json.dumps(self.serialise_dict(element), **kwargs) | python | def serialise(self, element: Element, **kwargs) -> str:
"""
Serialises the given element into JSON.
>>> JSONSerialiser().serialise(String(content='Hello'))
'{"element": "string", "content": "Hello"}'
"""
return json.dumps(self.serialise_dict(element), **kwargs) | [
"def",
"serialise",
"(",
"self",
",",
"element",
":",
"Element",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"serialise_dict",
"(",
"element",
")",
",",
"*",
"*",
"kwargs",
")"
] | Serialises the given element into JSON.
>>> JSONSerialiser().serialise(String(content='Hello'))
'{"element": "string", "content": "Hello"}' | [
"Serialises",
"the",
"given",
"element",
"into",
"JSON",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/json.py#L62-L70 |
kylef/refract.py | refract/json.py | JSONDeserialiser.deserialise | def deserialise(self, element_json: str) -> Element:
"""
Deserialises the given JSON into an element.
>>> json = '{"element": "string", "content": "Hello"'
>>> JSONDeserialiser().deserialise(json)
String(content='Hello')
"""
return self.deserialise_dict(json.loa... | python | def deserialise(self, element_json: str) -> Element:
"""
Deserialises the given JSON into an element.
>>> json = '{"element": "string", "content": "Hello"'
>>> JSONDeserialiser().deserialise(json)
String(content='Hello')
"""
return self.deserialise_dict(json.loa... | [
"def",
"deserialise",
"(",
"self",
",",
"element_json",
":",
"str",
")",
"->",
"Element",
":",
"return",
"self",
".",
"deserialise_dict",
"(",
"json",
".",
"loads",
"(",
"element_json",
")",
")"
] | Deserialises the given JSON into an element.
>>> json = '{"element": "string", "content": "Hello"'
>>> JSONDeserialiser().deserialise(json)
String(content='Hello') | [
"Deserialises",
"the",
"given",
"JSON",
"into",
"an",
"element",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/json.py#L140-L149 |
kylef/refract.py | refract/json.py | CompactJSONSerialiser.serialise | def serialise(self, element: Element) -> str:
"""
Serialises the given element into Compact JSON.
>>> CompactJSONSerialiser().serialise(String(content='Hello'))
'["string", null, null, "Hello"]'
"""
return json.dumps(self.serialise_element(element)) | python | def serialise(self, element: Element) -> str:
"""
Serialises the given element into Compact JSON.
>>> CompactJSONSerialiser().serialise(String(content='Hello'))
'["string", null, null, "Hello"]'
"""
return json.dumps(self.serialise_element(element)) | [
"def",
"serialise",
"(",
"self",
",",
"element",
":",
"Element",
")",
"->",
"str",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"serialise_element",
"(",
"element",
")",
")"
] | Serialises the given element into Compact JSON.
>>> CompactJSONSerialiser().serialise(String(content='Hello'))
'["string", null, null, "Hello"]' | [
"Serialises",
"the",
"given",
"element",
"into",
"Compact",
"JSON",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/json.py#L236-L244 |
kylef/refract.py | refract/json.py | CompactJSONDeserialiser.deserialise | def deserialise(self, content) -> Element:
"""
Deserialises the given compact JSON into an element.
>>> deserialiser = CompactJSONDeserialiser()
>>> deserialiser.deserialise('["string", null, null, "Hi"]')
String(content='Hi')
"""
content = json.loads(content)
... | python | def deserialise(self, content) -> Element:
"""
Deserialises the given compact JSON into an element.
>>> deserialiser = CompactJSONDeserialiser()
>>> deserialiser.deserialise('["string", null, null, "Hi"]')
String(content='Hi')
"""
content = json.loads(content)
... | [
"def",
"deserialise",
"(",
"self",
",",
"content",
")",
"->",
"Element",
":",
"content",
"=",
"json",
".",
"loads",
"(",
"content",
")",
"if",
"not",
"isinstance",
"(",
"content",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"'Given content was not c... | Deserialises the given compact JSON into an element.
>>> deserialiser = CompactJSONDeserialiser()
>>> deserialiser.deserialise('["string", null, null, "Hi"]')
String(content='Hi') | [
"Deserialises",
"the",
"given",
"compact",
"JSON",
"into",
"an",
"element",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/json.py#L306-L319 |
jmvrbanac/Specter | specter/runner.py | SpecterRunner.combine_coverage_reports | def combine_coverage_reports(self, omit, parallel):
""" Method to force the combination of parallel coverage reports."""
tmp_cov = coverage.coverage(omit=omit, data_suffix=parallel)
tmp_cov.load()
tmp_cov.combine()
tmp_cov.save() | python | def combine_coverage_reports(self, omit, parallel):
""" Method to force the combination of parallel coverage reports."""
tmp_cov = coverage.coverage(omit=omit, data_suffix=parallel)
tmp_cov.load()
tmp_cov.combine()
tmp_cov.save() | [
"def",
"combine_coverage_reports",
"(",
"self",
",",
"omit",
",",
"parallel",
")",
":",
"tmp_cov",
"=",
"coverage",
".",
"coverage",
"(",
"omit",
"=",
"omit",
",",
"data_suffix",
"=",
"parallel",
")",
"tmp_cov",
".",
"load",
"(",
")",
"tmp_cov",
".",
"co... | Method to force the combination of parallel coverage reports. | [
"Method",
"to",
"force",
"the",
"combination",
"of",
"parallel",
"coverage",
"reports",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/runner.py#L120-L125 |
meraki-analytics/datapipelines-python | datapipelines/transformers.py | DataTransformer.transforms | def transforms(self) -> Mapping[Type, Iterable[Type]]:
"""The available data transformers."""
try:
return getattr(self.__class__, "transform")._transforms
except AttributeError:
return {} | python | def transforms(self) -> Mapping[Type, Iterable[Type]]:
"""The available data transformers."""
try:
return getattr(self.__class__, "transform")._transforms
except AttributeError:
return {} | [
"def",
"transforms",
"(",
"self",
")",
"->",
"Mapping",
"[",
"Type",
",",
"Iterable",
"[",
"Type",
"]",
"]",
":",
"try",
":",
"return",
"getattr",
"(",
"self",
".",
"__class__",
",",
"\"transform\"",
")",
".",
"_transforms",
"except",
"AttributeError",
"... | The available data transformers. | [
"The",
"available",
"data",
"transformers",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/transformers.py#L19-L24 |
meraki-analytics/datapipelines-python | datapipelines/transformers.py | DataTransformer.transform | def transform(self, target_type: Type[T], value: F, context: PipelineContext = None) -> T:
"""Transforms an object to a new type.
Args:
target_type: The type to be converted to.
value: The object to be transformed.
context: The context of the transformation (mutable)... | python | def transform(self, target_type: Type[T], value: F, context: PipelineContext = None) -> T:
"""Transforms an object to a new type.
Args:
target_type: The type to be converted to.
value: The object to be transformed.
context: The context of the transformation (mutable)... | [
"def",
"transform",
"(",
"self",
",",
"target_type",
":",
"Type",
"[",
"T",
"]",
",",
"value",
":",
"F",
",",
"context",
":",
"PipelineContext",
"=",
"None",
")",
"->",
"T",
":",
"pass"
] | Transforms an object to a new type.
Args:
target_type: The type to be converted to.
value: The object to be transformed.
context: The context of the transformation (mutable). | [
"Transforms",
"an",
"object",
"to",
"a",
"new",
"type",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/transformers.py#L27-L35 |
jmvrbanac/Specter | specter/spec.py | CaseWrapper.serialize | def serialize(self):
""" Serializes the CaseWrapper object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed.
"""
expects = [exp.serialize() for exp in self.expects]
... | python | def serialize(self):
""" Serializes the CaseWrapper object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed.
"""
expects = [exp.serialize() for exp in self.expects]
... | [
"def",
"serialize",
"(",
"self",
")",
":",
"expects",
"=",
"[",
"exp",
".",
"serialize",
"(",
")",
"for",
"exp",
"in",
"self",
".",
"expects",
"]",
"converted_dict",
"=",
"{",
"'id'",
":",
"self",
".",
"id",
",",
"'name'",
":",
"self",
".",
"pretty... | Serializes the CaseWrapper object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed. | [
"Serializes",
"the",
"CaseWrapper",
"object",
"for",
"collection",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/spec.py#L53-L76 |
jmvrbanac/Specter | specter/spec.py | Describe.serialize | def serialize(self):
""" Serializes the Spec/Describe object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed.
"""
cases = [case.serialize() for key, case in six.iterit... | python | def serialize(self):
""" Serializes the Spec/Describe object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed.
"""
cases = [case.serialize() for key, case in six.iterit... | [
"def",
"serialize",
"(",
"self",
")",
":",
"cases",
"=",
"[",
"case",
".",
"serialize",
"(",
")",
"for",
"key",
",",
"case",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"cases",
")",
"]",
"specs",
"=",
"[",
"spec",
".",
"serialize",
"(",
")"... | Serializes the Spec/Describe object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed. | [
"Serializes",
"the",
"Spec",
"/",
"Describe",
"object",
"for",
"collection",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/spec.py#L280-L299 |
jmvrbanac/Specter | specter/spec.py | Describe._run_hooks | def _run_hooks(self):
"""Calls any registered hooks providing the current state."""
for hook in self.hooks:
getattr(self, hook)(self._state) | python | def _run_hooks(self):
"""Calls any registered hooks providing the current state."""
for hook in self.hooks:
getattr(self, hook)(self._state) | [
"def",
"_run_hooks",
"(",
"self",
")",
":",
"for",
"hook",
"in",
"self",
".",
"hooks",
":",
"getattr",
"(",
"self",
",",
"hook",
")",
"(",
"self",
".",
"_state",
")"
] | Calls any registered hooks providing the current state. | [
"Calls",
"any",
"registered",
"hooks",
"providing",
"the",
"current",
"state",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/spec.py#L301-L304 |
kylef/refract.py | refract/elements/array.py | Array.append | def append(self, element):
"""
Append an element onto the array.
>>> array = Array()
>>> array.append('test')
"""
from refract.refraction import refract
self.content.append(refract(element)) | python | def append(self, element):
"""
Append an element onto the array.
>>> array = Array()
>>> array.append('test')
"""
from refract.refraction import refract
self.content.append(refract(element)) | [
"def",
"append",
"(",
"self",
",",
"element",
")",
":",
"from",
"refract",
".",
"refraction",
"import",
"refract",
"self",
".",
"content",
".",
"append",
"(",
"refract",
"(",
"element",
")",
")"
] | Append an element onto the array.
>>> array = Array()
>>> array.append('test') | [
"Append",
"an",
"element",
"onto",
"the",
"array",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/elements/array.py#L60-L69 |
kylef/refract.py | refract/elements/array.py | Array.insert | def insert(self, index: int, element):
"""
Insert an element at a given position.
>>> array = Array()
>>> array.insert(0, Element())
"""
from refract.refraction import refract
self.content.insert(index, refract(element)) | python | def insert(self, index: int, element):
"""
Insert an element at a given position.
>>> array = Array()
>>> array.insert(0, Element())
"""
from refract.refraction import refract
self.content.insert(index, refract(element)) | [
"def",
"insert",
"(",
"self",
",",
"index",
":",
"int",
",",
"element",
")",
":",
"from",
"refract",
".",
"refraction",
"import",
"refract",
"self",
".",
"content",
".",
"insert",
"(",
"index",
",",
"refract",
"(",
"element",
")",
")"
] | Insert an element at a given position.
>>> array = Array()
>>> array.insert(0, Element()) | [
"Insert",
"an",
"element",
"at",
"a",
"given",
"position",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/elements/array.py#L71-L80 |
kylef/refract.py | refract/elements/array.py | Array.index | def index(self, element: Element) -> int:
"""
Return the index in the array of the first item whose value is element.
It is an error if there is no such item.
>>> element = String('hello')
>>> array = Array(content=[element])
>>> array.index(element)
0
""... | python | def index(self, element: Element) -> int:
"""
Return the index in the array of the first item whose value is element.
It is an error if there is no such item.
>>> element = String('hello')
>>> array = Array(content=[element])
>>> array.index(element)
0
""... | [
"def",
"index",
"(",
"self",
",",
"element",
":",
"Element",
")",
"->",
"int",
":",
"from",
"refract",
".",
"refraction",
"import",
"refract",
"return",
"self",
".",
"content",
".",
"index",
"(",
"refract",
"(",
"element",
")",
")"
] | Return the index in the array of the first item whose value is element.
It is an error if there is no such item.
>>> element = String('hello')
>>> array = Array(content=[element])
>>> array.index(element)
0 | [
"Return",
"the",
"index",
"in",
"the",
"array",
"of",
"the",
"first",
"item",
"whose",
"value",
"is",
"element",
".",
"It",
"is",
"an",
"error",
"if",
"there",
"is",
"no",
"such",
"item",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/elements/array.py#L82-L94 |
meraki-analytics/datapipelines-python | datapipelines/sources.py | DataSource.provides | def provides(self): # type: Union[Iterable[Type[T]], Type[Any]]
"""The types of objects the data store provides."""
types = set()
any_dispatch = False
try:
types.update(getattr(self.__class__, "get")._provides)
any_dispatch = True
except AttributeError:
... | python | def provides(self): # type: Union[Iterable[Type[T]], Type[Any]]
"""The types of objects the data store provides."""
types = set()
any_dispatch = False
try:
types.update(getattr(self.__class__, "get")._provides)
any_dispatch = True
except AttributeError:
... | [
"def",
"provides",
"(",
"self",
")",
":",
"# type: Union[Iterable[Type[T]], Type[Any]]",
"types",
"=",
"set",
"(",
")",
"any_dispatch",
"=",
"False",
"try",
":",
"types",
".",
"update",
"(",
"getattr",
"(",
"self",
".",
"__class__",
",",
"\"get\"",
")",
".",... | The types of objects the data store provides. | [
"The",
"types",
"of",
"objects",
"the",
"data",
"store",
"provides",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/sources.py#L19-L33 |
meraki-analytics/datapipelines-python | datapipelines/sources.py | DataSource.get | def get(self, type: Type[T], query: Mapping[str, Any], context: PipelineContext = None) -> T:
"""Gets a query from the data source.
Args:
query: The query being requested.
context: The context for the extraction (mutable).
Returns:
The requested object.
... | python | def get(self, type: Type[T], query: Mapping[str, Any], context: PipelineContext = None) -> T:
"""Gets a query from the data source.
Args:
query: The query being requested.
context: The context for the extraction (mutable).
Returns:
The requested object.
... | [
"def",
"get",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T",
"]",
",",
"query",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
",",
"context",
":",
"PipelineContext",
"=",
"None",
")",
"->",
"T",
":",
"pass"
] | Gets a query from the data source.
Args:
query: The query being requested.
context: The context for the extraction (mutable).
Returns:
The requested object. | [
"Gets",
"a",
"query",
"from",
"the",
"data",
"source",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/sources.py#L36-L46 |
meraki-analytics/datapipelines-python | datapipelines/sources.py | DataSource.get_many | def get_many(self, type: Type[T], query: Mapping[str, Any], context: PipelineContext = None) -> Iterable[T]:
"""Gets a query from the data source, which contains a request for multiple objects.
Args:
query: The query being requested (contains a request for multiple objects).
con... | python | def get_many(self, type: Type[T], query: Mapping[str, Any], context: PipelineContext = None) -> Iterable[T]:
"""Gets a query from the data source, which contains a request for multiple objects.
Args:
query: The query being requested (contains a request for multiple objects).
con... | [
"def",
"get_many",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T",
"]",
",",
"query",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
",",
"context",
":",
"PipelineContext",
"=",
"None",
")",
"->",
"Iterable",
"[",
"T",
"]",
":",
"pass"
] | Gets a query from the data source, which contains a request for multiple objects.
Args:
query: The query being requested (contains a request for multiple objects).
context: The context for the extraction (mutable).
Returns:
The requested objects. | [
"Gets",
"a",
"query",
"from",
"the",
"data",
"source",
"which",
"contains",
"a",
"request",
"for",
"multiple",
"objects",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/sources.py#L49-L59 |
jmvrbanac/Specter | specter/reporting/__init__.py | ReporterPluginManager.subscribe_all_to_spec | def subscribe_all_to_spec(self, spec):
""" Will automatically not subscribe reporters that are not parallel
or serial depending on the current mode.
"""
for reporter in self.reporters:
if self.can_use_reporter(reporter, self.parallel):
reporter.subscribe_to_sp... | python | def subscribe_all_to_spec(self, spec):
""" Will automatically not subscribe reporters that are not parallel
or serial depending on the current mode.
"""
for reporter in self.reporters:
if self.can_use_reporter(reporter, self.parallel):
reporter.subscribe_to_sp... | [
"def",
"subscribe_all_to_spec",
"(",
"self",
",",
"spec",
")",
":",
"for",
"reporter",
"in",
"self",
".",
"reporters",
":",
"if",
"self",
".",
"can_use_reporter",
"(",
"reporter",
",",
"self",
".",
"parallel",
")",
":",
"reporter",
".",
"subscribe_to_spec",
... | Will automatically not subscribe reporters that are not parallel
or serial depending on the current mode. | [
"Will",
"automatically",
"not",
"subscribe",
"reporters",
"that",
"are",
"not",
"parallel",
"or",
"serial",
"depending",
"on",
"the",
"current",
"mode",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/reporting/__init__.py#L77-L83 |
jmvrbanac/Specter | specter/reporting/console.py | ConsoleReporter.output | def output(self, msg, indent, status=None):
""" Alias for print_indent_msg with color determined by status."""
color = None
if self.use_color:
color = get_color_from_status(status)
print_indent_msg(msg, indent, color) | python | def output(self, msg, indent, status=None):
""" Alias for print_indent_msg with color determined by status."""
color = None
if self.use_color:
color = get_color_from_status(status)
print_indent_msg(msg, indent, color) | [
"def",
"output",
"(",
"self",
",",
"msg",
",",
"indent",
",",
"status",
"=",
"None",
")",
":",
"color",
"=",
"None",
"if",
"self",
".",
"use_color",
":",
"color",
"=",
"get_color_from_status",
"(",
"status",
")",
"print_indent_msg",
"(",
"msg",
",",
"i... | Alias for print_indent_msg with color determined by status. | [
"Alias",
"for",
"print_indent_msg",
"with",
"color",
"determined",
"by",
"status",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/reporting/console.py#L139-L144 |
jmvrbanac/Specter | specter/util.py | get_real_last_traceback | def get_real_last_traceback(exception):
""" An unfortunate evil... All because Python's traceback cannot
determine where my executed code is coming from...
"""
traceback_blocks = []
_n, _n, exc_traceback = sys.exc_info()
tb_list = get_all_tracebacks(exc_traceback)[1:]
# Remove already captu... | python | def get_real_last_traceback(exception):
""" An unfortunate evil... All because Python's traceback cannot
determine where my executed code is coming from...
"""
traceback_blocks = []
_n, _n, exc_traceback = sys.exc_info()
tb_list = get_all_tracebacks(exc_traceback)[1:]
# Remove already captu... | [
"def",
"get_real_last_traceback",
"(",
"exception",
")",
":",
"traceback_blocks",
"=",
"[",
"]",
"_n",
",",
"_n",
",",
"exc_traceback",
"=",
"sys",
".",
"exc_info",
"(",
")",
"tb_list",
"=",
"get_all_tracebacks",
"(",
"exc_traceback",
")",
"[",
"1",
":",
"... | An unfortunate evil... All because Python's traceback cannot
determine where my executed code is coming from... | [
"An",
"unfortunate",
"evil",
"...",
"All",
"because",
"Python",
"s",
"traceback",
"cannot",
"determine",
"where",
"my",
"executed",
"code",
"is",
"coming",
"from",
"..."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/util.py#L155-L183 |
kylef/refract.py | refract/contrib/apielements.py | HTTPMessage.assets | def assets(self) -> List[Asset]:
"""
Returns the assets in the transaction.
"""
return list(filter(is_element(Asset), self.content)) | python | def assets(self) -> List[Asset]:
"""
Returns the assets in the transaction.
"""
return list(filter(is_element(Asset), self.content)) | [
"def",
"assets",
"(",
"self",
")",
"->",
"List",
"[",
"Asset",
"]",
":",
"return",
"list",
"(",
"filter",
"(",
"is_element",
"(",
"Asset",
")",
",",
"self",
".",
"content",
")",
")"
] | Returns the assets in the transaction. | [
"Returns",
"the",
"assets",
"in",
"the",
"transaction",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/contrib/apielements.py#L79-L84 |
jmvrbanac/Specter | specter/vendor/ast_decompiler.py | decompile | def decompile(ast, indentation=4, line_length=100, starting_indentation=0):
"""Decompiles an AST into Python code.
Arguments:
- ast: code to decompile, using AST objects as generated by the standard library ast module
- indentation: indentation level of lines
- line_length: if lines become longer t... | python | def decompile(ast, indentation=4, line_length=100, starting_indentation=0):
"""Decompiles an AST into Python code.
Arguments:
- ast: code to decompile, using AST objects as generated by the standard library ast module
- indentation: indentation level of lines
- line_length: if lines become longer t... | [
"def",
"decompile",
"(",
"ast",
",",
"indentation",
"=",
"4",
",",
"line_length",
"=",
"100",
",",
"starting_indentation",
"=",
"0",
")",
":",
"decompiler",
"=",
"Decompiler",
"(",
"indentation",
"=",
"indentation",
",",
"line_length",
"=",
"line_length",
",... | Decompiles an AST into Python code.
Arguments:
- ast: code to decompile, using AST objects as generated by the standard library ast module
- indentation: indentation level of lines
- line_length: if lines become longer than this length, ast_decompiler will try to break them up
(but it will not ne... | [
"Decompiles",
"an",
"AST",
"into",
"Python",
"code",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/vendor/ast_decompiler.py#L94-L110 |
jmvrbanac/Specter | specter/vendor/ast_decompiler.py | Decompiler.write_expression_list | def write_expression_list(self, nodes, separator=', ', allow_newlines=True, need_parens=True,
final_separator_if_multiline=True):
"""Writes a list of nodes, separated by separator.
If allow_newlines, will write the expression over multiple lines if necessary to say within
... | python | def write_expression_list(self, nodes, separator=', ', allow_newlines=True, need_parens=True,
final_separator_if_multiline=True):
"""Writes a list of nodes, separated by separator.
If allow_newlines, will write the expression over multiple lines if necessary to say within
... | [
"def",
"write_expression_list",
"(",
"self",
",",
"nodes",
",",
"separator",
"=",
"', '",
",",
"allow_newlines",
"=",
"True",
",",
"need_parens",
"=",
"True",
",",
"final_separator_if_multiline",
"=",
"True",
")",
":",
"first",
"=",
"True",
"last_line",
"=",
... | Writes a list of nodes, separated by separator.
If allow_newlines, will write the expression over multiple lines if necessary to say within
max_line_length. If need_parens, will surround the expression with parentheses in this case.
If final_separator_if_multiline, will write a separator at the... | [
"Writes",
"a",
"list",
"of",
"nodes",
"separated",
"by",
"separator",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/vendor/ast_decompiler.py#L164-L208 |
kylef/refract.py | refract/elements/base.py | Element.defract | def defract(self):
"""
Returns the underlying (unrefracted) value of element
>>> Element(content='Hello').defract
'Hello'
>>> Element(content=Element(content='Hello')).defract
'Hello'
>>> Element(content=[Element(content='Hello')]).defract
['Hello']
... | python | def defract(self):
"""
Returns the underlying (unrefracted) value of element
>>> Element(content='Hello').defract
'Hello'
>>> Element(content=Element(content='Hello')).defract
'Hello'
>>> Element(content=[Element(content='Hello')]).defract
['Hello']
... | [
"def",
"defract",
"(",
"self",
")",
":",
"from",
"refract",
".",
"elements",
".",
"object",
"import",
"Object",
"def",
"get_value",
"(",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"KeyValuePair",
")",
":",
"return",
"(",
"get_value",
"(",
... | Returns the underlying (unrefracted) value of element
>>> Element(content='Hello').defract
'Hello'
>>> Element(content=Element(content='Hello')).defract
'Hello'
>>> Element(content=[Element(content='Hello')]).defract
['Hello'] | [
"Returns",
"the",
"underlying",
"(",
"unrefracted",
")",
"value",
"of",
"element"
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/elements/base.py#L104-L132 |
kylef/refract.py | refract/elements/base.py | Element.children | def children(self):
"""
Returns all of the children elements.
"""
if isinstance(self.content, list):
return self.content
elif isinstance(self.content, Element):
return [self.content]
else:
return [] | python | def children(self):
"""
Returns all of the children elements.
"""
if isinstance(self.content, list):
return self.content
elif isinstance(self.content, Element):
return [self.content]
else:
return [] | [
"def",
"children",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"content",
",",
"list",
")",
":",
"return",
"self",
".",
"content",
"elif",
"isinstance",
"(",
"self",
".",
"content",
",",
"Element",
")",
":",
"return",
"[",
"self",
".... | Returns all of the children elements. | [
"Returns",
"all",
"of",
"the",
"children",
"elements",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/elements/base.py#L193-L203 |
kylef/refract.py | refract/elements/base.py | Element.recursive_children | def recursive_children(self):
"""
Generator returning all recursive children elements.
"""
for child in self.children:
yield child
for recursive_child in child.recursive_children:
yield recursive_child | python | def recursive_children(self):
"""
Generator returning all recursive children elements.
"""
for child in self.children:
yield child
for recursive_child in child.recursive_children:
yield recursive_child | [
"def",
"recursive_children",
"(",
"self",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
":",
"yield",
"child",
"for",
"recursive_child",
"in",
"child",
".",
"recursive_children",
":",
"yield",
"recursive_child"
] | Generator returning all recursive children elements. | [
"Generator",
"returning",
"all",
"recursive",
"children",
"elements",
"."
] | train | https://github.com/kylef/refract.py/blob/f58ddf619038b580ab50c2e7f867d59d153eabbb/refract/elements/base.py#L206-L215 |
jmvrbanac/Specter | specter/expect.py | expect | def expect(obj, caller_args=[]):
"""Primary method for test assertions in Specter
:param obj: The evaluated target object
:param caller_args: Is only used when using expecting a raised Exception
"""
line, module = get_module_and_line('__spec__')
src_params = ExpectParams(line, module)
expe... | python | def expect(obj, caller_args=[]):
"""Primary method for test assertions in Specter
:param obj: The evaluated target object
:param caller_args: Is only used when using expecting a raised Exception
"""
line, module = get_module_and_line('__spec__')
src_params = ExpectParams(line, module)
expe... | [
"def",
"expect",
"(",
"obj",
",",
"caller_args",
"=",
"[",
"]",
")",
":",
"line",
",",
"module",
"=",
"get_module_and_line",
"(",
"'__spec__'",
")",
"src_params",
"=",
"ExpectParams",
"(",
"line",
",",
"module",
")",
"expect_obj",
"=",
"ExpectAssert",
"(",... | Primary method for test assertions in Specter
:param obj: The evaluated target object
:param caller_args: Is only used when using expecting a raised Exception | [
"Primary",
"method",
"for",
"test",
"assertions",
"in",
"Specter"
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L202-L217 |
jmvrbanac/Specter | specter/expect.py | require | def require(obj, caller_args=[]):
"""Primary method for test assertions in Specter
:param obj: The evaluated target object
:param caller_args: Is only used when using expecting a raised Exception
"""
line, module = get_module_and_line('__spec__')
src_params = ExpectParams(line, module)
req... | python | def require(obj, caller_args=[]):
"""Primary method for test assertions in Specter
:param obj: The evaluated target object
:param caller_args: Is only used when using expecting a raised Exception
"""
line, module = get_module_and_line('__spec__')
src_params = ExpectParams(line, module)
req... | [
"def",
"require",
"(",
"obj",
",",
"caller_args",
"=",
"[",
"]",
")",
":",
"line",
",",
"module",
"=",
"get_module_and_line",
"(",
"'__spec__'",
")",
"src_params",
"=",
"ExpectParams",
"(",
"line",
",",
"module",
")",
"require_obj",
"=",
"RequireAssert",
"... | Primary method for test assertions in Specter
:param obj: The evaluated target object
:param caller_args: Is only used when using expecting a raised Exception | [
"Primary",
"method",
"for",
"test",
"assertions",
"in",
"Specter"
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L220-L235 |
jmvrbanac/Specter | specter/expect.py | skip | def skip(reason):
"""The skip decorator allows for you to always bypass a test.
:param reason: Expects a string
"""
def decorator(test_func):
if not isinstance(test_func, (type, ClassObjType)):
func_data = None
if test_func.__name__ == 'DECORATOR_ONCALL':
... | python | def skip(reason):
"""The skip decorator allows for you to always bypass a test.
:param reason: Expects a string
"""
def decorator(test_func):
if not isinstance(test_func, (type, ClassObjType)):
func_data = None
if test_func.__name__ == 'DECORATOR_ONCALL':
... | [
"def",
"skip",
"(",
"reason",
")",
":",
"def",
"decorator",
"(",
"test_func",
")",
":",
"if",
"not",
"isinstance",
"(",
"test_func",
",",
"(",
"type",
",",
"ClassObjType",
")",
")",
":",
"func_data",
"=",
"None",
"if",
"test_func",
".",
"__name__",
"==... | The skip decorator allows for you to always bypass a test.
:param reason: Expects a string | [
"The",
"skip",
"decorator",
"allows",
"for",
"you",
"to",
"always",
"bypass",
"a",
"test",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L238-L259 |
jmvrbanac/Specter | specter/expect.py | skip_if | def skip_if(condition, reason=None):
"""The skip_if decorator allows for you to bypass a test on conditions
:param condition: Expects a boolean
:param reason: Expects a string
"""
if condition:
return skip(reason)
def wrapper(func):
return func
return wrapper | python | def skip_if(condition, reason=None):
"""The skip_if decorator allows for you to bypass a test on conditions
:param condition: Expects a boolean
:param reason: Expects a string
"""
if condition:
return skip(reason)
def wrapper(func):
return func
return wrapper | [
"def",
"skip_if",
"(",
"condition",
",",
"reason",
"=",
"None",
")",
":",
"if",
"condition",
":",
"return",
"skip",
"(",
"reason",
")",
"def",
"wrapper",
"(",
"func",
")",
":",
"return",
"func",
"return",
"wrapper"
] | The skip_if decorator allows for you to bypass a test on conditions
:param condition: Expects a boolean
:param reason: Expects a string | [
"The",
"skip_if",
"decorator",
"allows",
"for",
"you",
"to",
"bypass",
"a",
"test",
"on",
"conditions"
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L262-L273 |
jmvrbanac/Specter | specter/expect.py | incomplete | def incomplete(test_func):
"""The incomplete decorator behaves much like a normal skip; however,
tests that are marked as incomplete get tracked under a different metric.
This allows for you to create a skeleton around all of your features and
specifications, and track what tests have been written and w... | python | def incomplete(test_func):
"""The incomplete decorator behaves much like a normal skip; however,
tests that are marked as incomplete get tracked under a different metric.
This allows for you to create a skeleton around all of your features and
specifications, and track what tests have been written and w... | [
"def",
"incomplete",
"(",
"test_func",
")",
":",
"if",
"not",
"isinstance",
"(",
"test_func",
",",
"(",
"type",
",",
"ClassObjType",
")",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"test_func",
")",
"def",
"skip_wrapper",
"(",
"*",
"args",
",",
"*"... | The incomplete decorator behaves much like a normal skip; however,
tests that are marked as incomplete get tracked under a different metric.
This allows for you to create a skeleton around all of your features and
specifications, and track what tests have been written and what
tests are left outstanding... | [
"The",
"incomplete",
"decorator",
"behaves",
"much",
"like",
"a",
"normal",
"skip",
";",
"however",
"tests",
"that",
"are",
"marked",
"as",
"incomplete",
"get",
"tracked",
"under",
"a",
"different",
"metric",
".",
"This",
"allows",
"for",
"you",
"to",
"creat... | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L276-L294 |
jmvrbanac/Specter | specter/expect.py | metadata | def metadata(**key_value_pairs):
"""The metadata decorator allows for you to tag specific tests with
key/value data for run-time processing or reporting. The common use case
is to use metadata to tag a test as a positive or negative test type.
.. code-block:: python
# Example of using the meta... | python | def metadata(**key_value_pairs):
"""The metadata decorator allows for you to tag specific tests with
key/value data for run-time processing or reporting. The common use case
is to use metadata to tag a test as a positive or negative test type.
.. code-block:: python
# Example of using the meta... | [
"def",
"metadata",
"(",
"*",
"*",
"key_value_pairs",
")",
":",
"def",
"onTestFunc",
"(",
"func",
")",
":",
"def",
"DECORATOR_ONCALL",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"(",
"func",
",",
"key_value_pairs",
")",
"return",
"DE... | The metadata decorator allows for you to tag specific tests with
key/value data for run-time processing or reporting. The common use case
is to use metadata to tag a test as a positive or negative test type.
.. code-block:: python
# Example of using the metadata decorator
@metadata(type='n... | [
"The",
"metadata",
"decorator",
"allows",
"for",
"you",
"to",
"tag",
"specific",
"tests",
"with",
"key",
"/",
"value",
"data",
"for",
"run",
"-",
"time",
"processing",
"or",
"reporting",
".",
"The",
"common",
"use",
"case",
"is",
"to",
"use",
"metadata",
... | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L297-L313 |
jmvrbanac/Specter | specter/expect.py | ExpectAssert.serialize | def serialize(self):
"""Serializes the ExpectAssert object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed.
"""
converted_dict = {
'success': self.success,
... | python | def serialize(self):
"""Serializes the ExpectAssert object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed.
"""
converted_dict = {
'success': self.success,
... | [
"def",
"serialize",
"(",
"self",
")",
":",
"converted_dict",
"=",
"{",
"'success'",
":",
"self",
".",
"success",
",",
"'assertion'",
":",
"str",
"(",
"self",
")",
",",
"'required'",
":",
"self",
".",
"required",
"}",
"return",
"converted_dict"
] | Serializes the ExpectAssert object for collection.
Warning, this will only grab the available information.
It is strongly that you only call this once all specs and
tests have completed. | [
"Serializes",
"the",
"ExpectAssert",
"object",
"for",
"collection",
"."
] | train | https://github.com/jmvrbanac/Specter/blob/1f5a729b0aa16242add8c1c754efa268335e3944/specter/expect.py#L41-L53 |
meraki-analytics/datapipelines-python | datapipelines/sinks.py | DataSink.accepts | def accepts(self): # type: Union[Iterable[Type[T]], Type[Any]]
"""The types of objects the data sink can store."""
types = set()
any_dispatch = False
try:
types.update(getattr(self.__class__, "put")._accepts)
any_dispatch = True
except AttributeError:
... | python | def accepts(self): # type: Union[Iterable[Type[T]], Type[Any]]
"""The types of objects the data sink can store."""
types = set()
any_dispatch = False
try:
types.update(getattr(self.__class__, "put")._accepts)
any_dispatch = True
except AttributeError:
... | [
"def",
"accepts",
"(",
"self",
")",
":",
"# type: Union[Iterable[Type[T]], Type[Any]]",
"types",
"=",
"set",
"(",
")",
"any_dispatch",
"=",
"False",
"try",
":",
"types",
".",
"update",
"(",
"getattr",
"(",
"self",
".",
"__class__",
",",
"\"put\"",
")",
".",
... | The types of objects the data sink can store. | [
"The",
"types",
"of",
"objects",
"the",
"data",
"sink",
"can",
"store",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/sinks.py#L16-L30 |
meraki-analytics/datapipelines-python | datapipelines/sinks.py | DataSink.put_many | def put_many(self, type: Type[T], items: Iterable[T], context: PipelineContext = None) -> None:
"""Puts multiple objects of the same type into the data sink.
Args:
type: The type of the objects being inserted.
items: The objects to be inserted.
context: The context o... | python | def put_many(self, type: Type[T], items: Iterable[T], context: PipelineContext = None) -> None:
"""Puts multiple objects of the same type into the data sink.
Args:
type: The type of the objects being inserted.
items: The objects to be inserted.
context: The context o... | [
"def",
"put_many",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T",
"]",
",",
"items",
":",
"Iterable",
"[",
"T",
"]",
",",
"context",
":",
"PipelineContext",
"=",
"None",
")",
"->",
"None",
":",
"pass"
] | Puts multiple objects of the same type into the data sink.
Args:
type: The type of the objects being inserted.
items: The objects to be inserted.
context: The context of the insertion (mutable). | [
"Puts",
"multiple",
"objects",
"of",
"the",
"same",
"type",
"into",
"the",
"data",
"sink",
"."
] | train | https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/sinks.py#L44-L52 |
internetarchive/warc | warc/__init__.py | open | def open(filename, mode="rb", format = None):
"""Shorthand for WARCFile(filename, mode).
Auto detects file and opens it.
"""
if format == "auto" or format == None:
format = detect_format(filename)
if format == "warc":
return WARCFile(filename, mode)
elif format == "arc":
... | python | def open(filename, mode="rb", format = None):
"""Shorthand for WARCFile(filename, mode).
Auto detects file and opens it.
"""
if format == "auto" or format == None:
format = detect_format(filename)
if format == "warc":
return WARCFile(filename, mode)
elif format == "arc":
... | [
"def",
"open",
"(",
"filename",
",",
"mode",
"=",
"\"rb\"",
",",
"format",
"=",
"None",
")",
":",
"if",
"format",
"==",
"\"auto\"",
"or",
"format",
"==",
"None",
":",
"format",
"=",
"detect_format",
"(",
"filename",
")",
"if",
"format",
"==",
"\"warc\"... | Shorthand for WARCFile(filename, mode).
Auto detects file and opens it. | [
"Shorthand",
"for",
"WARCFile",
"(",
"filename",
"mode",
")",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/__init__.py#L24-L38 |
internetarchive/warc | warc/warc.py | WARCHeader.init_defaults | def init_defaults(self):
"""Initializes important headers to default values, if not already specified.
The WARC-Record-ID header is set to a newly generated UUID.
The WARC-Date header is set to the current datetime.
The Content-Type is set based on the WARC-Type header.
... | python | def init_defaults(self):
"""Initializes important headers to default values, if not already specified.
The WARC-Record-ID header is set to a newly generated UUID.
The WARC-Date header is set to the current datetime.
The Content-Type is set based on the WARC-Type header.
... | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"if",
"\"WARC-Record-ID\"",
"not",
"in",
"self",
":",
"self",
"[",
"'WARC-Record-ID'",
"]",
"=",
"\"<urn:uuid:%s>\"",
"%",
"uuid",
".",
"uuid1",
"(",
")",
"if",
"\"WARC-Date\"",
"not",
"in",
"self",
":",
"self... | Initializes important headers to default values, if not already specified.
The WARC-Record-ID header is set to a newly generated UUID.
The WARC-Date header is set to the current datetime.
The Content-Type is set based on the WARC-Type header.
The Content-Length is initialized to... | [
"Initializes",
"important",
"headers",
"to",
"default",
"values",
"if",
"not",
"already",
"specified",
".",
"The",
"WARC",
"-",
"Record",
"-",
"ID",
"header",
"is",
"set",
"to",
"a",
"newly",
"generated",
"UUID",
".",
"The",
"WARC",
"-",
"Date",
"header",
... | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/warc.py#L75-L88 |
internetarchive/warc | warc/warc.py | WARCHeader.write_to | def write_to(self, f):
"""Writes this header to a file, in the format specified by WARC.
"""
f.write(self.version + "\r\n")
for name, value in self.items():
name = name.title()
# Use standard forms for commonly used patterns
name = name.replace("Warc-"... | python | def write_to(self, f):
"""Writes this header to a file, in the format specified by WARC.
"""
f.write(self.version + "\r\n")
for name, value in self.items():
name = name.title()
# Use standard forms for commonly used patterns
name = name.replace("Warc-"... | [
"def",
"write_to",
"(",
"self",
",",
"f",
")",
":",
"f",
".",
"write",
"(",
"self",
".",
"version",
"+",
"\"\\r\\n\"",
")",
"for",
"name",
",",
"value",
"in",
"self",
".",
"items",
"(",
")",
":",
"name",
"=",
"name",
".",
"title",
"(",
")",
"# ... | Writes this header to a file, in the format specified by WARC. | [
"Writes",
"this",
"header",
"to",
"a",
"file",
"in",
"the",
"format",
"specified",
"by",
"WARC",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/warc.py#L90-L104 |
internetarchive/warc | warc/warc.py | WARCRecord.from_response | def from_response(response):
"""Creates a WARCRecord from given response object.
This must be called before reading the response. The response can be
read after this method is called.
:param response: An instance of :class:`requests.models.Response`.
"""
# Get ... | python | def from_response(response):
"""Creates a WARCRecord from given response object.
This must be called before reading the response. The response can be
read after this method is called.
:param response: An instance of :class:`requests.models.Response`.
"""
# Get ... | [
"def",
"from_response",
"(",
"response",
")",
":",
"# Get the httplib.HTTPResponse object",
"http_response",
"=",
"response",
".",
"raw",
".",
"_original_response",
"# HTTP status line, headers and body as strings",
"status_line",
"=",
"\"HTTP/1.1 %d %s\"",
"%",
"(",
"http_re... | Creates a WARCRecord from given response object.
This must be called before reading the response. The response can be
read after this method is called.
:param response: An instance of :class:`requests.models.Response`. | [
"Creates",
"a",
"WARCRecord",
"from",
"given",
"response",
"object",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/warc.py#L216-L242 |
internetarchive/warc | warc/warc.py | WARCFile.write_record | def write_record(self, warc_record):
"""Adds a warc record to this WARC file.
"""
warc_record.write_to(self.fileobj)
# Each warc record is written as separate member in the gzip file
# so that each record can be read independetly.
if isinstance(self.fileobj, gzip2.GzipFil... | python | def write_record(self, warc_record):
"""Adds a warc record to this WARC file.
"""
warc_record.write_to(self.fileobj)
# Each warc record is written as separate member in the gzip file
# so that each record can be read independetly.
if isinstance(self.fileobj, gzip2.GzipFil... | [
"def",
"write_record",
"(",
"self",
",",
"warc_record",
")",
":",
"warc_record",
".",
"write_to",
"(",
"self",
".",
"fileobj",
")",
"# Each warc record is written as separate member in the gzip file",
"# so that each record can be read independetly.",
"if",
"isinstance",
"(",... | Adds a warc record to this WARC file. | [
"Adds",
"a",
"warc",
"record",
"to",
"this",
"WARC",
"file",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/warc.py#L265-L272 |
internetarchive/warc | warc/warc.py | WARCFile.browse | def browse(self):
"""Utility to browse through the records in the warc file.
This returns an iterator over (record, offset, size) for each record in
the file. If the file is gzip compressed, the offset and size will
corresponds to the compressed file.
The pay... | python | def browse(self):
"""Utility to browse through the records in the warc file.
This returns an iterator over (record, offset, size) for each record in
the file. If the file is gzip compressed, the offset and size will
corresponds to the compressed file.
The pay... | [
"def",
"browse",
"(",
"self",
")",
":",
"offset",
"=",
"0",
"for",
"record",
"in",
"self",
".",
"reader",
":",
"# Just read the first 1MB of the payload.",
"# This will make sure memory consuption is under control and it ",
"# is possible to look at the first MB of the payload, w... | Utility to browse through the records in the warc file.
This returns an iterator over (record, offset, size) for each record in
the file. If the file is gzip compressed, the offset and size will
corresponds to the compressed file.
The payload of each record is limite... | [
"Utility",
"to",
"browse",
"through",
"the",
"records",
"in",
"the",
"warc",
"file",
".",
"This",
"returns",
"an",
"iterator",
"over",
"(",
"record",
"offset",
"size",
")",
"for",
"each",
"record",
"in",
"the",
"file",
".",
"If",
"the",
"file",
"is",
"... | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/warc.py#L284-L304 |
internetarchive/warc | warc/warc.py | WARCFile.tell | def tell(self):
"""Returns the file offset. If this is a compressed file, then the
offset in the compressed file is returned.
"""
if isinstance(self.fileobj, gzip2.GzipFile):
return self.fileobj.fileobj.tell()
else:
return self.fileobj.tell() | python | def tell(self):
"""Returns the file offset. If this is a compressed file, then the
offset in the compressed file is returned.
"""
if isinstance(self.fileobj, gzip2.GzipFile):
return self.fileobj.fileobj.tell()
else:
return self.fileobj.tell() | [
"def",
"tell",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"fileobj",
",",
"gzip2",
".",
"GzipFile",
")",
":",
"return",
"self",
".",
"fileobj",
".",
"fileobj",
".",
"tell",
"(",
")",
"else",
":",
"return",
"self",
".",
"fileobj",
... | Returns the file offset. If this is a compressed file, then the
offset in the compressed file is returned. | [
"Returns",
"the",
"file",
"offset",
".",
"If",
"this",
"is",
"a",
"compressed",
"file",
"then",
"the",
"offset",
"in",
"the",
"compressed",
"file",
"is",
"returned",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/warc.py#L306-L313 |
internetarchive/warc | warc/gzip2.py | GzipFile.close_member | def close_member(self):
"""Closes the current member being written.
"""
# The new member is not yet started, no need to close
if self._new_member:
return
self.fileobj.write(self.compress.flush())
write32u(self.fileobj, self.crc)
# self.siz... | python | def close_member(self):
"""Closes the current member being written.
"""
# The new member is not yet started, no need to close
if self._new_member:
return
self.fileobj.write(self.compress.flush())
write32u(self.fileobj, self.crc)
# self.siz... | [
"def",
"close_member",
"(",
"self",
")",
":",
"# The new member is not yet started, no need to close",
"if",
"self",
".",
"_new_member",
":",
"return",
"self",
".",
"fileobj",
".",
"write",
"(",
"self",
".",
"compress",
".",
"flush",
"(",
")",
")",
"write32u",
... | Closes the current member being written. | [
"Closes",
"the",
"current",
"member",
"being",
"written",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/gzip2.py#L42-L59 |
internetarchive/warc | warc/gzip2.py | GzipFile._start_member | def _start_member(self):
"""Starts writing a new member if required.
"""
if self._new_member:
self._init_write(self.name)
self._write_gzip_header()
self._new_member = False | python | def _start_member(self):
"""Starts writing a new member if required.
"""
if self._new_member:
self._init_write(self.name)
self._write_gzip_header()
self._new_member = False | [
"def",
"_start_member",
"(",
"self",
")",
":",
"if",
"self",
".",
"_new_member",
":",
"self",
".",
"_init_write",
"(",
"self",
".",
"name",
")",
"self",
".",
"_write_gzip_header",
"(",
")",
"self",
".",
"_new_member",
"=",
"False"
] | Starts writing a new member if required. | [
"Starts",
"writing",
"a",
"new",
"member",
"if",
"required",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/gzip2.py#L61-L67 |
internetarchive/warc | warc/gzip2.py | GzipFile.close | def close(self):
"""Closes the gzip with care to handle multiple members.
"""
if self.fileobj is None:
return
if self.mode == WRITE:
self.close_member()
self.fileobj = None
elif self.mode == READ:
self.fileobj = None
... | python | def close(self):
"""Closes the gzip with care to handle multiple members.
"""
if self.fileobj is None:
return
if self.mode == WRITE:
self.close_member()
self.fileobj = None
elif self.mode == READ:
self.fileobj = None
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"fileobj",
"is",
"None",
":",
"return",
"if",
"self",
".",
"mode",
"==",
"WRITE",
":",
"self",
".",
"close_member",
"(",
")",
"self",
".",
"fileobj",
"=",
"None",
"elif",
"self",
".",
"mode"... | Closes the gzip with care to handle multiple members. | [
"Closes",
"the",
"gzip",
"with",
"care",
"to",
"handle",
"multiple",
"members",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/gzip2.py#L73-L86 |
internetarchive/warc | warc/gzip2.py | GzipFile.read_member | def read_member(self):
"""Returns a file-like object to read one member from the gzip file.
"""
if self._member_lock is False:
self._member_lock = True
if self._new_member:
try:
# Read one byte to move to the next member
BaseGzipFi... | python | def read_member(self):
"""Returns a file-like object to read one member from the gzip file.
"""
if self._member_lock is False:
self._member_lock = True
if self._new_member:
try:
# Read one byte to move to the next member
BaseGzipFi... | [
"def",
"read_member",
"(",
"self",
")",
":",
"if",
"self",
".",
"_member_lock",
"is",
"False",
":",
"self",
".",
"_member_lock",
"=",
"True",
"if",
"self",
".",
"_new_member",
":",
"try",
":",
"# Read one byte to move to the next member",
"BaseGzipFile",
".",
... | Returns a file-like object to read one member from the gzip file. | [
"Returns",
"a",
"file",
"-",
"like",
"object",
"to",
"read",
"one",
"member",
"from",
"the",
"gzip",
"file",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/gzip2.py#L95-L109 |
internetarchive/warc | warc/gzip2.py | GzipFile.write_member | def write_member(self, data):
"""Writes the given data as one gzip member.
The data can be a string, an iterator that gives strings or a file-like object.
"""
if isinstance(data, basestring):
self.write(data)
else:
for text in data:
... | python | def write_member(self, data):
"""Writes the given data as one gzip member.
The data can be a string, an iterator that gives strings or a file-like object.
"""
if isinstance(data, basestring):
self.write(data)
else:
for text in data:
... | [
"def",
"write_member",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"basestring",
")",
":",
"self",
".",
"write",
"(",
"data",
")",
"else",
":",
"for",
"text",
"in",
"data",
":",
"self",
".",
"write",
"(",
"text",
")",
... | Writes the given data as one gzip member.
The data can be a string, an iterator that gives strings or a file-like object. | [
"Writes",
"the",
"given",
"data",
"as",
"one",
"gzip",
"member",
".",
"The",
"data",
"can",
"be",
"a",
"string",
"an",
"iterator",
"that",
"gives",
"strings",
"or",
"a",
"file",
"-",
"like",
"object",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/gzip2.py#L111-L121 |
internetarchive/warc | warc/arc.py | ARCHeader.write_to | def write_to(self, f, version = None):
"""
Writes out the arc header to the file like object `f`.
If the version field is 1, it writes out an arc v1 header,
otherwise (and this is default), it outputs a v2 header.
"""
if not version:
version = self.version
... | python | def write_to(self, f, version = None):
"""
Writes out the arc header to the file like object `f`.
If the version field is 1, it writes out an arc v1 header,
otherwise (and this is default), it outputs a v2 header.
"""
if not version:
version = self.version
... | [
"def",
"write_to",
"(",
"self",
",",
"f",
",",
"version",
"=",
"None",
")",
":",
"if",
"not",
"version",
":",
"version",
"=",
"self",
".",
"version",
"if",
"version",
"==",
"1",
":",
"header",
"=",
"\"%(url)s %(ip_address)s %(date)s %(content_type)s %(length)s... | Writes out the arc header to the file like object `f`.
If the version field is 1, it writes out an arc v1 header,
otherwise (and this is default), it outputs a v2 header. | [
"Writes",
"out",
"the",
"arc",
"header",
"to",
"the",
"file",
"like",
"object",
"f",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L69-L94 |
internetarchive/warc | warc/arc.py | ARCRecord.from_string | def from_string(cls, string, version):
"""
Constructs an ARC record from a string and returns it.
TODO: It might be best to merge this with the _read_arc_record
function rather than reimplement the functionality here.
"""
header, payload = string.split("\n",1)
... | python | def from_string(cls, string, version):
"""
Constructs an ARC record from a string and returns it.
TODO: It might be best to merge this with the _read_arc_record
function rather than reimplement the functionality here.
"""
header, payload = string.split("\n",1)
... | [
"def",
"from_string",
"(",
"cls",
",",
"string",
",",
"version",
")",
":",
"header",
",",
"payload",
"=",
"string",
".",
"split",
"(",
"\"\\n\"",
",",
"1",
")",
"if",
"payload",
"[",
"0",
"]",
"==",
"'\\n'",
":",
"# There's an extra",
"payload",
"=",
... | Constructs an ARC record from a string and returns it.
TODO: It might be best to merge this with the _read_arc_record
function rather than reimplement the functionality here. | [
"Constructs",
"an",
"ARC",
"record",
"from",
"a",
"string",
"and",
"returns",
"it",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L161-L179 |
internetarchive/warc | warc/arc.py | ARCFile._write_header | def _write_header(self):
"Writes out an ARC header"
if "org" not in self.file_headers:
warnings.warn("Using 'unknown' for Archiving organisation name")
self.file_headers['org'] = "Unknown"
if "date" not in self.file_headers:
now = datetime.datetime.utcnow()
... | python | def _write_header(self):
"Writes out an ARC header"
if "org" not in self.file_headers:
warnings.warn("Using 'unknown' for Archiving organisation name")
self.file_headers['org'] = "Unknown"
if "date" not in self.file_headers:
now = datetime.datetime.utcnow()
... | [
"def",
"_write_header",
"(",
"self",
")",
":",
"if",
"\"org\"",
"not",
"in",
"self",
".",
"file_headers",
":",
"warnings",
".",
"warn",
"(",
"\"Using 'unknown' for Archiving organisation name\"",
")",
"self",
".",
"file_headers",
"[",
"'org'",
"]",
"=",
"\"Unkno... | Writes out an ARC header | [
"Writes",
"out",
"an",
"ARC",
"header"
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L264-L295 |
internetarchive/warc | warc/arc.py | ARCFile.write | def write(self, arc_record):
"Writes out the given arc record to the file"
if not self.version:
self.version = 2
if not self.header_written:
self.header_written = True
self._write_header()
arc_record.write_to(self.fileobj, self.version)
self.fi... | python | def write(self, arc_record):
"Writes out the given arc record to the file"
if not self.version:
self.version = 2
if not self.header_written:
self.header_written = True
self._write_header()
arc_record.write_to(self.fileobj, self.version)
self.fi... | [
"def",
"write",
"(",
"self",
",",
"arc_record",
")",
":",
"if",
"not",
"self",
".",
"version",
":",
"self",
".",
"version",
"=",
"2",
"if",
"not",
"self",
".",
"header_written",
":",
"self",
".",
"header_written",
"=",
"True",
"self",
".",
"_write_head... | Writes out the given arc record to the file | [
"Writes",
"out",
"the",
"given",
"arc",
"record",
"to",
"the",
"file"
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L297-L305 |
internetarchive/warc | warc/arc.py | ARCFile._read_file_header | def _read_file_header(self):
"""Reads out the file header for the arc file. If version was
not provided, this will autopopulate it."""
header = self.fileobj.readline()
payload1 = self.fileobj.readline()
payload2 = self.fileobj.readline()
version, reserved, organisation = ... | python | def _read_file_header(self):
"""Reads out the file header for the arc file. If version was
not provided, this will autopopulate it."""
header = self.fileobj.readline()
payload1 = self.fileobj.readline()
payload2 = self.fileobj.readline()
version, reserved, organisation = ... | [
"def",
"_read_file_header",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"fileobj",
".",
"readline",
"(",
")",
"payload1",
"=",
"self",
".",
"fileobj",
".",
"readline",
"(",
")",
"payload2",
"=",
"self",
".",
"fileobj",
".",
"readline",
"(",
")",... | Reads out the file header for the arc file. If version was
not provided, this will autopopulate it. | [
"Reads",
"out",
"the",
"file",
"header",
"for",
"the",
"arc",
"file",
".",
"If",
"version",
"was",
"not",
"provided",
"this",
"will",
"autopopulate",
"it",
"."
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L307-L335 |
internetarchive/warc | warc/arc.py | ARCFile._read_arc_record | def _read_arc_record(self):
"Reads out an arc record, formats it and returns it"
#XXX:Noufal Stream payload here rather than just read it
# r = self.fileobj.readline() # Drop the initial newline
# if r == "":
# return None
# header = self.fileobj.readline()
#... | python | def _read_arc_record(self):
"Reads out an arc record, formats it and returns it"
#XXX:Noufal Stream payload here rather than just read it
# r = self.fileobj.readline() # Drop the initial newline
# if r == "":
# return None
# header = self.fileobj.readline()
#... | [
"def",
"_read_arc_record",
"(",
"self",
")",
":",
"#XXX:Noufal Stream payload here rather than just read it",
"# r = self.fileobj.readline() # Drop the initial newline",
"# if r == \"\":",
"# return None",
"# header = self.fileobj.readline()",
"# Strip the initial new lines and read first ... | Reads out an arc record, formats it and returns it | [
"Reads",
"out",
"an",
"arc",
"record",
"formats",
"it",
"and",
"returns",
"it"
] | train | https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L337-L366 |
figo-connect/schwifty | schwifty/bic.py | BIC.from_bank_code | def from_bank_code(cls, country_code, bank_code):
"""Create a new BIC object from country- and bank-code.
Examples:
>>> bic = BIC.from_bank_code('DE', '20070000')
>>> bic.country_code
'DE'
>>> bic.bank_code
'DEUT'
>>> bic.location_... | python | def from_bank_code(cls, country_code, bank_code):
"""Create a new BIC object from country- and bank-code.
Examples:
>>> bic = BIC.from_bank_code('DE', '20070000')
>>> bic.country_code
'DE'
>>> bic.bank_code
'DEUT'
>>> bic.location_... | [
"def",
"from_bank_code",
"(",
"cls",
",",
"country_code",
",",
"bank_code",
")",
":",
"try",
":",
"return",
"cls",
"(",
"registry",
".",
"get",
"(",
"'bank_code'",
")",
"[",
"(",
"country_code",
",",
"bank_code",
")",
"]",
"[",
"'bic'",
"]",
")",
"exce... | Create a new BIC object from country- and bank-code.
Examples:
>>> bic = BIC.from_bank_code('DE', '20070000')
>>> bic.country_code
'DE'
>>> bic.bank_code
'DEUT'
>>> bic.location_code
'HH'
>>> BIC.from_bank_code('DE... | [
"Create",
"a",
"new",
"BIC",
"object",
"from",
"country",
"-",
"and",
"bank",
"-",
"code",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/bic.py#L45-L80 |
figo-connect/schwifty | schwifty/bic.py | BIC.formatted | def formatted(self):
"""str: The BIC separated in the blocks bank-, country- and location-code."""
formatted = ' '.join([self.bank_code, self.country_code, self.location_code])
if self.branch_code:
formatted += ' ' + self.branch_code
return formatted | python | def formatted(self):
"""str: The BIC separated in the blocks bank-, country- and location-code."""
formatted = ' '.join([self.bank_code, self.country_code, self.location_code])
if self.branch_code:
formatted += ' ' + self.branch_code
return formatted | [
"def",
"formatted",
"(",
"self",
")",
":",
"formatted",
"=",
"' '",
".",
"join",
"(",
"[",
"self",
".",
"bank_code",
",",
"self",
".",
"country_code",
",",
"self",
".",
"location_code",
"]",
")",
"if",
"self",
".",
"branch_code",
":",
"formatted",
"+="... | str: The BIC separated in the blocks bank-, country- and location-code. | [
"str",
":",
"The",
"BIC",
"separated",
"in",
"the",
"blocks",
"bank",
"-",
"country",
"-",
"and",
"location",
"-",
"code",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/bic.py#L104-L109 |
figo-connect/schwifty | schwifty/bic.py | BIC.country_bank_code | def country_bank_code(self):
"""str or None: The country specific bank-code associated with the BIC."""
entry = registry.get('bic').get(self.compact)
if entry:
return entry.get('bank_code') | python | def country_bank_code(self):
"""str or None: The country specific bank-code associated with the BIC."""
entry = registry.get('bic').get(self.compact)
if entry:
return entry.get('bank_code') | [
"def",
"country_bank_code",
"(",
"self",
")",
":",
"entry",
"=",
"registry",
".",
"get",
"(",
"'bic'",
")",
".",
"get",
"(",
"self",
".",
"compact",
")",
"if",
"entry",
":",
"return",
"entry",
".",
"get",
"(",
"'bank_code'",
")"
] | str or None: The country specific bank-code associated with the BIC. | [
"str",
"or",
"None",
":",
"The",
"country",
"specific",
"bank",
"-",
"code",
"associated",
"with",
"the",
"BIC",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/bic.py#L112-L116 |
figo-connect/schwifty | schwifty/bic.py | BIC.bank_name | def bank_name(self):
"""str or None: The name of the bank associated with the BIC."""
entry = registry.get('bic').get(self.compact)
if entry:
return entry.get('name') | python | def bank_name(self):
"""str or None: The name of the bank associated with the BIC."""
entry = registry.get('bic').get(self.compact)
if entry:
return entry.get('name') | [
"def",
"bank_name",
"(",
"self",
")",
":",
"entry",
"=",
"registry",
".",
"get",
"(",
"'bic'",
")",
".",
"get",
"(",
"self",
".",
"compact",
")",
"if",
"entry",
":",
"return",
"entry",
".",
"get",
"(",
"'name'",
")"
] | str or None: The name of the bank associated with the BIC. | [
"str",
"or",
"None",
":",
"The",
"name",
"of",
"the",
"bank",
"associated",
"with",
"the",
"BIC",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/bic.py#L119-L123 |
figo-connect/schwifty | schwifty/bic.py | BIC.bank_short_name | def bank_short_name(self):
"""str or None: The short name of the bank associated with the BIC."""
entry = registry.get('bic').get(self.compact)
if entry:
return entry.get('short_name') | python | def bank_short_name(self):
"""str or None: The short name of the bank associated with the BIC."""
entry = registry.get('bic').get(self.compact)
if entry:
return entry.get('short_name') | [
"def",
"bank_short_name",
"(",
"self",
")",
":",
"entry",
"=",
"registry",
".",
"get",
"(",
"'bic'",
")",
".",
"get",
"(",
"self",
".",
"compact",
")",
"if",
"entry",
":",
"return",
"entry",
".",
"get",
"(",
"'short_name'",
")"
] | str or None: The short name of the bank associated with the BIC. | [
"str",
"or",
"None",
":",
"The",
"short",
"name",
"of",
"the",
"bank",
"associated",
"with",
"the",
"BIC",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/bic.py#L126-L130 |
figo-connect/schwifty | schwifty/iban.py | IBAN.generate | def generate(cls, country_code, bank_code, account_code):
"""Generate an IBAN from it's components.
If the bank-code and/or account-number have less digits than required by their
country specific representation, the respective component is padded with zeros.
Examples:
To g... | python | def generate(cls, country_code, bank_code, account_code):
"""Generate an IBAN from it's components.
If the bank-code and/or account-number have less digits than required by their
country specific representation, the respective component is padded with zeros.
Examples:
To g... | [
"def",
"generate",
"(",
"cls",
",",
"country_code",
",",
"bank_code",
",",
"account_code",
")",
":",
"spec",
"=",
"_get_iban_spec",
"(",
"country_code",
")",
"bank_code_length",
"=",
"code_length",
"(",
"spec",
",",
"'bank_code'",
")",
"branch_code_length",
"=",... | Generate an IBAN from it's components.
If the bank-code and/or account-number have less digits than required by their
country specific representation, the respective component is padded with zeros.
Examples:
To generate an IBAN do the following::
>>> bank_code = '... | [
"Generate",
"an",
"IBAN",
"from",
"it",
"s",
"components",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/iban.py#L75-L113 |
figo-connect/schwifty | schwifty/iban.py | IBAN.formatted | def formatted(self):
"""str: The IBAN formatted in blocks of 4 digits."""
return ' '.join(self.compact[i:i + 4] for i in range(0, len(self.compact), 4)) | python | def formatted(self):
"""str: The IBAN formatted in blocks of 4 digits."""
return ' '.join(self.compact[i:i + 4] for i in range(0, len(self.compact), 4)) | [
"def",
"formatted",
"(",
"self",
")",
":",
"return",
"' '",
".",
"join",
"(",
"self",
".",
"compact",
"[",
"i",
":",
"i",
"+",
"4",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"compact",
")",
",",
"4",
")",
")"
] | str: The IBAN formatted in blocks of 4 digits. | [
"str",
":",
"The",
"IBAN",
"formatted",
"in",
"blocks",
"of",
"4",
"digits",
"."
] | train | https://github.com/figo-connect/schwifty/blob/69376fade070dbfdf89c57a0060bc290f7a744bb/schwifty/iban.py#L145-L147 |
ZELLMECHANIK-DRESDEN/dclab | dclab/cli.py | tdms2rtdc | def tdms2rtdc():
"""Convert .tdms datasets to the hdf5-based .rtdc file format"""
parser = tdms2rtdc_parser()
args = parser.parse_args()
path_tdms = pathlib.Path(args.tdms_path).resolve()
path_rtdc = pathlib.Path(args.rtdc_path)
# Determine whether input path is a tdms file or a directory
... | python | def tdms2rtdc():
"""Convert .tdms datasets to the hdf5-based .rtdc file format"""
parser = tdms2rtdc_parser()
args = parser.parse_args()
path_tdms = pathlib.Path(args.tdms_path).resolve()
path_rtdc = pathlib.Path(args.rtdc_path)
# Determine whether input path is a tdms file or a directory
... | [
"def",
"tdms2rtdc",
"(",
")",
":",
"parser",
"=",
"tdms2rtdc_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"path_tdms",
"=",
"pathlib",
".",
"Path",
"(",
"args",
".",
"tdms_path",
")",
".",
"resolve",
"(",
")",
"path_rtdc",
"="... | Convert .tdms datasets to the hdf5-based .rtdc file format | [
"Convert",
".",
"tdms",
"datasets",
"to",
"the",
"hdf5",
"-",
"based",
".",
"rtdc",
"file",
"format"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/cli.py#L21-L75 |
ZELLMECHANIK-DRESDEN/dclab | dclab/cli.py | verify_dataset | def verify_dataset():
"""Perform checks on experimental datasets"""
parser = verify_dataset_parser()
args = parser.parse_args()
path_in = pathlib.Path(args.path).resolve()
viol, aler, info = load.check_dataset(path_in)
print_info("Checking {}".format(path_in))
for inf in info:
print_... | python | def verify_dataset():
"""Perform checks on experimental datasets"""
parser = verify_dataset_parser()
args = parser.parse_args()
path_in = pathlib.Path(args.path).resolve()
viol, aler, info = load.check_dataset(path_in)
print_info("Checking {}".format(path_in))
for inf in info:
print_... | [
"def",
"verify_dataset",
"(",
")",
":",
"parser",
"=",
"verify_dataset_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"path_in",
"=",
"pathlib",
".",
"Path",
"(",
"args",
".",
"path",
")",
".",
"resolve",
"(",
")",
"viol",
",",
... | Perform checks on experimental datasets | [
"Perform",
"checks",
"on",
"experimental",
"datasets"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/cli.py#L105-L119 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/config.py | load_from_file | def load_from_file(cfg_file):
"""Load the configuration from a file
Parameters
----------
cfg_file: str
Path to configuration file
Returns
-------
cfg : CaseInsensitiveDict
Dictionary with configuration parameters
"""
path = pathlib.Path(cfg_file).resolve()
wi... | python | def load_from_file(cfg_file):
"""Load the configuration from a file
Parameters
----------
cfg_file: str
Path to configuration file
Returns
-------
cfg : CaseInsensitiveDict
Dictionary with configuration parameters
"""
path = pathlib.Path(cfg_file).resolve()
wi... | [
"def",
"load_from_file",
"(",
"cfg_file",
")",
":",
"path",
"=",
"pathlib",
".",
"Path",
"(",
"cfg_file",
")",
".",
"resolve",
"(",
")",
"with",
"path",
".",
"open",
"(",
"'r'",
")",
"as",
"f",
":",
"code",
"=",
"f",
".",
"readlines",
"(",
")",
"... | Load the configuration from a file
Parameters
----------
cfg_file: str
Path to configuration file
Returns
-------
cfg : CaseInsensitiveDict
Dictionary with configuration parameters | [
"Load",
"the",
"configuration",
"from",
"a",
"file"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/config.py#L190-L234 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/config.py | keyval_str2typ | def keyval_str2typ(var, val):
"""Convert a variable from a string to its correct type
Parameters
----------
var: str
The variable name
val: str
The value of the variable represented as a string
Returns
-------
varout: str
Stripped lowercase `var`
valout: any... | python | def keyval_str2typ(var, val):
"""Convert a variable from a string to its correct type
Parameters
----------
var: str
The variable name
val: str
The value of the variable represented as a string
Returns
-------
varout: str
Stripped lowercase `var`
valout: any... | [
"def",
"keyval_str2typ",
"(",
"var",
",",
"val",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"val",
",",
"str_types",
")",
")",
":",
"# already a type:",
"return",
"var",
".",
"strip",
"(",
")",
",",
"val",
"var",
"=",
"var",
".",
"strip",
"(",
... | Convert a variable from a string to its correct type
Parameters
----------
var: str
The variable name
val: str
The value of the variable represented as a string
Returns
-------
varout: str
Stripped lowercase `var`
valout: any type
The value converted fro... | [
"Convert",
"a",
"variable",
"from",
"a",
"string",
"to",
"its",
"correct",
"type"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/config.py#L237-L291 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/config.py | keyval_typ2str | def keyval_typ2str(var, val):
"""Convert a variable to a string
Parameters
----------
var: str
The variable name
val: any type
The value of the variable
Returns
-------
varout: str
Stripped lowercase `var`
valout: any type
The value converted to a us... | python | def keyval_typ2str(var, val):
"""Convert a variable to a string
Parameters
----------
var: str
The variable name
val: any type
The value of the variable
Returns
-------
varout: str
Stripped lowercase `var`
valout: any type
The value converted to a us... | [
"def",
"keyval_typ2str",
"(",
"var",
",",
"val",
")",
":",
"varout",
"=",
"var",
".",
"strip",
"(",
")",
"if",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"data",
"=",
"\", \"",
".",
"join",
"(",
"[",
"keyval_typ2str",
"(",
"var",
",",
"it",
... | Convert a variable to a string
Parameters
----------
var: str
The variable name
val: any type
The value of the variable
Returns
-------
varout: str
Stripped lowercase `var`
valout: any type
The value converted to a useful string representation
See A... | [
"Convert",
"a",
"variable",
"to",
"a",
"string"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/config.py#L294-L323 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/config.py | Configuration._init_default_values | def _init_default_values(self):
"""Set default initial values
The default values are hard-coded for backwards compatibility
and for several functionalities in dclab.
"""
# Do not filter out invalid event values
self["filtering"]["remove invalid events"] = False
#... | python | def _init_default_values(self):
"""Set default initial values
The default values are hard-coded for backwards compatibility
and for several functionalities in dclab.
"""
# Do not filter out invalid event values
self["filtering"]["remove invalid events"] = False
#... | [
"def",
"_init_default_values",
"(",
"self",
")",
":",
"# Do not filter out invalid event values",
"self",
"[",
"\"filtering\"",
"]",
"[",
"\"remove invalid events\"",
"]",
"=",
"False",
"# Enable filters switch is mandatory",
"self",
"[",
"\"filtering\"",
"]",
"[",
"\"ena... | Set default initial values
The default values are hard-coded for backwards compatibility
and for several functionalities in dclab. | [
"Set",
"default",
"initial",
"values"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/config.py#L130-L150 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/config.py | Configuration.save | def save(self, filename):
"""Save the configuration to a file"""
filename = pathlib.Path(filename)
out = []
keys = sorted(list(self.keys()))
for key in keys:
out.append("[{}]".format(key))
section = self[key]
ikeys = list(section.keys())
... | python | def save(self, filename):
"""Save the configuration to a file"""
filename = pathlib.Path(filename)
out = []
keys = sorted(list(self.keys()))
for key in keys:
out.append("[{}]".format(key))
section = self[key]
ikeys = list(section.keys())
... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"filename",
"=",
"pathlib",
".",
"Path",
"(",
"filename",
")",
"out",
"=",
"[",
"]",
"keys",
"=",
"sorted",
"(",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
")",
"for",
"key",
"in",
"k... | Save the configuration to a file | [
"Save",
"the",
"configuration",
"to",
"a",
"file"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/config.py#L160-L179 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/config.py | Configuration.update | def update(self, newcfg):
"""Update current config with a dictionary"""
for key in newcfg.keys():
if key not in self._cfg:
self._cfg[key] = CaseInsensitiveDict()
for skey in newcfg[key]:
self._cfg[key][skey] = newcfg[key][skey] | python | def update(self, newcfg):
"""Update current config with a dictionary"""
for key in newcfg.keys():
if key not in self._cfg:
self._cfg[key] = CaseInsensitiveDict()
for skey in newcfg[key]:
self._cfg[key][skey] = newcfg[key][skey] | [
"def",
"update",
"(",
"self",
",",
"newcfg",
")",
":",
"for",
"key",
"in",
"newcfg",
".",
"keys",
"(",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_cfg",
":",
"self",
".",
"_cfg",
"[",
"key",
"]",
"=",
"CaseInsensitiveDict",
"(",
")",
"for"... | Update current config with a dictionary | [
"Update",
"current",
"config",
"with",
"a",
"dictionary"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/config.py#L181-L187 |
ZELLMECHANIK-DRESDEN/dclab | dclab/features/emodulus.py | convert | def convert(area_um, deform, emodulus,
channel_width_in, channel_width_out,
flow_rate_in, flow_rate_out,
viscosity_in, viscosity_out,
inplace=False):
"""convert area-deformation-emodulus triplet
The conversion formula is described in :cite:`Mietke2015`.
Para... | python | def convert(area_um, deform, emodulus,
channel_width_in, channel_width_out,
flow_rate_in, flow_rate_out,
viscosity_in, viscosity_out,
inplace=False):
"""convert area-deformation-emodulus triplet
The conversion formula is described in :cite:`Mietke2015`.
Para... | [
"def",
"convert",
"(",
"area_um",
",",
"deform",
",",
"emodulus",
",",
"channel_width_in",
",",
"channel_width_out",
",",
"flow_rate_in",
",",
"flow_rate_out",
",",
"viscosity_in",
",",
"viscosity_out",
",",
"inplace",
"=",
"False",
")",
":",
"copy",
"=",
"not... | convert area-deformation-emodulus triplet
The conversion formula is described in :cite:`Mietke2015`.
Parameters
----------
area_um: ndarray
Convex cell area [µm²]
deform: ndarray
Deformation
emodulus: ndarray
Young's Modulus [kPa]
channel_width_in: float
Ori... | [
"convert",
"area",
"-",
"deformation",
"-",
"emodulus",
"triplet"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/features/emodulus.py#L15-L72 |
ZELLMECHANIK-DRESDEN/dclab | dclab/features/emodulus.py | corrpix_deform_delta | def corrpix_deform_delta(area_um, px_um=0.34):
"""Deformation correction term for pixelation effects
The contour in RT-DC measurements is computed on a
pixelated grid. Due to sampling problems, the measured
deformation is overestimated and must be corrected.
The correction formula is described in ... | python | def corrpix_deform_delta(area_um, px_um=0.34):
"""Deformation correction term for pixelation effects
The contour in RT-DC measurements is computed on a
pixelated grid. Due to sampling problems, the measured
deformation is overestimated and must be corrected.
The correction formula is described in ... | [
"def",
"corrpix_deform_delta",
"(",
"area_um",
",",
"px_um",
"=",
"0.34",
")",
":",
"# A triple-exponential decay can be used to correct for pixelation",
"# for apparent cell areas between 10 and 1250µm².",
"# For 99 different radii between 0.4 μm and 20 μm circular objects were",
"# simul... | Deformation correction term for pixelation effects
The contour in RT-DC measurements is computed on a
pixelated grid. Due to sampling problems, the measured
deformation is overestimated and must be corrected.
The correction formula is described in :cite:`Herold2017`.
Parameters
----------
... | [
"Deformation",
"correction",
"term",
"for",
"pixelation",
"effects"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/features/emodulus.py#L75-L117 |
ZELLMECHANIK-DRESDEN/dclab | dclab/features/emodulus.py | get_emodulus | def get_emodulus(area_um, deform, medium="CellCarrier",
channel_width=20.0, flow_rate=0.16, px_um=0.34,
temperature=23.0, copy=True):
"""Compute apparent Young's modulus using a look-up table
Parameters
----------
area_um: float or ndarray
Apparent (2D image) a... | python | def get_emodulus(area_um, deform, medium="CellCarrier",
channel_width=20.0, flow_rate=0.16, px_um=0.34,
temperature=23.0, copy=True):
"""Compute apparent Young's modulus using a look-up table
Parameters
----------
area_um: float or ndarray
Apparent (2D image) a... | [
"def",
"get_emodulus",
"(",
"area_um",
",",
"deform",
",",
"medium",
"=",
"\"CellCarrier\"",
",",
"channel_width",
"=",
"20.0",
",",
"flow_rate",
"=",
"0.16",
",",
"px_um",
"=",
"0.34",
",",
"temperature",
"=",
"23.0",
",",
"copy",
"=",
"True",
")",
":",... | Compute apparent Young's modulus using a look-up table
Parameters
----------
area_um: float or ndarray
Apparent (2D image) area [µm²] of the event(s)
deform: float or ndarray
The deformation (1-circularity) of the event(s)
medium: str or float
The medium to compute the visco... | [
"Compute",
"apparent",
"Young",
"s",
"modulus",
"using",
"a",
"look",
"-",
"up",
"table"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/features/emodulus.py#L120-L220 |
openstax/cnx-archive | cnxarchive/views/search.py | search | def search(request):
"""Search API."""
empty_response = json.dumps({
u'query': {
u'limits': [],
u'per_page': DEFAULT_PER_PAGE,
u'page': 1,
},
u'results': {
u'items': [],
u'total': 0,
u'limits': [],
},... | python | def search(request):
"""Search API."""
empty_response = json.dumps({
u'query': {
u'limits': [],
u'per_page': DEFAULT_PER_PAGE,
u'page': 1,
},
u'results': {
u'items': [],
u'total': 0,
u'limits': [],
},... | [
"def",
"search",
"(",
"request",
")",
":",
"empty_response",
"=",
"json",
".",
"dumps",
"(",
"{",
"u'query'",
":",
"{",
"u'limits'",
":",
"[",
"]",
",",
"u'per_page'",
":",
"DEFAULT_PER_PAGE",
",",
"u'page'",
":",
"1",
",",
"}",
",",
"u'results'",
":",... | Search API. | [
"Search",
"API",
"."
] | train | https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/views/search.py#L40-L172 |
xenon-middleware/pyxenon | xenon/exceptions.py | make_exception | def make_exception(method, e):
"""Creates an exception for a given method, and RpcError."""
x = e.details()
name = x[:x.find(':')].split('.')[-1]
if name in globals():
cls = globals()[name]
else:
cls = UnknownRpcException # noqa
return cls(method, e.code(), e.details()) | python | def make_exception(method, e):
"""Creates an exception for a given method, and RpcError."""
x = e.details()
name = x[:x.find(':')].split('.')[-1]
if name in globals():
cls = globals()[name]
else:
cls = UnknownRpcException # noqa
return cls(method, e.code(), e.details()) | [
"def",
"make_exception",
"(",
"method",
",",
"e",
")",
":",
"x",
"=",
"e",
".",
"details",
"(",
")",
"name",
"=",
"x",
"[",
":",
"x",
".",
"find",
"(",
"':'",
")",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"if",
"name",
"in",
... | Creates an exception for a given method, and RpcError. | [
"Creates",
"an",
"exception",
"for",
"a",
"given",
"method",
"and",
"RpcError",
"."
] | train | https://github.com/xenon-middleware/pyxenon/blob/d61109ad339ee9bb9f0723471d532727b0f235ad/xenon/exceptions.py#L18-L27 |
robmcmullen/atrcopy | atrcopy/utils.py | text_to_int | def text_to_int(text, default_base="hex"):
""" Convert text to int, raising exeception on invalid input
"""
if text.startswith("0x"):
value = int(text[2:], 16)
elif text.startswith("$"):
value = int(text[1:], 16)
elif text.startswith("#"):
value = int(text[1:], 10)
elif t... | python | def text_to_int(text, default_base="hex"):
""" Convert text to int, raising exeception on invalid input
"""
if text.startswith("0x"):
value = int(text[2:], 16)
elif text.startswith("$"):
value = int(text[1:], 16)
elif text.startswith("#"):
value = int(text[1:], 10)
elif t... | [
"def",
"text_to_int",
"(",
"text",
",",
"default_base",
"=",
"\"hex\"",
")",
":",
"if",
"text",
".",
"startswith",
"(",
"\"0x\"",
")",
":",
"value",
"=",
"int",
"(",
"text",
"[",
"2",
":",
"]",
",",
"16",
")",
"elif",
"text",
".",
"startswith",
"("... | Convert text to int, raising exeception on invalid input | [
"Convert",
"text",
"to",
"int",
"raising",
"exeception",
"on",
"invalid",
"input"
] | train | https://github.com/robmcmullen/atrcopy/blob/dafba8e74c718e95cf81fd72c184fa193ecec730/atrcopy/utils.py#L44-L60 |
robmcmullen/atrcopy | atrcopy/utils.py | VTOC.assign_sector_numbers | def assign_sector_numbers(self, dirent, sector_list):
""" Map out the sectors and link the sectors together
raises NotEnoughSpaceOnDisk if the whole file won't fit. It will not
allow partial writes.
"""
num = len(sector_list)
order = self.reserve_space(num)
if le... | python | def assign_sector_numbers(self, dirent, sector_list):
""" Map out the sectors and link the sectors together
raises NotEnoughSpaceOnDisk if the whole file won't fit. It will not
allow partial writes.
"""
num = len(sector_list)
order = self.reserve_space(num)
if le... | [
"def",
"assign_sector_numbers",
"(",
"self",
",",
"dirent",
",",
"sector_list",
")",
":",
"num",
"=",
"len",
"(",
"sector_list",
")",
"order",
"=",
"self",
".",
"reserve_space",
"(",
"num",
")",
"if",
"len",
"(",
"order",
")",
"!=",
"num",
":",
"raise"... | Map out the sectors and link the sectors together
raises NotEnoughSpaceOnDisk if the whole file won't fit. It will not
allow partial writes. | [
"Map",
"out",
"the",
"sectors",
"and",
"link",
"the",
"sectors",
"together"
] | train | https://github.com/robmcmullen/atrcopy/blob/dafba8e74c718e95cf81fd72c184fa193ecec730/atrcopy/utils.py#L322-L343 |
ZELLMECHANIK-DRESDEN/dclab | dclab/downsampling.py | downsample_rand | def downsample_rand(a, samples, remove_invalid=False, ret_idx=False):
"""Downsampling by randomly removing points
Parameters
----------
a: 1d ndarray
The input array to downsample
samples: int
The desired number of samples
remove_invalid: bool
Remove nan and inf values b... | python | def downsample_rand(a, samples, remove_invalid=False, ret_idx=False):
"""Downsampling by randomly removing points
Parameters
----------
a: 1d ndarray
The input array to downsample
samples: int
The desired number of samples
remove_invalid: bool
Remove nan and inf values b... | [
"def",
"downsample_rand",
"(",
"a",
",",
"samples",
",",
"remove_invalid",
"=",
"False",
",",
"ret_idx",
"=",
"False",
")",
":",
"# fixed random state for this method",
"rs",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"seed",
"=",
"47",
")",
".",
"... | Downsampling by randomly removing points
Parameters
----------
a: 1d ndarray
The input array to downsample
samples: int
The desired number of samples
remove_invalid: bool
Remove nan and inf values before downsampling
ret_idx: bool
Also return a boolean array that... | [
"Downsampling",
"by",
"randomly",
"removing",
"points"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/downsampling.py#L11-L68 |
ZELLMECHANIK-DRESDEN/dclab | dclab/downsampling.py | downsample_grid | def downsample_grid(a, b, samples, ret_idx=False):
"""Content-based downsampling for faster visualization
The arrays `a` and `b` make up a 2D scatter plot with high
and low density values. This method takes out points at
indices with high density.
Parameters
----------
a, b: 1d ndarrays
... | python | def downsample_grid(a, b, samples, ret_idx=False):
"""Content-based downsampling for faster visualization
The arrays `a` and `b` make up a 2D scatter plot with high
and low density values. This method takes out points at
indices with high density.
Parameters
----------
a, b: 1d ndarrays
... | [
"def",
"downsample_grid",
"(",
"a",
",",
"b",
",",
"samples",
",",
"ret_idx",
"=",
"False",
")",
":",
"# fixed random state for this method",
"rs",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"seed",
"=",
"47",
")",
".",
"get_state",
"(",
")",
"sa... | Content-based downsampling for faster visualization
The arrays `a` and `b` make up a 2D scatter plot with high
and low density values. This method takes out points at
indices with high density.
Parameters
----------
a, b: 1d ndarrays
The input arrays to downsample
samples: int
... | [
"Content",
"-",
"based",
"downsampling",
"for",
"faster",
"visualization"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/downsampling.py#L72-L167 |
ZELLMECHANIK-DRESDEN/dclab | dclab/downsampling.py | valid | def valid(a, b):
"""Check whether `a` and `b` are not inf or nan"""
return ~(np.isnan(a) | np.isinf(a) | np.isnan(b) | np.isinf(b)) | python | def valid(a, b):
"""Check whether `a` and `b` are not inf or nan"""
return ~(np.isnan(a) | np.isinf(a) | np.isnan(b) | np.isinf(b)) | [
"def",
"valid",
"(",
"a",
",",
"b",
")",
":",
"return",
"~",
"(",
"np",
".",
"isnan",
"(",
"a",
")",
"|",
"np",
".",
"isinf",
"(",
"a",
")",
"|",
"np",
".",
"isnan",
"(",
"b",
")",
"|",
"np",
".",
"isinf",
"(",
"b",
")",
")"
] | Check whether `a` and `b` are not inf or nan | [
"Check",
"whether",
"a",
"and",
"b",
"are",
"not",
"inf",
"or",
"nan"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/downsampling.py#L170-L172 |
ZELLMECHANIK-DRESDEN/dclab | dclab/downsampling.py | norm | def norm(a, ref1, ref2):
"""
Normalize `a` with min/max values of `ref1`, using all elements of
`ref1` where the `ref1` and `ref2` are not nan or inf"""
ref = ref1[valid(ref1, ref2)]
return (a-ref.min())/(ref.max()-ref.min()) | python | def norm(a, ref1, ref2):
"""
Normalize `a` with min/max values of `ref1`, using all elements of
`ref1` where the `ref1` and `ref2` are not nan or inf"""
ref = ref1[valid(ref1, ref2)]
return (a-ref.min())/(ref.max()-ref.min()) | [
"def",
"norm",
"(",
"a",
",",
"ref1",
",",
"ref2",
")",
":",
"ref",
"=",
"ref1",
"[",
"valid",
"(",
"ref1",
",",
"ref2",
")",
"]",
"return",
"(",
"a",
"-",
"ref",
".",
"min",
"(",
")",
")",
"/",
"(",
"ref",
".",
"max",
"(",
")",
"-",
"ref... | Normalize `a` with min/max values of `ref1`, using all elements of
`ref1` where the `ref1` and `ref2` are not nan or inf | [
"Normalize",
"a",
"with",
"min",
"/",
"max",
"values",
"of",
"ref1",
"using",
"all",
"elements",
"of",
"ref1",
"where",
"the",
"ref1",
"and",
"ref2",
"are",
"not",
"nan",
"or",
"inf"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/downsampling.py#L175-L180 |
ZELLMECHANIK-DRESDEN/dclab | dclab/external/statsmodels/nonparametric/kernels.py | gaussian | def gaussian(h, Xi, x):
"""
Gaussian Kernel for continuous variables
Parameters
----------
h : 1-D ndarray, shape (K,)
The bandwidths used to estimate the value of the kernel function.
Xi : 1-D ndarray, shape (K,)
The value of the training set.
x : 1-D ndarray, shape (K,)
... | python | def gaussian(h, Xi, x):
"""
Gaussian Kernel for continuous variables
Parameters
----------
h : 1-D ndarray, shape (K,)
The bandwidths used to estimate the value of the kernel function.
Xi : 1-D ndarray, shape (K,)
The value of the training set.
x : 1-D ndarray, shape (K,)
... | [
"def",
"gaussian",
"(",
"h",
",",
"Xi",
",",
"x",
")",
":",
"return",
"(",
"1.",
"/",
"np",
".",
"sqrt",
"(",
"2",
"*",
"np",
".",
"pi",
")",
")",
"*",
"np",
".",
"exp",
"(",
"-",
"(",
"Xi",
"-",
"x",
")",
"**",
"2",
"/",
"(",
"h",
"*... | Gaussian Kernel for continuous variables
Parameters
----------
h : 1-D ndarray, shape (K,)
The bandwidths used to estimate the value of the kernel function.
Xi : 1-D ndarray, shape (K,)
The value of the training set.
x : 1-D ndarray, shape (K,)
The value at which the kernel d... | [
"Gaussian",
"Kernel",
"for",
"continuous",
"variables",
"Parameters",
"----------",
"h",
":",
"1",
"-",
"D",
"ndarray",
"shape",
"(",
"K",
")",
"The",
"bandwidths",
"used",
"to",
"estimate",
"the",
"value",
"of",
"the",
"kernel",
"function",
".",
"Xi",
":"... | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/external/statsmodels/nonparametric/kernels.py#L19-L37 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/fmt_hdf5.py | RTDC_HDF5.parse_config | def parse_config(h5path):
"""Parse the RT-DC configuration of an hdf5 file"""
with h5py.File(h5path, mode="r") as fh5:
h5attrs = dict(fh5.attrs)
# Convert byte strings to unicode strings
# https://github.com/h5py/h5py/issues/379
for key in h5attrs:
if isi... | python | def parse_config(h5path):
"""Parse the RT-DC configuration of an hdf5 file"""
with h5py.File(h5path, mode="r") as fh5:
h5attrs = dict(fh5.attrs)
# Convert byte strings to unicode strings
# https://github.com/h5py/h5py/issues/379
for key in h5attrs:
if isi... | [
"def",
"parse_config",
"(",
"h5path",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"h5path",
",",
"mode",
"=",
"\"r\"",
")",
"as",
"fh5",
":",
"h5attrs",
"=",
"dict",
"(",
"fh5",
".",
"attrs",
")",
"# Convert byte strings to unicode strings",
"# https://githu... | Parse the RT-DC configuration of an hdf5 file | [
"Parse",
"the",
"RT",
"-",
"DC",
"configuration",
"of",
"an",
"hdf5",
"file"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/fmt_hdf5.py#L144-L167 |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/fmt_hdf5.py | RTDC_HDF5.hash | def hash(self):
"""Hash value based on file name and content"""
if self._hash is None:
tohash = [self.path.name]
# Hash a maximum of ~1MB of the hdf5 file
tohash.append(hashfile(self.path, blocksize=65536, count=20))
self._hash = hashobj(tohash)
re... | python | def hash(self):
"""Hash value based on file name and content"""
if self._hash is None:
tohash = [self.path.name]
# Hash a maximum of ~1MB of the hdf5 file
tohash.append(hashfile(self.path, blocksize=65536, count=20))
self._hash = hashobj(tohash)
re... | [
"def",
"hash",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hash",
"is",
"None",
":",
"tohash",
"=",
"[",
"self",
".",
"path",
".",
"name",
"]",
"# Hash a maximum of ~1MB of the hdf5 file",
"tohash",
".",
"append",
"(",
"hashfile",
"(",
"self",
".",
"path... | Hash value based on file name and content | [
"Hash",
"value",
"based",
"on",
"file",
"name",
"and",
"content"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/fmt_hdf5.py#L170-L177 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | bin_num_doane | def bin_num_doane(a):
"""Compute number of bins based on Doane's formula"""
bad = np.isnan(a) | np.isinf(a)
data = a[~bad]
acc = bin_width_doane(a)
num = np.int(np.round((data.max() - data.min()) / acc))
return num | python | def bin_num_doane(a):
"""Compute number of bins based on Doane's formula"""
bad = np.isnan(a) | np.isinf(a)
data = a[~bad]
acc = bin_width_doane(a)
num = np.int(np.round((data.max() - data.min()) / acc))
return num | [
"def",
"bin_num_doane",
"(",
"a",
")",
":",
"bad",
"=",
"np",
".",
"isnan",
"(",
"a",
")",
"|",
"np",
".",
"isinf",
"(",
"a",
")",
"data",
"=",
"a",
"[",
"~",
"bad",
"]",
"acc",
"=",
"bin_width_doane",
"(",
"a",
")",
"num",
"=",
"np",
".",
... | Compute number of bins based on Doane's formula | [
"Compute",
"number",
"of",
"bins",
"based",
"on",
"Doane",
"s",
"formula"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L14-L20 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | bin_width_doane | def bin_width_doane(a):
"""Compute accuracy (bin width) based on Doane's formula
References
----------
- `<https://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width>`_
- `<https://stats.stackexchange.com/questions/55134/
doanes-formula-for-histogram-binning>`_
"""
bad = np.isna... | python | def bin_width_doane(a):
"""Compute accuracy (bin width) based on Doane's formula
References
----------
- `<https://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width>`_
- `<https://stats.stackexchange.com/questions/55134/
doanes-formula-for-histogram-binning>`_
"""
bad = np.isna... | [
"def",
"bin_width_doane",
"(",
"a",
")",
":",
"bad",
"=",
"np",
".",
"isnan",
"(",
"a",
")",
"|",
"np",
".",
"isinf",
"(",
"a",
")",
"data",
"=",
"a",
"[",
"~",
"bad",
"]",
"n",
"=",
"data",
".",
"size",
"g1",
"=",
"skew",
"(",
"data",
")",... | Compute accuracy (bin width) based on Doane's formula
References
----------
- `<https://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width>`_
- `<https://stats.stackexchange.com/questions/55134/
doanes-formula-for-histogram-binning>`_ | [
"Compute",
"accuracy",
"(",
"bin",
"width",
")",
"based",
"on",
"Doane",
"s",
"formula"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L23-L39 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | ignore_nan_inf | def ignore_nan_inf(kde_method):
"""Ignores nans and infs from the input data
Invalid positions in the resulting density are set to nan.
"""
def new_kde_method(events_x, events_y, xout=None, yout=None,
*args, **kwargs):
bad_in = get_bad_vals(events_x, events_y)
if ... | python | def ignore_nan_inf(kde_method):
"""Ignores nans and infs from the input data
Invalid positions in the resulting density are set to nan.
"""
def new_kde_method(events_x, events_y, xout=None, yout=None,
*args, **kwargs):
bad_in = get_bad_vals(events_x, events_y)
if ... | [
"def",
"ignore_nan_inf",
"(",
"kde_method",
")",
":",
"def",
"new_kde_method",
"(",
"events_x",
",",
"events_y",
",",
"xout",
"=",
"None",
",",
"yout",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"bad_in",
"=",
"get_bad_vals",
"("... | Ignores nans and infs from the input data
Invalid positions in the resulting density are set to nan. | [
"Ignores",
"nans",
"and",
"infs",
"from",
"the",
"input",
"data"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L46-L77 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | kde_gauss | def kde_gauss(events_x, events_y, xout=None, yout=None):
""" Gaussian Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which... | python | def kde_gauss(events_x, events_y, xout=None, yout=None):
""" Gaussian Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which... | [
"def",
"kde_gauss",
"(",
"events_x",
",",
"events_y",
",",
"xout",
"=",
"None",
",",
"yout",
"=",
"None",
")",
":",
"valid_combi",
"=",
"(",
"(",
"xout",
"is",
"None",
"and",
"yout",
"is",
"None",
")",
"or",
"(",
"xout",
"is",
"not",
"None",
"and",... | Gaussian Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which the KDE should be computed.
If set to none, input coordi... | [
"Gaussian",
"Kernel",
"Density",
"Estimation"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L82-L119 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | kde_histogram | def kde_histogram(events_x, events_y, xout=None, yout=None, bins=None):
""" Histogram-based Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
Th... | python | def kde_histogram(events_x, events_y, xout=None, yout=None, bins=None):
""" Histogram-based Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
Th... | [
"def",
"kde_histogram",
"(",
"events_x",
",",
"events_y",
",",
"xout",
"=",
"None",
",",
"yout",
"=",
"None",
",",
"bins",
"=",
"None",
")",
":",
"valid_combi",
"=",
"(",
"(",
"xout",
"is",
"None",
"and",
"yout",
"is",
"None",
")",
"or",
"(",
"xout... | Histogram-based Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which the KDE should be computed.
If set to none, input... | [
"Histogram",
"-",
"based",
"Kernel",
"Density",
"Estimation"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L124-L174 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | kde_none | def kde_none(events_x, events_y, xout=None, yout=None):
""" No Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which the KD... | python | def kde_none(events_x, events_y, xout=None, yout=None):
""" No Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which the KD... | [
"def",
"kde_none",
"(",
"events_x",
",",
"events_y",
",",
"xout",
"=",
"None",
",",
"yout",
"=",
"None",
")",
":",
"valid_combi",
"=",
"(",
"(",
"xout",
"is",
"None",
"and",
"yout",
"is",
"None",
")",
"or",
"(",
"xout",
"is",
"not",
"None",
"and",
... | No Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
xout, yout: ndarray
The coordinates at which the KDE should be computed.
If set to none, input coordinates ... | [
"No",
"Kernel",
"Density",
"Estimation"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L177-L209 |
ZELLMECHANIK-DRESDEN/dclab | dclab/kde_methods.py | kde_multivariate | def kde_multivariate(events_x, events_y, xout=None, yout=None, bw=None):
""" Multivariate Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
bw: tuple (bwx, bwy) or None
... | python | def kde_multivariate(events_x, events_y, xout=None, yout=None, bw=None):
""" Multivariate Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
bw: tuple (bwx, bwy) or None
... | [
"def",
"kde_multivariate",
"(",
"events_x",
",",
"events_y",
",",
"xout",
"=",
"None",
",",
"yout",
"=",
"None",
",",
"bw",
"=",
"None",
")",
":",
"valid_combi",
"=",
"(",
"(",
"xout",
"is",
"None",
"and",
"yout",
"is",
"None",
")",
"or",
"(",
"xou... | Multivariate Kernel Density Estimation
Parameters
----------
events_x, events_y: 1D ndarray
The input points for kernel density estimation. Input
is flattened automatically.
bw: tuple (bwx, bwy) or None
The bandwith for kernel density estimation.
xout, yout: ndarray
... | [
"Multivariate",
"Kernel",
"Density",
"Estimation"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/kde_methods.py#L214-L257 |
openstax/cnx-archive | cnxarchive/views/legacy_redirect.py | redirect_legacy_content | def redirect_legacy_content(request):
"""Redirect from legacy /content/id/version to new /contents/uuid@version.
Handles collection context (book) as well.
"""
routing_args = request.matchdict
objid = routing_args['objid']
objver = routing_args.get('objver')
filename = routing_args.get('fil... | python | def redirect_legacy_content(request):
"""Redirect from legacy /content/id/version to new /contents/uuid@version.
Handles collection context (book) as well.
"""
routing_args = request.matchdict
objid = routing_args['objid']
objver = routing_args.get('objver')
filename = routing_args.get('fil... | [
"def",
"redirect_legacy_content",
"(",
"request",
")",
":",
"routing_args",
"=",
"request",
".",
"matchdict",
"objid",
"=",
"routing_args",
"[",
"'objid'",
"]",
"objver",
"=",
"routing_args",
".",
"get",
"(",
"'objver'",
")",
"filename",
"=",
"routing_args",
"... | Redirect from legacy /content/id/version to new /contents/uuid@version.
Handles collection context (book) as well. | [
"Redirect",
"from",
"legacy",
"/",
"content",
"/",
"id",
"/",
"version",
"to",
"new",
"/",
"contents",
"/",
"uuid@version",
"."
] | train | https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/views/legacy_redirect.py#L72-L119 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics._add | def _add(self, isoel, col1, col2, method, meta):
"""Convenience method for population self._data"""
self._data[method][col1][col2]["isoelastics"] = isoel
self._data[method][col1][col2]["meta"] = meta
# Use advanced slicing to flip the data columns
isoel_flip = [iso[:, [1, 0, 2]]... | python | def _add(self, isoel, col1, col2, method, meta):
"""Convenience method for population self._data"""
self._data[method][col1][col2]["isoelastics"] = isoel
self._data[method][col1][col2]["meta"] = meta
# Use advanced slicing to flip the data columns
isoel_flip = [iso[:, [1, 0, 2]]... | [
"def",
"_add",
"(",
"self",
",",
"isoel",
",",
"col1",
",",
"col2",
",",
"method",
",",
"meta",
")",
":",
"self",
".",
"_data",
"[",
"method",
"]",
"[",
"col1",
"]",
"[",
"col2",
"]",
"[",
"\"isoelastics\"",
"]",
"=",
"isoel",
"self",
".",
"_data... | Convenience method for population self._data | [
"Convenience",
"method",
"for",
"population",
"self",
".",
"_data"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L33-L41 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics.add | def add(self, isoel, col1, col2, channel_width,
flow_rate, viscosity, method):
"""Add isoelastics
Parameters
----------
isoel: list of ndarrays
Each list item resembles one isoelastic line stored
as an array of shape (N,3). The last column contains
... | python | def add(self, isoel, col1, col2, channel_width,
flow_rate, viscosity, method):
"""Add isoelastics
Parameters
----------
isoel: list of ndarrays
Each list item resembles one isoelastic line stored
as an array of shape (N,3). The last column contains
... | [
"def",
"add",
"(",
"self",
",",
"isoel",
",",
"col1",
",",
"col2",
",",
"channel_width",
",",
"flow_rate",
",",
"viscosity",
",",
"method",
")",
":",
"if",
"method",
"not",
"in",
"VALID_METHODS",
":",
"validstr",
"=",
"\",\"",
".",
"join",
"(",
"VALID_... | Add isoelastics
Parameters
----------
isoel: list of ndarrays
Each list item resembles one isoelastic line stored
as an array of shape (N,3). The last column contains
the emodulus data.
col1: str
Name of the first feature of all isoelastic... | [
"Add",
"isoelastics"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L43-L102 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics.add_px_err | def add_px_err(isoel, col1, col2, px_um, inplace=False):
"""Undo pixelation correction
Isoelasticity lines are already corrected for pixelation
effects as described in
Mapping of Deformation to Apparent Young's Modulus
in Real-Time Deformability Cytometry
Christoph Hero... | python | def add_px_err(isoel, col1, col2, px_um, inplace=False):
"""Undo pixelation correction
Isoelasticity lines are already corrected for pixelation
effects as described in
Mapping of Deformation to Apparent Young's Modulus
in Real-Time Deformability Cytometry
Christoph Hero... | [
"def",
"add_px_err",
"(",
"isoel",
",",
"col1",
",",
"col2",
",",
"px_um",
",",
"inplace",
"=",
"False",
")",
":",
"Isoelastics",
".",
"check_col12",
"(",
"col1",
",",
"col2",
")",
"if",
"\"deform\"",
"in",
"[",
"col1",
",",
"col2",
"]",
":",
"# add ... | Undo pixelation correction
Isoelasticity lines are already corrected for pixelation
effects as described in
Mapping of Deformation to Apparent Young's Modulus
in Real-Time Deformability Cytometry
Christoph Herold, arXiv:1704.00572 [cond-mat.soft] (2017)
https://arxiv.or... | [
"Undo",
"pixelation",
"correction"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L105-L154 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics.convert | def convert(isoel, col1, col2,
channel_width_in, channel_width_out,
flow_rate_in, flow_rate_out,
viscosity_in, viscosity_out,
inplace=False):
"""Convert isoelastics in area_um-deform space
Parameters
----------
isoel: list ... | python | def convert(isoel, col1, col2,
channel_width_in, channel_width_out,
flow_rate_in, flow_rate_out,
viscosity_in, viscosity_out,
inplace=False):
"""Convert isoelastics in area_um-deform space
Parameters
----------
isoel: list ... | [
"def",
"convert",
"(",
"isoel",
",",
"col1",
",",
"col2",
",",
"channel_width_in",
",",
"channel_width_out",
",",
"flow_rate_in",
",",
"flow_rate_out",
",",
"viscosity_in",
",",
"viscosity_out",
",",
"inplace",
"=",
"False",
")",
":",
"Isoelastics",
".",
"chec... | Convert isoelastics in area_um-deform space
Parameters
----------
isoel: list of 2d ndarrays of shape (N, 3)
Each item in the list corresponds to one isoelasticity
line. The first column is defined by `col1`, the second
by `col2`, and the third column is the ... | [
"Convert",
"isoelastics",
"in",
"area_um",
"-",
"deform",
"space"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L168-L231 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics.get | def get(self, col1, col2, method, channel_width, flow_rate=None,
viscosity=None, add_px_err=False, px_um=None):
"""Get isoelastics
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g. isoel[0][:,0])
col2: str
... | python | def get(self, col1, col2, method, channel_width, flow_rate=None,
viscosity=None, add_px_err=False, px_um=None):
"""Get isoelastics
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g. isoel[0][:,0])
col2: str
... | [
"def",
"get",
"(",
"self",
",",
"col1",
",",
"col2",
",",
"method",
",",
"channel_width",
",",
"flow_rate",
"=",
"None",
",",
"viscosity",
"=",
"None",
",",
"add_px_err",
"=",
"False",
",",
"px_um",
"=",
"None",
")",
":",
"if",
"method",
"not",
"in",... | Get isoelastics
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g. isoel[0][:,0])
col2: str
Name of the second feature of all isoelastics
(e.g. isoel[0][:,1])
method: str
The method used ... | [
"Get",
"isoelastics"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L233-L310 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics.get_with_rtdcbase | def get_with_rtdcbase(self, col1, col2, method, dataset,
viscosity=None, add_px_err=False):
"""Convenience method that extracts the metadata from RTDCBase
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g.... | python | def get_with_rtdcbase(self, col1, col2, method, dataset,
viscosity=None, add_px_err=False):
"""Convenience method that extracts the metadata from RTDCBase
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g.... | [
"def",
"get_with_rtdcbase",
"(",
"self",
",",
"col1",
",",
"col2",
",",
"method",
",",
"dataset",
",",
"viscosity",
"=",
"None",
",",
"add_px_err",
"=",
"False",
")",
":",
"cfg",
"=",
"dataset",
".",
"config",
"return",
"self",
".",
"get",
"(",
"col1",... | Convenience method that extracts the metadata from RTDCBase
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g. isoel[0][:,0])
col2: str
Name of the second feature of all isoelastics
(e.g. isoel[0][:,1])
... | [
"Convenience",
"method",
"that",
"extracts",
"the",
"metadata",
"from",
"RTDCBase"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L312-L346 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | Isoelastics.load_data | def load_data(self, path):
"""Load isoelastics from a text file
The text file is loaded with `numpy.loadtxt` and must have
three columns, representing the two data columns and the
elastic modulus with units defined in `definitions.py`.
The file header must have a section definin... | python | def load_data(self, path):
"""Load isoelastics from a text file
The text file is loaded with `numpy.loadtxt` and must have
three columns, representing the two data columns and the
elastic modulus with units defined in `definitions.py`.
The file header must have a section definin... | [
"def",
"load_data",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"pathlib",
".",
"Path",
"(",
"path",
")",
".",
"resolve",
"(",
")",
"# Get metadata",
"meta",
"=",
"{",
"}",
"with",
"path",
".",
"open",
"(",
")",
"as",
"fd",
":",
"while",
"Tr... | Load isoelastics from a text file
The text file is loaded with `numpy.loadtxt` and must have
three columns, representing the two data columns and the
elastic modulus with units defined in `definitions.py`.
The file header must have a section defining meta data of the
content lik... | [
"Load",
"isoelastics",
"from",
"a",
"text",
"file"
] | train | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L348-L417 |
openstax/cnx-archive | cnxarchive/views/robots.py | robots | def robots(request):
"""Return a simple "don't index me" robots.txt file."""
resp = request.response
resp.status = '200 OK'
resp.content_type = 'text/plain'
resp.body = """
User-Agent: *
Disallow: /
"""
return resp | python | def robots(request):
"""Return a simple "don't index me" robots.txt file."""
resp = request.response
resp.status = '200 OK'
resp.content_type = 'text/plain'
resp.body = """
User-Agent: *
Disallow: /
"""
return resp | [
"def",
"robots",
"(",
"request",
")",
":",
"resp",
"=",
"request",
".",
"response",
"resp",
".",
"status",
"=",
"'200 OK'",
"resp",
".",
"content_type",
"=",
"'text/plain'",
"resp",
".",
"body",
"=",
"\"\"\"\nUser-Agent: *\nDisallow: /\n\"\"\"",
"return",
"resp"... | Return a simple "don't index me" robots.txt file. | [
"Return",
"a",
"simple",
"don",
"t",
"index",
"me",
"robots",
".",
"txt",
"file",
"."
] | train | https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/views/robots.py#L14-L24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.