partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | LookupLib.copy_data_in_redis | Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redis
Returns:
bool: returns True when the data has been copied... | pyhamtools/lookuplib.py | def copy_data_in_redis(self, redis_prefix, redis_instance):
"""
Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redi... | def copy_data_in_redis(self, redis_prefix, redis_instance):
"""
Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redi... | [
"Copy",
"the",
"complete",
"lookup",
"data",
"into",
"redis",
".",
"Old",
"data",
"will",
"be",
"overwritten",
"."
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L151-L223 | [
"def",
"copy_data_in_redis",
"(",
"self",
",",
"redis_prefix",
",",
"redis_instance",
")",
":",
"if",
"redis_instance",
"is",
"not",
"None",
":",
"self",
".",
"_redis",
"=",
"redis_instance",
"if",
"self",
".",
"_redis",
"is",
"None",
":",
"raise",
"Attribut... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib.lookup_entity | Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:
The following code queries the the Cl... | pyhamtools/lookuplib.py | def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:... | def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:... | [
"Returns",
"lookup",
"data",
"of",
"an",
"ADIF",
"Entity"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L243-L302 | [
"def",
"lookup_entity",
"(",
"self",
",",
"entity",
"=",
"None",
")",
":",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogxml\"",
":",
"entity",
"=",
"int",
"(",
"entity",
")",
"if",
"entity",
"in",
"self",
".",
"_entities",
":",
"return",
"self",
"... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._strip_metadata | Create a copy of dict and remove not needed data | pyhamtools/lookuplib.py | def _strip_metadata(self, my_dict):
"""
Create a copy of dict and remove not needed data
"""
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.... | def _strip_metadata(self, my_dict):
"""
Create a copy of dict and remove not needed data
"""
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.... | [
"Create",
"a",
"copy",
"of",
"dict",
"and",
"remove",
"not",
"needed",
"data"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L304-L319 | [
"def",
"_strip_metadata",
"(",
"self",
",",
"my_dict",
")",
":",
"new_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"my_dict",
")",
"if",
"const",
".",
"START",
"in",
"new_dict",
":",
"del",
"new_dict",
"[",
"const",
".",
"START",
"]",
"if",
"const",
".",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib.lookup_callsign | Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary containing the country specific data of the callsign
Raises... | pyhamtools/lookuplib.py | def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
"""
Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
... | def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
"""
Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
... | [
"Returns",
"lookup",
"data",
"if",
"an",
"exception",
"exists",
"for",
"a",
"callsign"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L322-L388 | [
"def",
"lookup_callsign",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"timestamp",
"=",
"timestamp_now",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogapi\"",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._get_dicts_from_redis | Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface. | pyhamtools/lookuplib.py | def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
"""
Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface.
"""
r = self._redis
data_dict = {}
data_index_dict = {}
if r... | def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
"""
Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface.
"""
r = self._redis
data_dict = {}
data_index_dict = {}
if r... | [
"Retrieve",
"the",
"data",
"of",
"an",
"item",
"from",
"redis",
"and",
"put",
"it",
"in",
"an",
"index",
"and",
"data",
"dictionary",
"to",
"match",
"the",
"common",
"query",
"interface",
"."
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L390-L411 | [
"def",
"_get_dicts_from_redis",
"(",
"self",
",",
"name",
",",
"index_name",
",",
"redis_prefix",
",",
"item",
")",
":",
"r",
"=",
"self",
".",
"_redis",
"data_dict",
"=",
"{",
"}",
"data_index_dict",
"=",
"{",
"}",
"if",
"redis_prefix",
"is",
"None",
":... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._check_data_for_date | Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the data is returned. Otherwise a KeyError is raised. | pyhamtools/lookuplib.py | def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the... | def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the... | [
"Checks",
"if",
"the",
"item",
"is",
"found",
"in",
"the",
"index",
".",
"An",
"entry",
"in",
"the",
"index",
"points",
"to",
"the",
"data",
"in",
"the",
"data_dict",
".",
"This",
"is",
"mainly",
"used",
"retrieve",
"callsigns",
"and",
"prefixes",
".",
... | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L413-L450 | [
"def",
"_check_data_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < timestamp",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._check_inv_operation_for_date | Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised. | pyhamtools/lookuplib.py | def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised.
"""
if item in data_index... | def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised.
"""
if item in data_index... | [
"Checks",
"if",
"the",
"callsign",
"is",
"marked",
"as",
"an",
"invalid",
"operation",
"for",
"a",
"given",
"timestamp",
".",
"In",
"case",
"the",
"operation",
"is",
"invalid",
"True",
"is",
"returned",
".",
"Otherwise",
"a",
"KeyError",
"is",
"raised",
".... | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L453-L482 | [
"def",
"_check_inv_operation_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < time... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib.lookup_prefix | Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary containing the country specific data of the Prefix
Raises:
KeyE... | pyhamtools/lookuplib.py | def lookup_prefix(self, prefix, timestamp=timestamp_now):
"""
Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary contai... | def lookup_prefix(self, prefix, timestamp=timestamp_now):
"""
Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary contai... | [
"Returns",
"lookup",
"data",
"of",
"a",
"Prefix"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L485-L538 | [
"def",
"lookup_prefix",
"(",
"self",
",",
"prefix",
",",
"timestamp",
"=",
"timestamp_now",
")",
":",
"prefix",
"=",
"prefix",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogxml\"",
"or",
"self",
".",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib.is_invalid_operation | Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
bool: True if a record exists for this callsign (at the given time)
Raises:
... | pyhamtools/lookuplib.py | def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Ret... | def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Ret... | [
"Returns",
"True",
"if",
"an",
"operations",
"is",
"known",
"as",
"invalid"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L540-L591 | [
"def",
"is_invalid_operation",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._check_zone_exception_for_date | Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised | pyhamtools/lookuplib.py | def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised
"""
if ... | def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised
"""
if ... | [
"Checks",
"the",
"index",
"and",
"data",
"if",
"a",
"cq",
"-",
"zone",
"exception",
"exists",
"for",
"the",
"callsign",
"When",
"a",
"zone",
"exception",
"is",
"found",
"the",
"zone",
"is",
"returned",
".",
"If",
"no",
"exception",
"is",
"found",
"a",
... | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L594-L624 | [
"def",
"_check_zone_exception_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < tim... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib.lookup_zone_exception | Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
int: Value of the the CQ Zone exception which exists for this callsign (at the given ti... | pyhamtools/lookuplib.py | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | [
"Returns",
"a",
"CQ",
"Zone",
"if",
"an",
"exception",
"exists",
"for",
"the",
"given",
"callsign"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L627-L673 | [
"def",
"lookup_zone_exception",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._lookup_clublogAPI | Set up the Lookup object for Clublog Online API | pyhamtools/lookuplib.py | def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublog Online API
"""
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : time... | def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublog Online API
"""
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : time... | [
"Set",
"up",
"the",
"Lookup",
"object",
"for",
"Clublog",
"Online",
"API"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L675-L712 | [
"def",
"_lookup_clublogAPI",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"timestamp",
"=",
"timestamp_now",
",",
"url",
"=",
"\"https://secure.clublog.org/dxcc\"",
",",
"apikey",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"year\"",
":",
"timestamp",
".",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._lookup_qrz_dxcc | Performs the dxcc lookup against the QRZ.com XML API: | pyhamtools/lookuplib.py | def _lookup_qrz_dxcc(self, dxcc_or_callsign, apikey, apiv="1.3.3"):
""" Performs the dxcc lookup against the QRZ.com XML API:
"""
response = self._request_dxcc_info_from_qrz(dxcc_or_callsign, apikey, apiv=apiv)
root = BeautifulSoup(response.text, "html.parser")
lookup = {}
... | def _lookup_qrz_dxcc(self, dxcc_or_callsign, apikey, apiv="1.3.3"):
""" Performs the dxcc lookup against the QRZ.com XML API:
"""
response = self._request_dxcc_info_from_qrz(dxcc_or_callsign, apikey, apiv=apiv)
root = BeautifulSoup(response.text, "html.parser")
lookup = {}
... | [
"Performs",
"the",
"dxcc",
"lookup",
"against",
"the",
"QRZ",
".",
"com",
"XML",
"API",
":"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L746-L790 | [
"def",
"_lookup_qrz_dxcc",
"(",
"self",
",",
"dxcc_or_callsign",
",",
"apikey",
",",
"apiv",
"=",
"\"1.3.3\"",
")",
":",
"response",
"=",
"self",
".",
"_request_dxcc_info_from_qrz",
"(",
"dxcc_or_callsign",
",",
"apikey",
",",
"apiv",
"=",
"apiv",
")",
"root",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._lookup_qrz_callsign | Performs the callsign lookup against the QRZ.com XML API: | pyhamtools/lookuplib.py | def _lookup_qrz_callsign(self, callsign=None, apikey=None, apiv="1.3.3"):
""" Performs the callsign lookup against the QRZ.com XML API:
"""
if apikey is None:
raise AttributeError("Session Key Missing")
callsign = callsign.upper()
response = self._request_callsign_... | def _lookup_qrz_callsign(self, callsign=None, apikey=None, apiv="1.3.3"):
""" Performs the callsign lookup against the QRZ.com XML API:
"""
if apikey is None:
raise AttributeError("Session Key Missing")
callsign = callsign.upper()
response = self._request_callsign_... | [
"Performs",
"the",
"callsign",
"lookup",
"against",
"the",
"QRZ",
".",
"com",
"XML",
"API",
":"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L793-L958 | [
"def",
"_lookup_qrz_callsign",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"apikey",
"=",
"None",
",",
"apiv",
"=",
"\"1.3.3\"",
")",
":",
"if",
"apikey",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"\"Session Key Missing\"",
")",
"callsign",
"=",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._load_clublogXML | Load and process the ClublogXML file either as a download or from file | pyhamtools/lookuplib.py | def _load_clublogXML(self,
url="https://secure.clublog.org/cty.php",
apikey=None,
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
if self._download:
cty_file = self... | def _load_clublogXML(self,
url="https://secure.clublog.org/cty.php",
apikey=None,
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
if self._download:
cty_file = self... | [
"Load",
"and",
"process",
"the",
"ClublogXML",
"file",
"either",
"as",
"a",
"download",
"or",
"from",
"file"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L960-L989 | [
"def",
"_load_clublogXML",
"(",
"self",
",",
"url",
"=",
"\"https://secure.clublog.org/cty.php\"",
",",
"apikey",
"=",
"None",
",",
"cty_file",
"=",
"None",
")",
":",
"if",
"self",
".",
"_download",
":",
"cty_file",
"=",
"self",
".",
"_download_file",
"(",
"... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._load_countryfile | Load and process the ClublogXML file either as a download or from file | pyhamtools/lookuplib.py | def _load_countryfile(self,
url="https://www.country-files.com/cty/cty.plist",
country_mapping_filename="countryfilemapping.json",
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
... | def _load_countryfile(self,
url="https://www.country-files.com/cty/cty.plist",
country_mapping_filename="countryfilemapping.json",
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
... | [
"Load",
"and",
"process",
"the",
"ClublogXML",
"file",
"either",
"as",
"a",
"download",
"or",
"from",
"file"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L991-L1023 | [
"def",
"_load_countryfile",
"(",
"self",
",",
"url",
"=",
"\"https://www.country-files.com/cty/cty.plist\"",
",",
"country_mapping_filename",
"=",
"\"countryfilemapping.json\"",
",",
"cty_file",
"=",
"None",
")",
":",
"cwdFile",
"=",
"os",
".",
"path",
".",
"abspath",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._download_file | Download lookup files either from Clublog or Country-files.com | pyhamtools/lookuplib.py | def _download_file(self, url, apikey=None):
""" Download lookup files either from Clublog or Country-files.com
"""
import gzip
import tempfile
cty = {}
cty_date = ""
cty_file_path = None
filename = None
# download file
if apikey: # clubl... | def _download_file(self, url, apikey=None):
""" Download lookup files either from Clublog or Country-files.com
"""
import gzip
import tempfile
cty = {}
cty_date = ""
cty_file_path = None
filename = None
# download file
if apikey: # clubl... | [
"Download",
"lookup",
"files",
"either",
"from",
"Clublog",
"or",
"Country",
"-",
"files",
".",
"com"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1025-L1082 | [
"def",
"_download_file",
"(",
"self",
",",
"url",
",",
"apikey",
"=",
"None",
")",
":",
"import",
"gzip",
"import",
"tempfile",
"cty",
"=",
"{",
"}",
"cty_date",
"=",
"\"\"",
"cty_file_path",
"=",
"None",
"filename",
"=",
"None",
"# download file",
"if",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._extract_clublog_header | Extract the header of the Clublog XML File | pyhamtools/lookuplib.py | def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File
"""
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_heade... | def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File
"""
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_heade... | [
"Extract",
"the",
"header",
"of",
"the",
"Clublog",
"XML",
"File"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1084-L1119 | [
"def",
"_extract_clublog_header",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"cty_header",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"cty_xml_filename",
",",
"\"r\"",
")",
"as",
"cty",
":",
"raw_header",
"=",
"cty",
".",
"readline",
"(",
")",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._remove_clublog_xml_header | remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser | pyhamtools/lookuplib.py | def _remove_clublog_xml_header(self, cty_xml_filename):
"""
remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser
"""
import tempfile
try:
with open(cty_xml_filename, "r") as f:
c... | def _remove_clublog_xml_header(self, cty_xml_filename):
"""
remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser
"""
import tempfile
try:
with open(cty_xml_filename, "r") as f:
c... | [
"remove",
"the",
"header",
"of",
"the",
"Clublog",
"XML",
"File",
"to",
"make",
"it",
"properly",
"parseable",
"for",
"the",
"python",
"ElementTree",
"XML",
"parser"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1122-L1147 | [
"def",
"_remove_clublog_xml_header",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"import",
"tempfile",
"try",
":",
"with",
"open",
"(",
"cty_xml_filename",
",",
"\"r\"",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"readlines",
"(",
")",
"cty_dir",
"... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._parse_clublog_xml | parse the content of a clublog XML file and return the
parsed values in dictionaries | pyhamtools/lookuplib.py | def _parse_clublog_xml(self, cty_xml_filename):
"""
parse the content of a clublog XML file and return the
parsed values in dictionaries
"""
entities = {}
call_exceptions = {}
prefixes = {}
invalid_operations = {}
zone_exceptions = {}
ca... | def _parse_clublog_xml(self, cty_xml_filename):
"""
parse the content of a clublog XML file and return the
parsed values in dictionaries
"""
entities = {}
call_exceptions = {}
prefixes = {}
invalid_operations = {}
zone_exceptions = {}
ca... | [
"parse",
"the",
"content",
"of",
"a",
"clublog",
"XML",
"file",
"and",
"return",
"the",
"parsed",
"values",
"in",
"dictionaries"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1149-L1364 | [
"def",
"_parse_clublog_xml",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"entities",
"=",
"{",
"}",
"call_exceptions",
"=",
"{",
"}",
"prefixes",
"=",
"{",
"}",
"invalid_operations",
"=",
"{",
"}",
"zone_exceptions",
"=",
"{",
"}",
"call_exceptions_index",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._parse_country_file | Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions | pyhamtools/lookuplib.py | def _parse_country_file(self, cty_file, country_mapping_filename=None):
"""
Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions
"""
import plistlib
cty_list = None... | def _parse_country_file(self, cty_file, country_mapping_filename=None):
"""
Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions
"""
import plistlib
cty_list = None... | [
"Parse",
"the",
"content",
"of",
"a",
"PLIST",
"file",
"from",
"country",
"-",
"files",
".",
"com",
"return",
"the",
"parsed",
"values",
"in",
"dictionaries",
".",
"Country",
"-",
"files",
".",
"com",
"provides",
"Prefixes",
"and",
"Exceptions"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1366-L1433 | [
"def",
"_parse_country_file",
"(",
"self",
",",
"cty_file",
",",
"country_mapping_filename",
"=",
"None",
")",
":",
"import",
"plistlib",
"cty_list",
"=",
"None",
"entities",
"=",
"{",
"}",
"exceptions",
"=",
"{",
"}",
"prefixes",
"=",
"{",
"}",
"exceptions_... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._generate_random_word | Generates a random word | pyhamtools/lookuplib.py | def _generate_random_word(self, length):
"""
Generates a random word
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) | def _generate_random_word(self, length):
"""
Generates a random word
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) | [
"Generates",
"a",
"random",
"word"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1435-L1439 | [
"def",
"_generate_random_word",
"(",
"self",
",",
"length",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_lowercase",
")",
"for",
"_",
"in",
"range",
"(",
"length",
")",
")"
] | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._check_html_response | Checks if the API Key is valid and if the request returned a 200 status (ok) | pyhamtools/lookuplib.py | def _check_html_response(self, response):
"""
Checks if the API Key is valid and if the request returned a 200 status (ok)
"""
error1 = "Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php"
error2 = "Invalid or missing API Key... | def _check_html_response(self, response):
"""
Checks if the API Key is valid and if the request returned a 200 status (ok)
"""
error1 = "Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php"
error2 = "Invalid or missing API Key... | [
"Checks",
"if",
"the",
"API",
"Key",
"is",
"valid",
"and",
"if",
"the",
"request",
"returned",
"a",
"200",
"status",
"(",
"ok",
")"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1441-L1457 | [
"def",
"_check_html_response",
"(",
"self",
",",
"response",
")",
":",
"error1",
"=",
"\"Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php\"",
"error2",
"=",
"\"Invalid or missing API Key\"",
"if",
"response",
".",
"status_code",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._serialize_data | Serialize a Dictionary into JSON | pyhamtools/lookuplib.py | def _serialize_data(self, my_dict):
"""
Serialize a Dictionary into JSON
"""
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_di... | def _serialize_data(self, my_dict):
"""
Serialize a Dictionary into JSON
"""
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_di... | [
"Serialize",
"a",
"Dictionary",
"into",
"JSON"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1460-L1471 | [
"def",
"_serialize_data",
"(",
"self",
",",
"my_dict",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"item",
"in",
"my_dict",
":",
"if",
"isinstance",
"(",
"my_dict",
"[",
"item",
"]",
",",
"datetime",
")",
":",
"new_dict",
"[",
"item",
"]",
"=",
"my_d... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | LookupLib._deserialize_data | Deserialize a JSON into a dictionary | pyhamtools/lookuplib.py | def _deserialize_data(self, json_data):
"""
Deserialize a JSON into a dictionary
"""
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dic... | def _deserialize_data(self, json_data):
"""
Deserialize a JSON into a dictionary
"""
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dic... | [
"Deserialize",
"a",
"JSON",
"into",
"a",
"dictionary"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1473-L1507 | [
"def",
"_deserialize_data",
"(",
"self",
",",
"json_data",
")",
":",
"my_dict",
"=",
"json",
".",
"loads",
"(",
"json_data",
".",
"decode",
"(",
"'utf8'",
")",
".",
"replace",
"(",
"\"'\"",
",",
"'\"'",
")",
",",
"encoding",
"=",
"'UTF-8'",
")",
"for",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | get_methods | Return the names of all callable attributes of an object | lightflow/models/mongo_proxy.py | def get_methods(*objs):
""" Return the names of all callable attributes of an object"""
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) | def get_methods(*objs):
""" Return the names of all callable attributes of an object"""
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) | [
"Return",
"the",
"names",
"of",
"all",
"callable",
"attributes",
"of",
"an",
"object"
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/mongo_proxy.py#L18-L25 | [
"def",
"get_methods",
"(",
"*",
"objs",
")",
":",
"return",
"set",
"(",
"attr",
"for",
"obj",
"in",
"objs",
"for",
"attr",
"in",
"dir",
"(",
"obj",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"and",
"callable",
"(",
"getattr",
"("... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Config.from_file | Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
Returns:
An instance of the Config cl... | lightflow/config.py | def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
... | def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
... | [
"Create",
"a",
"new",
"Config",
"object",
"from",
"a",
"configuration",
"file",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L43-L59 | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"config",
"=",
"cls",
"(",
")",
"config",
".",
"load_from_file",
"(",
"filename",
",",
"strict",
"=",
"strict",
")",
"return",
"config"
] | dc53dbc1d961e20fb144273baca258060705c03e |
train | Config.load_from_file | Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGHTFLOW_CONFIG_ENV
2. In the current execution directory
... | lightflow/config.py | def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGH... | def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGH... | [
"Load",
"the",
"configuration",
"from",
"a",
"file",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L61-L97 | [
"def",
"load_from_file",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"self",
".",
"set_to_default",
"(",
")",
"if",
"filename",
":",
"self",
".",
"_update_from_file",
"(",
"filename",
")",
"else",
":",
"if... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Config.load_from_dict | Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration. | lightflow/config.py | def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration.
"""
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() | def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration.
"""
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() | [
"Load",
"the",
"configuration",
"from",
"a",
"dictionary",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L99-L107 | [
"def",
"load_from_dict",
"(",
"self",
",",
"conf_dict",
"=",
"None",
")",
":",
"self",
".",
"set_to_default",
"(",
")",
"self",
".",
"_update_dict",
"(",
"self",
".",
"_config",
",",
"conf_dict",
")",
"self",
".",
"_update_python_paths",
"(",
")"
] | dc53dbc1d961e20fb144273baca258060705c03e |
train | Config._update_from_file | Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The path and name to the configuration file. | lightflow/config.py | def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The pat... | def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The pat... | [
"Helper",
"method",
"to",
"update",
"an",
"existing",
"configuration",
"with",
"the",
"values",
"from",
"a",
"file",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L169-L188 | [
"def",
"_update_from_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"config_file",
":",
"yaml_dict",
"=",
"yaml",
"... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Config._update_dict | Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict | lightflow/config.py | def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict
"""
for key, value in from_dict.items()... | def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict
"""
for key, value in from_dict.items()... | [
"Recursively",
"merges",
"the",
"fields",
"for",
"two",
"dictionaries",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L190-L202 | [
"def",
"_update_dict",
"(",
"self",
",",
"to_dict",
",",
"from_dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"from_dict",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"to_dict",
"and",
"isinstance",
"(",
"to_dict",
"[",
"key",
"]",
",",
"dict... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Config._update_python_paths | Append the workflow and libraries paths to the PYTHONPATH. | lightflow/config.py | def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
... | def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
... | [
"Append",
"the",
"workflow",
"and",
"libraries",
"paths",
"to",
"the",
"PYTHONPATH",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L204-L212 | [
"def",
"_update_python_paths",
"(",
"self",
")",
":",
"for",
"path",
"in",
"self",
".",
"_config",
"[",
"'workflows'",
"]",
"+",
"self",
".",
"_config",
"[",
"'libraries'",
"]",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",... | dc53dbc1d961e20fb144273baca258060705c03e |
train | decode_char_spot | Chop Line from DX-Cluster into pieces and return a dict with the spot data | pyhamtools/dxcluster.py | def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data"""
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
... | def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data"""
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
... | [
"Chop",
"Line",
"from",
"DX",
"-",
"Cluster",
"into",
"pieces",
"and",
"return",
"a",
"dict",
"with",
"the",
"spot",
"data"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L16-L36 | [
"def",
"decode_char_spot",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"# Spotter callsign",
"if",
"re",
".",
"match",
"(",
"'[A-Za-z0-9\\/]+[:$]'",
",",
"raw_string",
"[",
"6",
":",
"15",
"]",
")",
":",
"data",
"[",
"const",
".",
"SPOTTER",
"]",... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | decode_pc11_message | Decode PC11 message, which usually contains DX Spots | pyhamtools/dxcluster.py | def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots"""
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H... | def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots"""
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H... | [
"Decode",
"PC11",
"message",
"which",
"usually",
"contains",
"DX",
"Spots"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L38-L50 | [
"def",
"decode_pc11_message",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"spot",
"=",
"raw_string",
".",
"split",
"(",
"\"^\"",
")",
"data",
"[",
"const",
".",
"FREQUENCY",
"]",
"=",
"float",
"(",
"spot",
"[",
"1",
"]",
")",
"data",
"[",
"... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | decode_pc23_message | Decode PC23 Message which usually contains WCY | pyhamtools/dxcluster.py | def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = ... | def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = ... | [
"Decode",
"PC23",
"Message",
"which",
"usually",
"contains",
"WCY"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L68-L83 | [
"def",
"decode_pc23_message",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"wcy",
"=",
"raw_string",
".",
"split",
"(",
"\"^\"",
")",
"data",
"[",
"const",
".",
"R",
"]",
"=",
"int",
"(",
"wcy",
"[",
"1",
"]",
")",
"data",
"[",
"const",
".... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | BaseTask._run | The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskData): The data object that has been passed from the
predecessor task.
store (DataStoreDocument... | lightflow/models/task.py | def _run(self, data, store, signal, context, *,
success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskDat... | def _run(self, data, store, signal, context, *,
success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskDat... | [
"The",
"internal",
"run",
"method",
"that",
"decorates",
"the",
"public",
"run",
"method",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task.py#L208-L295 | [
"def",
"_run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
",",
"success_callback",
"=",
"None",
",",
"stop_callback",
"=",
"None",
",",
"abort_callback",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"d... | dc53dbc1d961e20fb144273baca258060705c03e |
train | latlong_to_locator | converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When called with wrong or invalid input args
T... | pyhamtools/locator.py | def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When ... | def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When ... | [
"converts",
"WGS84",
"coordinates",
"into",
"the",
"corresponding",
"Maidenhead",
"Locator"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L10-L55 | [
"def",
"latlong_to_locator",
"(",
"latitude",
",",
"longitude",
")",
":",
"if",
"longitude",
">=",
"180",
"or",
"longitude",
"<=",
"-",
"180",
":",
"raise",
"ValueError",
"if",
"latitude",
">=",
"90",
"or",
"latitude",
"<=",
"-",
"90",
":",
"raise",
"Val... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | locator_to_latlong | converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wrong or invalid input arg
TypeE... | pyhamtools/locator.py | def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wro... | def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wro... | [
"converts",
"Maidenhead",
"locator",
"in",
"the",
"corresponding",
"WGS84",
"coordinates"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L57-L125 | [
"def",
"locator_to_latlong",
"(",
"locator",
")",
":",
"locator",
"=",
"locator",
".",
"upper",
"(",
")",
"if",
"len",
"(",
"locator",
")",
"==",
"5",
"or",
"len",
"(",
"locator",
")",
"<",
"4",
":",
"raise",
"ValueError",
"if",
"ord",
"(",
"locator"... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | calculate_distance | calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
Raises:
ValueError: When called wi... | pyhamtools/locator.py | def calculate_distance(locator1, locator2):
"""calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
... | def calculate_distance(locator1, locator2):
"""calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
... | [
"calculates",
"the",
"(",
"shortpath",
")",
"distance",
"between",
"two",
"Maidenhead",
"locators"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L128-L167 | [
"def",
"calculate_distance",
"(",
"locator1",
",",
"locator2",
")",
":",
"R",
"=",
"6371",
"#earh radius",
"lat1",
",",
"long1",
"=",
"locator_to_latlong",
"(",
"locator1",
")",
"lat2",
",",
"long2",
"=",
"locator_to_latlong",
"(",
"locator2",
")",
"d_lat",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | calculate_distance_longpath | calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
Raises:
ValueError: When called wit... | pyhamtools/locator.py | def calculate_distance_longpath(locator1, locator2):
"""calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in... | def calculate_distance_longpath(locator1, locator2):
"""calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in... | [
"calculates",
"the",
"(",
"longpath",
")",
"distance",
"between",
"two",
"Maidenhead",
"locators"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L170-L196 | [
"def",
"calculate_distance_longpath",
"(",
"locator1",
",",
"locator2",
")",
":",
"c",
"=",
"40008",
"#[km] earth circumference",
"sp",
"=",
"calculate_distance",
"(",
"locator1",
",",
"locator2",
")",
"return",
"c",
"-",
"sp"
] | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | calculate_heading | calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Raises:
ValueError: When called with wrong... | pyhamtools/locator.py | def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Rais... | def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Rais... | [
"calculates",
"the",
"heading",
"from",
"the",
"first",
"to",
"the",
"second",
"locator"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L199-L237 | [
"def",
"calculate_heading",
"(",
"locator1",
",",
"locator2",
")",
":",
"lat1",
",",
"long1",
"=",
"locator_to_latlong",
"(",
"locator1",
")",
"lat2",
",",
"long2",
"=",
"locator_to_latlong",
"(",
"locator2",
")",
"r_lat1",
"=",
"radians",
"(",
"lat1",
")",
... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | calculate_heading_longpath | calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long path heading in deg
Raises:
ValueError: ... | pyhamtools/locator.py | def calculate_heading_longpath(locator1, locator2):
"""calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long pa... | def calculate_heading_longpath(locator1, locator2):
"""calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long pa... | [
"calculates",
"the",
"heading",
"from",
"the",
"first",
"to",
"the",
"second",
"locator",
"(",
"long",
"path",
")"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L239-L266 | [
"def",
"calculate_heading_longpath",
"(",
"locator1",
",",
"locator2",
")",
":",
"heading",
"=",
"calculate_heading",
"(",
"locator1",
",",
"locator2",
")",
"lp",
"=",
"(",
"heading",
"+",
"180",
")",
"%",
"360",
"return",
"lp"
] | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | calculate_sunrise_sunset | calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for the calculations (UTC)
Returns:
dict: Containing datetim... | pyhamtools/locator.py | def calculate_sunrise_sunset(locator, calc_date=datetime.utcnow()):
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for th... | def calculate_sunrise_sunset(locator, calc_date=datetime.utcnow()):
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for th... | [
"calculates",
"the",
"next",
"sunset",
"and",
"sunrise",
"for",
"a",
"Maidenhead",
"locator",
"at",
"a",
"give",
"date",
"&",
"time"
] | dh1tw/pyhamtools | python | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L268-L358 | [
"def",
"calculate_sunrise_sunset",
"(",
"locator",
",",
"calc_date",
"=",
"datetime",
".",
"utcnow",
"(",
")",
")",
":",
"morning_dawn",
"=",
"None",
"sunrise",
"=",
"None",
"evening_dawn",
"=",
"None",
"sunset",
"=",
"None",
"latitude",
",",
"longitude",
"=... | ee7e4b8732e23c298da10e07163748156c16d0fa |
train | cloudpickle_dumps | Encode Python objects into a byte stream using cloudpickle. | lightflow/queue/pickle.py | def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
""" Encode Python objects into a byte stream using cloudpickle. """
return dumper(obj, protocol=serialization.pickle_protocol) | def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
""" Encode Python objects into a byte stream using cloudpickle. """
return dumper(obj, protocol=serialization.pickle_protocol) | [
"Encode",
"Python",
"objects",
"into",
"a",
"byte",
"stream",
"using",
"cloudpickle",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/pickle.py#L18-L20 | [
"def",
"cloudpickle_dumps",
"(",
"obj",
",",
"dumper",
"=",
"cloudpickle",
".",
"dumps",
")",
":",
"return",
"dumper",
"(",
"obj",
",",
"protocol",
"=",
"serialization",
".",
"pickle_protocol",
")"
] | dc53dbc1d961e20fb144273baca258060705c03e |
train | patch_celery | Monkey patch Celery to use cloudpickle instead of pickle. | lightflow/queue/pickle.py | def patch_celery():
""" Monkey patch Celery to use cloudpickle instead of pickle. """
registry = serialization.registry
serialization.pickle = cloudpickle
registry.unregister('pickle')
registry.register('pickle', cloudpickle_dumps, cloudpickle_loads,
content_type='application/x... | def patch_celery():
""" Monkey patch Celery to use cloudpickle instead of pickle. """
registry = serialization.registry
serialization.pickle = cloudpickle
registry.unregister('pickle')
registry.register('pickle', cloudpickle_dumps, cloudpickle_loads,
content_type='application/x... | [
"Monkey",
"patch",
"Celery",
"to",
"use",
"cloudpickle",
"instead",
"of",
"pickle",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/pickle.py#L23-L40 | [
"def",
"patch_celery",
"(",
")",
":",
"registry",
"=",
"serialization",
".",
"registry",
"serialization",
".",
"pickle",
"=",
"cloudpickle",
"registry",
".",
"unregister",
"(",
"'pickle'",
")",
"registry",
".",
"register",
"(",
"'pickle'",
",",
"cloudpickle_dump... | dc53dbc1d961e20fb144273baca258060705c03e |
train | SignalConnection.connect | Connects to the redis database. | lightflow/models/signal.py | def connect(self):
""" Connects to the redis database. """
self._connection = StrictRedis(
host=self._host,
port=self._port,
db=self._database,
password=self._password) | def connect(self):
""" Connects to the redis database. """
self._connection = StrictRedis(
host=self._host,
port=self._port,
db=self._database,
password=self._password) | [
"Connects",
"to",
"the",
"redis",
"database",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L47-L53 | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_connection",
"=",
"StrictRedis",
"(",
"host",
"=",
"self",
".",
"_host",
",",
"port",
"=",
"self",
".",
"_port",
",",
"db",
"=",
"self",
".",
"_database",
",",
"password",
"=",
"self",
".",
"_... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Server.receive | Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is returned. | lightflow/models/signal.py | def receive(self):
""" Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is ... | def receive(self):
""" Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is ... | [
"Returns",
"a",
"single",
"request",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L118-L129 | [
"def",
"receive",
"(",
"self",
")",
":",
"pickled_request",
"=",
"self",
".",
"_connection",
".",
"connection",
".",
"lpop",
"(",
"self",
".",
"_request_key",
")",
"return",
"pickle",
".",
"loads",
"(",
"pickled_request",
")",
"if",
"pickled_request",
"is",
... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Server.send | Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent. | lightflow/models/signal.py | def send(self, response):
""" Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent.
"""
self._connection.connection.set('{}:{}'.format(SIGNAL_REDIS_PREFIX, response.uid),
... | def send(self, response):
""" Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent.
"""
self._connection.connection.set('{}:{}'.format(SIGNAL_REDIS_PREFIX, response.uid),
... | [
"Send",
"a",
"response",
"back",
"to",
"the",
"client",
"that",
"issued",
"a",
"request",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L131-L138 | [
"def",
"send",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"set",
"(",
"'{}:{}'",
".",
"format",
"(",
"SIGNAL_REDIS_PREFIX",
",",
"response",
".",
"uid",
")",
",",
"pickle",
".",
"dumps",
"(",
"response",
... | dc53dbc1d961e20fb144273baca258060705c03e |
train | Server.restore | Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue. | lightflow/models/signal.py | def restore(self, request):
""" Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue.
"""
self._connection.connection.rpush(self._request_key, pickle.dump... | def restore(self, request):
""" Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue.
"""
self._connection.connection.rpush(self._request_key, pickle.dump... | [
"Push",
"the",
"request",
"back",
"onto",
"the",
"queue",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L140-L147 | [
"def",
"restore",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"rpush",
"(",
"self",
".",
"_request_key",
",",
"pickle",
".",
"dumps",
"(",
"request",
")",
")"
] | dc53dbc1d961e20fb144273baca258060705c03e |
train | Client.send | Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request. | lightflow/models/signal.py | def send(self, request):
""" Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request.
"""
self._connection.c... | def send(self, request):
""" Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request.
"""
self._connection.c... | [
"Send",
"a",
"request",
"to",
"the",
"server",
"and",
"wait",
"for",
"its",
"response",
"."
] | AustralianSynchrotron/lightflow | python | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L171-L192 | [
"def",
"send",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"rpush",
"(",
"self",
".",
"_request_key",
",",
"pickle",
".",
"dumps",
"(",
"request",
")",
")",
"resp_key",
"=",
"'{}:{}'",
".",
"format",
"(",
... | dc53dbc1d961e20fb144273baca258060705c03e |
train | verify_pattern | Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise | grammaregex/grammaregex.py | def verify_pattern(pattern):
"""Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise
"""
regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$")
def __verify_pattern__(__pa... | def verify_pattern(pattern):
"""Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise
"""
regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$")
def __verify_pattern__(__pa... | [
"Verifies",
"if",
"pattern",
"for",
"matching",
"and",
"finding",
"fulfill",
"expected",
"structure",
"."
] | krzysiekfonal/grammaregex | python | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L40-L60 | [
"def",
"verify_pattern",
"(",
"pattern",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"\"^!?[a-zA-Z]+$|[*]{1,2}$\"",
")",
"def",
"__verify_pattern__",
"(",
"__pattern__",
")",
":",
"if",
"not",
"__pattern__",
":",
"return",
"False",
"elif",
"__pattern__",
... | 5212075433fc5201da628acf09cdf5bf73aa1ad0 |
train | print_tree | Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...) | grammaregex/grammaregex.py | def print_tree(sent, token_attr):
"""Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...)
"""
def __print_sent__(token, attr):
print("{", en... | def print_tree(sent, token_attr):
"""Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...)
"""
def __print_sent__(token, attr):
print("{", en... | [
"Prints",
"sentences",
"tree",
"as",
"string",
"using",
"token_attr",
"from",
"token",
"(",
"like",
"pos_",
"tag_",
"etc",
".",
")"
] | krzysiekfonal/grammaregex | python | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L63-L76 | [
"def",
"print_tree",
"(",
"sent",
",",
"token_attr",
")",
":",
"def",
"__print_sent__",
"(",
"token",
",",
"attr",
")",
":",
"print",
"(",
"\"{\"",
",",
"end",
"=",
"\" \"",
")",
"[",
"__print_sent__",
"(",
"t",
",",
"attr",
")",
"for",
"t",
"in",
... | 5212075433fc5201da628acf09cdf5bf73aa1ad0 |
train | match_tree | Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to pattern, False otherwise
:raises... | grammaregex/grammaregex.py | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | [
"Matches",
"given",
"sentence",
"with",
"provided",
"pattern",
"."
] | krzysiekfonal/grammaregex | python | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L79-L111 | [
"def",
"match_tree",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
")",
":",
"pat_node",
"=",
"p",
"."... | 5212075433fc5201da628acf09cdf5bf73aa1ad0 |
train | find_tokens | Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: Spacy... | grammaregex/grammaregex.py | def find_tokens(sentence, pattern):
"""Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which senten... | def find_tokens(sentence, pattern):
"""Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which senten... | [
"Find",
"all",
"tokens",
"from",
"parts",
"of",
"sentence",
"fitted",
"to",
"pattern",
"being",
"on",
"the",
"end",
"of",
"matched",
"sub",
"-",
"tree",
"(",
"of",
"sentence",
")"
] | krzysiekfonal/grammaregex | python | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L114-L146 | [
"def",
"find_tokens",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
",",
"tokens",
")",
":",
"pat_node",... | 5212075433fc5201da628acf09cdf5bf73aa1ad0 |
train | Liquid.split | Split a string using a single-character delimter
@params:
`s`: the string
`delimter`: the single-character delimter
`trim`: whether to trim each part. Default: True
@examples:
```python
ret = split("'a,b',c", ",")
# ret == ["'a,b'", "c"]
# ',' inside quotes will be recognized.
```
@returns... | liquid/__init__.py | def split (s, delimter, trim = True, limit = 0): # pragma: no cover
"""
Split a string using a single-character delimter
@params:
`s`: the string
`delimter`: the single-character delimter
`trim`: whether to trim each part. Default: True
@examples:
```python
ret = split("'a,b',c", ",")
# ret ==... | def split (s, delimter, trim = True, limit = 0): # pragma: no cover
"""
Split a string using a single-character delimter
@params:
`s`: the string
`delimter`: the single-character delimter
`trim`: whether to trim each part. Default: True
@examples:
```python
ret = split("'a,b',c", ",")
# ret ==... | [
"Split",
"a",
"string",
"using",
"a",
"single",
"-",
"character",
"delimter"
] | pwwang/liquidpy | python | https://github.com/pwwang/liquidpy/blob/f422af836740b7facfbc6b89e5162a17d619dd07/liquid/__init__.py#L367-L421 | [
"def",
"split",
"(",
"s",
",",
"delimter",
",",
"trim",
"=",
"True",
",",
"limit",
"=",
"0",
")",
":",
"# pragma: no cover",
"ret",
"=",
"[",
"]",
"special1",
"=",
"[",
"'('",
",",
"')'",
",",
"'['",
",",
"']'",
",",
"'{'",
",",
"'}'",
"]",
"sp... | f422af836740b7facfbc6b89e5162a17d619dd07 |
train | Liquid.render | Render this template by applying it to `context`.
@params:
`context`: a dictionary of values to use in this rendering.
@returns:
The rendered string | liquid/__init__.py | def render(self, **context):
"""
Render this template by applying it to `context`.
@params:
`context`: a dictionary of values to use in this rendering.
@returns:
The rendered string
"""
# Make the complete context we'll use.
localns = self.envs.copy()
localns.update(context)
try:
exec(str(se... | def render(self, **context):
"""
Render this template by applying it to `context`.
@params:
`context`: a dictionary of values to use in this rendering.
@returns:
The rendered string
"""
# Make the complete context we'll use.
localns = self.envs.copy()
localns.update(context)
try:
exec(str(se... | [
"Render",
"this",
"template",
"by",
"applying",
"it",
"to",
"context",
"."
] | pwwang/liquidpy | python | https://github.com/pwwang/liquidpy/blob/f422af836740b7facfbc6b89e5162a17d619dd07/liquid/__init__.py#L575-L624 | [
"def",
"render",
"(",
"self",
",",
"*",
"*",
"context",
")",
":",
"# Make the complete context we'll use.",
"localns",
"=",
"self",
".",
"envs",
".",
"copy",
"(",
")",
"localns",
".",
"update",
"(",
"context",
")",
"try",
":",
"exec",
"(",
"str",
"(",
... | f422af836740b7facfbc6b89e5162a17d619dd07 |
train | LiquidCode.addLine | Add a line of source to the code.
Indentation and newline will be added for you, don't provide them.
@params:
`line`: The line to add | liquid/builder.py | def addLine(self, line):
"""
Add a line of source to the code.
Indentation and newline will be added for you, don't provide them.
@params:
`line`: The line to add
"""
if not isinstance(line, LiquidLine):
line = LiquidLine(line)
line.ndent = self.ndent
self.codes.append(line) | def addLine(self, line):
"""
Add a line of source to the code.
Indentation and newline will be added for you, don't provide them.
@params:
`line`: The line to add
"""
if not isinstance(line, LiquidLine):
line = LiquidLine(line)
line.ndent = self.ndent
self.codes.append(line) | [
"Add",
"a",
"line",
"of",
"source",
"to",
"the",
"code",
".",
"Indentation",
"and",
"newline",
"will",
"be",
"added",
"for",
"you",
"don",
"t",
"provide",
"them",
"."
] | pwwang/liquidpy | python | https://github.com/pwwang/liquidpy/blob/f422af836740b7facfbc6b89e5162a17d619dd07/liquid/builder.py#L57-L67 | [
"def",
"addLine",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"isinstance",
"(",
"line",
",",
"LiquidLine",
")",
":",
"line",
"=",
"LiquidLine",
"(",
"line",
")",
"line",
".",
"ndent",
"=",
"self",
".",
"ndent",
"self",
".",
"codes",
".",
"app... | f422af836740b7facfbc6b89e5162a17d619dd07 |
train | Log.level | Get or set the logging level. | zenlog/__init__.py | def level(self, lvl=None):
'''Get or set the logging level.'''
if not lvl:
return self._lvl
self._lvl = self._parse_level(lvl)
self.stream.setLevel(self._lvl)
logging.root.setLevel(self._lvl) | def level(self, lvl=None):
'''Get or set the logging level.'''
if not lvl:
return self._lvl
self._lvl = self._parse_level(lvl)
self.stream.setLevel(self._lvl)
logging.root.setLevel(self._lvl) | [
"Get",
"or",
"set",
"the",
"logging",
"level",
"."
] | ManufacturaInd/python-zenlog | python | https://github.com/ManufacturaInd/python-zenlog/blob/8f4ddf281287c99e286b78ef2d0d949a7172ba4c/zenlog/__init__.py#L90-L96 | [
"def",
"level",
"(",
"self",
",",
"lvl",
"=",
"None",
")",
":",
"if",
"not",
"lvl",
":",
"return",
"self",
".",
"_lvl",
"self",
".",
"_lvl",
"=",
"self",
".",
"_parse_level",
"(",
"lvl",
")",
"self",
".",
"stream",
".",
"setLevel",
"(",
"self",
"... | 8f4ddf281287c99e286b78ef2d0d949a7172ba4c |
train | get_rate_from_db | Fetch currency conversion rate from the database | django_prices_openexchangerates/__init__.py | def get_rate_from_db(currency: str) -> Decimal:
"""
Fetch currency conversion rate from the database
"""
from .models import ConversionRate
try:
rate = ConversionRate.objects.get_rate(currency)
except ConversionRate.DoesNotExist: # noqa
raise ValueError('No conversion rate for %... | def get_rate_from_db(currency: str) -> Decimal:
"""
Fetch currency conversion rate from the database
"""
from .models import ConversionRate
try:
rate = ConversionRate.objects.get_rate(currency)
except ConversionRate.DoesNotExist: # noqa
raise ValueError('No conversion rate for %... | [
"Fetch",
"currency",
"conversion",
"rate",
"from",
"the",
"database"
] | mirumee/django-prices-openexchangerates | python | https://github.com/mirumee/django-prices-openexchangerates/blob/3f633ad20f62dce03c526e9af93335f2b6b1a950/django_prices_openexchangerates/__init__.py#L15-L24 | [
"def",
"get_rate_from_db",
"(",
"currency",
":",
"str",
")",
"->",
"Decimal",
":",
"from",
".",
"models",
"import",
"ConversionRate",
"try",
":",
"rate",
"=",
"ConversionRate",
".",
"objects",
".",
"get_rate",
"(",
"currency",
")",
"except",
"ConversionRate",
... | 3f633ad20f62dce03c526e9af93335f2b6b1a950 |
train | get_conversion_rate | Get conversion rate to use in exchange | django_prices_openexchangerates/__init__.py | def get_conversion_rate(from_currency: str, to_currency: str) -> Decimal:
"""
Get conversion rate to use in exchange
"""
reverse_rate = False
if to_currency == BASE_CURRENCY:
# Fetch exchange rate for base currency and use 1 / rate for conversion
rate_currency = from_currency
... | def get_conversion_rate(from_currency: str, to_currency: str) -> Decimal:
"""
Get conversion rate to use in exchange
"""
reverse_rate = False
if to_currency == BASE_CURRENCY:
# Fetch exchange rate for base currency and use 1 / rate for conversion
rate_currency = from_currency
... | [
"Get",
"conversion",
"rate",
"to",
"use",
"in",
"exchange"
] | mirumee/django-prices-openexchangerates | python | https://github.com/mirumee/django-prices-openexchangerates/blob/3f633ad20f62dce03c526e9af93335f2b6b1a950/django_prices_openexchangerates/__init__.py#L27-L44 | [
"def",
"get_conversion_rate",
"(",
"from_currency",
":",
"str",
",",
"to_currency",
":",
"str",
")",
"->",
"Decimal",
":",
"reverse_rate",
"=",
"False",
"if",
"to_currency",
"==",
"BASE_CURRENCY",
":",
"# Fetch exchange rate for base currency and use 1 / rate for conversi... | 3f633ad20f62dce03c526e9af93335f2b6b1a950 |
train | exchange_currency | Exchanges Money, TaxedMoney and their ranges to the specified currency.
get_rate parameter is a callable taking single argument (target currency)
that returns proper conversion rate | django_prices_openexchangerates/__init__.py | def exchange_currency(
base: T, to_currency: str, *, conversion_rate: Decimal=None) -> T:
"""
Exchanges Money, TaxedMoney and their ranges to the specified currency.
get_rate parameter is a callable taking single argument (target currency)
that returns proper conversion rate
"""
if base.... | def exchange_currency(
base: T, to_currency: str, *, conversion_rate: Decimal=None) -> T:
"""
Exchanges Money, TaxedMoney and their ranges to the specified currency.
get_rate parameter is a callable taking single argument (target currency)
that returns proper conversion rate
"""
if base.... | [
"Exchanges",
"Money",
"TaxedMoney",
"and",
"their",
"ranges",
"to",
"the",
"specified",
"currency",
".",
"get_rate",
"parameter",
"is",
"a",
"callable",
"taking",
"single",
"argument",
"(",
"target",
"currency",
")",
"that",
"returns",
"proper",
"conversion",
"r... | mirumee/django-prices-openexchangerates | python | https://github.com/mirumee/django-prices-openexchangerates/blob/3f633ad20f62dce03c526e9af93335f2b6b1a950/django_prices_openexchangerates/__init__.py#L47-L85 | [
"def",
"exchange_currency",
"(",
"base",
":",
"T",
",",
"to_currency",
":",
"str",
",",
"*",
",",
"conversion_rate",
":",
"Decimal",
"=",
"None",
")",
"->",
"T",
":",
"if",
"base",
".",
"currency",
"==",
"to_currency",
":",
"return",
"base",
"if",
"bas... | 3f633ad20f62dce03c526e9af93335f2b6b1a950 |
train | normalize | Normalize *location_name* by stripping punctuation and collapsing
runs of whitespace, and return the normalized name. | carmen/resolvers/profile.py | def normalize(location_name, preserve_commas=False):
"""Normalize *location_name* by stripping punctuation and collapsing
runs of whitespace, and return the normalized name."""
def replace(match):
if preserve_commas and ',' in match.group(0):
return ','
return ' '
return NORM... | def normalize(location_name, preserve_commas=False):
"""Normalize *location_name* by stripping punctuation and collapsing
runs of whitespace, and return the normalized name."""
def replace(match):
if preserve_commas and ',' in match.group(0):
return ','
return ' '
return NORM... | [
"Normalize",
"*",
"location_name",
"*",
"by",
"stripping",
"punctuation",
"and",
"collapsing",
"runs",
"of",
"whitespace",
"and",
"return",
"the",
"normalized",
"name",
"."
] | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/resolvers/profile.py#L15-L22 | [
"def",
"normalize",
"(",
"location_name",
",",
"preserve_commas",
"=",
"False",
")",
":",
"def",
"replace",
"(",
"match",
")",
":",
"if",
"preserve_commas",
"and",
"','",
"in",
"match",
".",
"group",
"(",
"0",
")",
":",
"return",
"','",
"return",
"' '",
... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | StationStatistics.calc_precipitation_stats | Calculates precipitation statistics for the cascade model while aggregating hourly observations
Parameters
----------
months : Months for each seasons to be used for statistics (array of numpy array, default=1-12, e.g., [np.arange(12) + 1])
avg_stats : average statistics for ... | melodist/stationstatistics.py | def calc_precipitation_stats(self, months=None, avg_stats=True, percentile=50):
"""
Calculates precipitation statistics for the cascade model while aggregating hourly observations
Parameters
----------
months : Months for each seasons to be used for statistics (array of n... | def calc_precipitation_stats(self, months=None, avg_stats=True, percentile=50):
"""
Calculates precipitation statistics for the cascade model while aggregating hourly observations
Parameters
----------
months : Months for each seasons to be used for statistics (array of n... | [
"Calculates",
"precipitation",
"statistics",
"for",
"the",
"cascade",
"model",
"while",
"aggregating",
"hourly",
"observations"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L77-L92 | [
"def",
"calc_precipitation_stats",
"(",
"self",
",",
"months",
"=",
"None",
",",
"avg_stats",
"=",
"True",
",",
"percentile",
"=",
"50",
")",
":",
"if",
"months",
"is",
"None",
":",
"months",
"=",
"[",
"np",
".",
"arange",
"(",
"12",
")",
"+",
"1",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | StationStatistics.calc_wind_stats | Calculates statistics in order to derive diurnal patterns of wind speed | melodist/stationstatistics.py | def calc_wind_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of wind speed
"""
a, b, t_shift = melodist.fit_cosine_function(self.data.wind)
self.wind.update(a=a, b=b, t_shift=t_shift) | def calc_wind_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of wind speed
"""
a, b, t_shift = melodist.fit_cosine_function(self.data.wind)
self.wind.update(a=a, b=b, t_shift=t_shift) | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"diurnal",
"patterns",
"of",
"wind",
"speed"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L94-L99 | [
"def",
"calc_wind_stats",
"(",
"self",
")",
":",
"a",
",",
"b",
",",
"t_shift",
"=",
"melodist",
".",
"fit_cosine_function",
"(",
"self",
".",
"data",
".",
"wind",
")",
"self",
".",
"wind",
".",
"update",
"(",
"a",
"=",
"a",
",",
"b",
"=",
"b",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | StationStatistics.calc_humidity_stats | Calculates statistics in order to derive diurnal patterns of relative humidity. | melodist/stationstatistics.py | def calc_humidity_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of relative humidity.
"""
a1, a0 = melodist.calculate_dewpoint_regression(self.data, return_stats=False)
self.hum.update(a0=a0, a1=a1)
self.hum.kr = 12
self.hum.month_hou... | def calc_humidity_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of relative humidity.
"""
a1, a0 = melodist.calculate_dewpoint_regression(self.data, return_stats=False)
self.hum.update(a0=a0, a1=a1)
self.hum.kr = 12
self.hum.month_hou... | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"diurnal",
"patterns",
"of",
"relative",
"humidity",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L101-L109 | [
"def",
"calc_humidity_stats",
"(",
"self",
")",
":",
"a1",
",",
"a0",
"=",
"melodist",
".",
"calculate_dewpoint_regression",
"(",
"self",
".",
"data",
",",
"return_stats",
"=",
"False",
")",
"self",
".",
"hum",
".",
"update",
"(",
"a0",
"=",
"a0",
",",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | StationStatistics.calc_temperature_stats | Calculates statistics in order to derive diurnal patterns of temperature | melodist/stationstatistics.py | def calc_temperature_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of temperature
"""
self.temp.max_delta = melodist.get_shift_by_data(self.data.temp, self._lon, self._lat, self._timezone)
self.temp.mean_course = melodist.util.calculate_mean_daily_cou... | def calc_temperature_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of temperature
"""
self.temp.max_delta = melodist.get_shift_by_data(self.data.temp, self._lon, self._lat, self._timezone)
self.temp.mean_course = melodist.util.calculate_mean_daily_cou... | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"diurnal",
"patterns",
"of",
"temperature"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L111-L116 | [
"def",
"calc_temperature_stats",
"(",
"self",
")",
":",
"self",
".",
"temp",
".",
"max_delta",
"=",
"melodist",
".",
"get_shift_by_data",
"(",
"self",
".",
"data",
".",
"temp",
",",
"self",
".",
"_lon",
",",
"self",
".",
"_lat",
",",
"self",
".",
"_tim... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | StationStatistics.calc_radiation_stats | Calculates statistics in order to derive solar radiation from sunshine duration or
minimum/maximum temperature.
Parameters
----------
data_daily : DataFrame, optional
Daily data from the associated ``Station`` object.
day_length : Series, optional
Day le... | melodist/stationstatistics.py | def calc_radiation_stats(self, data_daily=None, day_length=None, how='all'):
"""
Calculates statistics in order to derive solar radiation from sunshine duration or
minimum/maximum temperature.
Parameters
----------
data_daily : DataFrame, optional
Daily data ... | def calc_radiation_stats(self, data_daily=None, day_length=None, how='all'):
"""
Calculates statistics in order to derive solar radiation from sunshine duration or
minimum/maximum temperature.
Parameters
----------
data_daily : DataFrame, optional
Daily data ... | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"solar",
"radiation",
"from",
"sunshine",
"duration",
"or",
"minimum",
"/",
"maximum",
"temperature",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L118-L186 | [
"def",
"calc_radiation_stats",
"(",
"self",
",",
"data_daily",
"=",
"None",
",",
"day_length",
"=",
"None",
",",
"how",
"=",
"'all'",
")",
":",
"assert",
"how",
"in",
"(",
"'all'",
",",
"'seasonal'",
",",
"'monthly'",
")",
"self",
".",
"glob",
".",
"me... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | StationStatistics.to_json | Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data | melodist/stationstatistics.py | def to_json(self, filename=None):
"""
Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data
"""
def json_encoder(obj):
if isinstance(obj, pd.DataFrame) or isinstance(obj, pd.Series)... | def to_json(self, filename=None):
"""
Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data
"""
def json_encoder(obj):
if isinstance(obj, pd.DataFrame) or isinstance(obj, pd.Series)... | [
"Exports",
"statistical",
"data",
"to",
"a",
"JSON",
"formatted",
"file"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L188-L223 | [
"def",
"to_json",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"def",
"json_encoder",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"pd",
".",
"DataFrame",
")",
"or",
"isinstance",
"(",
"obj",
",",
"pd",
".",
"Series",
")",
":"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | StationStatistics.from_json | Imports statistical data from a JSON formatted file
Parameters
----------
filename: input file that holds statistics data | melodist/stationstatistics.py | def from_json(cls, filename):
"""
Imports statistical data from a JSON formatted file
Parameters
----------
filename: input file that holds statistics data
"""
def json_decoder(d):
if 'p01' in d and 'pxx' in d: # we assume this is a CascadeStatist... | def from_json(cls, filename):
"""
Imports statistical data from a JSON formatted file
Parameters
----------
filename: input file that holds statistics data
"""
def json_decoder(d):
if 'p01' in d and 'pxx' in d: # we assume this is a CascadeStatist... | [
"Imports",
"statistical",
"data",
"from",
"a",
"JSON",
"formatted",
"file"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L226-L272 | [
"def",
"from_json",
"(",
"cls",
",",
"filename",
")",
":",
"def",
"json_decoder",
"(",
"d",
")",
":",
"if",
"'p01'",
"in",
"d",
"and",
"'pxx'",
"in",
"d",
":",
"# we assume this is a CascadeStatistics object",
"return",
"melodist",
".",
"cascade",
".",
"Casc... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | disaggregate_radiation | general function for radiation disaggregation
Args:
daily_data: daily values
sun_times: daily dataframe including results of the util.sun_times function
pot_rad: hourly dataframe including potential radiation
method: keyword specifying the disaggregation method to be used
... | melodist/radiation.py | def disaggregate_radiation(data_daily,
sun_times=None,
pot_rad=None,
method='pot_rad',
angstr_a=0.25,
angstr_b=0.5,
bristcamp_a=0.75,
... | def disaggregate_radiation(data_daily,
sun_times=None,
pot_rad=None,
method='pot_rad',
angstr_a=0.25,
angstr_b=0.5,
bristcamp_a=0.75,
... | [
"general",
"function",
"for",
"radiation",
"disaggregation",
"Args",
":",
"daily_data",
":",
"daily",
"values",
"sun_times",
":",
"daily",
"dataframe",
"including",
"results",
"of",
"the",
"util",
".",
"sun_times",
"function",
"pot_rad",
":",
"hourly",
"dataframe"... | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L37-L93 | [
"def",
"disaggregate_radiation",
"(",
"data_daily",
",",
"sun_times",
"=",
"None",
",",
"pot_rad",
"=",
"None",
",",
"method",
"=",
"'pot_rad'",
",",
"angstr_a",
"=",
"0.25",
",",
"angstr_b",
"=",
"0.5",
",",
"bristcamp_a",
"=",
"0.75",
",",
"bristcamp_c",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | potential_radiation | Calculate potential shortwave radiation for a specific location and time.
This routine calculates global radiation as described in:
Liston, G. E. and Elder, K. (2006): A Meteorological Distribution System for
High-Resolution Terrestrial Modeling (MicroMet), J. Hydrometeorol., 7, 217–234.
Correct... | melodist/radiation.py | def potential_radiation(dates, lon, lat, timezone, terrain_slope=0, terrain_slope_azimuth=0,
cloud_fraction=0, split=False):
"""
Calculate potential shortwave radiation for a specific location and time.
This routine calculates global radiation as described in:
Liston, G. E... | def potential_radiation(dates, lon, lat, timezone, terrain_slope=0, terrain_slope_azimuth=0,
cloud_fraction=0, split=False):
"""
Calculate potential shortwave radiation for a specific location and time.
This routine calculates global radiation as described in:
Liston, G. E... | [
"Calculate",
"potential",
"shortwave",
"radiation",
"for",
"a",
"specific",
"location",
"and",
"time",
".",
"This",
"routine",
"calculates",
"global",
"radiation",
"as",
"described",
"in",
":",
"Liston",
"G",
".",
"E",
".",
"and",
"Elder",
"K",
".",
"(",
"... | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L96-L177 | [
"def",
"potential_radiation",
"(",
"dates",
",",
"lon",
",",
"lat",
",",
"timezone",
",",
"terrain_slope",
"=",
"0",
",",
"terrain_slope_azimuth",
"=",
"0",
",",
"cloud_fraction",
"=",
"0",
",",
"split",
"=",
"False",
")",
":",
"solar_constant",
"=",
"1367... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | bristow_campbell | calculates potential shortwave radiation based on minimum and maximum temperature
This routine calculates global radiation as described in:
Bristow, Keith L., and Gaylon S. Campbell: On the relationship between
incoming solar radiation and daily maximum and minimum temperature.
Agricultural and fo... | melodist/radiation.py | def bristow_campbell(tmin, tmax, pot_rad_daily, A, C):
"""calculates potential shortwave radiation based on minimum and maximum temperature
This routine calculates global radiation as described in:
Bristow, Keith L., and Gaylon S. Campbell: On the relationship between
incoming solar radiation and ... | def bristow_campbell(tmin, tmax, pot_rad_daily, A, C):
"""calculates potential shortwave radiation based on minimum and maximum temperature
This routine calculates global radiation as described in:
Bristow, Keith L., and Gaylon S. Campbell: On the relationship between
incoming solar radiation and ... | [
"calculates",
"potential",
"shortwave",
"radiation",
"based",
"on",
"minimum",
"and",
"maximum",
"temperature",
"This",
"routine",
"calculates",
"global",
"radiation",
"as",
"described",
"in",
":",
"Bristow",
"Keith",
"L",
".",
"and",
"Gaylon",
"S",
".",
"Campbe... | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L180-L221 | [
"def",
"bristow_campbell",
"(",
"tmin",
",",
"tmax",
",",
"pot_rad_daily",
",",
"A",
",",
"C",
")",
":",
"assert",
"tmin",
".",
"index",
".",
"equals",
"(",
"tmax",
".",
"index",
")",
"temp",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"=",
"dict",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | fit_bristow_campbell_params | Fit the A and C parameters for the Bristow & Campbell (1984) model using observed daily
minimum and maximum temperature and mean daily (e.g. aggregated from hourly values) solar
radiation.
Parameters
----------
tmin : Series
Observed daily minimum temperature.
tmax : Series
... | melodist/radiation.py | def fit_bristow_campbell_params(tmin, tmax, pot_rad_daily, obs_rad_daily):
"""
Fit the A and C parameters for the Bristow & Campbell (1984) model using observed daily
minimum and maximum temperature and mean daily (e.g. aggregated from hourly values) solar
radiation.
Parameters
---------... | def fit_bristow_campbell_params(tmin, tmax, pot_rad_daily, obs_rad_daily):
"""
Fit the A and C parameters for the Bristow & Campbell (1984) model using observed daily
minimum and maximum temperature and mean daily (e.g. aggregated from hourly values) solar
radiation.
Parameters
---------... | [
"Fit",
"the",
"A",
"and",
"C",
"parameters",
"for",
"the",
"Bristow",
"&",
"Campbell",
"(",
"1984",
")",
"model",
"using",
"observed",
"daily",
"minimum",
"and",
"maximum",
"temperature",
"and",
"mean",
"daily",
"(",
"e",
".",
"g",
".",
"aggregated",
"fr... | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L224-L250 | [
"def",
"fit_bristow_campbell_params",
"(",
"tmin",
",",
"tmax",
",",
"pot_rad_daily",
",",
"obs_rad_daily",
")",
":",
"def",
"bc_absbias",
"(",
"ac",
")",
":",
"return",
"np",
".",
"abs",
"(",
"np",
".",
"mean",
"(",
"bristow_campbell",
"(",
"df",
".",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | angstroem | Calculate mean daily radiation from observed sunshine duration according to Angstroem (1924).
Parameters
----------
ssd : Series
Observed daily sunshine duration.
day_length : Series
Day lengths as calculated by ``calc_sun_times``.
pot_rad_daily : Series
Mean po... | melodist/radiation.py | def angstroem(ssd, day_length, pot_rad_daily, a, b):
"""
Calculate mean daily radiation from observed sunshine duration according to Angstroem (1924).
Parameters
----------
ssd : Series
Observed daily sunshine duration.
day_length : Series
Day lengths as calculated by... | def angstroem(ssd, day_length, pot_rad_daily, a, b):
"""
Calculate mean daily radiation from observed sunshine duration according to Angstroem (1924).
Parameters
----------
ssd : Series
Observed daily sunshine duration.
day_length : Series
Day lengths as calculated by... | [
"Calculate",
"mean",
"daily",
"radiation",
"from",
"observed",
"sunshine",
"duration",
"according",
"to",
"Angstroem",
"(",
"1924",
")",
".",
"Parameters",
"----------",
"ssd",
":",
"Series",
"Observed",
"daily",
"sunshine",
"duration",
".",
"day_length",
":",
"... | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L253-L281 | [
"def",
"angstroem",
"(",
"ssd",
",",
"day_length",
",",
"pot_rad_daily",
",",
"a",
",",
"b",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"pd",
".",
"Series",
")",
":",
"months",
"=",
"ssd",
".",
"index",
".",
"month",
"a",
"=",
"a",
".",
"loc",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | fit_angstroem_params | Fit the a and b parameters for the Angstroem (1924) model using observed daily
sunshine duration and mean daily (e.g. aggregated from hourly values) solar
radiation.
Parameters
----------
ssd : Series
Observed daily sunshine duration.
day_length : Series
Day lengths a... | melodist/radiation.py | def fit_angstroem_params(ssd, day_length, pot_rad_daily, obs_rad_daily):
"""
Fit the a and b parameters for the Angstroem (1924) model using observed daily
sunshine duration and mean daily (e.g. aggregated from hourly values) solar
radiation.
Parameters
----------
ssd : Series
... | def fit_angstroem_params(ssd, day_length, pot_rad_daily, obs_rad_daily):
"""
Fit the a and b parameters for the Angstroem (1924) model using observed daily
sunshine duration and mean daily (e.g. aggregated from hourly values) solar
radiation.
Parameters
----------
ssd : Series
... | [
"Fit",
"the",
"a",
"and",
"b",
"parameters",
"for",
"the",
"Angstroem",
"(",
"1924",
")",
"model",
"using",
"observed",
"daily",
"sunshine",
"duration",
"and",
"mean",
"daily",
"(",
"e",
".",
"g",
".",
"aggregated",
"from",
"hourly",
"values",
")",
"sola... | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L284-L312 | [
"def",
"fit_angstroem_params",
"(",
"ssd",
",",
"day_length",
",",
"pot_rad_daily",
",",
"obs_rad_daily",
")",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"=",
"dict",
"(",
"ssd",
"=",
"ssd",
",",
"day_length",
"=",
"day_length",
",",
"pot",
"="... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | register | Return a decorator that registers the decorated class as a
resolver with the given *name*. | carmen/resolver.py | def register(name):
"""Return a decorator that registers the decorated class as a
resolver with the given *name*."""
def decorator(class_):
if name in known_resolvers:
raise ValueError('duplicate resolver name "%s"' % name)
known_resolvers[name] = class_
return decorator | def register(name):
"""Return a decorator that registers the decorated class as a
resolver with the given *name*."""
def decorator(class_):
if name in known_resolvers:
raise ValueError('duplicate resolver name "%s"' % name)
known_resolvers[name] = class_
return decorator | [
"Return",
"a",
"decorator",
"that",
"registers",
"the",
"decorated",
"class",
"as",
"a",
"resolver",
"with",
"the",
"given",
"*",
"name",
"*",
"."
] | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/resolver.py#L105-L112 | [
"def",
"register",
"(",
"name",
")",
":",
"def",
"decorator",
"(",
"class_",
")",
":",
"if",
"name",
"in",
"known_resolvers",
":",
"raise",
"ValueError",
"(",
"'duplicate resolver name \"%s\"'",
"%",
"name",
")",
"known_resolvers",
"[",
"name",
"]",
"=",
"cl... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | get_resolver | Return a location resolver. The *order* argument, if given,
should be a list of resolver names; results from resolvers named
earlier in the list are preferred over later ones. For a list of
built-in resolver names, see :doc:`/resolvers`. The *options*
argument can be used to pass configuration option... | carmen/resolver.py | def get_resolver(order=None, options=None, modules=None):
"""Return a location resolver. The *order* argument, if given,
should be a list of resolver names; results from resolvers named
earlier in the list are preferred over later ones. For a list of
built-in resolver names, see :doc:`/resolvers`. Th... | def get_resolver(order=None, options=None, modules=None):
"""Return a location resolver. The *order* argument, if given,
should be a list of resolver names; results from resolvers named
earlier in the list are preferred over later ones. For a list of
built-in resolver names, see :doc:`/resolvers`. Th... | [
"Return",
"a",
"location",
"resolver",
".",
"The",
"*",
"order",
"*",
"argument",
"if",
"given",
"should",
"be",
"a",
"list",
"of",
"resolver",
"names",
";",
"results",
"from",
"resolvers",
"named",
"earlier",
"in",
"the",
"list",
"are",
"preferred",
"over... | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/resolver.py#L115-L149 | [
"def",
"get_resolver",
"(",
"order",
"=",
"None",
",",
"options",
"=",
"None",
",",
"modules",
"=",
"None",
")",
":",
"if",
"not",
"known_resolvers",
":",
"from",
".",
"import",
"resolvers",
"as",
"carmen_resolvers",
"modules",
"=",
"[",
"carmen_resolvers",
... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | AbstractResolver.load_locations | Load locations into this resolver from the given
*location_file*, which should contain one JSON object per line
representing a location. If *location_file* is not specified,
an internal location database is used. | carmen/resolver.py | def load_locations(self, location_file=None):
"""Load locations into this resolver from the given
*location_file*, which should contain one JSON object per line
representing a location. If *location_file* is not specified,
an internal location database is used."""
if location_fi... | def load_locations(self, location_file=None):
"""Load locations into this resolver from the given
*location_file*, which should contain one JSON object per line
representing a location. If *location_file* is not specified,
an internal location database is used."""
if location_fi... | [
"Load",
"locations",
"into",
"this",
"resolver",
"from",
"the",
"given",
"*",
"location_file",
"*",
"which",
"should",
"contain",
"one",
"JSON",
"object",
"per",
"line",
"representing",
"a",
"location",
".",
"If",
"*",
"location_file",
"*",
"is",
"not",
"spe... | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/resolver.py#L22-L40 | [
"def",
"load_locations",
"(",
"self",
",",
"location_file",
"=",
"None",
")",
":",
"if",
"location_file",
"is",
"None",
":",
"contents",
"=",
"pkgutil",
".",
"get_data",
"(",
"__package__",
",",
"'data/locations.json'",
")",
"contents_string",
"=",
"contents",
... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | Location.canonical | Return a tuple containing a canonicalized version of this
location's country, state, county, and city names. | carmen/location.py | def canonical(self):
"""Return a tuple containing a canonicalized version of this
location's country, state, county, and city names."""
try:
return tuple(map(lambda x: x.lower(), self.name()))
except:
return tuple([x.lower() for x in self.name()]) | def canonical(self):
"""Return a tuple containing a canonicalized version of this
location's country, state, county, and city names."""
try:
return tuple(map(lambda x: x.lower(), self.name()))
except:
return tuple([x.lower() for x in self.name()]) | [
"Return",
"a",
"tuple",
"containing",
"a",
"canonicalized",
"version",
"of",
"this",
"location",
"s",
"country",
"state",
"county",
"and",
"city",
"names",
"."
] | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/location.py#L79-L85 | [
"def",
"canonical",
"(",
"self",
")",
":",
"try",
":",
"return",
"tuple",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"lower",
"(",
")",
",",
"self",
".",
"name",
"(",
")",
")",
")",
"except",
":",
"return",
"tuple",
"(",
"[",
"x",
".",
"l... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | Location.name | Return a tuple containing this location's country, state,
county, and city names. | carmen/location.py | def name(self):
"""Return a tuple containing this location's country, state,
county, and city names."""
try:
return tuple(
getattr(self, x) if getattr(self, x) else u''
for x in ('country', 'state', 'county', 'city'))
except:
return... | def name(self):
"""Return a tuple containing this location's country, state,
county, and city names."""
try:
return tuple(
getattr(self, x) if getattr(self, x) else u''
for x in ('country', 'state', 'county', 'city'))
except:
return... | [
"Return",
"a",
"tuple",
"containing",
"this",
"location",
"s",
"country",
"state",
"county",
"and",
"city",
"names",
"."
] | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/location.py#L87-L97 | [
"def",
"name",
"(",
"self",
")",
":",
"try",
":",
"return",
"tuple",
"(",
"getattr",
"(",
"self",
",",
"x",
")",
"if",
"getattr",
"(",
"self",
",",
"x",
")",
"else",
"u''",
"for",
"x",
"in",
"(",
"'country'",
",",
"'state'",
",",
"'county'",
",",... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | Location.parent | Return a location representing the administrative unit above
the one represented by this location. | carmen/location.py | def parent(self):
"""Return a location representing the administrative unit above
the one represented by this location."""
if self.city:
return Location(
country=self.country, state=self.state, county=self.county)
if self.county:
return Location(co... | def parent(self):
"""Return a location representing the administrative unit above
the one represented by this location."""
if self.city:
return Location(
country=self.country, state=self.state, county=self.county)
if self.county:
return Location(co... | [
"Return",
"a",
"location",
"representing",
"the",
"administrative",
"unit",
"above",
"the",
"one",
"represented",
"by",
"this",
"location",
"."
] | mdredze/carmen-python | python | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/location.py#L99-L109 | [
"def",
"parent",
"(",
"self",
")",
":",
"if",
"self",
".",
"city",
":",
"return",
"Location",
"(",
"country",
"=",
"self",
".",
"country",
",",
"state",
"=",
"self",
".",
"state",
",",
"county",
"=",
"self",
".",
"county",
")",
"if",
"self",
".",
... | 070b974222b5407f7aae2518ffbdf9df198b8e96 |
train | disaggregate_humidity | general function for humidity disaggregation
Args:
daily_data: daily values
method: keyword specifying the disaggregation method to be used
temp: hourly temperature time series (necessary for some methods)
kr: parameter for linear_dewpoint_variation method (6 or 12)
month_ho... | melodist/humidity.py | def disaggregate_humidity(data_daily, method='equal', temp=None,
a0=None, a1=None, kr=None,
month_hour_precip_mean=None, preserve_daily_mean=False):
"""general function for humidity disaggregation
Args:
daily_data: daily values
method: keyword... | def disaggregate_humidity(data_daily, method='equal', temp=None,
a0=None, a1=None, kr=None,
month_hour_precip_mean=None, preserve_daily_mean=False):
"""general function for humidity disaggregation
Args:
daily_data: daily values
method: keyword... | [
"general",
"function",
"for",
"humidity",
"disaggregation"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/humidity.py#L33-L109 | [
"def",
"disaggregate_humidity",
"(",
"data_daily",
",",
"method",
"=",
"'equal'",
",",
"temp",
"=",
"None",
",",
"a0",
"=",
"None",
",",
"a1",
"=",
"None",
",",
"kr",
"=",
"None",
",",
"month_hour_precip_mean",
"=",
"None",
",",
"preserve_daily_mean",
"=",... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | _cosine_function | genrates a diurnal course of windspeed accroding to the cosine function
Args:
x: series of euqally distributed windspeed values
a: parameter a for the cosine function
b: parameter b for the cosine function
t_shift: parameter t_shift for the cosine function
Returns:
... | melodist/wind.py | def _cosine_function(x, a, b, t_shift):
"""genrates a diurnal course of windspeed accroding to the cosine function
Args:
x: series of euqally distributed windspeed values
a: parameter a for the cosine function
b: parameter b for the cosine function
t_shift: parameter t_shift for... | def _cosine_function(x, a, b, t_shift):
"""genrates a diurnal course of windspeed accroding to the cosine function
Args:
x: series of euqally distributed windspeed values
a: parameter a for the cosine function
b: parameter b for the cosine function
t_shift: parameter t_shift for... | [
"genrates",
"a",
"diurnal",
"course",
"of",
"windspeed",
"accroding",
"to",
"the",
"cosine",
"function"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/wind.py#L33-L47 | [
"def",
"_cosine_function",
"(",
"x",
",",
"a",
",",
"b",
",",
"t_shift",
")",
":",
"mean_wind",
",",
"t",
"=",
"x",
"return",
"a",
"*",
"mean_wind",
"*",
"np",
".",
"cos",
"(",
"np",
".",
"pi",
"*",
"(",
"t",
"-",
"t_shift",
")",
"/",
"12",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | disaggregate_wind | general function for windspeed disaggregation
Args:
wind_daily: daily values
method: keyword specifying the disaggregation method to be used
a: parameter a for the cosine function
b: parameter b for the cosine function
t_shift: parameter t_shift for the cosine function
... | melodist/wind.py | def disaggregate_wind(wind_daily, method='equal', a=None, b=None, t_shift=None):
"""general function for windspeed disaggregation
Args:
wind_daily: daily values
method: keyword specifying the disaggregation method to be used
a: parameter a for the cosine function
b: parameter b ... | def disaggregate_wind(wind_daily, method='equal', a=None, b=None, t_shift=None):
"""general function for windspeed disaggregation
Args:
wind_daily: daily values
method: keyword specifying the disaggregation method to be used
a: parameter a for the cosine function
b: parameter b ... | [
"general",
"function",
"for",
"windspeed",
"disaggregation"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/wind.py#L50-L75 | [
"def",
"disaggregate_wind",
"(",
"wind_daily",
",",
"method",
"=",
"'equal'",
",",
"a",
"=",
"None",
",",
"b",
"=",
"None",
",",
"t_shift",
"=",
"None",
")",
":",
"assert",
"method",
"in",
"(",
"'equal'",
",",
"'cosine'",
",",
"'random'",
")",
",",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | fit_cosine_function | fits a cosine function to observed hourly windspeed data
Args:
wind: observed hourly windspeed data
Returns:
parameters needed to generate diurnal features of windspeed using a cosine function | melodist/wind.py | def fit_cosine_function(wind):
"""fits a cosine function to observed hourly windspeed data
Args:
wind: observed hourly windspeed data
Returns:
parameters needed to generate diurnal features of windspeed using a cosine function
"""
wind_daily = wind.groupby(wind.index.date).... | def fit_cosine_function(wind):
"""fits a cosine function to observed hourly windspeed data
Args:
wind: observed hourly windspeed data
Returns:
parameters needed to generate diurnal features of windspeed using a cosine function
"""
wind_daily = wind.groupby(wind.index.date).... | [
"fits",
"a",
"cosine",
"function",
"to",
"observed",
"hourly",
"windspeed",
"data"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/wind.py#L78-L94 | [
"def",
"fit_cosine_function",
"(",
"wind",
")",
":",
"wind_daily",
"=",
"wind",
".",
"groupby",
"(",
"wind",
".",
"index",
".",
"date",
")",
".",
"mean",
"(",
")",
"wind_daily_hourly",
"=",
"pd",
".",
"Series",
"(",
"index",
"=",
"wind",
".",
"index",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | read_smet | Reads smet data and returns the data in required dataformat (pd df)
See https://models.slf.ch/docserver/meteoio/SMET_specifications.pdf
for further details on the specifications of this file format.
Parameters
----
filename : SMET file to read
mode : "d" for daily and "h" for hourly input
... | melodist/data_io.py | def read_smet(filename, mode):
"""Reads smet data and returns the data in required dataformat (pd df)
See https://models.slf.ch/docserver/meteoio/SMET_specifications.pdf
for further details on the specifications of this file format.
Parameters
----
filename : SMET file to read
mode : "... | def read_smet(filename, mode):
"""Reads smet data and returns the data in required dataformat (pd df)
See https://models.slf.ch/docserver/meteoio/SMET_specifications.pdf
for further details on the specifications of this file format.
Parameters
----
filename : SMET file to read
mode : "... | [
"Reads",
"smet",
"data",
"and",
"returns",
"the",
"data",
"in",
"required",
"dataformat",
"(",
"pd",
"df",
")"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/data_io.py#L33-L113 | [
"def",
"read_smet",
"(",
"filename",
",",
"mode",
")",
":",
"# dictionary",
"# based on smet spec V.1.1 and self defined",
"# daily data",
"dict_d",
"=",
"{",
"'TA'",
":",
"'tmean'",
",",
"'TMAX'",
":",
"'tmax'",
",",
"# no spec",
"'TMIN'",
":",
"'tmin'",
",",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | read_dwd | Reads dwd (German Weather Service) data and returns the data in required
dataformat (pd df)
Parameters
----
filename : DWD file to read (full path) / list of hourly files (RR+TU+FF)
metadata : corresponding DWD metadata file to read
mode : "d" for daily and "h" for hourly input
skip_las... | melodist/data_io.py | def read_dwd(filename, metadata, mode="d", skip_last=True):
"""Reads dwd (German Weather Service) data and returns the data in required
dataformat (pd df)
Parameters
----
filename : DWD file to read (full path) / list of hourly files (RR+TU+FF)
metadata : corresponding DWD metadata file to rea... | def read_dwd(filename, metadata, mode="d", skip_last=True):
"""Reads dwd (German Weather Service) data and returns the data in required
dataformat (pd df)
Parameters
----
filename : DWD file to read (full path) / list of hourly files (RR+TU+FF)
metadata : corresponding DWD metadata file to rea... | [
"Reads",
"dwd",
"(",
"German",
"Weather",
"Service",
")",
"data",
"and",
"returns",
"the",
"data",
"in",
"required",
"dataformat",
"(",
"pd",
"df",
")"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/data_io.py#L116-L233 | [
"def",
"read_dwd",
"(",
"filename",
",",
"metadata",
",",
"mode",
"=",
"\"d\"",
",",
"skip_last",
"=",
"True",
")",
":",
"def",
"read_single_dwd",
"(",
"filename",
",",
"metadata",
",",
"mode",
",",
"skip_last",
")",
":",
"# Param names {'DWD':'dissag_def'}",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | write_smet | writes smet files
Parameters
----
filename : filename/loction of output
data : data to write as pandas df
metadata: header to write input as dict
nodata_value: Nodata Value to write/use
mode: defines if to write daily ("d") or continuos data (default 'h')
check_nan... | melodist/data_io.py | def write_smet(filename, data, metadata, nodata_value=-999, mode='h', check_nan=True):
"""writes smet files
Parameters
----
filename : filename/loction of output
data : data to write as pandas df
metadata: header to write input as dict
nodata_value: Nodata Value to write/use
... | def write_smet(filename, data, metadata, nodata_value=-999, mode='h', check_nan=True):
"""writes smet files
Parameters
----
filename : filename/loction of output
data : data to write as pandas df
metadata: header to write input as dict
nodata_value: Nodata Value to write/use
... | [
"writes",
"smet",
"files"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/data_io.py#L236-L320 | [
"def",
"write_smet",
"(",
"filename",
",",
"data",
",",
"metadata",
",",
"nodata_value",
"=",
"-",
"999",
",",
"mode",
"=",
"'h'",
",",
"check_nan",
"=",
"True",
")",
":",
"# dictionary",
"# based on smet spec V.1.1 and selfdefined",
"# daily data",
"dict_d",
"=... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | read_single_knmi_file | reads a single file of KNMI's meteorological time series
data availability: www.knmi.nl/nederland-nu/klimatologie/uurgegevens
Args:
filename: the file to be opened
Returns:
pandas data frame including time series | melodist/data_io.py | def read_single_knmi_file(filename):
"""reads a single file of KNMI's meteorological time series
data availability: www.knmi.nl/nederland-nu/klimatologie/uurgegevens
Args:
filename: the file to be opened
Returns:
pandas data frame including time series
"""
hourly_data_obs_raw ... | def read_single_knmi_file(filename):
"""reads a single file of KNMI's meteorological time series
data availability: www.knmi.nl/nederland-nu/klimatologie/uurgegevens
Args:
filename: the file to be opened
Returns:
pandas data frame including time series
"""
hourly_data_obs_raw ... | [
"reads",
"a",
"single",
"file",
"of",
"KNMI",
"s",
"meteorological",
"time",
"series"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/data_io.py#L323-L367 | [
"def",
"read_single_knmi_file",
"(",
"filename",
")",
":",
"hourly_data_obs_raw",
"=",
"pd",
".",
"read_csv",
"(",
"filename",
",",
"parse_dates",
"=",
"[",
"[",
"'YYYYMMDD'",
",",
"'HH'",
"]",
"]",
",",
"date_parser",
"=",
"lambda",
"yyyymmdd",
",",
"hh",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | read_knmi_dataset | Reads files from a directory and merges the time series
Please note: For each station, a separate directory must be provided!
data availability: www.knmi.nl/nederland-nu/klimatologie/uurgegevens
Args:
directory: directory including the files
Returns:
pandas data frame including time s... | melodist/data_io.py | def read_knmi_dataset(directory):
"""Reads files from a directory and merges the time series
Please note: For each station, a separate directory must be provided!
data availability: www.knmi.nl/nederland-nu/klimatologie/uurgegevens
Args:
directory: directory including the files
Returns:
... | def read_knmi_dataset(directory):
"""Reads files from a directory and merges the time series
Please note: For each station, a separate directory must be provided!
data availability: www.knmi.nl/nederland-nu/klimatologie/uurgegevens
Args:
directory: directory including the files
Returns:
... | [
"Reads",
"files",
"from",
"a",
"directory",
"and",
"merges",
"the",
"time",
"series"
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/data_io.py#L370-L397 | [
"def",
"read_knmi_dataset",
"(",
"directory",
")",
":",
"filemask",
"=",
"'%s*.txt'",
"%",
"directory",
"filelist",
"=",
"glob",
".",
"glob",
"(",
"filemask",
")",
"columns_hourly",
"=",
"[",
"'temp'",
",",
"'precip'",
",",
"'glob'",
",",
"'hum'",
",",
"'w... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.calc_sun_times | Computes the times of sunrise, solar noon, and sunset for each day. | melodist/station.py | def calc_sun_times(self):
"""
Computes the times of sunrise, solar noon, and sunset for each day.
"""
self.sun_times = melodist.util.get_sun_times(self.data_daily.index, self.lon, self.lat, self.timezone) | def calc_sun_times(self):
"""
Computes the times of sunrise, solar noon, and sunset for each day.
"""
self.sun_times = melodist.util.get_sun_times(self.data_daily.index, self.lon, self.lat, self.timezone) | [
"Computes",
"the",
"times",
"of",
"sunrise",
"solar",
"noon",
"and",
"sunset",
"for",
"each",
"day",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L174-L179 | [
"def",
"calc_sun_times",
"(",
"self",
")",
":",
"self",
".",
"sun_times",
"=",
"melodist",
".",
"util",
".",
"get_sun_times",
"(",
"self",
".",
"data_daily",
".",
"index",
",",
"self",
".",
"lon",
",",
"self",
".",
"lat",
",",
"self",
".",
"timezone",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.disaggregate_wind | Disaggregate wind speed.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Mean daily wind speed is duplicated for the 24 hours of the day. (Default)
``cosine``
Distributes daily mean wind speed us... | melodist/station.py | def disaggregate_wind(self, method='equal'):
"""
Disaggregate wind speed.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Mean daily wind speed is duplicated for the 24 hours of the day. (Default)
... | def disaggregate_wind(self, method='equal'):
"""
Disaggregate wind speed.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Mean daily wind speed is duplicated for the 24 hours of the day. (Default)
... | [
"Disaggregate",
"wind",
"speed",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L181-L201 | [
"def",
"disaggregate_wind",
"(",
"self",
",",
"method",
"=",
"'equal'",
")",
":",
"self",
".",
"data_disagg",
".",
"wind",
"=",
"melodist",
".",
"disaggregate_wind",
"(",
"self",
".",
"data_daily",
".",
"wind",
",",
"method",
"=",
"method",
",",
"*",
"*"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.disaggregate_humidity | Disaggregate relative humidity.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Mean daily humidity is duplicated for the 24 hours of the day. (Default)
``minimal``:
Calculates humidity from dail... | melodist/station.py | def disaggregate_humidity(self, method='equal', preserve_daily_mean=False):
"""
Disaggregate relative humidity.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Mean daily humidity is duplicated for the 24 hou... | def disaggregate_humidity(self, method='equal', preserve_daily_mean=False):
"""
Disaggregate relative humidity.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Mean daily humidity is duplicated for the 24 hou... | [
"Disaggregate",
"relative",
"humidity",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L203-L243 | [
"def",
"disaggregate_humidity",
"(",
"self",
",",
"method",
"=",
"'equal'",
",",
"preserve_daily_mean",
"=",
"False",
")",
":",
"self",
".",
"data_disagg",
".",
"hum",
"=",
"melodist",
".",
"disaggregate_humidity",
"(",
"self",
".",
"data_daily",
",",
"temp",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.disaggregate_temperature | Disaggregate air temperature.
Parameters
----------
method : str, optional
Disaggregation method.
``sine_min_max``
Hourly temperatures follow a sine function preserving daily minimum
and maximum values. (Default)
``sine_mean`... | melodist/station.py | def disaggregate_temperature(self, method='sine_min_max', min_max_time='fix', mod_nighttime=False):
"""
Disaggregate air temperature.
Parameters
----------
method : str, optional
Disaggregation method.
``sine_min_max``
Hourly temperatures... | def disaggregate_temperature(self, method='sine_min_max', min_max_time='fix', mod_nighttime=False):
"""
Disaggregate air temperature.
Parameters
----------
method : str, optional
Disaggregation method.
``sine_min_max``
Hourly temperatures... | [
"Disaggregate",
"air",
"temperature",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L245-L296 | [
"def",
"disaggregate_temperature",
"(",
"self",
",",
"method",
"=",
"'sine_min_max'",
",",
"min_max_time",
"=",
"'fix'",
",",
"mod_nighttime",
"=",
"False",
")",
":",
"self",
".",
"data_disagg",
".",
"temp",
"=",
"melodist",
".",
"disaggregate_temperature",
"(",... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.disaggregate_precipitation | Disaggregate precipitation.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Daily precipitation is distributed equally over the 24 hours of the day. (Default)
``cascade``
Hourly precipitation val... | melodist/station.py | def disaggregate_precipitation(self, method='equal', zerodiv='uniform', shift=0, master_precip=None):
"""
Disaggregate precipitation.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Daily precipitation is dis... | def disaggregate_precipitation(self, method='equal', zerodiv='uniform', shift=0, master_precip=None):
"""
Disaggregate precipitation.
Parameters
----------
method : str, optional
Disaggregation method.
``equal``
Daily precipitation is dis... | [
"Disaggregate",
"precipitation",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L298-L338 | [
"def",
"disaggregate_precipitation",
"(",
"self",
",",
"method",
"=",
"'equal'",
",",
"zerodiv",
"=",
"'uniform'",
",",
"shift",
"=",
"0",
",",
"master_precip",
"=",
"None",
")",
":",
"if",
"method",
"==",
"'equal'",
":",
"precip_disagg",
"=",
"melodist",
... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.disaggregate_radiation | Disaggregate solar radiation.
Parameters
----------
method : str, optional
Disaggregation method.
``pot_rad``
Calculates potential clear-sky hourly radiation and scales it according to the
mean daily radiation. (Default)
``po... | melodist/station.py | def disaggregate_radiation(self, method='pot_rad', pot_rad=None):
"""
Disaggregate solar radiation.
Parameters
----------
method : str, optional
Disaggregation method.
``pot_rad``
Calculates potential clear-sky hourly radiation and scales... | def disaggregate_radiation(self, method='pot_rad', pot_rad=None):
"""
Disaggregate solar radiation.
Parameters
----------
method : str, optional
Disaggregation method.
``pot_rad``
Calculates potential clear-sky hourly radiation and scales... | [
"Disaggregate",
"solar",
"radiation",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L340-L383 | [
"def",
"disaggregate_radiation",
"(",
"self",
",",
"method",
"=",
"'pot_rad'",
",",
"pot_rad",
"=",
"None",
")",
":",
"if",
"self",
".",
"sun_times",
"is",
"None",
":",
"self",
".",
"calc_sun_times",
"(",
")",
"if",
"pot_rad",
"is",
"None",
"and",
"metho... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | Station.interpolate | Wrapper function for ``pandas.Series.interpolate`` that can be used to
"disaggregate" values using various interpolation methods.
Parameters
----------
column_hours : dict
Dictionary containing column names in ``data_daily`` and the hour
values they should be ass... | melodist/station.py | def interpolate(self, column_hours, method='linear', limit=24, limit_direction='both', **kwargs):
"""
Wrapper function for ``pandas.Series.interpolate`` that can be used to
"disaggregate" values using various interpolation methods.
Parameters
----------
column_hours : di... | def interpolate(self, column_hours, method='linear', limit=24, limit_direction='both', **kwargs):
"""
Wrapper function for ``pandas.Series.interpolate`` that can be used to
"disaggregate" values using various interpolation methods.
Parameters
----------
column_hours : di... | [
"Wrapper",
"function",
"for",
"pandas",
".",
"Series",
".",
"interpolate",
"that",
"can",
"be",
"used",
"to",
"disaggregate",
"values",
"using",
"various",
"interpolation",
"methods",
"."
] | kristianfoerster/melodist | python | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L385-L412 | [
"def",
"interpolate",
"(",
"self",
",",
"column_hours",
",",
"method",
"=",
"'linear'",
",",
"limit",
"=",
"24",
",",
"limit_direction",
"=",
"'both'",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"dict",
"(",
"kwargs",
",",
"method",
"=",
"method... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd |
train | QueryDbOrm._query_helper | Internal helper for preparing queries. | query/core.py | def _query_helper(self, by=None):
"""
Internal helper for preparing queries.
"""
if by is None:
primary_keys = self.table.primary_key.columns.keys()
if len(primary_keys) > 1:
warnings.warn("WARNING: MORE THAN 1 PRIMARY KEY FOR TABLE %s. "
... | def _query_helper(self, by=None):
"""
Internal helper for preparing queries.
"""
if by is None:
primary_keys = self.table.primary_key.columns.keys()
if len(primary_keys) > 1:
warnings.warn("WARNING: MORE THAN 1 PRIMARY KEY FOR TABLE %s. "
... | [
"Internal",
"helper",
"for",
"preparing",
"queries",
"."
] | boydgreenfield/query | python | https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L72-L99 | [
"def",
"_query_helper",
"(",
"self",
",",
"by",
"=",
"None",
")",
":",
"if",
"by",
"is",
"None",
":",
"primary_keys",
"=",
"self",
".",
"table",
".",
"primary_key",
".",
"columns",
".",
"keys",
"(",
")",
"if",
"len",
"(",
"primary_keys",
")",
">",
... | 03aa43b746b43832af3f0403265e648a5617b62b |
train | QueryDbOrm.head | Get the first n entries for a given Table/Column. Additional keywords
passed to QueryDb.query().
Requires that the given table has a primary key specified. | query/core.py | def head(self, n=10, by=None, **kwargs):
"""
Get the first n entries for a given Table/Column. Additional keywords
passed to QueryDb.query().
Requires that the given table has a primary key specified.
"""
col, id_col = self._query_helper(by=by)
select = ("SELECT... | def head(self, n=10, by=None, **kwargs):
"""
Get the first n entries for a given Table/Column. Additional keywords
passed to QueryDb.query().
Requires that the given table has a primary key specified.
"""
col, id_col = self._query_helper(by=by)
select = ("SELECT... | [
"Get",
"the",
"first",
"n",
"entries",
"for",
"a",
"given",
"Table",
"/",
"Column",
".",
"Additional",
"keywords",
"passed",
"to",
"QueryDb",
".",
"query",
"()",
"."
] | boydgreenfield/query | python | https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L101-L113 | [
"def",
"head",
"(",
"self",
",",
"n",
"=",
"10",
",",
"by",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"col",
",",
"id_col",
"=",
"self",
".",
"_query_helper",
"(",
"by",
"=",
"by",
")",
"select",
"=",
"(",
"\"SELECT %s FROM %s ORDER BY %s ASC L... | 03aa43b746b43832af3f0403265e648a5617b62b |
train | QueryDbOrm.last | Alias for .tail(). | query/core.py | def last(self, n=10, by=None, **kwargs):
"""
Alias for .tail().
"""
return self.tail(n=n, by=by, **kwargs) | def last(self, n=10, by=None, **kwargs):
"""
Alias for .tail().
"""
return self.tail(n=n, by=by, **kwargs) | [
"Alias",
"for",
".",
"tail",
"()",
"."
] | boydgreenfield/query | python | https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L134-L138 | [
"def",
"last",
"(",
"self",
",",
"n",
"=",
"10",
",",
"by",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"tail",
"(",
"n",
"=",
"n",
",",
"by",
"=",
"by",
",",
"*",
"*",
"kwargs",
")"
] | 03aa43b746b43832af3f0403265e648a5617b62b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.