repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.gen_schlumberger | def gen_schlumberger(self, M, N, a=None):
"""generate one Schlumberger sounding configuration, that is, one set
of configurations for one potential dipole MN.
Parameters
----------
M: int
electrode number for the first potential electrode
N: int
e... | python | def gen_schlumberger(self, M, N, a=None):
"""generate one Schlumberger sounding configuration, that is, one set
of configurations for one potential dipole MN.
Parameters
----------
M: int
electrode number for the first potential electrode
N: int
e... | [
"def",
"gen_schlumberger",
"(",
"self",
",",
"M",
",",
"N",
",",
"a",
"=",
"None",
")",
":",
"if",
"a",
"is",
"None",
":",
"a",
"=",
"np",
".",
"abs",
"(",
"M",
"-",
"N",
")",
"nr_of_steps_left",
"=",
"int",
"(",
"min",
"(",
"M",
",",
"N",
... | generate one Schlumberger sounding configuration, that is, one set
of configurations for one potential dipole MN.
Parameters
----------
M: int
electrode number for the first potential electrode
N: int
electrode number for the second potential electrode
... | [
"generate",
"one",
"Schlumberger",
"sounding",
"configuration",
"that",
"is",
"one",
"set",
"of",
"configurations",
"for",
"one",
"potential",
"dipole",
"MN",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L459-L498 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.add_to_configs | def add_to_configs(self, configs):
"""Add one or more measurement configurations to the stored
configurations
Parameters
----------
configs: list or numpy.ndarray
list or array of configurations
Returns
-------
configs: Kx4 numpy.ndarray
... | python | def add_to_configs(self, configs):
"""Add one or more measurement configurations to the stored
configurations
Parameters
----------
configs: list or numpy.ndarray
list or array of configurations
Returns
-------
configs: Kx4 numpy.ndarray
... | [
"def",
"add_to_configs",
"(",
"self",
",",
"configs",
")",
":",
"if",
"len",
"(",
"configs",
")",
"==",
"0",
":",
"return",
"None",
"if",
"self",
".",
"configs",
"is",
"None",
":",
"self",
".",
"configs",
"=",
"np",
".",
"atleast_2d",
"(",
"configs",... | Add one or more measurement configurations to the stored
configurations
Parameters
----------
configs: list or numpy.ndarray
list or array of configurations
Returns
-------
configs: Kx4 numpy.ndarray
array holding all configurations of th... | [
"Add",
"one",
"or",
"more",
"measurement",
"configurations",
"to",
"the",
"stored",
"configurations"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L521-L543 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.split_into_normal_and_reciprocal | def split_into_normal_and_reciprocal(self, pad=False,
return_indices=False):
"""Split the stored configurations into normal and reciprocal
measurements
** *Rule 1: the normal configuration contains the smallest electrode
number of the four involv... | python | def split_into_normal_and_reciprocal(self, pad=False,
return_indices=False):
"""Split the stored configurations into normal and reciprocal
measurements
** *Rule 1: the normal configuration contains the smallest electrode
number of the four involv... | [
"def",
"split_into_normal_and_reciprocal",
"(",
"self",
",",
"pad",
"=",
"False",
",",
"return_indices",
"=",
"False",
")",
":",
"configs",
"=",
"np",
".",
"hstack",
"(",
"(",
"np",
".",
"sort",
"(",
"self",
".",
"configs",
"[",
":",
",",
"0",
":",
"... | Split the stored configurations into normal and reciprocal
measurements
** *Rule 1: the normal configuration contains the smallest electrode
number of the four involved electrodes in the current dipole* **
Parameters
----------
pad: bool, optional
if True, a... | [
"Split",
"the",
"stored",
"configurations",
"into",
"normal",
"and",
"reciprocal",
"measurements"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L545-L638 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.gen_reciprocals | def gen_reciprocals(self, append=False):
""" Generate reciprocal configurations, sort by AB, and optionally
append to configurations.
Parameters
----------
append : bool
Append reciprocals to configs (the default is False).
Examples
--------
... | python | def gen_reciprocals(self, append=False):
""" Generate reciprocal configurations, sort by AB, and optionally
append to configurations.
Parameters
----------
append : bool
Append reciprocals to configs (the default is False).
Examples
--------
... | [
"def",
"gen_reciprocals",
"(",
"self",
",",
"append",
"=",
"False",
")",
":",
"reciprocals",
"=",
"self",
".",
"configs",
".",
"copy",
"(",
")",
"[",
":",
",",
":",
":",
"-",
"1",
"]",
"reciprocals",
"[",
":",
",",
"0",
":",
"2",
"]",
"=",
"np"... | Generate reciprocal configurations, sort by AB, and optionally
append to configurations.
Parameters
----------
append : bool
Append reciprocals to configs (the default is False).
Examples
--------
>>> cfgs = ConfigManager(nr_of_electrodes=5)
... | [
"Generate",
"reciprocal",
"configurations",
"sort",
"by",
"AB",
"and",
"optionally",
"append",
"to",
"configurations",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L640-L673 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.gen_configs_permutate | def gen_configs_permutate(self,
injections_raw,
only_same_dipole_length=False,
ignore_crossed_dipoles=False,
silent=False):
""" Create measurement configurations out of a pool of current
... | python | def gen_configs_permutate(self,
injections_raw,
only_same_dipole_length=False,
ignore_crossed_dipoles=False,
silent=False):
""" Create measurement configurations out of a pool of current
... | [
"def",
"gen_configs_permutate",
"(",
"self",
",",
"injections_raw",
",",
"only_same_dipole_length",
"=",
"False",
",",
"ignore_crossed_dipoles",
"=",
"False",
",",
"silent",
"=",
"False",
")",
":",
"injections",
"=",
"np",
".",
"atleast_2d",
"(",
"injections_raw",... | Create measurement configurations out of a pool of current
injections. Use only the provided dipoles for potential dipole
selection. This means that we have always reciprocal measurements.
Remove quadpoles where electrodes are used both as current and voltage
dipoles.
Paramete... | [
"Create",
"measurement",
"configurations",
"out",
"of",
"a",
"pool",
"of",
"current",
"injections",
".",
"Use",
"only",
"the",
"provided",
"dipoles",
"for",
"potential",
"dipole",
"selection",
".",
"This",
"means",
"that",
"we",
"have",
"always",
"reciprocal",
... | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L675-L753 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.remove_max_dipole_sep | def remove_max_dipole_sep(self, maxsep=10):
"""Remove configurations with dipole separations higher than `maxsep`.
Parameters
----------
maxsep : int
Maximum separation between both dipoles (the default is 10).
"""
sep = np.abs(self.configs[:, 1] - self.confi... | python | def remove_max_dipole_sep(self, maxsep=10):
"""Remove configurations with dipole separations higher than `maxsep`.
Parameters
----------
maxsep : int
Maximum separation between both dipoles (the default is 10).
"""
sep = np.abs(self.configs[:, 1] - self.confi... | [
"def",
"remove_max_dipole_sep",
"(",
"self",
",",
"maxsep",
"=",
"10",
")",
":",
"sep",
"=",
"np",
".",
"abs",
"(",
"self",
".",
"configs",
"[",
":",
",",
"1",
"]",
"-",
"self",
".",
"configs",
"[",
":",
",",
"2",
"]",
")",
"self",
".",
"config... | Remove configurations with dipole separations higher than `maxsep`.
Parameters
----------
maxsep : int
Maximum separation between both dipoles (the default is 10). | [
"Remove",
"configurations",
"with",
"dipole",
"separations",
"higher",
"than",
"maxsep",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L755-L764 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.to_pg_scheme | def to_pg_scheme(self, container=None, positions=None):
"""Convert the configuration to a pygimli measurement scheme
Parameters
----------
container: reda.containers.ERT.ERT
an ERT data container (we take the electrode positions from here)
positions = None
R... | python | def to_pg_scheme(self, container=None, positions=None):
"""Convert the configuration to a pygimli measurement scheme
Parameters
----------
container: reda.containers.ERT.ERT
an ERT data container (we take the electrode positions from here)
positions = None
R... | [
"def",
"to_pg_scheme",
"(",
"self",
",",
"container",
"=",
"None",
",",
"positions",
"=",
"None",
")",
":",
"if",
"container",
"is",
"None",
"and",
"positions",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'electrode positions are required for BERT export'",
"... | Convert the configuration to a pygimli measurement scheme
Parameters
----------
container: reda.containers.ERT.ERT
an ERT data container (we take the electrode positions from here)
positions = None
Returns
-------
data: pybert.DataContainerERT
... | [
"Convert",
"the",
"configuration",
"to",
"a",
"pygimli",
"measurement",
"scheme"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L771-L836 | train |
geophysics-ubonn/reda | lib/reda/configs/configManager.py | ConfigManager.to_iris_syscal | def to_iris_syscal(self, filename):
"""Export to IRIS Instrument configuration file
Parameters
----------
filename : string
Path to output filename
"""
with open(filename, 'w') as fid:
# fprintf(fod, '#\t X\t Y\t Z\n');
fid.write('#\t ... | python | def to_iris_syscal(self, filename):
"""Export to IRIS Instrument configuration file
Parameters
----------
filename : string
Path to output filename
"""
with open(filename, 'w') as fid:
# fprintf(fod, '#\t X\t Y\t Z\n');
fid.write('#\t ... | [
"def",
"to_iris_syscal",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fid",
":",
"fid",
".",
"write",
"(",
"'#\\t X\\t Y\\t Z\\n'",
")",
"for",
"nr",
"in",
"range",
"(",
"0",
",",
"self",
".",
"conf... | Export to IRIS Instrument configuration file
Parameters
----------
filename : string
Path to output filename | [
"Export",
"to",
"IRIS",
"Instrument",
"configuration",
"file"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L838-L860 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.create_plan | def create_plan(self, *, plan_code, description, interval, interval_count, max_payments_allowed,
payment_attempts_delay, plan_value, plan_tax, plan_tax_return_base, currency,
max_payment_attempts=None, max_pending_payments=None, trial_days=None):
"""
Creating a ne... | python | def create_plan(self, *, plan_code, description, interval, interval_count, max_payments_allowed,
payment_attempts_delay, plan_value, plan_tax, plan_tax_return_base, currency,
max_payment_attempts=None, max_pending_payments=None, trial_days=None):
"""
Creating a ne... | [
"def",
"create_plan",
"(",
"self",
",",
"*",
",",
"plan_code",
",",
"description",
",",
"interval",
",",
"interval_count",
",",
"max_payments_allowed",
",",
"payment_attempts_delay",
",",
"plan_value",
",",
"plan_tax",
",",
"plan_tax_return_base",
",",
"currency",
... | Creating a new plan for subscriptions associated with the merchant.
Args:
plan_code: Unique code assigned by the merchant to the plan in order to identify it.
Alphanumeric. Min: 1 Max: 255.
description: Plan description.
Alphanumeric. Min: 1 Max: 255.
... | [
"Creating",
"a",
"new",
"plan",
"for",
"subscriptions",
"associated",
"with",
"the",
"merchant",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L10-L90 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.get_plan | def get_plan(self, plan_code):
"""
Check all the information of a plan for subscriptions associated with the merchant.
Args:
plan_code: Plan’s identification code for the merchant.
Returns:
"""
return self.client._get(self.url + 'plans/{}'.format(plan_code)... | python | def get_plan(self, plan_code):
"""
Check all the information of a plan for subscriptions associated with the merchant.
Args:
plan_code: Plan’s identification code for the merchant.
Returns:
"""
return self.client._get(self.url + 'plans/{}'.format(plan_code)... | [
"def",
"get_plan",
"(",
"self",
",",
"plan_code",
")",
":",
"return",
"self",
".",
"client",
".",
"_get",
"(",
"self",
".",
"url",
"+",
"'plans/{}'",
".",
"format",
"(",
"plan_code",
")",
",",
"headers",
"=",
"self",
".",
"get_headers",
"(",
")",
")"... | Check all the information of a plan for subscriptions associated with the merchant.
Args:
plan_code: Plan’s identification code for the merchant.
Returns: | [
"Check",
"all",
"the",
"information",
"of",
"a",
"plan",
"for",
"subscriptions",
"associated",
"with",
"the",
"merchant",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L92-L102 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.delete_plan | def delete_plan(self, plan_code):
"""
Delete an entire subscription plan associated with the merchant.
Args:
plan_code: Plan’s identification code for the merchant.
Returns:
"""
return self.client._delete(self.url + 'plans/{}'.format(plan_code), headers=sel... | python | def delete_plan(self, plan_code):
"""
Delete an entire subscription plan associated with the merchant.
Args:
plan_code: Plan’s identification code for the merchant.
Returns:
"""
return self.client._delete(self.url + 'plans/{}'.format(plan_code), headers=sel... | [
"def",
"delete_plan",
"(",
"self",
",",
"plan_code",
")",
":",
"return",
"self",
".",
"client",
".",
"_delete",
"(",
"self",
".",
"url",
"+",
"'plans/{}'",
".",
"format",
"(",
"plan_code",
")",
",",
"headers",
"=",
"self",
".",
"get_headers",
"(",
")",... | Delete an entire subscription plan associated with the merchant.
Args:
plan_code: Plan’s identification code for the merchant.
Returns: | [
"Delete",
"an",
"entire",
"subscription",
"plan",
"associated",
"with",
"the",
"merchant",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L107-L117 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.create_customer | def create_customer(self, *, full_name, email):
"""
Creation of a customer in the system.
Args:
full_name: Customer's complete name.
Alphanumeric. Max: 255.
email: Customer's email address.
Alphanumeric. Max: 255.
Returns:
"""
... | python | def create_customer(self, *, full_name, email):
"""
Creation of a customer in the system.
Args:
full_name: Customer's complete name.
Alphanumeric. Max: 255.
email: Customer's email address.
Alphanumeric. Max: 255.
Returns:
"""
... | [
"def",
"create_customer",
"(",
"self",
",",
"*",
",",
"full_name",
",",
"email",
")",
":",
"payload",
"=",
"{",
"\"fullName\"",
":",
"full_name",
",",
"\"email\"",
":",
"email",
"}",
"return",
"self",
".",
"client",
".",
"_post",
"(",
"self",
".",
"url... | Creation of a customer in the system.
Args:
full_name: Customer's complete name.
Alphanumeric. Max: 255.
email: Customer's email address.
Alphanumeric. Max: 255.
Returns: | [
"Creation",
"of",
"a",
"customer",
"in",
"the",
"system",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L119-L137 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.get_customer | def get_customer(self, customer_id):
"""
Queries the information related to the customer.
Args:
customer_id: Identifier of the client from which you want to find the associated information.
Returns:
"""
return self.client._get(self.url + 'customers/{}'.form... | python | def get_customer(self, customer_id):
"""
Queries the information related to the customer.
Args:
customer_id: Identifier of the client from which you want to find the associated information.
Returns:
"""
return self.client._get(self.url + 'customers/{}'.form... | [
"def",
"get_customer",
"(",
"self",
",",
"customer_id",
")",
":",
"return",
"self",
".",
"client",
".",
"_get",
"(",
"self",
".",
"url",
"+",
"'customers/{}'",
".",
"format",
"(",
"customer_id",
")",
",",
"headers",
"=",
"self",
".",
"get_headers",
"(",
... | Queries the information related to the customer.
Args:
customer_id: Identifier of the client from which you want to find the associated information.
Returns: | [
"Queries",
"the",
"information",
"related",
"to",
"the",
"customer",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L139-L149 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.delete_customer | def delete_customer(self, customer_id):
"""
Removes a user from the system.
Args:
customer_id: Identifier of the client to be deleted.
Returns:
"""
return self.client._delete(self.url + 'customers/{}'.format(customer_id), headers=self.get_headers()) | python | def delete_customer(self, customer_id):
"""
Removes a user from the system.
Args:
customer_id: Identifier of the client to be deleted.
Returns:
"""
return self.client._delete(self.url + 'customers/{}'.format(customer_id), headers=self.get_headers()) | [
"def",
"delete_customer",
"(",
"self",
",",
"customer_id",
")",
":",
"return",
"self",
".",
"client",
".",
"_delete",
"(",
"self",
".",
"url",
"+",
"'customers/{}'",
".",
"format",
"(",
"customer_id",
")",
",",
"headers",
"=",
"self",
".",
"get_headers",
... | Removes a user from the system.
Args:
customer_id: Identifier of the client to be deleted.
Returns: | [
"Removes",
"a",
"user",
"from",
"the",
"system",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L154-L164 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.create_subscription | def create_subscription(self, *, customer_id, credit_card_token, plan_code, quantity=None, installments=None,
trial_days=None, immediate_payment=None, extra1=None, extra2=None, delivery_address=None,
notify_url=None, recurring_bill_items=None):
"""
... | python | def create_subscription(self, *, customer_id, credit_card_token, plan_code, quantity=None, installments=None,
trial_days=None, immediate_payment=None, extra1=None, extra2=None, delivery_address=None,
notify_url=None, recurring_bill_items=None):
"""
... | [
"def",
"create_subscription",
"(",
"self",
",",
"*",
",",
"customer_id",
",",
"credit_card_token",
",",
"plan_code",
",",
"quantity",
"=",
"None",
",",
"installments",
"=",
"None",
",",
"trial_days",
"=",
"None",
",",
"immediate_payment",
"=",
"None",
",",
"... | Creating a new subscription of a client to a plan.
Args:
customer_id: Customer that will be associated to the subscription.
You can find more information in the "Customer" section of this page.
credit_card_token: Customer's credit card that is selected to make the payment.
... | [
"Creating",
"a",
"new",
"subscription",
"of",
"a",
"client",
"to",
"a",
"plan",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L240-L303 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.get_subscription | def get_subscription(self, subscription_id):
"""
Check the basic information associated with the specified subscription.
Args:
subscription_id: Identification of the subscription.
Returns:
"""
return self.client._put(self.url + 'subscriptions/{}'.format(sub... | python | def get_subscription(self, subscription_id):
"""
Check the basic information associated with the specified subscription.
Args:
subscription_id: Identification of the subscription.
Returns:
"""
return self.client._put(self.url + 'subscriptions/{}'.format(sub... | [
"def",
"get_subscription",
"(",
"self",
",",
"subscription_id",
")",
":",
"return",
"self",
".",
"client",
".",
"_put",
"(",
"self",
".",
"url",
"+",
"'subscriptions/{}'",
".",
"format",
"(",
"subscription_id",
")",
",",
"headers",
"=",
"self",
".",
"get_h... | Check the basic information associated with the specified subscription.
Args:
subscription_id: Identification of the subscription.
Returns: | [
"Check",
"the",
"basic",
"information",
"associated",
"with",
"the",
"specified",
"subscription",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L305-L315 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.update_subscription | def update_subscription(self, *, subscription_id, credit_card_token):
"""
Update information associated with the specified subscription. At the moment it is only possible
to update the token of the credit card to which the charge of the subscription is made.
Args:
subscripti... | python | def update_subscription(self, *, subscription_id, credit_card_token):
"""
Update information associated with the specified subscription. At the moment it is only possible
to update the token of the credit card to which the charge of the subscription is made.
Args:
subscripti... | [
"def",
"update_subscription",
"(",
"self",
",",
"*",
",",
"subscription_id",
",",
"credit_card_token",
")",
":",
"payload",
"=",
"{",
"\"creditCardToken\"",
":",
"credit_card_token",
"}",
"fmt",
"=",
"'subscriptions/{}'",
".",
"format",
"(",
"subscription_id",
")"... | Update information associated with the specified subscription. At the moment it is only possible
to update the token of the credit card to which the charge of the subscription is made.
Args:
subscription_id: Identification of the subscription.
credit_card_token:
Returns... | [
"Update",
"information",
"associated",
"with",
"the",
"specified",
"subscription",
".",
"At",
"the",
"moment",
"it",
"is",
"only",
"possible",
"to",
"update",
"the",
"token",
"of",
"the",
"credit",
"card",
"to",
"which",
"the",
"charge",
"of",
"the",
"subscr... | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L317-L333 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.delete_subscription | def delete_subscription(self, subscription_id):
"""
Unsubscribe, delete the relationship of the customer with the plan.
Args:
subscription_id: Identification of the subscription.
Returns:
"""
return self.client._delete(self.url + 'subscriptions/{}'.format(s... | python | def delete_subscription(self, subscription_id):
"""
Unsubscribe, delete the relationship of the customer with the plan.
Args:
subscription_id: Identification of the subscription.
Returns:
"""
return self.client._delete(self.url + 'subscriptions/{}'.format(s... | [
"def",
"delete_subscription",
"(",
"self",
",",
"subscription_id",
")",
":",
"return",
"self",
".",
"client",
".",
"_delete",
"(",
"self",
".",
"url",
"+",
"'subscriptions/{}'",
".",
"format",
"(",
"subscription_id",
")",
",",
"headers",
"=",
"self",
".",
... | Unsubscribe, delete the relationship of the customer with the plan.
Args:
subscription_id: Identification of the subscription.
Returns: | [
"Unsubscribe",
"delete",
"the",
"relationship",
"of",
"the",
"customer",
"with",
"the",
"plan",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L335-L345 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.create_additional_charge | def create_additional_charge(self, *, subscription_id, description, plan_value, plan_tax, plan_tax_return_base,
currency):
"""
Adds extra charges to the respective invoice for the current period.
Args:
subscription_id: Identification of the subscript... | python | def create_additional_charge(self, *, subscription_id, description, plan_value, plan_tax, plan_tax_return_base,
currency):
"""
Adds extra charges to the respective invoice for the current period.
Args:
subscription_id: Identification of the subscript... | [
"def",
"create_additional_charge",
"(",
"self",
",",
"*",
",",
"subscription_id",
",",
"description",
",",
"plan_value",
",",
"plan_tax",
",",
"plan_tax_return_base",
",",
"currency",
")",
":",
"payload",
"=",
"{",
"\"description\"",
":",
"description",
",",
"\"... | Adds extra charges to the respective invoice for the current period.
Args:
subscription_id: Identification of the subscription
description:
plan_value:
plan_tax:
plan_tax_return_base:
currency:
Returns: | [
"Adds",
"extra",
"charges",
"to",
"the",
"respective",
"invoice",
"for",
"the",
"current",
"period",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L347-L384 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.get_additional_charge_by_identifier | def get_additional_charge_by_identifier(self, recurring_billing_id):
"""
Query extra charge information of an invoice from its identifier.
Args:
recurring_billing_id: Identifier of the additional charge.
Returns:
"""
fmt = 'recurringBillItems/{}'.format(rec... | python | def get_additional_charge_by_identifier(self, recurring_billing_id):
"""
Query extra charge information of an invoice from its identifier.
Args:
recurring_billing_id: Identifier of the additional charge.
Returns:
"""
fmt = 'recurringBillItems/{}'.format(rec... | [
"def",
"get_additional_charge_by_identifier",
"(",
"self",
",",
"recurring_billing_id",
")",
":",
"fmt",
"=",
"'recurringBillItems/{}'",
".",
"format",
"(",
"recurring_billing_id",
")",
"return",
"self",
".",
"client",
".",
"_get",
"(",
"self",
".",
"url",
"+",
... | Query extra charge information of an invoice from its identifier.
Args:
recurring_billing_id: Identifier of the additional charge.
Returns: | [
"Query",
"extra",
"charge",
"information",
"of",
"an",
"invoice",
"from",
"its",
"identifier",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L386-L397 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.update_additional_charge | def update_additional_charge(self, *, recurring_billing_id, description, plan_value, plan_tax, plan_tax_return_base,
currency):
"""
Updates the information from an additional charge in an invoice.
Args:
recurring_billing_id: Identifier of the additio... | python | def update_additional_charge(self, *, recurring_billing_id, description, plan_value, plan_tax, plan_tax_return_base,
currency):
"""
Updates the information from an additional charge in an invoice.
Args:
recurring_billing_id: Identifier of the additio... | [
"def",
"update_additional_charge",
"(",
"self",
",",
"*",
",",
"recurring_billing_id",
",",
"description",
",",
"plan_value",
",",
"plan_tax",
",",
"plan_tax_return_base",
",",
"currency",
")",
":",
"payload",
"=",
"{",
"\"description\"",
":",
"description",
",",
... | Updates the information from an additional charge in an invoice.
Args:
recurring_billing_id: Identifier of the additional charge.
description:
plan_value:
plan_tax:
plan_tax_return_base:
currency:
Returns: | [
"Updates",
"the",
"information",
"from",
"an",
"additional",
"charge",
"in",
"an",
"invoice",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L429-L466 | train |
GearPlug/payu-python | payu/recurring.py | Recurring.delete_additional_charge | def delete_additional_charge(self, recurring_billing_id):
"""
Remove an extra charge from an invoice.
Args:
recurring_billing_id: Identifier of the additional charge.
Returns:
"""
fmt = 'recurringBillItems/{}'.format(recurring_billing_id)
return sel... | python | def delete_additional_charge(self, recurring_billing_id):
"""
Remove an extra charge from an invoice.
Args:
recurring_billing_id: Identifier of the additional charge.
Returns:
"""
fmt = 'recurringBillItems/{}'.format(recurring_billing_id)
return sel... | [
"def",
"delete_additional_charge",
"(",
"self",
",",
"recurring_billing_id",
")",
":",
"fmt",
"=",
"'recurringBillItems/{}'",
".",
"format",
"(",
"recurring_billing_id",
")",
"return",
"self",
".",
"client",
".",
"_delete",
"(",
"self",
".",
"url",
"+",
"fmt",
... | Remove an extra charge from an invoice.
Args:
recurring_billing_id: Identifier of the additional charge.
Returns: | [
"Remove",
"an",
"extra",
"charge",
"from",
"an",
"invoice",
"."
] | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/recurring.py#L468-L479 | train |
gtaylor/django-athumb | athumb/templatetags/thumbnail.py | thumbnail | def thumbnail(parser, token):
"""
Creates a thumbnail of for an ImageField.
To just output the absolute url to the thumbnail::
{% thumbnail image 80x80 %}
After the image path and dimensions, you can put any options::
{% thumbnail image 80x80 force_ssl=True %}
To put the thumbna... | python | def thumbnail(parser, token):
"""
Creates a thumbnail of for an ImageField.
To just output the absolute url to the thumbnail::
{% thumbnail image 80x80 %}
After the image path and dimensions, you can put any options::
{% thumbnail image 80x80 force_ssl=True %}
To put the thumbna... | [
"def",
"thumbnail",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"tag",
"=",
"args",
"[",
"0",
"]",
"if",
"len",
"(",
"args",
")",
">",
"4",
"and",
"args",
"[",
"-",
"2",
"]",
"==",
"'as'",
":",
... | Creates a thumbnail of for an ImageField.
To just output the absolute url to the thumbnail::
{% thumbnail image 80x80 %}
After the image path and dimensions, you can put any options::
{% thumbnail image 80x80 force_ssl=True %}
To put the thumbnail URL on the context instead of just rend... | [
"Creates",
"a",
"thumbnail",
"of",
"for",
"an",
"ImageField",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/templatetags/thumbnail.py#L142-L201 | train |
spacetelescope/stsci.imagestats | stsci/imagestats/__init__.py | ImageStats.printStats | def printStats(self):
""" Print the requested statistics values for those fields specified on input. """
print("--- Imagestats Results ---")
if (self.fields.find('npix') != -1 ):
print("Number of pixels : ",self.npix)
if (self.fields.find('min') != -1 ):
print(... | python | def printStats(self):
""" Print the requested statistics values for those fields specified on input. """
print("--- Imagestats Results ---")
if (self.fields.find('npix') != -1 ):
print("Number of pixels : ",self.npix)
if (self.fields.find('min') != -1 ):
print(... | [
"def",
"printStats",
"(",
"self",
")",
":",
"print",
"(",
"\"--- Imagestats Results ---\"",
")",
"if",
"(",
"self",
".",
"fields",
".",
"find",
"(",
"'npix'",
")",
"!=",
"-",
"1",
")",
":",
"print",
"(",
"\"Number of pixels : \"",
",",
"self",
".",
"np... | Print the requested statistics values for those fields specified on input. | [
"Print",
"the",
"requested",
"statistics",
"values",
"for",
"those",
"fields",
"specified",
"on",
"input",
"."
] | d7fc9fe9783f7ed3dc9e4af47acd357a5ccd68e3 | https://github.com/spacetelescope/stsci.imagestats/blob/d7fc9fe9783f7ed3dc9e4af47acd357a5ccd68e3/stsci/imagestats/__init__.py#L332-L351 | train |
digidotcom/python-wvalib | wva/http_client.py | WVAHttpClient.raw_request | def raw_request(self, method, uri, **kwargs):
"""Perform a WVA web services request and return the raw response object
:param method: The HTTP method to use when making this request
:param uri: The path past /ws to request. That is, the path requested for
a relpath of `a/b/c` would... | python | def raw_request(self, method, uri, **kwargs):
"""Perform a WVA web services request and return the raw response object
:param method: The HTTP method to use when making this request
:param uri: The path past /ws to request. That is, the path requested for
a relpath of `a/b/c` would... | [
"def",
"raw_request",
"(",
"self",
",",
"method",
",",
"uri",
",",
"**",
"kwargs",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
",",
"urllib3",
".",
"exceptions",
".",
"InsecureRequ... | Perform a WVA web services request and return the raw response object
:param method: The HTTP method to use when making this request
:param uri: The path past /ws to request. That is, the path requested for
a relpath of `a/b/c` would be `/ws/a/b/c`.
:raises WVAHttpSocketError: if t... | [
"Perform",
"a",
"WVA",
"web",
"services",
"request",
"and",
"return",
"the",
"raw",
"response",
"object"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/http_client.py#L79-L97 | train |
digidotcom/python-wvalib | wva/http_client.py | WVAHttpClient.request | def request(self, method, uri, **kwargs):
"""Perform a WVA web services request and return the decoded value if successful
:param method: The HTTP method to use when making this request
:param uri: The path past /ws to request. That is, the path requested for
a relpath of `a/b/c` w... | python | def request(self, method, uri, **kwargs):
"""Perform a WVA web services request and return the decoded value if successful
:param method: The HTTP method to use when making this request
:param uri: The path past /ws to request. That is, the path requested for
a relpath of `a/b/c` w... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"uri",
",",
"**",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"raw_request",
"(",
"method",
",",
"uri",
",",
"**",
"kwargs",
")",
"if",
"response",
".",
"status_code",
"!=",
"200",
":",
"except... | Perform a WVA web services request and return the decoded value if successful
:param method: The HTTP method to use when making this request
:param uri: The path past /ws to request. That is, the path requested for
a relpath of `a/b/c` would be `/ws/a/b/c`.
:raises WVAHttpError: if... | [
"Perform",
"a",
"WVA",
"web",
"services",
"request",
"and",
"return",
"the",
"decoded",
"value",
"if",
"successful"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/http_client.py#L99-L121 | train |
digidotcom/python-wvalib | wva/http_client.py | WVAHttpClient.post | def post(self, uri, data, **kwargs):
"""POST the provided data to the specified path
See :meth:`request` for additional details. The `data` parameter here is
expected to be a string type.
"""
return self.request("POST", uri, data=data, **kwargs) | python | def post(self, uri, data, **kwargs):
"""POST the provided data to the specified path
See :meth:`request` for additional details. The `data` parameter here is
expected to be a string type.
"""
return self.request("POST", uri, data=data, **kwargs) | [
"def",
"post",
"(",
"self",
",",
"uri",
",",
"data",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"POST\"",
",",
"uri",
",",
"data",
"=",
"data",
",",
"**",
"kwargs",
")"
] | POST the provided data to the specified path
See :meth:`request` for additional details. The `data` parameter here is
expected to be a string type. | [
"POST",
"the",
"provided",
"data",
"to",
"the",
"specified",
"path"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/http_client.py#L137-L143 | train |
digidotcom/python-wvalib | wva/http_client.py | WVAHttpClient.post_json | def post_json(self, uri, data, **kwargs):
"""POST the provided data as json to the specified path
See :meth:`request` for additional details.
"""
encoded_data = json.dumps(data)
kwargs.setdefault("headers", {}).update({
"Content-Type": "application/json", # tell ser... | python | def post_json(self, uri, data, **kwargs):
"""POST the provided data as json to the specified path
See :meth:`request` for additional details.
"""
encoded_data = json.dumps(data)
kwargs.setdefault("headers", {}).update({
"Content-Type": "application/json", # tell ser... | [
"def",
"post_json",
"(",
"self",
",",
"uri",
",",
"data",
",",
"**",
"kwargs",
")",
":",
"encoded_data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"kwargs",
".",
"setdefault",
"(",
"\"headers\"",
",",
"{",
"}",
")",
".",
"update",
"(",
"{",
"\"C... | POST the provided data as json to the specified path
See :meth:`request` for additional details. | [
"POST",
"the",
"provided",
"data",
"as",
"json",
"to",
"the",
"specified",
"path"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/http_client.py#L145-L154 | train |
digidotcom/python-wvalib | wva/http_client.py | WVAHttpClient.put | def put(self, uri, data, **kwargs):
"""PUT the provided data to the specified path
See :meth:`request` for additional details. The `data` parameter here is
expected to be a string type.
"""
return self.request("PUT", uri, data=data, **kwargs) | python | def put(self, uri, data, **kwargs):
"""PUT the provided data to the specified path
See :meth:`request` for additional details. The `data` parameter here is
expected to be a string type.
"""
return self.request("PUT", uri, data=data, **kwargs) | [
"def",
"put",
"(",
"self",
",",
"uri",
",",
"data",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"PUT\"",
",",
"uri",
",",
"data",
"=",
"data",
",",
"**",
"kwargs",
")"
] | PUT the provided data to the specified path
See :meth:`request` for additional details. The `data` parameter here is
expected to be a string type. | [
"PUT",
"the",
"provided",
"data",
"to",
"the",
"specified",
"path"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/http_client.py#L156-L162 | train |
digidotcom/python-wvalib | wva/http_client.py | WVAHttpClient.put_json | def put_json(self, uri, data, **kwargs):
"""PUT the provided data as json to the specified path
See :meth:`request` for additional details.
"""
encoded_data = json.dumps(data)
kwargs.setdefault("headers", {}).update({
"Content-Type": "application/json", # tell serve... | python | def put_json(self, uri, data, **kwargs):
"""PUT the provided data as json to the specified path
See :meth:`request` for additional details.
"""
encoded_data = json.dumps(data)
kwargs.setdefault("headers", {}).update({
"Content-Type": "application/json", # tell serve... | [
"def",
"put_json",
"(",
"self",
",",
"uri",
",",
"data",
",",
"**",
"kwargs",
")",
":",
"encoded_data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"kwargs",
".",
"setdefault",
"(",
"\"headers\"",
",",
"{",
"}",
")",
".",
"update",
"(",
"{",
"\"Co... | PUT the provided data as json to the specified path
See :meth:`request` for additional details. | [
"PUT",
"the",
"provided",
"data",
"as",
"json",
"to",
"the",
"specified",
"path"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/http_client.py#L164-L173 | train |
frawau/aiolifx | aiolifx/aiolifx.py | mac_to_ipv6_linklocal | def mac_to_ipv6_linklocal(mac,prefix="fe80::"):
""" Translate a MAC address into an IPv6 address in the prefixed network.
This function calculates the EUI (Extended Unique Identifier) from the given
MAC address and prepend the needed prefix to come up with a valid IPv6 address.
The default prefix is th... | python | def mac_to_ipv6_linklocal(mac,prefix="fe80::"):
""" Translate a MAC address into an IPv6 address in the prefixed network.
This function calculates the EUI (Extended Unique Identifier) from the given
MAC address and prepend the needed prefix to come up with a valid IPv6 address.
The default prefix is th... | [
"def",
"mac_to_ipv6_linklocal",
"(",
"mac",
",",
"prefix",
"=",
"\"fe80::\"",
")",
":",
"mac_value",
"=",
"int",
"(",
"mac",
".",
"translate",
"(",
"str",
".",
"maketrans",
"(",
"dict",
"(",
"[",
"(",
"x",
",",
"None",
")",
"for",
"x",
"in",
"[",
"... | Translate a MAC address into an IPv6 address in the prefixed network.
This function calculates the EUI (Extended Unique Identifier) from the given
MAC address and prepend the needed prefix to come up with a valid IPv6 address.
The default prefix is the link local prefix defined by RFC 4291 .
:para... | [
"Translate",
"a",
"MAC",
"address",
"into",
"an",
"IPv6",
"address",
"in",
"the",
"prefixed",
"network",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L41-L67 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.datagram_received | def datagram_received(self, data, addr):
"""Method run when data is received from the device
This method will unpack the data according to the LIFX protocol.
If the message represents some state information, it will update
the device state. Following that it will execute the callback co... | python | def datagram_received(self, data, addr):
"""Method run when data is received from the device
This method will unpack the data according to the LIFX protocol.
If the message represents some state information, it will update
the device state. Following that it will execute the callback co... | [
"def",
"datagram_received",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"self",
".",
"register",
"(",
")",
"response",
"=",
"unpack_lifx_message",
"(",
"data",
")",
"self",
".",
"lastmsg",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"i... | Method run when data is received from the device
This method will unpack the data according to the LIFX protocol.
If the message represents some state information, it will update
the device state. Following that it will execute the callback corresponding
to the message sequence number. ... | [
"Method",
"run",
"when",
"data",
"is",
"received",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L146-L180 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.register | def register(self):
"""Proxy method to register the device with the parent.
"""
if not self.registered:
self.registered = True
if self.parent:
self.parent.register(self) | python | def register(self):
"""Proxy method to register the device with the parent.
"""
if not self.registered:
self.registered = True
if self.parent:
self.parent.register(self) | [
"def",
"register",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"registered",
":",
"self",
".",
"registered",
"=",
"True",
"if",
"self",
".",
"parent",
":",
"self",
".",
"parent",
".",
"register",
"(",
"self",
")"
] | Proxy method to register the device with the parent. | [
"Proxy",
"method",
"to",
"register",
"the",
"device",
"with",
"the",
"parent",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L182-L188 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.unregister | def unregister(self):
"""Proxy method to unregister the device with the parent.
"""
if self.registered:
#Only if we have not received any message recently.
if datetime.datetime.now()-datetime.timedelta(seconds=self.unregister_timeout) > self.lastmsg:
self.... | python | def unregister(self):
"""Proxy method to unregister the device with the parent.
"""
if self.registered:
#Only if we have not received any message recently.
if datetime.datetime.now()-datetime.timedelta(seconds=self.unregister_timeout) > self.lastmsg:
self.... | [
"def",
"unregister",
"(",
"self",
")",
":",
"if",
"self",
".",
"registered",
":",
"if",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"unregister_timeout",
")",
">",
"self",
".",... | Proxy method to unregister the device with the parent. | [
"Proxy",
"method",
"to",
"unregister",
"the",
"device",
"with",
"the",
"parent",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L190-L198 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.fire_sending | async def fire_sending(self,msg,num_repeats):
"""Coroutine used to send message to the device when no response is needed.
:param msg: Message to send
:type msg: aiolifx.
:param num_repeats: number of times the message is to be sent.
:returns: The coroutine that c... | python | async def fire_sending(self,msg,num_repeats):
"""Coroutine used to send message to the device when no response is needed.
:param msg: Message to send
:type msg: aiolifx.
:param num_repeats: number of times the message is to be sent.
:returns: The coroutine that c... | [
"async",
"def",
"fire_sending",
"(",
"self",
",",
"msg",
",",
"num_repeats",
")",
":",
"if",
"num_repeats",
"is",
"None",
":",
"num_repeats",
"=",
"self",
".",
"retry_count",
"sent_msg_count",
"=",
"0",
"sleep_interval",
"=",
"0.05",
"while",
"(",
"sent_msg_... | Coroutine used to send message to the device when no response is needed.
:param msg: Message to send
:type msg: aiolifx.
:param num_repeats: number of times the message is to be sent.
:returns: The coroutine that can be scheduled to run
:rtype: coroutine | [
"Coroutine",
"used",
"to",
"send",
"message",
"to",
"the",
"device",
"when",
"no",
"response",
"is",
"needed",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L214-L231 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.try_sending | async def try_sending(self,msg,timeout_secs, max_attempts):
"""Coroutine used to send message to the device when a response or ack is needed.
This coroutine will try to send up to max_attempts time the message, waiting timeout_secs
for an answer. If no answer is received, it will consider that ... | python | async def try_sending(self,msg,timeout_secs, max_attempts):
"""Coroutine used to send message to the device when a response or ack is needed.
This coroutine will try to send up to max_attempts time the message, waiting timeout_secs
for an answer. If no answer is received, it will consider that ... | [
"async",
"def",
"try_sending",
"(",
"self",
",",
"msg",
",",
"timeout_secs",
",",
"max_attempts",
")",
":",
"if",
"timeout_secs",
"is",
"None",
":",
"timeout_secs",
"=",
"self",
".",
"timeout",
"if",
"max_attempts",
"is",
"None",
":",
"max_attempts",
"=",
... | Coroutine used to send message to the device when a response or ack is needed.
This coroutine will try to send up to max_attempts time the message, waiting timeout_secs
for an answer. If no answer is received, it will consider that the device is no longer
accessible and will unregister it.
... | [
"Coroutine",
"used",
"to",
"send",
"message",
"to",
"the",
"device",
"when",
"a",
"response",
"or",
"ack",
"is",
"needed",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L253-L293 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.req_with_ack | def req_with_ack(self, msg_type, payload, callb = None, timeout_secs=None, max_attempts=None):
"""Method to send a message expecting to receive an ACK.
:param msg_type: The type of the message to send, a subclass of aiolifx.Message
:type msg_type: class
:param payload: value... | python | def req_with_ack(self, msg_type, payload, callb = None, timeout_secs=None, max_attempts=None):
"""Method to send a message expecting to receive an ACK.
:param msg_type: The type of the message to send, a subclass of aiolifx.Message
:type msg_type: class
:param payload: value... | [
"def",
"req_with_ack",
"(",
"self",
",",
"msg_type",
",",
"payload",
",",
"callb",
"=",
"None",
",",
"timeout_secs",
"=",
"None",
",",
"max_attempts",
"=",
"None",
")",
":",
"msg",
"=",
"msg_type",
"(",
"self",
".",
"mac_addr",
",",
"self",
".",
"sourc... | Method to send a message expecting to receive an ACK.
:param msg_type: The type of the message to send, a subclass of aiolifx.Message
:type msg_type: class
:param payload: value to use when instantiating msg_type
:type payload: dict
:param callb: A callback t... | [
"Method",
"to",
"send",
"a",
"message",
"expecting",
"to",
"receive",
"an",
"ACK",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L296-L315 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_label | def get_label(self,callb=None):
"""Convenience method to request the label from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb ... | python | def get_label(self,callb=None):
"""Convenience method to request the label from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb ... | [
"def",
"get_label",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"if",
"self",
".",
"label",
"is",
"None",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_label",
")",
"if",
"callb",
":",
"mycallb",
"=",
"lambda",
"x",
",",
"y",
... | Convenience method to request the label from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response is received. Th... | [
"Convenience",
"method",
"to",
"request",
"the",
"label",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L367-L388 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.set_label | def set_label(self, value,callb=None):
"""Convenience method to set the label of the device
This method will send a SetLabel message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param value: The new label
... | python | def set_label(self, value,callb=None):
"""Convenience method to set the label of the device
This method will send a SetLabel message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param value: The new label
... | [
"def",
"set_label",
"(",
"self",
",",
"value",
",",
"callb",
"=",
"None",
")",
":",
"if",
"len",
"(",
"value",
")",
">",
"32",
":",
"value",
"=",
"value",
"[",
":",
"32",
"]",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_label",
",",
... | Convenience method to set the label of the device
This method will send a SetLabel message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param value: The new label
:type value: str
:param cal... | [
"Convenience",
"method",
"to",
"set",
"the",
"label",
"of",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L390-L410 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_location | def get_location(self,callb=None):
"""Convenience method to request the location from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that ... | python | def get_location(self,callb=None):
"""Convenience method to request the location from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that ... | [
"def",
"get_location",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"if",
"self",
".",
"location",
"is",
"None",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_location",
")",
"if",
"callb",
":",
"mycallb",
"=",
"lambda",
"x",
",",
... | Convenience method to request the location from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response is received.... | [
"Convenience",
"method",
"to",
"request",
"the",
"location",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L420-L441 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_group | def get_group(self,callb=None):
"""Convenience method to request the group from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb ... | python | def get_group(self,callb=None):
"""Convenience method to request the group from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb ... | [
"def",
"get_group",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"if",
"self",
".",
"group",
"is",
"None",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_group",
")",
"if",
"callb",
":",
"mycallb",
"=",
"lambda",
"x",
",",
"y",
... | Convenience method to request the group from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response is received. Th... | [
"Convenience",
"method",
"to",
"request",
"the",
"group",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L460-L481 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_wififirmware | def get_wififirmware(self,callb=None):
"""Convenience method to request the wifi firmware info from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and... | python | def get_wififirmware(self,callb=None):
"""Convenience method to request the wifi firmware info from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and... | [
"def",
"get_wififirmware",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"if",
"self",
".",
"wifi_firmware_version",
"is",
"None",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_wififirmware",
")",
"if",
"callb",
":",
"mycallb",
"=",
"la... | Convenience method to request the wifi firmware info from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response is... | [
"Convenience",
"method",
"to",
"request",
"the",
"wifi",
"firmware",
"info",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L560-L581 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.resp_set_wififirmware | def resp_set_wififirmware(self, resp):
"""Default callback for get_wififirmware
"""
if resp:
self.wifi_firmware_version = float(str(str(resp.version >> 16) + "." + str(resp.version & 0xff)))
self.wifi_firmware_build_timestamp = resp.build | python | def resp_set_wififirmware(self, resp):
"""Default callback for get_wififirmware
"""
if resp:
self.wifi_firmware_version = float(str(str(resp.version >> 16) + "." + str(resp.version & 0xff)))
self.wifi_firmware_build_timestamp = resp.build | [
"def",
"resp_set_wififirmware",
"(",
"self",
",",
"resp",
")",
":",
"if",
"resp",
":",
"self",
".",
"wifi_firmware_version",
"=",
"float",
"(",
"str",
"(",
"str",
"(",
"resp",
".",
"version",
">>",
"16",
")",
"+",
"\".\"",
"+",
"str",
"(",
"resp",
".... | Default callback for get_wififirmware | [
"Default",
"callback",
"for",
"get_wififirmware"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L583-L588 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_wifiinfo | def get_wifiinfo(self,callb=None):
"""Convenience method to request the wifi info from the device
This will request the information from the device and request that callb be executed
when a response is received. The is no default callback
:param callb: Callable to be used when the... | python | def get_wifiinfo(self,callb=None):
"""Convenience method to request the wifi info from the device
This will request the information from the device and request that callb be executed
when a response is received. The is no default callback
:param callb: Callable to be used when the... | [
"def",
"get_wifiinfo",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"req_with_resp",
"(",
"GetWifiInfo",
",",
"StateWifiInfo",
",",
"callb",
"=",
"callb",
")",
"return",
"None"
] | Convenience method to request the wifi info from the device
This will request the information from the device and request that callb be executed
when a response is received. The is no default callback
:param callb: Callable to be used when the response is received. If not set,
... | [
"Convenience",
"method",
"to",
"request",
"the",
"wifi",
"info",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L591-L604 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_hostfirmware | def get_hostfirmware(self,callb=None):
"""Convenience method to request the device firmware info from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
a... | python | def get_hostfirmware(self,callb=None):
"""Convenience method to request the device firmware info from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
a... | [
"def",
"get_hostfirmware",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"if",
"self",
".",
"host_firmware_version",
"is",
"None",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_hostfirmware",
")",
"if",
"callb",
":",
"mycallb",
"=",
"la... | Convenience method to request the device firmware info from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response ... | [
"Convenience",
"method",
"to",
"request",
"the",
"device",
"firmware",
"info",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L607-L628 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.resp_set_hostfirmware | def resp_set_hostfirmware(self, resp):
"""Default callback for get_hostfirmware
"""
if resp:
self.host_firmware_version = float(str(str(resp.version >> 16) + "." + str(resp.version & 0xff)))
self.host_firmware_build_timestamp = resp.build | python | def resp_set_hostfirmware(self, resp):
"""Default callback for get_hostfirmware
"""
if resp:
self.host_firmware_version = float(str(str(resp.version >> 16) + "." + str(resp.version & 0xff)))
self.host_firmware_build_timestamp = resp.build | [
"def",
"resp_set_hostfirmware",
"(",
"self",
",",
"resp",
")",
":",
"if",
"resp",
":",
"self",
".",
"host_firmware_version",
"=",
"float",
"(",
"str",
"(",
"str",
"(",
"resp",
".",
"version",
">>",
"16",
")",
"+",
"\".\"",
"+",
"str",
"(",
"resp",
".... | Default callback for get_hostfirmware | [
"Default",
"callback",
"for",
"get_hostfirmware"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L630-L635 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_hostinfo | def get_hostinfo(self,callb=None):
"""Convenience method to request the device info from the device
This will request the information from the device and request that callb be executed
when a response is received. The is no default callback
:param callb: Callable to be used when the r... | python | def get_hostinfo(self,callb=None):
"""Convenience method to request the device info from the device
This will request the information from the device and request that callb be executed
when a response is received. The is no default callback
:param callb: Callable to be used when the r... | [
"def",
"get_hostinfo",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"req_with_resp",
"(",
"GetInfo",
",",
"StateInfo",
",",
"callb",
"=",
"callb",
")",
"return",
"None"
] | Convenience method to request the device info from the device
This will request the information from the device and request that callb be executed
when a response is received. The is no default callback
:param callb: Callable to be used when the response is received. If not set,
... | [
"Convenience",
"method",
"to",
"request",
"the",
"device",
"info",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L638-L651 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.get_version | def get_version(self,callb=None):
"""Convenience method to request the version from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that ca... | python | def get_version(self,callb=None):
"""Convenience method to request the version from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that ca... | [
"def",
"get_version",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"if",
"self",
".",
"vendor",
"is",
"None",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_version",
")",
"if",
"callb",
":",
"mycallb",
"=",
"lambda",
"x",
",",
"y... | Convenience method to request the version from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response is received. ... | [
"Convenience",
"method",
"to",
"request",
"the",
"version",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L653-L674 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Device.resp_set_version | def resp_set_version(self, resp):
"""Default callback for get_version
"""
if resp:
self.vendor = resp.vendor
self.product = resp.product
self.version = resp.version | python | def resp_set_version(self, resp):
"""Default callback for get_version
"""
if resp:
self.vendor = resp.vendor
self.product = resp.product
self.version = resp.version | [
"def",
"resp_set_version",
"(",
"self",
",",
"resp",
")",
":",
"if",
"resp",
":",
"self",
".",
"vendor",
"=",
"resp",
".",
"vendor",
"self",
".",
"product",
"=",
"resp",
".",
"product",
"self",
".",
"version",
"=",
"resp",
".",
"version"
] | Default callback for get_version | [
"Default",
"callback",
"for",
"get_version"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L676-L682 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.resp_set_lightpower | def resp_set_lightpower(self, resp, power_level=None):
"""Default callback for set_power
"""
if power_level is not None:
self.power_level=power_level
elif resp:
self.power_level=resp.power_level | python | def resp_set_lightpower(self, resp, power_level=None):
"""Default callback for set_power
"""
if power_level is not None:
self.power_level=power_level
elif resp:
self.power_level=resp.power_level | [
"def",
"resp_set_lightpower",
"(",
"self",
",",
"resp",
",",
"power_level",
"=",
"None",
")",
":",
"if",
"power_level",
"is",
"not",
"None",
":",
"self",
".",
"power_level",
"=",
"power_level",
"elif",
"resp",
":",
"self",
".",
"power_level",
"=",
"resp",
... | Default callback for set_power | [
"Default",
"callback",
"for",
"set_power"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L834-L840 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.get_color | def get_color(self,callb=None):
"""Convenience method to request the colour status from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request tha... | python | def get_color(self,callb=None):
"""Convenience method to request the colour status from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request tha... | [
"def",
"get_color",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"req_with_resp",
"(",
"LightGet",
",",
"LightState",
",",
"callb",
"=",
"callb",
")",
"return",
"self",
".",
"color"
] | Convenience method to request the colour status from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response is rece... | [
"Convenience",
"method",
"to",
"request",
"the",
"colour",
"status",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L843-L858 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.set_color | def set_color(self, value, callb=None, duration=0, rapid=False):
"""Convenience method to set the colour status of the device
This method will send a LightSetColor message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
... | python | def set_color(self, value, callb=None, duration=0, rapid=False):
"""Convenience method to set the colour status of the device
This method will send a LightSetColor message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
... | [
"def",
"set_color",
"(",
"self",
",",
"value",
",",
"callb",
"=",
"None",
",",
"duration",
"=",
"0",
",",
"rapid",
"=",
"False",
")",
":",
"if",
"len",
"(",
"value",
")",
"==",
"4",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_ligh... | Convenience method to set the colour status of the device
This method will send a LightSetColor message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param value: The new state, a dictionary onf int with 4 keys Hue,... | [
"Convenience",
"method",
"to",
"set",
"the",
"colour",
"status",
"of",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L861-L892 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.resp_set_light | def resp_set_light(self, resp, color=None):
"""Default callback for set_color
"""
if color:
self.color=color
elif resp:
self.power_level = resp.power_level
self.color = resp.color
self.label = resp.label.decode().replace("\x00", "") | python | def resp_set_light(self, resp, color=None):
"""Default callback for set_color
"""
if color:
self.color=color
elif resp:
self.power_level = resp.power_level
self.color = resp.color
self.label = resp.label.decode().replace("\x00", "") | [
"def",
"resp_set_light",
"(",
"self",
",",
"resp",
",",
"color",
"=",
"None",
")",
":",
"if",
"color",
":",
"self",
".",
"color",
"=",
"color",
"elif",
"resp",
":",
"self",
".",
"power_level",
"=",
"resp",
".",
"power_level",
"self",
".",
"color",
"=... | Default callback for set_color | [
"Default",
"callback",
"for",
"set_color"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L897-L905 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.get_color_zones | def get_color_zones(self, start_index, end_index=None, callb=None):
"""Convenience method to request the state of colour by zones from the device
This method will request the information from the device and request that callb
be executed when a response is received.
:param start_in... | python | def get_color_zones(self, start_index, end_index=None, callb=None):
"""Convenience method to request the state of colour by zones from the device
This method will request the information from the device and request that callb
be executed when a response is received.
:param start_in... | [
"def",
"get_color_zones",
"(",
"self",
",",
"start_index",
",",
"end_index",
"=",
"None",
",",
"callb",
"=",
"None",
")",
":",
"if",
"end_index",
"is",
"None",
":",
"end_index",
"=",
"start_index",
"+",
"7",
"args",
"=",
"{",
"\"start_index\"",
":",
"sta... | Convenience method to request the state of colour by zones from the device
This method will request the information from the device and request that callb
be executed when a response is received.
:param start_index: Index of the start of the zone of interest
:type start_index: ... | [
"Convenience",
"method",
"to",
"request",
"the",
"state",
"of",
"colour",
"by",
"zones",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L908-L930 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.set_color_zones | def set_color_zones(self, start_index, end_index, color, duration=0, apply=1, callb=None, rapid=False):
"""Convenience method to set the colour status zone of the device
This method will send a MultiZoneSetColorZones message to the device, and request callb be executed
when an ACK is received. ... | python | def set_color_zones(self, start_index, end_index, color, duration=0, apply=1, callb=None, rapid=False):
"""Convenience method to set the colour status zone of the device
This method will send a MultiZoneSetColorZones message to the device, and request callb be executed
when an ACK is received. ... | [
"def",
"set_color_zones",
"(",
"self",
",",
"start_index",
",",
"end_index",
",",
"color",
",",
"duration",
"=",
"0",
",",
"apply",
"=",
"1",
",",
"callb",
"=",
"None",
",",
"rapid",
"=",
"False",
")",
":",
"if",
"len",
"(",
"color",
")",
"==",
"4"... | Convenience method to set the colour status zone of the device
This method will send a MultiZoneSetColorZones message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param start_index: Index of the start of the zone o... | [
"Convenience",
"method",
"to",
"set",
"the",
"colour",
"status",
"zone",
"of",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L932-L975 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.get_infrared | def get_infrared(self,callb=None):
"""Convenience method to request the infrared brightness from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and re... | python | def get_infrared(self,callb=None):
"""Convenience method to request the infrared brightness from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and re... | [
"def",
"get_infrared",
"(",
"self",
",",
"callb",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"req_with_resp",
"(",
"LightGetInfrared",
",",
"LightStateInfrared",
",",
"callb",
"=",
"callb",
")",
"return",
"self",
".",
"infrared_brightness"
] | Convenience method to request the infrared brightness from the device
This method will check whether the value has already been retrieved from the device,
if so, it will simply return it. If no, it will request the information from the device
and request that callb be executed when a response i... | [
"Convenience",
"method",
"to",
"request",
"the",
"infrared",
"brightness",
"from",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1045-L1060 | train |
frawau/aiolifx | aiolifx/aiolifx.py | Light.set_infrared | def set_infrared(self, infrared_brightness, callb=None, rapid=False):
"""Convenience method to set the infrared status of the device
This method will send a SetPower message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
... | python | def set_infrared(self, infrared_brightness, callb=None, rapid=False):
"""Convenience method to set the infrared status of the device
This method will send a SetPower message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
... | [
"def",
"set_infrared",
"(",
"self",
",",
"infrared_brightness",
",",
"callb",
"=",
"None",
",",
"rapid",
"=",
"False",
")",
":",
"mypartial",
"=",
"partial",
"(",
"self",
".",
"resp_set_infrared",
",",
"infrared_brightness",
"=",
"infrared_brightness",
")",
"i... | Convenience method to set the infrared status of the device
This method will send a SetPower message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param infrared_brightness: The new state
:type infrared_... | [
"Convenience",
"method",
"to",
"set",
"the",
"infrared",
"status",
"of",
"the",
"device"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1063-L1092 | train |
frawau/aiolifx | aiolifx/aiolifx.py | LifxDiscovery.start | def start(self, listen_ip=LISTEN_IP, listen_port=0):
"""Start discovery task."""
coro = self.loop.create_datagram_endpoint(
lambda: self, local_addr=(listen_ip, listen_port))
self.task = self.loop.create_task(coro)
return self.task | python | def start(self, listen_ip=LISTEN_IP, listen_port=0):
"""Start discovery task."""
coro = self.loop.create_datagram_endpoint(
lambda: self, local_addr=(listen_ip, listen_port))
self.task = self.loop.create_task(coro)
return self.task | [
"def",
"start",
"(",
"self",
",",
"listen_ip",
"=",
"LISTEN_IP",
",",
"listen_port",
"=",
"0",
")",
":",
"coro",
"=",
"self",
".",
"loop",
".",
"create_datagram_endpoint",
"(",
"lambda",
":",
"self",
",",
"local_addr",
"=",
"(",
"listen_ip",
",",
"listen... | Start discovery task. | [
"Start",
"discovery",
"task",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1150-L1156 | train |
frawau/aiolifx | aiolifx/aiolifx.py | LifxDiscovery.connection_made | def connection_made(self, transport):
"""Method run when the UDP broadcast server is started
"""
#print('started')
self.transport = transport
sock = self.transport.get_extra_info("socket")
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setsockopt(... | python | def connection_made(self, transport):
"""Method run when the UDP broadcast server is started
"""
#print('started')
self.transport = transport
sock = self.transport.get_extra_info("socket")
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setsockopt(... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"transport",
"=",
"transport",
"sock",
"=",
"self",
".",
"transport",
".",
"get_extra_info",
"(",
"\"socket\"",
")",
"sock",
".",
"setsockopt",
"(",
"socket",
".",
"SOL_SOCKET",
... | Method run when the UDP broadcast server is started | [
"Method",
"run",
"when",
"the",
"UDP",
"broadcast",
"server",
"is",
"started"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1158-L1166 | train |
frawau/aiolifx | aiolifx/aiolifx.py | LifxDiscovery.datagram_received | def datagram_received(self, data, addr):
"""Method run when data is received from the devices
This method will unpack the data according to the LIFX protocol.
If a new device is found, the Light device will be created and started aa
a DatagramProtocol and will be registered with the par... | python | def datagram_received(self, data, addr):
"""Method run when data is received from the devices
This method will unpack the data according to the LIFX protocol.
If a new device is found, the Light device will be created and started aa
a DatagramProtocol and will be registered with the par... | [
"def",
"datagram_received",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"response",
"=",
"unpack_lifx_message",
"(",
"data",
")",
"response",
".",
"ip_addr",
"=",
"addr",
"[",
"0",
"]",
"mac_addr",
"=",
"response",
".",
"target_addr",
"if",
"mac_addr"... | Method run when data is received from the devices
This method will unpack the data according to the LIFX protocol.
If a new device is found, the Light device will be created and started aa
a DatagramProtocol and will be registered with the parent.
:param data: raw data
... | [
"Method",
"run",
"when",
"data",
"is",
"received",
"from",
"the",
"devices"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1168-L1222 | train |
frawau/aiolifx | aiolifx/aiolifx.py | LifxDiscovery.discover | def discover(self):
"""Method to send a discovery message
"""
if self.transport:
if self.discovery_countdown <= 0:
self.discovery_countdown = self.discovery_interval
msg = GetService(BROADCAST_MAC, self.source_id, seq_num=0, payload={}, ack_requested=F... | python | def discover(self):
"""Method to send a discovery message
"""
if self.transport:
if self.discovery_countdown <= 0:
self.discovery_countdown = self.discovery_interval
msg = GetService(BROADCAST_MAC, self.source_id, seq_num=0, payload={}, ack_requested=F... | [
"def",
"discover",
"(",
"self",
")",
":",
"if",
"self",
".",
"transport",
":",
"if",
"self",
".",
"discovery_countdown",
"<=",
"0",
":",
"self",
".",
"discovery_countdown",
"=",
"self",
".",
"discovery_interval",
"msg",
"=",
"GetService",
"(",
"BROADCAST_MAC... | Method to send a discovery message | [
"Method",
"to",
"send",
"a",
"discovery",
"message"
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1224-L1234 | train |
frawau/aiolifx | aiolifx/aiolifx.py | LifxScan.scan | async def scan(self, timeout=1):
"""Return a list of local IP addresses on interfaces with LIFX bulbs."""
adapters = await self.loop.run_in_executor(None, ifaddr.get_adapters)
ips = [ip.ip for adapter in ifaddr.get_adapters() for ip in adapter.ips if ip.is_IPv4]
if not ips:
... | python | async def scan(self, timeout=1):
"""Return a list of local IP addresses on interfaces with LIFX bulbs."""
adapters = await self.loop.run_in_executor(None, ifaddr.get_adapters)
ips = [ip.ip for adapter in ifaddr.get_adapters() for ip in adapter.ips if ip.is_IPv4]
if not ips:
... | [
"async",
"def",
"scan",
"(",
"self",
",",
"timeout",
"=",
"1",
")",
":",
"adapters",
"=",
"await",
"self",
".",
"loop",
".",
"run_in_executor",
"(",
"None",
",",
"ifaddr",
".",
"get_adapters",
")",
"ips",
"=",
"[",
"ip",
".",
"ip",
"for",
"adapter",
... | Return a list of local IP addresses on interfaces with LIFX bulbs. | [
"Return",
"a",
"list",
"of",
"local",
"IP",
"addresses",
"on",
"interfaces",
"with",
"LIFX",
"bulbs",
"."
] | 9bd8c5e6d291f4c79314989402f7e2c6476d5851 | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1269-L1294 | train |
geophysics-ubonn/reda | lib/reda/importers/eit_fzj.py | _get_file_version | def _get_file_version(filename):
"""High level import function that tries to determine the specific version
of the data format used.
Parameters
----------
filename: string
File path to a .mat matlab filename, as produced by the various
versions of the emmt_pp.exe postprocessing prog... | python | def _get_file_version(filename):
"""High level import function that tries to determine the specific version
of the data format used.
Parameters
----------
filename: string
File path to a .mat matlab filename, as produced by the various
versions of the emmt_pp.exe postprocessing prog... | [
"def",
"_get_file_version",
"(",
"filename",
")",
":",
"mat",
"=",
"sio",
".",
"loadmat",
"(",
"filename",
",",
"squeeze_me",
"=",
"True",
")",
"version",
"=",
"mat",
"[",
"'MP'",
"]",
"[",
"'Version'",
"]",
".",
"item",
"(",
")",
"del",
"(",
"mat",
... | High level import function that tries to determine the specific version
of the data format used.
Parameters
----------
filename: string
File path to a .mat matlab filename, as produced by the various
versions of the emmt_pp.exe postprocessing program.
Returns
-------
versio... | [
"High",
"level",
"import",
"function",
"that",
"tries",
"to",
"determine",
"the",
"specific",
"version",
"of",
"the",
"data",
"format",
"used",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/eit_fzj.py#L34-L54 | train |
geophysics-ubonn/reda | lib/reda/importers/eit_fzj.py | MD_ConfigsPermutate | def MD_ConfigsPermutate(df_md):
"""Given a MD DataFrame, return a Nx4 array which permutes the current
injection dipoles.
"""
g_current_injections = df_md.groupby(['a', 'b'])
ab = np.array(list(g_current_injections.groups.keys()))
config_mgr = ConfigManager(nr_of_electrodes=ab.max())
config_... | python | def MD_ConfigsPermutate(df_md):
"""Given a MD DataFrame, return a Nx4 array which permutes the current
injection dipoles.
"""
g_current_injections = df_md.groupby(['a', 'b'])
ab = np.array(list(g_current_injections.groups.keys()))
config_mgr = ConfigManager(nr_of_electrodes=ab.max())
config_... | [
"def",
"MD_ConfigsPermutate",
"(",
"df_md",
")",
":",
"g_current_injections",
"=",
"df_md",
".",
"groupby",
"(",
"[",
"'a'",
",",
"'b'",
"]",
")",
"ab",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"g_current_injections",
".",
"groups",
".",
"keys",
"(",
... | Given a MD DataFrame, return a Nx4 array which permutes the current
injection dipoles. | [
"Given",
"a",
"MD",
"DataFrame",
"return",
"a",
"Nx4",
"array",
"which",
"permutes",
"the",
"current",
"injection",
"dipoles",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/eit_fzj.py#L57-L65 | train |
geophysics-ubonn/reda | lib/reda/importers/eit_fzj.py | apply_correction_factors | def apply_correction_factors(df, correction_file):
"""Apply correction factors for a pseudo-2D measurement setup. See Weigand
and Kemna, 2017, Biogeosciences, for detailed information.
"""
if isinstance(correction_file, (list, tuple)):
corr_data_raw = np.vstack(
[np.loadtxt(x) for x ... | python | def apply_correction_factors(df, correction_file):
"""Apply correction factors for a pseudo-2D measurement setup. See Weigand
and Kemna, 2017, Biogeosciences, for detailed information.
"""
if isinstance(correction_file, (list, tuple)):
corr_data_raw = np.vstack(
[np.loadtxt(x) for x ... | [
"def",
"apply_correction_factors",
"(",
"df",
",",
"correction_file",
")",
":",
"if",
"isinstance",
"(",
"correction_file",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"corr_data_raw",
"=",
"np",
".",
"vstack",
"(",
"[",
"np",
".",
"loadtxt",
"(",
"x"... | Apply correction factors for a pseudo-2D measurement setup. See Weigand
and Kemna, 2017, Biogeosciences, for detailed information. | [
"Apply",
"correction",
"factors",
"for",
"a",
"pseudo",
"-",
"2D",
"measurement",
"setup",
".",
"See",
"Weigand",
"and",
"Kemna",
"2017",
"Biogeosciences",
"for",
"detailed",
"information",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/eit_fzj.py#L217-L283 | train |
evolbioinfo/pastml | pastml/ml.py | get_pij_method | def get_pij_method(model=F81, frequencies=None, kappa=None):
"""
Returns a function for calculation of probability matrix of substitutions i->j over time t.
:param kappa: kappa parameter for HKY model
:type kappa: float
:param frequencies: array of state frequencies \pi_i
:type frequencies: num... | python | def get_pij_method(model=F81, frequencies=None, kappa=None):
"""
Returns a function for calculation of probability matrix of substitutions i->j over time t.
:param kappa: kappa parameter for HKY model
:type kappa: float
:param frequencies: array of state frequencies \pi_i
:type frequencies: num... | [
"def",
"get_pij_method",
"(",
"model",
"=",
"F81",
",",
"frequencies",
"=",
"None",
",",
"kappa",
"=",
"None",
")",
":",
"if",
"is_f81_like",
"(",
"model",
")",
":",
"mu",
"=",
"get_mu",
"(",
"frequencies",
")",
"return",
"lambda",
"t",
":",
"get_f81_p... | Returns a function for calculation of probability matrix of substitutions i->j over time t.
:param kappa: kappa parameter for HKY model
:type kappa: float
:param frequencies: array of state frequencies \pi_i
:type frequencies: numpy.array
:param model: model of character evolution
:type model: ... | [
"Returns",
"a",
"function",
"for",
"calculation",
"of",
"probability",
"matrix",
"of",
"substitutions",
"i",
"-",
">",
"j",
"over",
"time",
"t",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L87-L106 | train |
evolbioinfo/pastml | pastml/ml.py | initialize_allowed_states | def initialize_allowed_states(tree, feature, states):
"""
Initializes the allowed state arrays for tips based on their states given by the feature.
:param tree: tree for which the tip likelihoods are to be initialized
:type tree: ete3.Tree
:param feature: feature in which the tip states are stored
... | python | def initialize_allowed_states(tree, feature, states):
"""
Initializes the allowed state arrays for tips based on their states given by the feature.
:param tree: tree for which the tip likelihoods are to be initialized
:type tree: ete3.Tree
:param feature: feature in which the tip states are stored
... | [
"def",
"initialize_allowed_states",
"(",
"tree",
",",
"feature",
",",
"states",
")",
":",
"allowed_states_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"ALLOWED_STATES",
")",
"state2index",
"=",
"dict",
"(",
"zip",
"(",
"states",
",",
"range... | Initializes the allowed state arrays for tips based on their states given by the feature.
:param tree: tree for which the tip likelihoods are to be initialized
:type tree: ete3.Tree
:param feature: feature in which the tip states are stored
(the value could be None for a missing state or list if mu... | [
"Initializes",
"the",
"allowed",
"state",
"arrays",
"for",
"tips",
"based",
"on",
"their",
"states",
"given",
"by",
"the",
"feature",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L309-L333 | train |
evolbioinfo/pastml | pastml/ml.py | alter_zero_tip_allowed_states | def alter_zero_tip_allowed_states(tree, feature):
"""
Alters the bottom-up likelihood arrays for zero-distance tips
to make sure they do not contradict with other zero-distance tip siblings.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood is alte... | python | def alter_zero_tip_allowed_states(tree, feature):
"""
Alters the bottom-up likelihood arrays for zero-distance tips
to make sure they do not contradict with other zero-distance tip siblings.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood is alte... | [
"def",
"alter_zero_tip_allowed_states",
"(",
"tree",
",",
"feature",
")",
":",
"zero_parent2tips",
"=",
"defaultdict",
"(",
"list",
")",
"allowed_state_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"ALLOWED_STATES",
")",
"for",
"tip",
"in",
"t... | Alters the bottom-up likelihood arrays for zero-distance tips
to make sure they do not contradict with other zero-distance tip siblings.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood is altered
:return: void, modifies the get_personalised_feature_n... | [
"Alters",
"the",
"bottom",
"-",
"up",
"likelihood",
"arrays",
"for",
"zero",
"-",
"distance",
"tips",
"to",
"make",
"sure",
"they",
"do",
"not",
"contradict",
"with",
"other",
"zero",
"-",
"distance",
"tip",
"siblings",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L336-L375 | train |
evolbioinfo/pastml | pastml/ml.py | unalter_zero_tip_allowed_states | def unalter_zero_tip_allowed_states(tree, feature, state2index):
"""
Unalters the bottom-up likelihood arrays for zero-distance tips
to contain ones only in their states.
:param state2index: dict, mapping between states and their indices in the likelihood array
:param tree: ete3.Tree, the tree of i... | python | def unalter_zero_tip_allowed_states(tree, feature, state2index):
"""
Unalters the bottom-up likelihood arrays for zero-distance tips
to contain ones only in their states.
:param state2index: dict, mapping between states and their indices in the likelihood array
:param tree: ete3.Tree, the tree of i... | [
"def",
"unalter_zero_tip_allowed_states",
"(",
"tree",
",",
"feature",
",",
"state2index",
")",
":",
"allowed_state_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"ALLOWED_STATES",
")",
"for",
"tip",
"in",
"tree",
":",
"if",
"tip",
".",
"dist... | Unalters the bottom-up likelihood arrays for zero-distance tips
to contain ones only in their states.
:param state2index: dict, mapping between states and their indices in the likelihood array
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood was alter... | [
"Unalters",
"the",
"bottom",
"-",
"up",
"likelihood",
"arrays",
"for",
"zero",
"-",
"distance",
"tips",
"to",
"contain",
"ones",
"only",
"in",
"their",
"states",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L378-L399 | train |
evolbioinfo/pastml | pastml/ml.py | unalter_zero_tip_joint_states | def unalter_zero_tip_joint_states(tree, feature, state2index):
"""
Unalters the joint tip states for zero-distance tips
to contain only their states.
:param state2index: dict, mapping between states and their indices in the joint state array
:param tree: ete3.Tree, the tree of interest
:param f... | python | def unalter_zero_tip_joint_states(tree, feature, state2index):
"""
Unalters the joint tip states for zero-distance tips
to contain only their states.
:param state2index: dict, mapping between states and their indices in the joint state array
:param tree: ete3.Tree, the tree of interest
:param f... | [
"def",
"unalter_zero_tip_joint_states",
"(",
"tree",
",",
"feature",
",",
"state2index",
")",
":",
"lh_joint_state_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"BU_LH_JOINT_STATES",
")",
"for",
"tip",
"in",
"tree",
":",
"if",
"tip",
".",
"d... | Unalters the joint tip states for zero-distance tips
to contain only their states.
:param state2index: dict, mapping between states and their indices in the joint state array
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood was altered
:return: vo... | [
"Unalters",
"the",
"joint",
"tip",
"states",
"for",
"zero",
"-",
"distance",
"tips",
"to",
"contain",
"only",
"their",
"states",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L402-L425 | train |
evolbioinfo/pastml | pastml/ml.py | calculate_marginal_likelihoods | def calculate_marginal_likelihoods(tree, feature, frequencies):
"""
Calculates marginal likelihoods for each tree node
by multiplying state frequencies with their bottom-up and top-down likelihoods.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood... | python | def calculate_marginal_likelihoods(tree, feature, frequencies):
"""
Calculates marginal likelihoods for each tree node
by multiplying state frequencies with their bottom-up and top-down likelihoods.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood... | [
"def",
"calculate_marginal_likelihoods",
"(",
"tree",
",",
"feature",
",",
"frequencies",
")",
":",
"bu_lh_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"BU_LH",
")",
"bu_lh_sf_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
... | Calculates marginal likelihoods for each tree node
by multiplying state frequencies with their bottom-up and top-down likelihoods.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the likelihood is calculated
:param frequencies: numpy array of state frequencies
... | [
"Calculates",
"marginal",
"likelihoods",
"for",
"each",
"tree",
"node",
"by",
"multiplying",
"state",
"frequencies",
"with",
"their",
"bottom",
"-",
"up",
"and",
"top",
"-",
"down",
"likelihoods",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L428-L455 | train |
evolbioinfo/pastml | pastml/ml.py | convert_likelihoods_to_probabilities | def convert_likelihoods_to_probabilities(tree, feature, states):
"""
Normalizes each node marginal likelihoods to convert them to marginal probabilities.
:param states: numpy array of states in the order corresponding to the marginal likelihood arrays
:param tree: ete3.Tree, the tree of interest
:p... | python | def convert_likelihoods_to_probabilities(tree, feature, states):
"""
Normalizes each node marginal likelihoods to convert them to marginal probabilities.
:param states: numpy array of states in the order corresponding to the marginal likelihood arrays
:param tree: ete3.Tree, the tree of interest
:p... | [
"def",
"convert_likelihoods_to_probabilities",
"(",
"tree",
",",
"feature",
",",
"states",
")",
":",
"lh_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"LH",
")",
"name2probs",
"=",
"{",
"}",
"for",
"node",
"in",
"tree",
".",
"traverse",
... | Normalizes each node marginal likelihoods to convert them to marginal probabilities.
:param states: numpy array of states in the order corresponding to the marginal likelihood arrays
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the probabilities are calculated
:... | [
"Normalizes",
"each",
"node",
"marginal",
"likelihoods",
"to",
"convert",
"them",
"to",
"marginal",
"probabilities",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L476-L493 | train |
evolbioinfo/pastml | pastml/ml.py | choose_ancestral_states_mppa | def choose_ancestral_states_mppa(tree, feature, states, force_joint=True):
"""
Chooses node ancestral states based on their marginal probabilities using MPPA method.
:param force_joint: make sure that Joint state is chosen even if it has a low probability.
:type force_joint: bool
:param tree: tree ... | python | def choose_ancestral_states_mppa(tree, feature, states, force_joint=True):
"""
Chooses node ancestral states based on their marginal probabilities using MPPA method.
:param force_joint: make sure that Joint state is chosen even if it has a low probability.
:type force_joint: bool
:param tree: tree ... | [
"def",
"choose_ancestral_states_mppa",
"(",
"tree",
",",
"feature",
",",
"states",
",",
"force_joint",
"=",
"True",
")",
":",
"lh_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"LH",
")",
"allowed_state_feature",
"=",
"get_personalized_feature_na... | Chooses node ancestral states based on their marginal probabilities using MPPA method.
:param force_joint: make sure that Joint state is chosen even if it has a low probability.
:type force_joint: bool
:param tree: tree of interest
:type tree: ete3.Tree
:param feature: character for which the ances... | [
"Chooses",
"node",
"ancestral",
"states",
"based",
"on",
"their",
"marginal",
"probabilities",
"using",
"MPPA",
"method",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L496-L563 | train |
evolbioinfo/pastml | pastml/ml.py | choose_ancestral_states_map | def choose_ancestral_states_map(tree, feature, states):
"""
Chooses node ancestral states based on their marginal probabilities using MAP method.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the ancestral states are to be chosen
:param states: numpy.array of... | python | def choose_ancestral_states_map(tree, feature, states):
"""
Chooses node ancestral states based on their marginal probabilities using MAP method.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the ancestral states are to be chosen
:param states: numpy.array of... | [
"def",
"choose_ancestral_states_map",
"(",
"tree",
",",
"feature",
",",
"states",
")",
":",
"lh_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"LH",
")",
"allowed_state_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"ALLOWED... | Chooses node ancestral states based on their marginal probabilities using MAP method.
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the ancestral states are to be chosen
:param states: numpy.array of possible character states in order corresponding to the probabiliti... | [
"Chooses",
"node",
"ancestral",
"states",
"based",
"on",
"their",
"marginal",
"probabilities",
"using",
"MAP",
"method",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L566-L582 | train |
evolbioinfo/pastml | pastml/ml.py | choose_ancestral_states_joint | def choose_ancestral_states_joint(tree, feature, states, frequencies):
"""
Chooses node ancestral states based on their marginal probabilities using joint method.
:param frequencies: numpy array of state frequencies
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for whi... | python | def choose_ancestral_states_joint(tree, feature, states, frequencies):
"""
Chooses node ancestral states based on their marginal probabilities using joint method.
:param frequencies: numpy array of state frequencies
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for whi... | [
"def",
"choose_ancestral_states_joint",
"(",
"tree",
",",
"feature",
",",
"states",
",",
"frequencies",
")",
":",
"lh_feature",
"=",
"get_personalized_feature_name",
"(",
"feature",
",",
"BU_LH",
")",
"lh_state_feature",
"=",
"get_personalized_feature_name",
"(",
"fea... | Chooses node ancestral states based on their marginal probabilities using joint method.
:param frequencies: numpy array of state frequencies
:param tree: ete3.Tree, the tree of interest
:param feature: str, character for which the ancestral states are to be chosen
:param states: numpy.array of possible... | [
"Chooses",
"node",
"ancestral",
"states",
"based",
"on",
"their",
"marginal",
"probabilities",
"using",
"joint",
"method",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L585-L609 | train |
evolbioinfo/pastml | pastml/__init__.py | col_name2cat | def col_name2cat(column):
"""
Reformats the column string to make sure it contains only numerical, letter characters or underscore.
:param column: column name to be reformatted
:type column: str
:return: column name with illegal characters removed
:rtype: str
"""
column_string = ''.join... | python | def col_name2cat(column):
"""
Reformats the column string to make sure it contains only numerical, letter characters or underscore.
:param column: column name to be reformatted
:type column: str
:return: column name with illegal characters removed
:rtype: str
"""
column_string = ''.join... | [
"def",
"col_name2cat",
"(",
"column",
")",
":",
"column_string",
"=",
"''",
".",
"join",
"(",
"s",
"for",
"s",
"in",
"column",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"if",
"s",
".",
"isalnum",
"(",
")",
"or",
"'_'",
"==",
"s",
")",
"return"... | Reformats the column string to make sure it contains only numerical, letter characters or underscore.
:param column: column name to be reformatted
:type column: str
:return: column name with illegal characters removed
:rtype: str | [
"Reformats",
"the",
"column",
"string",
"to",
"make",
"sure",
"it",
"contains",
"only",
"numerical",
"letter",
"characters",
"or",
"underscore",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/__init__.py#L14-L24 | train |
lambdalisue/notify | src/notify/conf.py | get_user_config_filename | def get_user_config_filename(appname='notify'):
"""
Get user config filename.
It will return operating system dependent config filename.
Parameters
----------
appname : string
An application name used for filename
Returns
-------
string
A filename of user configura... | python | def get_user_config_filename(appname='notify'):
"""
Get user config filename.
It will return operating system dependent config filename.
Parameters
----------
appname : string
An application name used for filename
Returns
-------
string
A filename of user configura... | [
"def",
"get_user_config_filename",
"(",
"appname",
"=",
"'notify'",
")",
":",
"import",
"platform",
"system",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"system",
"==",
"'Windows'",
":",
"rootname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".... | Get user config filename.
It will return operating system dependent config filename.
Parameters
----------
appname : string
An application name used for filename
Returns
-------
string
A filename of user configuration. | [
"Get",
"user",
"config",
"filename",
"."
] | 1b6d7d1faa2cea13bfaa1f35130f279a0115e686 | https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/conf.py#L24-L70 | train |
lambdalisue/notify | src/notify/conf.py | config_to_options | def config_to_options(config):
"""
Convert ConfigParser instance to argparse.Namespace
Parameters
----------
config : object
A ConfigParser instance
Returns
-------
object
An argparse.Namespace instance
"""
class Options:
host=config.get('smtp', 'host', ... | python | def config_to_options(config):
"""
Convert ConfigParser instance to argparse.Namespace
Parameters
----------
config : object
A ConfigParser instance
Returns
-------
object
An argparse.Namespace instance
"""
class Options:
host=config.get('smtp', 'host', ... | [
"def",
"config_to_options",
"(",
"config",
")",
":",
"class",
"Options",
":",
"host",
"=",
"config",
".",
"get",
"(",
"'smtp'",
",",
"'host'",
",",
"raw",
"=",
"True",
")",
"port",
"=",
"config",
".",
"getint",
"(",
"'smtp'",
",",
"'port'",
")",
"to_... | Convert ConfigParser instance to argparse.Namespace
Parameters
----------
config : object
A ConfigParser instance
Returns
-------
object
An argparse.Namespace instance | [
"Convert",
"ConfigParser",
"instance",
"to",
"argparse",
".",
"Namespace"
] | 1b6d7d1faa2cea13bfaa1f35130f279a0115e686 | https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/conf.py#L73-L99 | train |
lambdalisue/notify | src/notify/conf.py | create_default_config | def create_default_config():
"""
Create default ConfigParser instance
"""
import codecs
config = ConfigParser.SafeConfigParser()
config.readfp(StringIO(DEFAULT_CONFIG))
# Load user settings
filename = get_user_config_filename()
if not os.path.exists(filename):
from wizard im... | python | def create_default_config():
"""
Create default ConfigParser instance
"""
import codecs
config = ConfigParser.SafeConfigParser()
config.readfp(StringIO(DEFAULT_CONFIG))
# Load user settings
filename = get_user_config_filename()
if not os.path.exists(filename):
from wizard im... | [
"def",
"create_default_config",
"(",
")",
":",
"import",
"codecs",
"config",
"=",
"ConfigParser",
".",
"SafeConfigParser",
"(",
")",
"config",
".",
"readfp",
"(",
"StringIO",
"(",
"DEFAULT_CONFIG",
")",
")",
"filename",
"=",
"get_user_config_filename",
"(",
")",... | Create default ConfigParser instance | [
"Create",
"default",
"ConfigParser",
"instance"
] | 1b6d7d1faa2cea13bfaa1f35130f279a0115e686 | https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/conf.py#L102-L121 | train |
geophysics-ubonn/reda | lib/reda/utils/helper_functions.py | has_multiple_timesteps | def has_multiple_timesteps(data):
"""Return True if `data` container has multiple timesteps."""
if "timestep" in data.keys():
if len(np.unique(data["timestep"])) > 1:
return True
return False | python | def has_multiple_timesteps(data):
"""Return True if `data` container has multiple timesteps."""
if "timestep" in data.keys():
if len(np.unique(data["timestep"])) > 1:
return True
return False | [
"def",
"has_multiple_timesteps",
"(",
"data",
")",
":",
"if",
"\"timestep\"",
"in",
"data",
".",
"keys",
"(",
")",
":",
"if",
"len",
"(",
"np",
".",
"unique",
"(",
"data",
"[",
"\"timestep\"",
"]",
")",
")",
">",
"1",
":",
"return",
"True",
"return",... | Return True if `data` container has multiple timesteps. | [
"Return",
"True",
"if",
"data",
"container",
"has",
"multiple",
"timesteps",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/helper_functions.py#L83-L88 | train |
geophysics-ubonn/reda | lib/reda/utils/helper_functions.py | split_timesteps | def split_timesteps(data, consistent_abmn=False):
"""Split data into multiple timesteps."""
if has_multiple_timesteps(data):
grouped = data.groupby("timestep")
return [group[1] for group in grouped]
else:
return data | python | def split_timesteps(data, consistent_abmn=False):
"""Split data into multiple timesteps."""
if has_multiple_timesteps(data):
grouped = data.groupby("timestep")
return [group[1] for group in grouped]
else:
return data | [
"def",
"split_timesteps",
"(",
"data",
",",
"consistent_abmn",
"=",
"False",
")",
":",
"if",
"has_multiple_timesteps",
"(",
"data",
")",
":",
"grouped",
"=",
"data",
".",
"groupby",
"(",
"\"timestep\"",
")",
"return",
"[",
"group",
"[",
"1",
"]",
"for",
... | Split data into multiple timesteps. | [
"Split",
"data",
"into",
"multiple",
"timesteps",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/helper_functions.py#L90-L96 | train |
kaustavdm/pyAvroPhonetic | pyavrophonetic/avro.py | parse | def parse(text):
"""Parses input text, matches and replaces using avrodict
If a valid replacement is found, returns the replaced string. If
no replacement is found, returns the input text.
Usage:
::
from pyavrophonetic import avro
avro.parse("ami banglay gan gai")
"""
# Sanit... | python | def parse(text):
"""Parses input text, matches and replaces using avrodict
If a valid replacement is found, returns the replaced string. If
no replacement is found, returns the input text.
Usage:
::
from pyavrophonetic import avro
avro.parse("ami banglay gan gai")
"""
# Sanit... | [
"def",
"parse",
"(",
"text",
")",
":",
"fixed_text",
"=",
"validate",
".",
"fix_string_case",
"(",
"utf",
"(",
"text",
")",
")",
"output",
"=",
"[",
"]",
"cur_end",
"=",
"0",
"for",
"cur",
",",
"i",
"in",
"enumerate",
"(",
"fixed_text",
")",
":",
"... | Parses input text, matches and replaces using avrodict
If a valid replacement is found, returns the replaced string. If
no replacement is found, returns the input text.
Usage:
::
from pyavrophonetic import avro
avro.parse("ami banglay gan gai") | [
"Parses",
"input",
"text",
"matches",
"and",
"replaces",
"using",
"avrodict"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/avro.py#L38-L109 | train |
kaustavdm/pyAvroPhonetic | pyavrophonetic/avro.py | match_non_rule_patterns | def match_non_rule_patterns(fixed_text, cur=0):
"""Matches given text at cursor position with non rule patterns
Returns a dictionary of three elements:
- "matched" - Bool: depending on if match found
- "found" - string/None: Value of matched pattern's 'find' key or none
- "replaced": string Replac... | python | def match_non_rule_patterns(fixed_text, cur=0):
"""Matches given text at cursor position with non rule patterns
Returns a dictionary of three elements:
- "matched" - Bool: depending on if match found
- "found" - string/None: Value of matched pattern's 'find' key or none
- "replaced": string Replac... | [
"def",
"match_non_rule_patterns",
"(",
"fixed_text",
",",
"cur",
"=",
"0",
")",
":",
"pattern",
"=",
"exact_find_in_pattern",
"(",
"fixed_text",
",",
"cur",
",",
"NON_RULE_PATTERNS",
")",
"if",
"len",
"(",
"pattern",
")",
">",
"0",
":",
"return",
"{",
"\"m... | Matches given text at cursor position with non rule patterns
Returns a dictionary of three elements:
- "matched" - Bool: depending on if match found
- "found" - string/None: Value of matched pattern's 'find' key or none
- "replaced": string Replaced string if match found else input string at
curso... | [
"Matches",
"given",
"text",
"at",
"cursor",
"position",
"with",
"non",
"rule",
"patterns"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/avro.py#L111-L128 | train |
kaustavdm/pyAvroPhonetic | pyavrophonetic/avro.py | match_rule_patterns | def match_rule_patterns(fixed_text, cur=0):
"""Matches given text at cursor position with rule patterns
Returns a dictionary of four elements:
- "matched" - Bool: depending on if match found
- "found" - string/None: Value of matched pattern's 'find' key or none
- "replaced": string Replaced string... | python | def match_rule_patterns(fixed_text, cur=0):
"""Matches given text at cursor position with rule patterns
Returns a dictionary of four elements:
- "matched" - Bool: depending on if match found
- "found" - string/None: Value of matched pattern's 'find' key or none
- "replaced": string Replaced string... | [
"def",
"match_rule_patterns",
"(",
"fixed_text",
",",
"cur",
"=",
"0",
")",
":",
"pattern",
"=",
"exact_find_in_pattern",
"(",
"fixed_text",
",",
"cur",
",",
"RULE_PATTERNS",
")",
"if",
"len",
"(",
"pattern",
")",
">",
"0",
":",
"return",
"{",
"\"matched\"... | Matches given text at cursor position with rule patterns
Returns a dictionary of four elements:
- "matched" - Bool: depending on if match found
- "found" - string/None: Value of matched pattern's 'find' key or none
- "replaced": string Replaced string if match found else input string at
cursor
... | [
"Matches",
"given",
"text",
"at",
"cursor",
"position",
"with",
"rule",
"patterns"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/avro.py#L130-L149 | train |
kaustavdm/pyAvroPhonetic | pyavrophonetic/avro.py | exact_find_in_pattern | def exact_find_in_pattern(fixed_text, cur=0, patterns=PATTERNS):
"""Returns pattern items that match given text, cur position and pattern"""
return [x for x in patterns if (cur + len(x['find']) <= len(fixed_text))
and x['find'] == fixed_text[cur:(cur + len(x['find']))]] | python | def exact_find_in_pattern(fixed_text, cur=0, patterns=PATTERNS):
"""Returns pattern items that match given text, cur position and pattern"""
return [x for x in patterns if (cur + len(x['find']) <= len(fixed_text))
and x['find'] == fixed_text[cur:(cur + len(x['find']))]] | [
"def",
"exact_find_in_pattern",
"(",
"fixed_text",
",",
"cur",
"=",
"0",
",",
"patterns",
"=",
"PATTERNS",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"patterns",
"if",
"(",
"cur",
"+",
"len",
"(",
"x",
"[",
"'find'",
"]",
")",
"<=",
"len",
"("... | Returns pattern items that match given text, cur position and pattern | [
"Returns",
"pattern",
"items",
"that",
"match",
"given",
"text",
"cur",
"position",
"and",
"pattern"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/avro.py#L151-L154 | train |
kaustavdm/pyAvroPhonetic | pyavrophonetic/avro.py | process_rules | def process_rules(rules, fixed_text, cur = 0, cur_end = 1):
"""Process rules matched in pattern and returns suitable replacement
If any rule's condition is satisfied, output the rules "replace",
else output None
"""
replaced = ''
# iterate through rules
for rule in rules:
matched =... | python | def process_rules(rules, fixed_text, cur = 0, cur_end = 1):
"""Process rules matched in pattern and returns suitable replacement
If any rule's condition is satisfied, output the rules "replace",
else output None
"""
replaced = ''
# iterate through rules
for rule in rules:
matched =... | [
"def",
"process_rules",
"(",
"rules",
",",
"fixed_text",
",",
"cur",
"=",
"0",
",",
"cur_end",
"=",
"1",
")",
":",
"replaced",
"=",
"''",
"for",
"rule",
"in",
"rules",
":",
"matched",
"=",
"False",
"for",
"match",
"in",
"rule",
"[",
"'matches'",
"]",... | Process rules matched in pattern and returns suitable replacement
If any rule's condition is satisfied, output the rules "replace",
else output None | [
"Process",
"rules",
"matched",
"in",
"pattern",
"and",
"returns",
"suitable",
"replacement"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/avro.py#L156-L183 | train |
kaustavdm/pyAvroPhonetic | pyavrophonetic/avro.py | process_match | def process_match(match, fixed_text, cur, cur_end):
"""Processes a single match in rules"""
# Set our tools
# -- Initial/default value for replace
replace = True
# -- Set check cursor depending on match['type']
if match['type'] == 'prefix':
chk = cur - 1
else:
# suffix
... | python | def process_match(match, fixed_text, cur, cur_end):
"""Processes a single match in rules"""
# Set our tools
# -- Initial/default value for replace
replace = True
# -- Set check cursor depending on match['type']
if match['type'] == 'prefix':
chk = cur - 1
else:
# suffix
... | [
"def",
"process_match",
"(",
"match",
",",
"fixed_text",
",",
"cur",
",",
"cur_end",
")",
":",
"replace",
"=",
"True",
"if",
"match",
"[",
"'type'",
"]",
"==",
"'prefix'",
":",
"chk",
"=",
"cur",
"-",
"1",
"else",
":",
"chk",
"=",
"cur_end",
"if",
... | Processes a single match in rules | [
"Processes",
"a",
"single",
"match",
"in",
"rules"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/avro.py#L185-L248 | train |
digidotcom/python-wvalib | wva/cli.py | cli | def cli(ctx, hostname, username, password, config_dir, https):
"""Command-line interface for interacting with a WVA device"""
ctx.is_root = True
ctx.user_values_entered = False
ctx.config_dir = os.path.abspath(os.path.expanduser(config_dir))
ctx.config = load_config(ctx)
ctx.hostname = hostname
... | python | def cli(ctx, hostname, username, password, config_dir, https):
"""Command-line interface for interacting with a WVA device"""
ctx.is_root = True
ctx.user_values_entered = False
ctx.config_dir = os.path.abspath(os.path.expanduser(config_dir))
ctx.config = load_config(ctx)
ctx.hostname = hostname
... | [
"def",
"cli",
"(",
"ctx",
",",
"hostname",
",",
"username",
",",
"password",
",",
"config_dir",
",",
"https",
")",
":",
"ctx",
".",
"is_root",
"=",
"True",
"ctx",
".",
"user_values_entered",
"=",
"False",
"ctx",
".",
"config_dir",
"=",
"os",
".",
"path... | Command-line interface for interacting with a WVA device | [
"Command",
"-",
"line",
"interface",
"for",
"interacting",
"with",
"a",
"WVA",
"device"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L110-L123 | train |
digidotcom/python-wvalib | wva/cli.py | get | def get(ctx, uri):
"""Perform an HTTP GET of the provided URI
The URI provided is relative to the /ws base to allow for easy navigation of
the resources exposed by the WVA. Example Usage::
\b
$ wva get /
{'ws': ['vehicle',
'hw',
'config',
'state',
'file... | python | def get(ctx, uri):
"""Perform an HTTP GET of the provided URI
The URI provided is relative to the /ws base to allow for easy navigation of
the resources exposed by the WVA. Example Usage::
\b
$ wva get /
{'ws': ['vehicle',
'hw',
'config',
'state',
'file... | [
"def",
"get",
"(",
"ctx",
",",
"uri",
")",
":",
"http_client",
"=",
"get_wva",
"(",
"ctx",
")",
".",
"get_http_client",
"(",
")",
"cli_pprint",
"(",
"http_client",
".",
"get",
"(",
"uri",
")",
")"
] | Perform an HTTP GET of the provided URI
The URI provided is relative to the /ws base to allow for easy navigation of
the resources exposed by the WVA. Example Usage::
\b
$ wva get /
{'ws': ['vehicle',
'hw',
'config',
'state',
'files',
'alarms',... | [
"Perform",
"an",
"HTTP",
"GET",
"of",
"the",
"provided",
"URI"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L161-L196 | train |
digidotcom/python-wvalib | wva/cli.py | delete | def delete(ctx, uri):
"""DELETE the specified URI
Example:
\b
$ wva get files/userfs/WEB/python
{'file_list': ['files/userfs/WEB/python/.ssh',
'files/userfs/WEB/python/README.md']}
$ wva delete files/userfs/WEB/python/README.md
''
$ wva get files/userfs/WEB/python
{'fil... | python | def delete(ctx, uri):
"""DELETE the specified URI
Example:
\b
$ wva get files/userfs/WEB/python
{'file_list': ['files/userfs/WEB/python/.ssh',
'files/userfs/WEB/python/README.md']}
$ wva delete files/userfs/WEB/python/README.md
''
$ wva get files/userfs/WEB/python
{'fil... | [
"def",
"delete",
"(",
"ctx",
",",
"uri",
")",
":",
"http_client",
"=",
"get_wva",
"(",
"ctx",
")",
".",
"get_http_client",
"(",
")",
"cli_pprint",
"(",
"http_client",
".",
"delete",
"(",
"uri",
")",
")"
] | DELETE the specified URI
Example:
\b
$ wva get files/userfs/WEB/python
{'file_list': ['files/userfs/WEB/python/.ssh',
'files/userfs/WEB/python/README.md']}
$ wva delete files/userfs/WEB/python/README.md
''
$ wva get files/userfs/WEB/python
{'file_list': ['files/userfs/WEB/p... | [
"DELETE",
"the",
"specified",
"URI"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L202-L217 | train |
digidotcom/python-wvalib | wva/cli.py | post | def post(ctx, uri, input_file):
"""POST file data to a specific URI
Note that POST is not used for most web services URIs. Instead,
PUT is used for creating resources.
"""
http_client = get_wva(ctx).get_http_client()
cli_pprint(http_client.post(uri, input_file.read())) | python | def post(ctx, uri, input_file):
"""POST file data to a specific URI
Note that POST is not used for most web services URIs. Instead,
PUT is used for creating resources.
"""
http_client = get_wva(ctx).get_http_client()
cli_pprint(http_client.post(uri, input_file.read())) | [
"def",
"post",
"(",
"ctx",
",",
"uri",
",",
"input_file",
")",
":",
"http_client",
"=",
"get_wva",
"(",
"ctx",
")",
".",
"get_http_client",
"(",
")",
"cli_pprint",
"(",
"http_client",
".",
"post",
"(",
"uri",
",",
"input_file",
".",
"read",
"(",
")",
... | POST file data to a specific URI
Note that POST is not used for most web services URIs. Instead,
PUT is used for creating resources. | [
"POST",
"file",
"data",
"to",
"a",
"specific",
"URI"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L224-L231 | train |
digidotcom/python-wvalib | wva/cli.py | sample | def sample(ctx, element, timestamp, repeat, delay):
"""Sample the value of a vehicle data element
This command allows for the current value of a vehicle data element
to be sampled:
\b
$ wva vehicle sample VehicleSpeed
168.15329
Optionally, the value may be samples multiple times:
\b
$ wva vehicle sa... | python | def sample(ctx, element, timestamp, repeat, delay):
"""Sample the value of a vehicle data element
This command allows for the current value of a vehicle data element
to be sampled:
\b
$ wva vehicle sample VehicleSpeed
168.15329
Optionally, the value may be samples multiple times:
\b
$ wva vehicle sa... | [
"def",
"sample",
"(",
"ctx",
",",
"element",
",",
"timestamp",
",",
"repeat",
",",
"delay",
")",
":",
"element",
"=",
"get_wva",
"(",
"ctx",
")",
".",
"get_vehicle_data_element",
"(",
"element",
")",
"for",
"i",
"in",
"xrange",
"(",
"repeat",
")",
":",... | Sample the value of a vehicle data element
This command allows for the current value of a vehicle data element
to be sampled:
\b
$ wva vehicle sample VehicleSpeed
168.15329
Optionally, the value may be samples multiple times:
\b
$ wva vehicle sample VehicleSpeed --repeat 10 --delay 1 --timestamp
148... | [
"Sample",
"the",
"value",
"of",
"a",
"vehicle",
"data",
"element"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L293-L330 | train |
digidotcom/python-wvalib | wva/cli.py | list | def list(ctx):
"""List short name of all current subscriptions"""
wva = get_wva(ctx)
for subscription in wva.get_subscriptions():
print(subscription.short_name) | python | def list(ctx):
"""List short name of all current subscriptions"""
wva = get_wva(ctx)
for subscription in wva.get_subscriptions():
print(subscription.short_name) | [
"def",
"list",
"(",
"ctx",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"for",
"subscription",
"in",
"wva",
".",
"get_subscriptions",
"(",
")",
":",
"print",
"(",
"subscription",
".",
"short_name",
")"
] | List short name of all current subscriptions | [
"List",
"short",
"name",
"of",
"all",
"current",
"subscriptions"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L344-L348 | train |
digidotcom/python-wvalib | wva/cli.py | delete | def delete(ctx, short_name):
"""Delete a specific subscription by short name"""
wva = get_wva(ctx)
subscription = wva.get_subscription(short_name)
subscription.delete() | python | def delete(ctx, short_name):
"""Delete a specific subscription by short name"""
wva = get_wva(ctx)
subscription = wva.get_subscription(short_name)
subscription.delete() | [
"def",
"delete",
"(",
"ctx",
",",
"short_name",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"subscription",
"=",
"wva",
".",
"get_subscription",
"(",
"short_name",
")",
"subscription",
".",
"delete",
"(",
")"
] | Delete a specific subscription by short name | [
"Delete",
"a",
"specific",
"subscription",
"by",
"short",
"name"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L354-L358 | train |
digidotcom/python-wvalib | wva/cli.py | clear | def clear(ctx):
"""Remove all registered subscriptions
Example:
\b
$ wva subscriptions clear
Deleting engineload... Done
Deleting fuelrate... Done
Deleting throttle... Done
Deleting rpm... Done
Deleting speedy... Done
To remove a specific subscription, use 'wva subscription remove <name>'... | python | def clear(ctx):
"""Remove all registered subscriptions
Example:
\b
$ wva subscriptions clear
Deleting engineload... Done
Deleting fuelrate... Done
Deleting throttle... Done
Deleting rpm... Done
Deleting speedy... Done
To remove a specific subscription, use 'wva subscription remove <name>'... | [
"def",
"clear",
"(",
"ctx",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"for",
"subscription",
"in",
"wva",
".",
"get_subscriptions",
"(",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"Deleting {}... \"",
".",
"format",
"(",
"subscription",... | Remove all registered subscriptions
Example:
\b
$ wva subscriptions clear
Deleting engineload... Done
Deleting fuelrate... Done
Deleting throttle... Done
Deleting rpm... Done
Deleting speedy... Done
To remove a specific subscription, use 'wva subscription remove <name>' instead. | [
"Remove",
"all",
"registered",
"subscriptions"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L363-L383 | train |
digidotcom/python-wvalib | wva/cli.py | show | def show(ctx, short_name):
"""Show metadata for a specific subscription
Example:
\b
$ wva subscriptions show speed
{'buffer': 'queue', 'interval': 5, 'uri': 'vehicle/data/VehicleSpeed'}
"""
wva = get_wva(ctx)
subscription = wva.get_subscription(short_name)
cli_pprint(subscription.get_metadata(... | python | def show(ctx, short_name):
"""Show metadata for a specific subscription
Example:
\b
$ wva subscriptions show speed
{'buffer': 'queue', 'interval': 5, 'uri': 'vehicle/data/VehicleSpeed'}
"""
wva = get_wva(ctx)
subscription = wva.get_subscription(short_name)
cli_pprint(subscription.get_metadata(... | [
"def",
"show",
"(",
"ctx",
",",
"short_name",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"subscription",
"=",
"wva",
".",
"get_subscription",
"(",
"short_name",
")",
"cli_pprint",
"(",
"subscription",
".",
"get_metadata",
"(",
")",
")"
] | Show metadata for a specific subscription
Example:
\b
$ wva subscriptions show speed
{'buffer': 'queue', 'interval': 5, 'uri': 'vehicle/data/VehicleSpeed'} | [
"Show",
"metadata",
"for",
"a",
"specific",
"subscription"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L389-L400 | train |
digidotcom/python-wvalib | wva/cli.py | add | def add(ctx, short_name, uri, interval, buffer):
"""Add a subscription with a given short_name for a given uri
This command can be used to create subscriptions to receive new pieces
of vehicle data on the stream channel on a periodic basis. By default,
subscriptions are buffered and have a 5 second interval:
\b
... | python | def add(ctx, short_name, uri, interval, buffer):
"""Add a subscription with a given short_name for a given uri
This command can be used to create subscriptions to receive new pieces
of vehicle data on the stream channel on a periodic basis. By default,
subscriptions are buffered and have a 5 second interval:
\b
... | [
"def",
"add",
"(",
"ctx",
",",
"short_name",
",",
"uri",
",",
"interval",
",",
"buffer",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"subscription",
"=",
"wva",
".",
"get_subscription",
"(",
"short_name",
")",
"subscription",
".",
"create",
"(",
... | Add a subscription with a given short_name for a given uri
This command can be used to create subscriptions to receive new pieces
of vehicle data on the stream channel on a periodic basis. By default,
subscriptions are buffered and have a 5 second interval:
\b
$ wva subscriptions add speed vehicle/data/VehicleSp... | [
"Add",
"a",
"subscription",
"with",
"a",
"given",
"short_name",
"for",
"a",
"given",
"uri"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L409-L432 | train |
digidotcom/python-wvalib | wva/cli.py | listen | def listen(ctx):
"""Output the contents of the WVA event stream
This command shows the data being received from the WVA event stream based on
the subscriptions that have been set up and the data on the WVA vehicle bus.
\b
$ wva subscriptions listen
{'data': {'VehicleSpeed': {'timestamp': '2015-03-25T00:11... | python | def listen(ctx):
"""Output the contents of the WVA event stream
This command shows the data being received from the WVA event stream based on
the subscriptions that have been set up and the data on the WVA vehicle bus.
\b
$ wva subscriptions listen
{'data': {'VehicleSpeed': {'timestamp': '2015-03-25T00:11... | [
"def",
"listen",
"(",
"ctx",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"es",
"=",
"wva",
".",
"get_event_stream",
"(",
")",
"def",
"cb",
"(",
"event",
")",
":",
"cli_pprint",
"(",
"event",
")",
"es",
".",
"add_event_listener",
"(",
"cb",
")... | Output the contents of the WVA event stream
This command shows the data being received from the WVA event stream based on
the subscriptions that have been set up and the data on the WVA vehicle bus.
\b
$ wva subscriptions listen
{'data': {'VehicleSpeed': {'timestamp': '2015-03-25T00:11:53Z',
... | [
"Output",
"the",
"contents",
"of",
"the",
"WVA",
"event",
"stream"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L437-L473 | train |
digidotcom/python-wvalib | wva/cli.py | graph | def graph(ctx, items, seconds, ylim):
"""Present a live graph of the incoming streaming data
This command requires that matplotlib be installed and accessible
to the application in order to work. The application reads
data from the WVA event stream and plots all data for specified
parameters within some time wind... | python | def graph(ctx, items, seconds, ylim):
"""Present a live graph of the incoming streaming data
This command requires that matplotlib be installed and accessible
to the application in order to work. The application reads
data from the WVA event stream and plots all data for specified
parameters within some time wind... | [
"def",
"graph",
"(",
"ctx",
",",
"items",
",",
"seconds",
",",
"ylim",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"es",
"=",
"wva",
".",
"get_event_stream",
"(",
")",
"try",
":",
"from",
"wva",
"import",
"grapher",
"except",
"ImportError",
":"... | Present a live graph of the incoming streaming data
This command requires that matplotlib be installed and accessible
to the application in order to work. The application reads
data from the WVA event stream and plots all data for specified
parameters within some time window. Subscriptions must be
set up prior to ru... | [
"Present",
"a",
"live",
"graph",
"of",
"the",
"incoming",
"streaming",
"data"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L481-L507 | train |
digidotcom/python-wvalib | wva/cli.py | authorize | def authorize(ctx, public_key, append):
"""Enable ssh login as the Python user for the current user
This command will create an authorized_keys file on the target device
containing the current users public key. This will allow ssh to
the WVA from this machine.
"""
wva = get_wva(ctx)
http_client = wva.get... | python | def authorize(ctx, public_key, append):
"""Enable ssh login as the Python user for the current user
This command will create an authorized_keys file on the target device
containing the current users public key. This will allow ssh to
the WVA from this machine.
"""
wva = get_wva(ctx)
http_client = wva.get... | [
"def",
"authorize",
"(",
"ctx",
",",
"public_key",
",",
"append",
")",
":",
"wva",
"=",
"get_wva",
"(",
"ctx",
")",
"http_client",
"=",
"wva",
".",
"get_http_client",
"(",
")",
"authorized_keys_uri",
"=",
"\"/files/userfs/WEB/python/.ssh/authorized_keys\"",
"autho... | Enable ssh login as the Python user for the current user
This command will create an authorized_keys file on the target device
containing the current users public key. This will allow ssh to
the WVA from this machine. | [
"Enable",
"ssh",
"login",
"as",
"the",
"Python",
"user",
"for",
"the",
"current",
"user"
] | 4252735e2775f80ebaffd813fbe84046d26906b3 | https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L523-L546 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.