repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
proteanhq/protean | src/protean/core/provider/__init__.py | Providers._initialize_providers | def _initialize_providers(self):
"""Read config file and initialize providers"""
configured_providers = active_config.DATABASES
provider_objects = {}
if not isinstance(configured_providers, dict) or configured_providers == {}:
raise ConfigurationError(
"'DATA... | python | def _initialize_providers(self):
"""Read config file and initialize providers"""
configured_providers = active_config.DATABASES
provider_objects = {}
if not isinstance(configured_providers, dict) or configured_providers == {}:
raise ConfigurationError(
"'DATA... | [
"def",
"_initialize_providers",
"(",
"self",
")",
":",
"configured_providers",
"=",
"active_config",
".",
"DATABASES",
"provider_objects",
"=",
"{",
"}",
"if",
"not",
"isinstance",
"(",
"configured_providers",
",",
"dict",
")",
"or",
"configured_providers",
"==",
... | Read config file and initialize providers | [
"Read",
"config",
"file",
"and",
"initialize",
"providers"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/provider/__init__.py#L14-L35 |
proteanhq/protean | src/protean/core/provider/__init__.py | Providers.get_provider | def get_provider(self, provider_name='default'):
"""Fetch provider with the name specified in Configuration file"""
try:
if self._providers is None:
self._providers = self._initialize_providers()
return self._providers[provider_name]
except KeyError:
... | python | def get_provider(self, provider_name='default'):
"""Fetch provider with the name specified in Configuration file"""
try:
if self._providers is None:
self._providers = self._initialize_providers()
return self._providers[provider_name]
except KeyError:
... | [
"def",
"get_provider",
"(",
"self",
",",
"provider_name",
"=",
"'default'",
")",
":",
"try",
":",
"if",
"self",
".",
"_providers",
"is",
"None",
":",
"self",
".",
"_providers",
"=",
"self",
".",
"_initialize_providers",
"(",
")",
"return",
"self",
".",
"... | Fetch provider with the name specified in Configuration file | [
"Fetch",
"provider",
"with",
"the",
"name",
"specified",
"in",
"Configuration",
"file"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/provider/__init__.py#L37-L44 |
proteanhq/protean | src/protean/core/provider/__init__.py | Providers.get_connection | def get_connection(self, provider_name='default'):
"""Fetch connection from Provider"""
try:
return self._providers[provider_name].get_connection()
except KeyError:
raise AssertionError(f'No Provider registered with name {provider_name}') | python | def get_connection(self, provider_name='default'):
"""Fetch connection from Provider"""
try:
return self._providers[provider_name].get_connection()
except KeyError:
raise AssertionError(f'No Provider registered with name {provider_name}') | [
"def",
"get_connection",
"(",
"self",
",",
"provider_name",
"=",
"'default'",
")",
":",
"try",
":",
"return",
"self",
".",
"_providers",
"[",
"provider_name",
"]",
".",
"get_connection",
"(",
")",
"except",
"KeyError",
":",
"raise",
"AssertionError",
"(",
"f... | Fetch connection from Provider | [
"Fetch",
"connection",
"from",
"Provider"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/provider/__init__.py#L46-L51 |
proteanhq/protean | src/protean/conf/__init__.py | Config.update_defaults | def update_defaults(self, ext_config):
""" Update the default settings for an extension from an object"""
for setting in dir(ext_config):
if setting.isupper() and not hasattr(self, setting):
setattr(self, setting, getattr(ext_config, setting)) | python | def update_defaults(self, ext_config):
""" Update the default settings for an extension from an object"""
for setting in dir(ext_config):
if setting.isupper() and not hasattr(self, setting):
setattr(self, setting, getattr(ext_config, setting)) | [
"def",
"update_defaults",
"(",
"self",
",",
"ext_config",
")",
":",
"for",
"setting",
"in",
"dir",
"(",
"ext_config",
")",
":",
"if",
"setting",
".",
"isupper",
"(",
")",
"and",
"not",
"hasattr",
"(",
"self",
",",
"setting",
")",
":",
"setattr",
"(",
... | Update the default settings for an extension from an object | [
"Update",
"the",
"default",
"settings",
"for",
"an",
"extension",
"from",
"an",
"object"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/conf/__init__.py#L59-L63 |
deep-compute/deeputil | deeputil/keep_running.py | keeprunning | def keeprunning(wait_secs=0, exit_on_success=False,
on_success=None, on_error=None, on_done=None):
'''
Example 1: dosomething needs to run until completion condition
without needing to have a loop in its code. Also, when error
happens, we should NOT terminate execution
>>> from deep... | python | def keeprunning(wait_secs=0, exit_on_success=False,
on_success=None, on_error=None, on_done=None):
'''
Example 1: dosomething needs to run until completion condition
without needing to have a loop in its code. Also, when error
happens, we should NOT terminate execution
>>> from deep... | [
"def",
"keeprunning",
"(",
"wait_secs",
"=",
"0",
",",
"exit_on_success",
"=",
"False",
",",
"on_success",
"=",
"None",
",",
"on_error",
"=",
"None",
",",
"on_done",
"=",
"None",
")",
":",
"def",
"decfn",
"(",
"fn",
")",
":",
"def",
"_call_callback",
"... | Example 1: dosomething needs to run until completion condition
without needing to have a loop in its code. Also, when error
happens, we should NOT terminate execution
>>> from deeputil import AttrDict
>>> @keeprunning(wait_secs=1)
... def dosomething(state):
... state.i += 1
... pri... | [
"Example",
"1",
":",
"dosomething",
"needs",
"to",
"run",
"until",
"completion",
"condition",
"without",
"needing",
"to",
"have",
"a",
"loop",
"in",
"its",
"code",
".",
"Also",
"when",
"error",
"happens",
"we",
"should",
"NOT",
"terminate",
"execution"
] | train | https://github.com/deep-compute/deeputil/blob/9af5702bc3fd990688bf2aed16c20fa104be66df/deeputil/keep_running.py#L10-L171 |
proteanhq/protean | src/protean/core/field/utils.py | fetch_entity_cls_from_registry | def fetch_entity_cls_from_registry(entity):
"""Util Method to fetch an Entity class from an entity's name"""
# Defensive check to ensure we only process if `to_cls` is a string
if isinstance(entity, str):
try:
return repo_factory.get_entity(entity)
except AssertionError:
... | python | def fetch_entity_cls_from_registry(entity):
"""Util Method to fetch an Entity class from an entity's name"""
# Defensive check to ensure we only process if `to_cls` is a string
if isinstance(entity, str):
try:
return repo_factory.get_entity(entity)
except AssertionError:
... | [
"def",
"fetch_entity_cls_from_registry",
"(",
"entity",
")",
":",
"# Defensive check to ensure we only process if `to_cls` is a string",
"if",
"isinstance",
"(",
"entity",
",",
"str",
")",
":",
"try",
":",
"return",
"repo_factory",
".",
"get_entity",
"(",
"entity",
")",... | Util Method to fetch an Entity class from an entity's name | [
"Util",
"Method",
"to",
"fetch",
"an",
"Entity",
"class",
"from",
"an",
"entity",
"s",
"name"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/field/utils.py#L5-L16 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory.register | def register(self, entity_cls, provider_name=None):
""" Register the given model with the factory
:param entity_cls: Entity class to be registered
:param provider: Optional provider to associate with Entity class
"""
self._validate_entity_cls(entity_cls)
# Register the e... | python | def register(self, entity_cls, provider_name=None):
""" Register the given model with the factory
:param entity_cls: Entity class to be registered
:param provider: Optional provider to associate with Entity class
"""
self._validate_entity_cls(entity_cls)
# Register the e... | [
"def",
"register",
"(",
"self",
",",
"entity_cls",
",",
"provider_name",
"=",
"None",
")",
":",
"self",
".",
"_validate_entity_cls",
"(",
"entity_cls",
")",
"# Register the entity if not registered already",
"entity_name",
"=",
"fully_qualified_name",
"(",
"entity_cls",... | Register the given model with the factory
:param entity_cls: Entity class to be registered
:param provider: Optional provider to associate with Entity class | [
"Register",
"the",
"given",
"model",
"with",
"the",
"factory",
":",
"param",
"entity_cls",
":",
"Entity",
"class",
"to",
"be",
"registered",
":",
"param",
"provider",
":",
"Optional",
"provider",
"to",
"associate",
"with",
"Entity",
"class"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L34-L64 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory._find_entity_in_records_by_class_name | def _find_entity_in_records_by_class_name(self, entity_name):
"""Fetch by Entity Name in values"""
records = {
key: value for (key, value)
in self._registry.items()
if value.name == entity_name
}
# If more than one record was found, we are dealing with... | python | def _find_entity_in_records_by_class_name(self, entity_name):
"""Fetch by Entity Name in values"""
records = {
key: value for (key, value)
in self._registry.items()
if value.name == entity_name
}
# If more than one record was found, we are dealing with... | [
"def",
"_find_entity_in_records_by_class_name",
"(",
"self",
",",
"entity_name",
")",
":",
"records",
"=",
"{",
"key",
":",
"value",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
".",
"_registry",
".",
"items",
"(",
")",
"if",
"value",
".",
"name",... | Fetch by Entity Name in values | [
"Fetch",
"by",
"Entity",
"Name",
"in",
"values"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L66-L83 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory._get_entity_by_class | def _get_entity_by_class(self, entity_cls):
"""Fetch Entity record with Entity class details"""
entity_qualname = fully_qualified_name(entity_cls)
if entity_qualname in self._registry:
return self._registry[entity_qualname]
else:
return self._find_entity_in_record... | python | def _get_entity_by_class(self, entity_cls):
"""Fetch Entity record with Entity class details"""
entity_qualname = fully_qualified_name(entity_cls)
if entity_qualname in self._registry:
return self._registry[entity_qualname]
else:
return self._find_entity_in_record... | [
"def",
"_get_entity_by_class",
"(",
"self",
",",
"entity_cls",
")",
":",
"entity_qualname",
"=",
"fully_qualified_name",
"(",
"entity_cls",
")",
"if",
"entity_qualname",
"in",
"self",
".",
"_registry",
":",
"return",
"self",
".",
"_registry",
"[",
"entity_qualname... | Fetch Entity record with Entity class details | [
"Fetch",
"Entity",
"record",
"with",
"Entity",
"class",
"details"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L85-L91 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory._get_entity_by_name | def _get_entity_by_name(self, entity_name):
"""Fetch Entity record with an Entity name"""
if entity_name in self._registry:
return self._registry[entity_name]
else:
return self._find_entity_in_records_by_class_name(entity_name) | python | def _get_entity_by_name(self, entity_name):
"""Fetch Entity record with an Entity name"""
if entity_name in self._registry:
return self._registry[entity_name]
else:
return self._find_entity_in_records_by_class_name(entity_name) | [
"def",
"_get_entity_by_name",
"(",
"self",
",",
"entity_name",
")",
":",
"if",
"entity_name",
"in",
"self",
".",
"_registry",
":",
"return",
"self",
".",
"_registry",
"[",
"entity_name",
"]",
"else",
":",
"return",
"self",
".",
"_find_entity_in_records_by_class_... | Fetch Entity record with an Entity name | [
"Fetch",
"Entity",
"record",
"with",
"an",
"Entity",
"name"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L93-L98 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory._validate_entity_cls | def _validate_entity_cls(self, entity_cls):
"""Validate that Entity is a valid class"""
# Import here to avoid cyclic dependency
from protean.core.entity import Entity
if not issubclass(entity_cls, Entity):
raise AssertionError(
f'Entity {entity_cls.__name__}... | python | def _validate_entity_cls(self, entity_cls):
"""Validate that Entity is a valid class"""
# Import here to avoid cyclic dependency
from protean.core.entity import Entity
if not issubclass(entity_cls, Entity):
raise AssertionError(
f'Entity {entity_cls.__name__}... | [
"def",
"_validate_entity_cls",
"(",
"self",
",",
"entity_cls",
")",
":",
"# Import here to avoid cyclic dependency",
"from",
"protean",
".",
"core",
".",
"entity",
"import",
"Entity",
"if",
"not",
"issubclass",
"(",
"entity_cls",
",",
"Entity",
")",
":",
"raise",
... | Validate that Entity is a valid class | [
"Validate",
"that",
"Entity",
"is",
"a",
"valid",
"class"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L100-L112 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory.get_model | def get_model(self, entity_cls):
"""Retrieve Model class connected to Entity"""
entity_record = self._get_entity_by_class(entity_cls)
model_cls = None
if entity_record.model_cls:
model_cls = entity_record.model_cls
else:
# We should ask the Provider to gi... | python | def get_model(self, entity_cls):
"""Retrieve Model class connected to Entity"""
entity_record = self._get_entity_by_class(entity_cls)
model_cls = None
if entity_record.model_cls:
model_cls = entity_record.model_cls
else:
# We should ask the Provider to gi... | [
"def",
"get_model",
"(",
"self",
",",
"entity_cls",
")",
":",
"entity_record",
"=",
"self",
".",
"_get_entity_by_class",
"(",
"entity_cls",
")",
"model_cls",
"=",
"None",
"if",
"entity_record",
".",
"model_cls",
":",
"model_cls",
"=",
"entity_record",
".",
"mo... | Retrieve Model class connected to Entity | [
"Retrieve",
"Model",
"class",
"connected",
"to",
"Entity"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L114-L133 |
proteanhq/protean | src/protean/core/repository/factory.py | RepositoryFactory.get_repository | def get_repository(self, entity_cls):
"""Retrieve a Repository for the Model with a live connection"""
entity_record = self._get_entity_by_class(entity_cls)
provider = self.get_provider(entity_record.provider_name)
return provider.get_repository(entity_record.entity_cls) | python | def get_repository(self, entity_cls):
"""Retrieve a Repository for the Model with a live connection"""
entity_record = self._get_entity_by_class(entity_cls)
provider = self.get_provider(entity_record.provider_name)
return provider.get_repository(entity_record.entity_cls) | [
"def",
"get_repository",
"(",
"self",
",",
"entity_cls",
")",
":",
"entity_record",
"=",
"self",
".",
"_get_entity_by_class",
"(",
"entity_cls",
")",
"provider",
"=",
"self",
".",
"get_provider",
"(",
"entity_record",
".",
"provider_name",
")",
"return",
"provid... | Retrieve a Repository for the Model with a live connection | [
"Retrieve",
"a",
"Repository",
"for",
"the",
"Model",
"with",
"a",
"live",
"connection"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/repository/factory.py#L143-L148 |
Danielhiversen/pymill | mill/__init__.py | set_heater_values | async def set_heater_values(heater_data, heater):
"""Set heater values from heater data"""
heater.current_temp = heater_data.get('currentTemp')
heater.device_status = heater_data.get('deviceStatus')
heater.available = heater.device_status == 0
heater.name = heater_data.get('deviceName')
heater.f... | python | async def set_heater_values(heater_data, heater):
"""Set heater values from heater data"""
heater.current_temp = heater_data.get('currentTemp')
heater.device_status = heater_data.get('deviceStatus')
heater.available = heater.device_status == 0
heater.name = heater_data.get('deviceName')
heater.f... | [
"async",
"def",
"set_heater_values",
"(",
"heater_data",
",",
"heater",
")",
":",
"heater",
".",
"current_temp",
"=",
"heater_data",
".",
"get",
"(",
"'currentTemp'",
")",
"heater",
".",
"device_status",
"=",
"heater_data",
".",
"get",
"(",
"'deviceStatus'",
"... | Set heater values from heater data | [
"Set",
"heater",
"values",
"from",
"heater",
"data"
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L445-L488 |
Danielhiversen/pymill | mill/__init__.py | Mill.connect | async def connect(self, retry=2):
"""Connect to Mill."""
# pylint: disable=too-many-return-statements
url = API_ENDPOINT_1 + 'login'
headers = {
"Content-Type": "application/x-zc-object",
"Connection": "Keep-Alive",
"X-Zc-Major-Domain": "seanywell",
... | python | async def connect(self, retry=2):
"""Connect to Mill."""
# pylint: disable=too-many-return-statements
url = API_ENDPOINT_1 + 'login'
headers = {
"Content-Type": "application/x-zc-object",
"Connection": "Keep-Alive",
"X-Zc-Major-Domain": "seanywell",
... | [
"async",
"def",
"connect",
"(",
"self",
",",
"retry",
"=",
"2",
")",
":",
"# pylint: disable=too-many-return-statements",
"url",
"=",
"API_ENDPOINT_1",
"+",
"'login'",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"\"application/x-zc-object\"",
",",
"\"Connection\"",
... | Connect to Mill. | [
"Connect",
"to",
"Mill",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L52-L100 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_connect | def sync_connect(self):
"""Close the Mill connection."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.connect())
loop.run_until_complete(task) | python | def sync_connect(self):
"""Close the Mill connection."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.connect())
loop.run_until_complete(task) | [
"def",
"sync_connect",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"connect",
"(",
")",
")",
"loop",
".",
"run_until_complete",
"(",
"task",
")"
] | Close the Mill connection. | [
"Close",
"the",
"Mill",
"connection",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L102-L106 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_close_connection | def sync_close_connection(self):
"""Close the Mill connection."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.close_connection())
loop.run_until_complete(task) | python | def sync_close_connection(self):
"""Close the Mill connection."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.close_connection())
loop.run_until_complete(task) | [
"def",
"sync_close_connection",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"close_connection",
"(",
")",
")",
"loop",
".",
"run_until_complete",
"(",
"task",
")... | Close the Mill connection. | [
"Close",
"the",
"Mill",
"connection",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L112-L116 |
Danielhiversen/pymill | mill/__init__.py | Mill.request | async def request(self, command, payload, retry=3):
"""Request data."""
# pylint: disable=too-many-return-statements
if self._token is None:
_LOGGER.error("No token")
return None
_LOGGER.debug(command, payload)
nonce = ''.join(random.choice(string.ascii... | python | async def request(self, command, payload, retry=3):
"""Request data."""
# pylint: disable=too-many-return-statements
if self._token is None:
_LOGGER.error("No token")
return None
_LOGGER.debug(command, payload)
nonce = ''.join(random.choice(string.ascii... | [
"async",
"def",
"request",
"(",
"self",
",",
"command",
",",
"payload",
",",
"retry",
"=",
"3",
")",
":",
"# pylint: disable=too-many-return-statements",
"if",
"self",
".",
"_token",
"is",
"None",
":",
"_LOGGER",
".",
"error",
"(",
"\"No token\"",
")",
"retu... | Request data. | [
"Request",
"data",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L118-L191 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_request | def sync_request(self, command, payload, retry=2):
"""Request data."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.request(command, payload, retry))
return loop.run_until_complete(task) | python | def sync_request(self, command, payload, retry=2):
"""Request data."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.request(command, payload, retry))
return loop.run_until_complete(task) | [
"def",
"sync_request",
"(",
"self",
",",
"command",
",",
"payload",
",",
"retry",
"=",
"2",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"request",
"(",
"command",
",",
... | Request data. | [
"Request",
"data",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L193-L197 |
Danielhiversen/pymill | mill/__init__.py | Mill.update_rooms | async def update_rooms(self):
"""Request data."""
homes = await self.get_home_list()
for home in homes:
payload = {"homeId": home.get("homeId"), "timeZoneNum": "+01:00"}
data = await self.request("selectRoombyHome", payload)
rooms = data.get('roomInfo', [])
... | python | async def update_rooms(self):
"""Request data."""
homes = await self.get_home_list()
for home in homes:
payload = {"homeId": home.get("homeId"), "timeZoneNum": "+01:00"}
data = await self.request("selectRoombyHome", payload)
rooms = data.get('roomInfo', [])
... | [
"async",
"def",
"update_rooms",
"(",
"self",
")",
":",
"homes",
"=",
"await",
"self",
".",
"get_home_list",
"(",
")",
"for",
"home",
"in",
"homes",
":",
"payload",
"=",
"{",
"\"homeId\"",
":",
"home",
".",
"get",
"(",
"\"homeId\"",
")",
",",
"\"timeZon... | Request data. | [
"Request",
"data",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L206-L241 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_update_rooms | def sync_update_rooms(self):
"""Request data."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.update_rooms())
return loop.run_until_complete(task) | python | def sync_update_rooms(self):
"""Request data."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.update_rooms())
return loop.run_until_complete(task) | [
"def",
"sync_update_rooms",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"update_rooms",
"(",
")",
")",
"return",
"loop",
".",
"run_until_complete",
"(",
"task",
... | Request data. | [
"Request",
"data",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L243-L247 |
Danielhiversen/pymill | mill/__init__.py | Mill.set_room_temperatures_by_name | async def set_room_temperatures_by_name(self, room_name, sleep_temp=None,
comfort_temp=None, away_temp=None):
"""Set room temps by name."""
if sleep_temp is None and comfort_temp is None and away_temp is None:
return
for room_id, _room in s... | python | async def set_room_temperatures_by_name(self, room_name, sleep_temp=None,
comfort_temp=None, away_temp=None):
"""Set room temps by name."""
if sleep_temp is None and comfort_temp is None and away_temp is None:
return
for room_id, _room in s... | [
"async",
"def",
"set_room_temperatures_by_name",
"(",
"self",
",",
"room_name",
",",
"sleep_temp",
"=",
"None",
",",
"comfort_temp",
"=",
"None",
",",
"away_temp",
"=",
"None",
")",
":",
"if",
"sleep_temp",
"is",
"None",
"and",
"comfort_temp",
"is",
"None",
... | Set room temps by name. | [
"Set",
"room",
"temps",
"by",
"name",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L249-L259 |
Danielhiversen/pymill | mill/__init__.py | Mill.set_room_temperatures | async def set_room_temperatures(self, room_id, sleep_temp=None,
comfort_temp=None, away_temp=None):
"""Set room temps."""
if sleep_temp is None and comfort_temp is None and away_temp is None:
return
room = self.rooms.get(room_id)
if room is... | python | async def set_room_temperatures(self, room_id, sleep_temp=None,
comfort_temp=None, away_temp=None):
"""Set room temps."""
if sleep_temp is None and comfort_temp is None and away_temp is None:
return
room = self.rooms.get(room_id)
if room is... | [
"async",
"def",
"set_room_temperatures",
"(",
"self",
",",
"room_id",
",",
"sleep_temp",
"=",
"None",
",",
"comfort_temp",
"=",
"None",
",",
"away_temp",
"=",
"None",
")",
":",
"if",
"sleep_temp",
"is",
"None",
"and",
"comfort_temp",
"is",
"None",
"and",
"... | Set room temps. | [
"Set",
"room",
"temps",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L261-L279 |
Danielhiversen/pymill | mill/__init__.py | Mill.update_heaters | async def update_heaters(self):
"""Request data."""
homes = await self.get_home_list()
for home in homes:
payload = {"homeId": home.get("homeId")}
data = await self.request("getIndependentDevices", payload)
if data is None:
continue
... | python | async def update_heaters(self):
"""Request data."""
homes = await self.get_home_list()
for home in homes:
payload = {"homeId": home.get("homeId")}
data = await self.request("getIndependentDevices", payload)
if data is None:
continue
... | [
"async",
"def",
"update_heaters",
"(",
"self",
")",
":",
"homes",
"=",
"await",
"self",
".",
"get_home_list",
"(",
")",
"for",
"home",
"in",
"homes",
":",
"payload",
"=",
"{",
"\"homeId\"",
":",
"home",
".",
"get",
"(",
"\"homeId\"",
")",
"}",
"data",
... | Request data. | [
"Request",
"data",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L281-L308 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_update_heaters | def sync_update_heaters(self):
"""Request data."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.update_heaters())
loop.run_until_complete(task) | python | def sync_update_heaters(self):
"""Request data."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.update_heaters())
loop.run_until_complete(task) | [
"def",
"sync_update_heaters",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"update_heaters",
"(",
")",
")",
"loop",
".",
"run_until_complete",
"(",
"task",
")"
] | Request data. | [
"Request",
"data",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L310-L314 |
Danielhiversen/pymill | mill/__init__.py | Mill.throttle_update_heaters | async def throttle_update_heaters(self):
"""Throttle update device."""
if (self._throttle_time is not None
and dt.datetime.now() - self._throttle_time < MIN_TIME_BETWEEN_UPDATES):
return
self._throttle_time = dt.datetime.now()
await self.update_heaters() | python | async def throttle_update_heaters(self):
"""Throttle update device."""
if (self._throttle_time is not None
and dt.datetime.now() - self._throttle_time < MIN_TIME_BETWEEN_UPDATES):
return
self._throttle_time = dt.datetime.now()
await self.update_heaters() | [
"async",
"def",
"throttle_update_heaters",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_throttle_time",
"is",
"not",
"None",
"and",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"self",
".",
"_throttle_time",
"<",
"MIN_TIME_BETWEEN_UPDATES",
")",
"... | Throttle update device. | [
"Throttle",
"update",
"device",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L316-L322 |
Danielhiversen/pymill | mill/__init__.py | Mill.throttle_update_all_heaters | async def throttle_update_all_heaters(self):
"""Throttle update all devices and rooms."""
if (self._throttle_all_time is not None
and dt.datetime.now() - self._throttle_all_time
< MIN_TIME_BETWEEN_UPDATES):
return
self._throttle_all_time = dt.datetime.... | python | async def throttle_update_all_heaters(self):
"""Throttle update all devices and rooms."""
if (self._throttle_all_time is not None
and dt.datetime.now() - self._throttle_all_time
< MIN_TIME_BETWEEN_UPDATES):
return
self._throttle_all_time = dt.datetime.... | [
"async",
"def",
"throttle_update_all_heaters",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_throttle_all_time",
"is",
"not",
"None",
"and",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"self",
".",
"_throttle_all_time",
"<",
"MIN_TIME_BETWEEN_UPDATES"... | Throttle update all devices and rooms. | [
"Throttle",
"update",
"all",
"devices",
"and",
"rooms",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L324-L331 |
Danielhiversen/pymill | mill/__init__.py | Mill.heater_control | async def heater_control(self, device_id, fan_status=None,
power_status=None):
"""Set heater temps."""
heater = self.heaters.get(device_id)
if heater is None:
_LOGGER.error("No such device")
return
if fan_status is None:
fa... | python | async def heater_control(self, device_id, fan_status=None,
power_status=None):
"""Set heater temps."""
heater = self.heaters.get(device_id)
if heater is None:
_LOGGER.error("No such device")
return
if fan_status is None:
fa... | [
"async",
"def",
"heater_control",
"(",
"self",
",",
"device_id",
",",
"fan_status",
"=",
"None",
",",
"power_status",
"=",
"None",
")",
":",
"heater",
"=",
"self",
".",
"heaters",
".",
"get",
"(",
"device_id",
")",
"if",
"heater",
"is",
"None",
":",
"_... | Set heater temps. | [
"Set",
"heater",
"temps",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L343-L364 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_heater_control | def sync_heater_control(self, device_id, fan_status=None,
power_status=None):
"""Set heater temps."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.heater_control(device_id,
fan_status,
... | python | def sync_heater_control(self, device_id, fan_status=None,
power_status=None):
"""Set heater temps."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.heater_control(device_id,
fan_status,
... | [
"def",
"sync_heater_control",
"(",
"self",
",",
"device_id",
",",
"fan_status",
"=",
"None",
",",
"power_status",
"=",
"None",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"... | Set heater temps. | [
"Set",
"heater",
"temps",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L366-L373 |
Danielhiversen/pymill | mill/__init__.py | Mill.set_heater_temp | async def set_heater_temp(self, device_id, set_temp):
"""Set heater temp."""
payload = {"homeType": 0,
"timeZoneNum": "+02:00",
"deviceId": device_id,
"value": int(set_temp),
"key": "holidayTemp"}
await self.request("cha... | python | async def set_heater_temp(self, device_id, set_temp):
"""Set heater temp."""
payload = {"homeType": 0,
"timeZoneNum": "+02:00",
"deviceId": device_id,
"value": int(set_temp),
"key": "holidayTemp"}
await self.request("cha... | [
"async",
"def",
"set_heater_temp",
"(",
"self",
",",
"device_id",
",",
"set_temp",
")",
":",
"payload",
"=",
"{",
"\"homeType\"",
":",
"0",
",",
"\"timeZoneNum\"",
":",
"\"+02:00\"",
",",
"\"deviceId\"",
":",
"device_id",
",",
"\"value\"",
":",
"int",
"(",
... | Set heater temp. | [
"Set",
"heater",
"temp",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L375-L382 |
Danielhiversen/pymill | mill/__init__.py | Mill.sync_set_heater_temp | def sync_set_heater_temp(self, device_id, set_temp):
"""Set heater temps."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.set_heater_temp(device_id, set_temp))
loop.run_until_complete(task) | python | def sync_set_heater_temp(self, device_id, set_temp):
"""Set heater temps."""
loop = asyncio.get_event_loop()
task = loop.create_task(self.set_heater_temp(device_id, set_temp))
loop.run_until_complete(task) | [
"def",
"sync_set_heater_temp",
"(",
"self",
",",
"device_id",
",",
"set_temp",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"task",
"=",
"loop",
".",
"create_task",
"(",
"self",
".",
"set_heater_temp",
"(",
"device_id",
",",
"set_temp",... | Set heater temps. | [
"Set",
"heater",
"temps",
"."
] | train | https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L384-L388 |
tadashi-aikawa/jumeaux | jumeaux/addons/log2reqs/csv.py | Executor.exec | def exec(self, payload: Log2ReqsAddOnPayload) -> TList[Request]:
"""Transform csv as below.
"title1","/path1","a=1&b=2","header1=1&header2=2"
"title2","/path2","c=1"
"title3","/path3",,"header1=1&header2=2"
"title4","/path4"
Exception:
ValueEr... | python | def exec(self, payload: Log2ReqsAddOnPayload) -> TList[Request]:
"""Transform csv as below.
"title1","/path1","a=1&b=2","header1=1&header2=2"
"title2","/path2","c=1"
"title3","/path3",,"header1=1&header2=2"
"title4","/path4"
Exception:
ValueEr... | [
"def",
"exec",
"(",
"self",
",",
"payload",
":",
"Log2ReqsAddOnPayload",
")",
"->",
"TList",
"[",
"Request",
"]",
":",
"outputs",
"=",
"[",
"]",
"with",
"open",
"(",
"payload",
".",
"file",
",",
"encoding",
"=",
"self",
".",
"config",
".",
"encoding",
... | Transform csv as below.
"title1","/path1","a=1&b=2","header1=1&header2=2"
"title2","/path2","c=1"
"title3","/path3",,"header1=1&header2=2"
"title4","/path4"
Exception:
ValueError: If fomat is invalid. | [
"Transform",
"csv",
"as",
"below",
".",
"title1",
"/",
"path1",
"a",
"=",
"1&b",
"=",
"2",
"header1",
"=",
"1&header2",
"=",
"2",
"title2",
"/",
"path2",
"c",
"=",
"1",
"title3",
"/",
"path3",
"header1",
"=",
"1&header2",
"=",
"2",
"title4",
"/",
"... | train | https://github.com/tadashi-aikawa/jumeaux/blob/23389bde3e9b27b3a646d99289f8b5ced411f6f0/jumeaux/addons/log2reqs/csv.py#L23-L49 |
wasp/waspy | waspy/app.py | Application.handle_request | async def handle_request(self, request: Request) -> Response:
"""
coroutine: This method is called by Transport
implementation to handle the actual request.
It returns a webtype.Response object.
"""
# Get handler
try:
try:
self._set_ctx... | python | async def handle_request(self, request: Request) -> Response:
"""
coroutine: This method is called by Transport
implementation to handle the actual request.
It returns a webtype.Response object.
"""
# Get handler
try:
try:
self._set_ctx... | [
"async",
"def",
"handle_request",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"Response",
":",
"# Get handler",
"try",
":",
"try",
":",
"self",
".",
"_set_ctx",
"(",
"request",
")",
"handler",
"=",
"self",
".",
"router",
".",
"get_handler_for_r... | coroutine: This method is called by Transport
implementation to handle the actual request.
It returns a webtype.Response object. | [
"coroutine",
":",
"This",
"method",
"is",
"called",
"by",
"Transport",
"implementation",
"to",
"handle",
"the",
"actual",
"request",
".",
"It",
"returns",
"a",
"webtype",
".",
"Response",
"object",
"."
] | train | https://github.com/wasp/waspy/blob/31cc352f300a089f9607d7f13d93591d4c69d5ec/waspy/app.py#L169-L234 |
martinmcbride/pysound | pysound/effects.py | echo | def echo(params, source, delay, strength):
'''
Create an echo
:param params:
:param source:
:param delay:
:param strength:
:return:
'''
source = create_buffer(params, source)
delay = create_buffer(params, delay)
strength = create_buffer(params, strength)
output = source[:... | python | def echo(params, source, delay, strength):
'''
Create an echo
:param params:
:param source:
:param delay:
:param strength:
:return:
'''
source = create_buffer(params, source)
delay = create_buffer(params, delay)
strength = create_buffer(params, strength)
output = source[:... | [
"def",
"echo",
"(",
"params",
",",
"source",
",",
"delay",
",",
"strength",
")",
":",
"source",
"=",
"create_buffer",
"(",
"params",
",",
"source",
")",
"delay",
"=",
"create_buffer",
"(",
"params",
",",
"delay",
")",
"strength",
"=",
"create_buffer",
"(... | Create an echo
:param params:
:param source:
:param delay:
:param strength:
:return: | [
"Create",
"an",
"echo",
":",
"param",
"params",
":",
":",
"param",
"source",
":",
":",
"param",
"delay",
":",
":",
"param",
"strength",
":",
":",
"return",
":"
] | train | https://github.com/martinmcbride/pysound/blob/253c8f712ad475318350e5a8ba21f6fefd7a3de2/pysound/effects.py#L11-L28 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet._clone | def _clone(self):
"""
Return a copy of the current QuerySet.
"""
clone = self.__class__(self._entity_cls, criteria=self._criteria,
offset=self._offset, limit=self._limit,
order_by=self._order_by)
return clone | python | def _clone(self):
"""
Return a copy of the current QuerySet.
"""
clone = self.__class__(self._entity_cls, criteria=self._criteria,
offset=self._offset, limit=self._limit,
order_by=self._order_by)
return clone | [
"def",
"_clone",
"(",
"self",
")",
":",
"clone",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"_entity_cls",
",",
"criteria",
"=",
"self",
".",
"_criteria",
",",
"offset",
"=",
"self",
".",
"_offset",
",",
"limit",
"=",
"self",
".",
"_limit",
","... | Return a copy of the current QuerySet. | [
"Return",
"a",
"copy",
"of",
"the",
"current",
"QuerySet",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L58-L65 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet._add_q | def _add_q(self, q_object):
"""Add a Q-object to the current filter."""
self._criteria = self._criteria._combine(q_object, q_object.connector) | python | def _add_q(self, q_object):
"""Add a Q-object to the current filter."""
self._criteria = self._criteria._combine(q_object, q_object.connector) | [
"def",
"_add_q",
"(",
"self",
",",
"q_object",
")",
":",
"self",
".",
"_criteria",
"=",
"self",
".",
"_criteria",
".",
"_combine",
"(",
"q_object",
",",
"q_object",
".",
"connector",
")"
] | Add a Q-object to the current filter. | [
"Add",
"a",
"Q",
"-",
"object",
"to",
"the",
"current",
"filter",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L67-L69 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.limit | def limit(self, limit):
"""Limit number of records"""
clone = self._clone()
if isinstance(limit, int):
clone._limit = limit
return clone | python | def limit(self, limit):
"""Limit number of records"""
clone = self._clone()
if isinstance(limit, int):
clone._limit = limit
return clone | [
"def",
"limit",
"(",
"self",
",",
"limit",
")",
":",
"clone",
"=",
"self",
".",
"_clone",
"(",
")",
"if",
"isinstance",
"(",
"limit",
",",
"int",
")",
":",
"clone",
".",
"_limit",
"=",
"limit",
"return",
"clone"
] | Limit number of records | [
"Limit",
"number",
"of",
"records"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L93-L100 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.offset | def offset(self, offset):
"""Fetch results after `offset` value"""
clone = self._clone()
if isinstance(offset, int):
clone._offset = offset
return clone | python | def offset(self, offset):
"""Fetch results after `offset` value"""
clone = self._clone()
if isinstance(offset, int):
clone._offset = offset
return clone | [
"def",
"offset",
"(",
"self",
",",
"offset",
")",
":",
"clone",
"=",
"self",
".",
"_clone",
"(",
")",
"if",
"isinstance",
"(",
"offset",
",",
"int",
")",
":",
"clone",
".",
"_offset",
"=",
"offset",
"return",
"clone"
] | Fetch results after `offset` value | [
"Fetch",
"results",
"after",
"offset",
"value"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L102-L109 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.order_by | def order_by(self, order_by: Union[set, str]):
"""Update order_by setting for filter set"""
clone = self._clone()
if isinstance(order_by, str):
order_by = {order_by}
clone._order_by = clone._order_by.union(order_by)
return clone | python | def order_by(self, order_by: Union[set, str]):
"""Update order_by setting for filter set"""
clone = self._clone()
if isinstance(order_by, str):
order_by = {order_by}
clone._order_by = clone._order_by.union(order_by)
return clone | [
"def",
"order_by",
"(",
"self",
",",
"order_by",
":",
"Union",
"[",
"set",
",",
"str",
"]",
")",
":",
"clone",
"=",
"self",
".",
"_clone",
"(",
")",
"if",
"isinstance",
"(",
"order_by",
",",
"str",
")",
":",
"order_by",
"=",
"{",
"order_by",
"}",
... | Update order_by setting for filter set | [
"Update",
"order_by",
"setting",
"for",
"filter",
"set"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L111-L119 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.all | def all(self):
"""Primary method to fetch data based on filters
Also trigged when the QuerySet is evaluated by calling one of the following methods:
* len()
* bool()
* list()
* Iteration
* Slicing
"""
logger.debug(f'Query `{sel... | python | def all(self):
"""Primary method to fetch data based on filters
Also trigged when the QuerySet is evaluated by calling one of the following methods:
* len()
* bool()
* list()
* Iteration
* Slicing
"""
logger.debug(f'Query `{sel... | [
"def",
"all",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"f'Query `{self.__class__.__name__}` objects with filters {self}'",
")",
"# Destroy any cached results",
"self",
".",
"_result_cache",
"=",
"None",
"# Fetch Model class and connected repository from Repository Fact... | Primary method to fetch data based on filters
Also trigged when the QuerySet is evaluated by calling one of the following methods:
* len()
* bool()
* list()
* Iteration
* Slicing | [
"Primary",
"method",
"to",
"fetch",
"data",
"based",
"on",
"filters"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L121-L157 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.update | def update(self, *data, **kwargs):
"""Updates all objects with details given if they match a set of conditions supplied.
This method updates each object individually, to fire callback methods and ensure
validations are run.
Returns the number of objects matched (which may not be equal ... | python | def update(self, *data, **kwargs):
"""Updates all objects with details given if they match a set of conditions supplied.
This method updates each object individually, to fire callback methods and ensure
validations are run.
Returns the number of objects matched (which may not be equal ... | [
"def",
"update",
"(",
"self",
",",
"*",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"updated_item_count",
"=",
"0",
"try",
":",
"items",
"=",
"self",
".",
"all",
"(",
")",
"for",
"item",
"in",
"items",
":",
"item",
".",
"update",
"(",
"*",
"data",... | Updates all objects with details given if they match a set of conditions supplied.
This method updates each object individually, to fire callback methods and ensure
validations are run.
Returns the number of objects matched (which may not be equal to the number of objects
updated i... | [
"Updates",
"all",
"objects",
"with",
"details",
"given",
"if",
"they",
"match",
"a",
"set",
"of",
"conditions",
"supplied",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L159-L179 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.raw | def raw(self, query: Any, data: Any = None):
"""Runs raw query directly on the database and returns Entity objects
Note that this method will raise an exception if the returned objects
are not of the Entity type.
`query` is not checked for correctness or validity, and any errors th... | python | def raw(self, query: Any, data: Any = None):
"""Runs raw query directly on the database and returns Entity objects
Note that this method will raise an exception if the returned objects
are not of the Entity type.
`query` is not checked for correctness or validity, and any errors th... | [
"def",
"raw",
"(",
"self",
",",
"query",
":",
"Any",
",",
"data",
":",
"Any",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"f'Query `{self.__class__.__name__}` objects with raw query {query}'",
")",
"# Destroy any cached results",
"self",
".",
"_result_cache"... | Runs raw query directly on the database and returns Entity objects
Note that this method will raise an exception if the returned objects
are not of the Entity type.
`query` is not checked for correctness or validity, and any errors thrown by the plugin or
database are passed as... | [
"Runs",
"raw",
"query",
"directly",
"on",
"the",
"database",
"and",
"returns",
"Entity",
"objects"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L181-L219 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.delete | def delete(self):
"""Deletes matching objects from the Repository
Does not throw error if no objects are matched.
Returns the number of objects matched (which may not be equal to the number of objects
deleted if objects rows already have the new value).
"""
# Fetch ... | python | def delete(self):
"""Deletes matching objects from the Repository
Does not throw error if no objects are matched.
Returns the number of objects matched (which may not be equal to the number of objects
deleted if objects rows already have the new value).
"""
# Fetch ... | [
"def",
"delete",
"(",
"self",
")",
":",
"# Fetch Model class and connected repository from Repository Factory",
"deleted_item_count",
"=",
"0",
"try",
":",
"items",
"=",
"self",
".",
"all",
"(",
")",
"for",
"item",
"in",
"items",
":",
"item",
".",
"delete",
"(",... | Deletes matching objects from the Repository
Does not throw error if no objects are matched.
Returns the number of objects matched (which may not be equal to the number of objects
deleted if objects rows already have the new value). | [
"Deletes",
"matching",
"objects",
"from",
"the",
"Repository"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L221-L241 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.update_all | def update_all(self, *args, **kwargs):
"""Updates all objects with details given if they match a set of conditions supplied.
This method forwards filters and updates directly to the repository. It does not
instantiate entities and it does not trigger Entity callbacks or validations.
Up... | python | def update_all(self, *args, **kwargs):
"""Updates all objects with details given if they match a set of conditions supplied.
This method forwards filters and updates directly to the repository. It does not
instantiate entities and it does not trigger Entity callbacks or validations.
Up... | [
"def",
"update_all",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"updated_item_count",
"=",
"0",
"repository",
"=",
"repo_factory",
".",
"get_repository",
"(",
"self",
".",
"_entity_cls",
")",
"try",
":",
"updated_item_count",
"=",
"r... | Updates all objects with details given if they match a set of conditions supplied.
This method forwards filters and updates directly to the repository. It does not
instantiate entities and it does not trigger Entity callbacks or validations.
Update values can be specified either as a dict, or ... | [
"Updates",
"all",
"objects",
"with",
"details",
"given",
"if",
"they",
"match",
"a",
"set",
"of",
"conditions",
"supplied",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L243-L264 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.delete_all | def delete_all(self, *args, **kwargs):
"""Deletes objects that match a set of conditions supplied.
This method forwards filters directly to the repository. It does not instantiate entities and
it does not trigger Entity callbacks or validations.
Returns the number of objects matched an... | python | def delete_all(self, *args, **kwargs):
"""Deletes objects that match a set of conditions supplied.
This method forwards filters directly to the repository. It does not instantiate entities and
it does not trigger Entity callbacks or validations.
Returns the number of objects matched an... | [
"def",
"delete_all",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"deleted_item_count",
"=",
"0",
"repository",
"=",
"repo_factory",
".",
"get_repository",
"(",
"self",
".",
"_entity_cls",
")",
"try",
":",
"deleted_item_count",
"=",
"r... | Deletes objects that match a set of conditions supplied.
This method forwards filters directly to the repository. It does not instantiate entities and
it does not trigger Entity callbacks or validations.
Returns the number of objects matched and deleted. | [
"Deletes",
"objects",
"that",
"match",
"a",
"set",
"of",
"conditions",
"supplied",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L266-L282 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.total | def total(self):
"""Return the total number of records"""
if self._result_cache:
return self._result_cache.total
return self.all().total | python | def total(self):
"""Return the total number of records"""
if self._result_cache:
return self._result_cache.total
return self.all().total | [
"def",
"total",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result_cache",
":",
"return",
"self",
".",
"_result_cache",
".",
"total",
"return",
"self",
".",
"all",
"(",
")",
".",
"total"
] | Return the total number of records | [
"Return",
"the",
"total",
"number",
"of",
"records"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L328-L333 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.items | def items(self):
"""Return result values"""
if self._result_cache:
return self._result_cache.items
return self.all().items | python | def items(self):
"""Return result values"""
if self._result_cache:
return self._result_cache.items
return self.all().items | [
"def",
"items",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result_cache",
":",
"return",
"self",
".",
"_result_cache",
".",
"items",
"return",
"self",
".",
"all",
"(",
")",
".",
"items"
] | Return result values | [
"Return",
"result",
"values"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L336-L341 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.first | def first(self):
"""Return the first result"""
if self._result_cache:
return self._result_cache.first
return self.all().first | python | def first(self):
"""Return the first result"""
if self._result_cache:
return self._result_cache.first
return self.all().first | [
"def",
"first",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result_cache",
":",
"return",
"self",
".",
"_result_cache",
".",
"first",
"return",
"self",
".",
"all",
"(",
")",
".",
"first"
] | Return the first result | [
"Return",
"the",
"first",
"result"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L344-L349 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.has_next | def has_next(self):
"""Return True if there are more values present"""
if self._result_cache:
return self._result_cache.has_next
return self.all().has_next | python | def has_next(self):
"""Return True if there are more values present"""
if self._result_cache:
return self._result_cache.has_next
return self.all().has_next | [
"def",
"has_next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result_cache",
":",
"return",
"self",
".",
"_result_cache",
".",
"has_next",
"return",
"self",
".",
"all",
"(",
")",
".",
"has_next"
] | Return True if there are more values present | [
"Return",
"True",
"if",
"there",
"are",
"more",
"values",
"present"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L352-L357 |
proteanhq/protean | src/protean/core/queryset.py | QuerySet.has_prev | def has_prev(self):
"""Return True if there are previous values present"""
if self._result_cache:
return self._result_cache.has_prev
return self.all().has_prev | python | def has_prev(self):
"""Return True if there are previous values present"""
if self._result_cache:
return self._result_cache.has_prev
return self.all().has_prev | [
"def",
"has_prev",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result_cache",
":",
"return",
"self",
".",
"_result_cache",
".",
"has_prev",
"return",
"self",
".",
"all",
"(",
")",
".",
"has_prev"
] | Return True if there are previous values present | [
"Return",
"True",
"if",
"there",
"are",
"previous",
"values",
"present"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/queryset.py#L360-L365 |
proteanhq/protean | src/protean/services/email/utils.py | get_connection | def get_connection(backend=None, fail_silently=False, **kwargs):
"""Load an email backend and return an instance of it.
If backend is None (default), use settings.EMAIL_BACKEND.
Both fail_silently and other keyword arguments are used in the
constructor of the backend.
"""
klass = perform_import(... | python | def get_connection(backend=None, fail_silently=False, **kwargs):
"""Load an email backend and return an instance of it.
If backend is None (default), use settings.EMAIL_BACKEND.
Both fail_silently and other keyword arguments are used in the
constructor of the backend.
"""
klass = perform_import(... | [
"def",
"get_connection",
"(",
"backend",
"=",
"None",
",",
"fail_silently",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"klass",
"=",
"perform_import",
"(",
"backend",
"or",
"active_config",
".",
"EMAIL_BACKEND",
")",
"return",
"klass",
"(",
"fail_silen... | Load an email backend and return an instance of it.
If backend is None (default), use settings.EMAIL_BACKEND.
Both fail_silently and other keyword arguments are used in the
constructor of the backend. | [
"Load",
"an",
"email",
"backend",
"and",
"return",
"an",
"instance",
"of",
"it",
".",
"If",
"backend",
"is",
"None",
"(",
"default",
")",
"use",
"settings",
".",
"EMAIL_BACKEND",
".",
"Both",
"fail_silently",
"and",
"other",
"keyword",
"arguments",
"are",
... | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/services/email/utils.py#L8-L15 |
proteanhq/protean | src/protean/services/email/utils.py | send_mail | def send_mail(subject, message, recipient_list, from_email=None,
fail_silently=False, auth_user=None, auth_password=None,
connection=None, **kwargs):
"""
Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipients... | python | def send_mail(subject, message, recipient_list, from_email=None,
fail_silently=False, auth_user=None, auth_password=None,
connection=None, **kwargs):
"""
Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipients... | [
"def",
"send_mail",
"(",
"subject",
",",
"message",
",",
"recipient_list",
",",
"from_email",
"=",
"None",
",",
"fail_silently",
"=",
"False",
",",
"auth_user",
"=",
"None",
",",
"auth_password",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"*",
"*",
... | Easy wrapper for sending a single message to a recipient list. All members
of the recipient list will see the other recipients in the 'To' field. | [
"Easy",
"wrapper",
"for",
"sending",
"a",
"single",
"message",
"to",
"a",
"recipient",
"list",
".",
"All",
"members",
"of",
"the",
"recipient",
"list",
"will",
"see",
"the",
"other",
"recipients",
"in",
"the",
"To",
"field",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/services/email/utils.py#L18-L34 |
proteanhq/protean | src/protean/services/email/utils.py | send_mass_mail | def send_mass_mail(data_tuple, fail_silently=False, auth_user=None,
auth_password=None, connection=None):
"""
Given a data_tuple of (subject, message, from_email, recipient_list), send
each message to each recipient list. Return the number of emails sent.
If from_email is None, use th... | python | def send_mass_mail(data_tuple, fail_silently=False, auth_user=None,
auth_password=None, connection=None):
"""
Given a data_tuple of (subject, message, from_email, recipient_list), send
each message to each recipient list. Return the number of emails sent.
If from_email is None, use th... | [
"def",
"send_mass_mail",
"(",
"data_tuple",
",",
"fail_silently",
"=",
"False",
",",
"auth_user",
"=",
"None",
",",
"auth_password",
"=",
"None",
",",
"connection",
"=",
"None",
")",
":",
"connection",
"=",
"connection",
"or",
"get_connection",
"(",
"username"... | Given a data_tuple of (subject, message, from_email, recipient_list), send
each message to each recipient list. Return the number of emails sent.
If from_email is None, use the DEFAULT_FROM_EMAIL setting. | [
"Given",
"a",
"data_tuple",
"of",
"(",
"subject",
"message",
"from_email",
"recipient_list",
")",
"send",
"each",
"message",
"to",
"each",
"recipient",
"list",
".",
"Return",
"the",
"number",
"of",
"emails",
"sent",
".",
"If",
"from_email",
"is",
"None",
"us... | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/services/email/utils.py#L37-L54 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.value | def value(self):
"""Utility method to retrieve Response Object information"""
# Set the code to the status value
if isinstance(self.code, Status):
code = self.code.value
else:
code = self.code
return {'code': code, 'errors': self.errors} | python | def value(self):
"""Utility method to retrieve Response Object information"""
# Set the code to the status value
if isinstance(self.code, Status):
code = self.code.value
else:
code = self.code
return {'code': code, 'errors': self.errors} | [
"def",
"value",
"(",
"self",
")",
":",
"# Set the code to the status value",
"if",
"isinstance",
"(",
"self",
".",
"code",
",",
"Status",
")",
":",
"code",
"=",
"self",
".",
"code",
".",
"value",
"else",
":",
"code",
"=",
"self",
".",
"code",
"return",
... | Utility method to retrieve Response Object information | [
"Utility",
"method",
"to",
"retrieve",
"Response",
"Object",
"information"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L62-L69 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.build_response | def build_response(cls, code=Status.SYSTEM_ERROR, errors=None):
"""Utility method to build a new Resource Error object.
Can be used to build all kinds of error messages.
"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(code, errors) | python | def build_response(cls, code=Status.SYSTEM_ERROR, errors=None):
"""Utility method to build a new Resource Error object.
Can be used to build all kinds of error messages.
"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(code, errors) | [
"def",
"build_response",
"(",
"cls",
",",
"code",
"=",
"Status",
".",
"SYSTEM_ERROR",
",",
"errors",
"=",
"None",
")",
":",
"errors",
"=",
"[",
"errors",
"]",
"if",
"not",
"isinstance",
"(",
"errors",
",",
"list",
")",
"else",
"errors",
"return",
"cls"... | Utility method to build a new Resource Error object.
Can be used to build all kinds of error messages. | [
"Utility",
"method",
"to",
"build",
"a",
"new",
"Resource",
"Error",
"object",
".",
"Can",
"be",
"used",
"to",
"build",
"all",
"kinds",
"of",
"error",
"messages",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L72-L77 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.build_from_invalid_request | def build_from_invalid_request(cls, invalid_request_object):
"""Utility method to build a new Error object from parameters.
Typically used to build HTTP 422 error response."""
errors = [{err['parameter']: err['message']} for err in invalid_request_object.errors]
return cls.build_response... | python | def build_from_invalid_request(cls, invalid_request_object):
"""Utility method to build a new Error object from parameters.
Typically used to build HTTP 422 error response."""
errors = [{err['parameter']: err['message']} for err in invalid_request_object.errors]
return cls.build_response... | [
"def",
"build_from_invalid_request",
"(",
"cls",
",",
"invalid_request_object",
")",
":",
"errors",
"=",
"[",
"{",
"err",
"[",
"'parameter'",
"]",
":",
"err",
"[",
"'message'",
"]",
"}",
"for",
"err",
"in",
"invalid_request_object",
".",
"errors",
"]",
"retu... | Utility method to build a new Error object from parameters.
Typically used to build HTTP 422 error response. | [
"Utility",
"method",
"to",
"build",
"a",
"new",
"Error",
"object",
"from",
"parameters",
".",
"Typically",
"used",
"to",
"build",
"HTTP",
"422",
"error",
"response",
"."
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L80-L84 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.build_not_found | def build_not_found(cls, errors=None):
"""Utility method to build a HTTP 404 Resource Error response"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.NOT_FOUND, errors) | python | def build_not_found(cls, errors=None):
"""Utility method to build a HTTP 404 Resource Error response"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.NOT_FOUND, errors) | [
"def",
"build_not_found",
"(",
"cls",
",",
"errors",
"=",
"None",
")",
":",
"errors",
"=",
"[",
"errors",
"]",
"if",
"not",
"isinstance",
"(",
"errors",
",",
"list",
")",
"else",
"errors",
"return",
"cls",
"(",
"Status",
".",
"NOT_FOUND",
",",
"errors"... | Utility method to build a HTTP 404 Resource Error response | [
"Utility",
"method",
"to",
"build",
"a",
"HTTP",
"404",
"Resource",
"Error",
"response"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L87-L90 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.build_system_error | def build_system_error(cls, errors=None):
"""Utility method to build a HTTP 500 System Error response"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.SYSTEM_ERROR, errors) | python | def build_system_error(cls, errors=None):
"""Utility method to build a HTTP 500 System Error response"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.SYSTEM_ERROR, errors) | [
"def",
"build_system_error",
"(",
"cls",
",",
"errors",
"=",
"None",
")",
":",
"errors",
"=",
"[",
"errors",
"]",
"if",
"not",
"isinstance",
"(",
"errors",
",",
"list",
")",
"else",
"errors",
"return",
"cls",
"(",
"Status",
".",
"SYSTEM_ERROR",
",",
"e... | Utility method to build a HTTP 500 System Error response | [
"Utility",
"method",
"to",
"build",
"a",
"HTTP",
"500",
"System",
"Error",
"response"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L93-L96 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.build_parameters_error | def build_parameters_error(cls, errors=None):
"""Utility method to build a HTTP 400 Parameter Error response"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.PARAMETERS_ERROR, errors) | python | def build_parameters_error(cls, errors=None):
"""Utility method to build a HTTP 400 Parameter Error response"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.PARAMETERS_ERROR, errors) | [
"def",
"build_parameters_error",
"(",
"cls",
",",
"errors",
"=",
"None",
")",
":",
"errors",
"=",
"[",
"errors",
"]",
"if",
"not",
"isinstance",
"(",
"errors",
",",
"list",
")",
"else",
"errors",
"return",
"cls",
"(",
"Status",
".",
"PARAMETERS_ERROR",
"... | Utility method to build a HTTP 400 Parameter Error response | [
"Utility",
"method",
"to",
"build",
"a",
"HTTP",
"400",
"Parameter",
"Error",
"response"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L99-L102 |
proteanhq/protean | src/protean/core/transport/response.py | ResponseFailure.build_unprocessable_error | def build_unprocessable_error(cls, errors=None):
"""Utility method to build a HTTP 422 Parameter Error object"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.UNPROCESSABLE_ENTITY, errors) | python | def build_unprocessable_error(cls, errors=None):
"""Utility method to build a HTTP 422 Parameter Error object"""
errors = [errors] if not isinstance(errors, list) else errors
return cls(Status.UNPROCESSABLE_ENTITY, errors) | [
"def",
"build_unprocessable_error",
"(",
"cls",
",",
"errors",
"=",
"None",
")",
":",
"errors",
"=",
"[",
"errors",
"]",
"if",
"not",
"isinstance",
"(",
"errors",
",",
"list",
")",
"else",
"errors",
"return",
"cls",
"(",
"Status",
".",
"UNPROCESSABLE_ENTIT... | Utility method to build a HTTP 422 Parameter Error object | [
"Utility",
"method",
"to",
"build",
"a",
"HTTP",
"422",
"Parameter",
"Error",
"object"
] | train | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/transport/response.py#L105-L108 |
martinmcbride/pysound | pysound/envelopes.py | linseg | def linseg(params, start=0, end=1):
'''
Signal starts at start value, ramps linearly up to end value
:param params: buffer parameters, controls length of signal created
:param start: start value (number)
:param end: end value (number)
:return: array of resulting signal
'''
return np.lins... | python | def linseg(params, start=0, end=1):
'''
Signal starts at start value, ramps linearly up to end value
:param params: buffer parameters, controls length of signal created
:param start: start value (number)
:param end: end value (number)
:return: array of resulting signal
'''
return np.lins... | [
"def",
"linseg",
"(",
"params",
",",
"start",
"=",
"0",
",",
"end",
"=",
"1",
")",
":",
"return",
"np",
".",
"linspace",
"(",
"start",
",",
"end",
",",
"num",
"=",
"params",
".",
"length",
",",
"endpoint",
"=",
"True",
")"
] | Signal starts at start value, ramps linearly up to end value
:param params: buffer parameters, controls length of signal created
:param start: start value (number)
:param end: end value (number)
:return: array of resulting signal | [
"Signal",
"starts",
"at",
"start",
"value",
"ramps",
"linearly",
"up",
"to",
"end",
"value",
":",
"param",
"params",
":",
"buffer",
"parameters",
"controls",
"length",
"of",
"signal",
"created",
":",
"param",
"start",
":",
"start",
"value",
"(",
"number",
... | train | https://github.com/martinmcbride/pysound/blob/253c8f712ad475318350e5a8ba21f6fefd7a3de2/pysound/envelopes.py#L8-L16 |
martinmcbride/pysound | pysound/envelopes.py | attack_decay | def attack_decay(params, attack, start=0, peak=1):
'''
Signal starts at min value, ramps linearly up to max value during the
attack time, than ramps back down to min value over remaining time
:param params: buffer parameters, controls length of signal created
:param attack: attack time, in samples
... | python | def attack_decay(params, attack, start=0, peak=1):
'''
Signal starts at min value, ramps linearly up to max value during the
attack time, than ramps back down to min value over remaining time
:param params: buffer parameters, controls length of signal created
:param attack: attack time, in samples
... | [
"def",
"attack_decay",
"(",
"params",
",",
"attack",
",",
"start",
"=",
"0",
",",
"peak",
"=",
"1",
")",
":",
"builder",
"=",
"GenericEnvelope",
"(",
"params",
")",
"builder",
".",
"set",
"(",
"start",
")",
"builder",
".",
"linseg",
"(",
"peak",
",",... | Signal starts at min value, ramps linearly up to max value during the
attack time, than ramps back down to min value over remaining time
:param params: buffer parameters, controls length of signal created
:param attack: attack time, in samples
:param start: start value (number)
:param peak: peak val... | [
"Signal",
"starts",
"at",
"min",
"value",
"ramps",
"linearly",
"up",
"to",
"max",
"value",
"during",
"the",
"attack",
"time",
"than",
"ramps",
"back",
"down",
"to",
"min",
"value",
"over",
"remaining",
"time",
":",
"param",
"params",
":",
"buffer",
"parame... | train | https://github.com/martinmcbride/pysound/blob/253c8f712ad475318350e5a8ba21f6fefd7a3de2/pysound/envelopes.py#L79-L94 |
martinmcbride/pysound | pysound/envelopes.py | GenericEnvelope.set | def set(self, value, samples=0):
'''
Set the current value and optionally maintain it for a period
:param value: New current value
:param samples: Add current value for this number of samples (if not zero)
:return:
'''
if self.params.length > self.pos and samples ... | python | def set(self, value, samples=0):
'''
Set the current value and optionally maintain it for a period
:param value: New current value
:param samples: Add current value for this number of samples (if not zero)
:return:
'''
if self.params.length > self.pos and samples ... | [
"def",
"set",
"(",
"self",
",",
"value",
",",
"samples",
"=",
"0",
")",
":",
"if",
"self",
".",
"params",
".",
"length",
">",
"self",
".",
"pos",
"and",
"samples",
">",
"0",
":",
"l",
"=",
"min",
"(",
"samples",
",",
"self",
".",
"params",
".",... | Set the current value and optionally maintain it for a period
:param value: New current value
:param samples: Add current value for this number of samples (if not zero)
:return: | [
"Set",
"the",
"current",
"value",
"and",
"optionally",
"maintain",
"it",
"for",
"a",
"period",
":",
"param",
"value",
":",
"New",
"current",
"value",
":",
"param",
"samples",
":",
"Add",
"current",
"value",
"for",
"this",
"number",
"of",
"samples",
"(",
... | train | https://github.com/martinmcbride/pysound/blob/253c8f712ad475318350e5a8ba21f6fefd7a3de2/pysound/envelopes.py#L30-L42 |
martinmcbride/pysound | pysound/envelopes.py | GenericEnvelope.linseg | def linseg(self, value, samples):
'''
Create a linear section moving from current value to new value over acertain number of
samples.
:param value: New value
:param samples: Length of segment in samples
:return:
'''
if self.params.length > self.pos and sam... | python | def linseg(self, value, samples):
'''
Create a linear section moving from current value to new value over acertain number of
samples.
:param value: New value
:param samples: Length of segment in samples
:return:
'''
if self.params.length > self.pos and sam... | [
"def",
"linseg",
"(",
"self",
",",
"value",
",",
"samples",
")",
":",
"if",
"self",
".",
"params",
".",
"length",
">",
"self",
".",
"pos",
"and",
"samples",
">",
"0",
":",
"len",
"=",
"min",
"(",
"samples",
",",
"self",
".",
"params",
".",
"lengt... | Create a linear section moving from current value to new value over acertain number of
samples.
:param value: New value
:param samples: Length of segment in samples
:return: | [
"Create",
"a",
"linear",
"section",
"moving",
"from",
"current",
"value",
"to",
"new",
"value",
"over",
"acertain",
"number",
"of",
"samples",
".",
":",
"param",
"value",
":",
"New",
"value",
":",
"param",
"samples",
":",
"Length",
"of",
"segment",
"in",
... | train | https://github.com/martinmcbride/pysound/blob/253c8f712ad475318350e5a8ba21f6fefd7a3de2/pysound/envelopes.py#L56-L70 |
heroku/salesforce-oauth-request | salesforce_oauth_request/utils.py | oauth_flow | def oauth_flow(s, oauth_url, username=None, password=None, sandbox=False):
"""s should be a requests session"""
r = s.get(oauth_url)
if r.status_code >= 300:
raise RuntimeError(r.text)
params = urlparse.parse_qs(urlparse.urlparse(r.url).query)
data = {"un":username,
"width":256... | python | def oauth_flow(s, oauth_url, username=None, password=None, sandbox=False):
"""s should be a requests session"""
r = s.get(oauth_url)
if r.status_code >= 300:
raise RuntimeError(r.text)
params = urlparse.parse_qs(urlparse.urlparse(r.url).query)
data = {"un":username,
"width":256... | [
"def",
"oauth_flow",
"(",
"s",
",",
"oauth_url",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"sandbox",
"=",
"False",
")",
":",
"r",
"=",
"s",
".",
"get",
"(",
"oauth_url",
")",
"if",
"r",
".",
"status_code",
">=",
"300",
":",
... | s should be a requests session | [
"s",
"should",
"be",
"a",
"requests",
"session"
] | train | https://github.com/heroku/salesforce-oauth-request/blob/16d4aa57f5bc00912d466a532c3f1d946d186da6/salesforce_oauth_request/utils.py#L113-L154 |
moonso/loqusdb | loqusdb/utils/update.py | update_database | def update_database(adapter, variant_file=None, sv_file=None, family_file=None, family_type='ped',
skip_case_id=False, gq_treshold=None, case_id=None, max_window = 3000):
"""Update a case in the database
Args:
adapter: Connection to database
variant_file(str): Path t... | python | def update_database(adapter, variant_file=None, sv_file=None, family_file=None, family_type='ped',
skip_case_id=False, gq_treshold=None, case_id=None, max_window = 3000):
"""Update a case in the database
Args:
adapter: Connection to database
variant_file(str): Path t... | [
"def",
"update_database",
"(",
"adapter",
",",
"variant_file",
"=",
"None",
",",
"sv_file",
"=",
"None",
",",
"family_file",
"=",
"None",
",",
"family_type",
"=",
"'ped'",
",",
"skip_case_id",
"=",
"False",
",",
"gq_treshold",
"=",
"None",
",",
"case_id",
... | Update a case in the database
Args:
adapter: Connection to database
variant_file(str): Path to variant file
sv_file(str): Path to sv variant file
family_file(str): Path to family file
family_type(str): Format of family file
skip_case_id(bool):... | [
"Update",
"a",
"case",
"in",
"the",
"database",
"Args",
":",
"adapter",
":",
"Connection",
"to",
"database",
"variant_file",
"(",
"str",
")",
":",
"Path",
"to",
"variant",
"file",
"sv_file",
"(",
"str",
")",
":",
"Path",
"to",
"sv",
"variant",
"file",
... | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/update.py#L23-L137 |
MainRo/cyclotron-py | cyclotron/router.py | make_crossroad_router | def make_crossroad_router(source, drain=False):
''' legacy crossroad implementation. deprecated
'''
sink_observer = None
def on_sink_subscribe(observer):
nonlocal sink_observer
sink_observer = observer
def dispose():
nonlocal sink_observer
sink_observer ... | python | def make_crossroad_router(source, drain=False):
''' legacy crossroad implementation. deprecated
'''
sink_observer = None
def on_sink_subscribe(observer):
nonlocal sink_observer
sink_observer = observer
def dispose():
nonlocal sink_observer
sink_observer ... | [
"def",
"make_crossroad_router",
"(",
"source",
",",
"drain",
"=",
"False",
")",
":",
"sink_observer",
"=",
"None",
"def",
"on_sink_subscribe",
"(",
"observer",
")",
":",
"nonlocal",
"sink_observer",
"sink_observer",
"=",
"observer",
"def",
"dispose",
"(",
")",
... | legacy crossroad implementation. deprecated | [
"legacy",
"crossroad",
"implementation",
".",
"deprecated"
] | train | https://github.com/MainRo/cyclotron-py/blob/4530f65173aa4b9e27c3d4a2f5d33900fc19f754/cyclotron/router.py#L5-L59 |
MainRo/cyclotron-py | cyclotron/router.py | make_error_router | def make_error_router():
""" Creates an error router
An error router takes a higher order observable a input and returns two
observables: One containing the flattened items of the input observable
and another one containing the flattened errors of the input observable.
.. image:: ../docs/asset/err... | python | def make_error_router():
""" Creates an error router
An error router takes a higher order observable a input and returns two
observables: One containing the flattened items of the input observable
and another one containing the flattened errors of the input observable.
.. image:: ../docs/asset/err... | [
"def",
"make_error_router",
"(",
")",
":",
"sink_observer",
"=",
"None",
"def",
"on_subscribe",
"(",
"observer",
")",
":",
"nonlocal",
"sink_observer",
"sink_observer",
"=",
"observer",
"def",
"dispose",
"(",
")",
":",
"nonlocal",
"sink_observer",
"sink_observer",... | Creates an error router
An error router takes a higher order observable a input and returns two
observables: One containing the flattened items of the input observable
and another one containing the flattened errors of the input observable.
.. image:: ../docs/asset/error_router.png
:scale: 60%... | [
"Creates",
"an",
"error",
"router"
] | train | https://github.com/MainRo/cyclotron-py/blob/4530f65173aa4b9e27c3d4a2f5d33900fc19f754/cyclotron/router.py#L145-L202 |
moonso/loqusdb | loqusdb/commands/load.py | load | def load(ctx, variant_file, sv_variants, family_file, family_type, skip_case_id, gq_treshold,
case_id, ensure_index, max_window, check_profile, hard_threshold, soft_threshold):
"""Load the variants of a case
A variant is loaded if it is observed in any individual of a case
If no family file is pro... | python | def load(ctx, variant_file, sv_variants, family_file, family_type, skip_case_id, gq_treshold,
case_id, ensure_index, max_window, check_profile, hard_threshold, soft_threshold):
"""Load the variants of a case
A variant is loaded if it is observed in any individual of a case
If no family file is pro... | [
"def",
"load",
"(",
"ctx",
",",
"variant_file",
",",
"sv_variants",
",",
"family_file",
",",
"family_type",
",",
"skip_case_id",
",",
"gq_treshold",
",",
"case_id",
",",
"ensure_index",
",",
"max_window",
",",
"check_profile",
",",
"hard_threshold",
",",
"soft_t... | Load the variants of a case
A variant is loaded if it is observed in any individual of a case
If no family file is provided all individuals in vcf file will be considered. | [
"Load",
"the",
"variants",
"of",
"a",
"case"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/load.py#L84-L141 |
moonso/loqusdb | loqusdb/plugins/mongo/adapter.py | MongoAdapter.wipe_db | def wipe_db(self):
"""Wipe the whole database"""
logger.warning("Wiping the whole database")
self.client.drop_database(self.db_name)
logger.debug("Database wiped") | python | def wipe_db(self):
"""Wipe the whole database"""
logger.warning("Wiping the whole database")
self.client.drop_database(self.db_name)
logger.debug("Database wiped") | [
"def",
"wipe_db",
"(",
"self",
")",
":",
"logger",
".",
"warning",
"(",
"\"Wiping the whole database\"",
")",
"self",
".",
"client",
".",
"drop_database",
"(",
"self",
".",
"db_name",
")",
"logger",
".",
"debug",
"(",
"\"Database wiped\"",
")"
] | Wipe the whole database | [
"Wipe",
"the",
"whole",
"database"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/adapter.py#L17-L21 |
moonso/loqusdb | loqusdb/plugins/mongo/adapter.py | MongoAdapter.check_indexes | def check_indexes(self):
"""Check if the indexes exists"""
for collection_name in INDEXES:
existing_indexes = self.indexes(collection_name)
indexes = INDEXES[collection_name]
for index in indexes:
index_name = index.document.get('name')
... | python | def check_indexes(self):
"""Check if the indexes exists"""
for collection_name in INDEXES:
existing_indexes = self.indexes(collection_name)
indexes = INDEXES[collection_name]
for index in indexes:
index_name = index.document.get('name')
... | [
"def",
"check_indexes",
"(",
"self",
")",
":",
"for",
"collection_name",
"in",
"INDEXES",
":",
"existing_indexes",
"=",
"self",
".",
"indexes",
"(",
"collection_name",
")",
"indexes",
"=",
"INDEXES",
"[",
"collection_name",
"]",
"for",
"index",
"in",
"indexes"... | Check if the indexes exists | [
"Check",
"if",
"the",
"indexes",
"exists"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/adapter.py#L43-L53 |
moonso/loqusdb | loqusdb/plugins/mongo/adapter.py | MongoAdapter.ensure_indexes | def ensure_indexes(self):
"""Update the indexes"""
for collection_name in INDEXES:
existing_indexes = self.indexes(collection_name)
indexes = INDEXES[collection_name]
for index in indexes:
index_name = index.document.get('name')
if inde... | python | def ensure_indexes(self):
"""Update the indexes"""
for collection_name in INDEXES:
existing_indexes = self.indexes(collection_name)
indexes = INDEXES[collection_name]
for index in indexes:
index_name = index.document.get('name')
if inde... | [
"def",
"ensure_indexes",
"(",
"self",
")",
":",
"for",
"collection_name",
"in",
"INDEXES",
":",
"existing_indexes",
"=",
"self",
".",
"indexes",
"(",
"collection_name",
")",
"indexes",
"=",
"INDEXES",
"[",
"collection_name",
"]",
"for",
"index",
"in",
"indexes... | Update the indexes | [
"Update",
"the",
"indexes"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/adapter.py#L55-L70 |
moonso/loqusdb | loqusdb/utils/variant.py | format_info | def format_info(variant, variant_type='snv'):
"""Format the info field for SNV variants
Args:
variant(dict)
variant_type(str): snv or sv
Returns:
vcf_info(str): A VCF formated info field
"""
observations = variant.get('observations',0)
homozygotes = varian... | python | def format_info(variant, variant_type='snv'):
"""Format the info field for SNV variants
Args:
variant(dict)
variant_type(str): snv or sv
Returns:
vcf_info(str): A VCF formated info field
"""
observations = variant.get('observations',0)
homozygotes = varian... | [
"def",
"format_info",
"(",
"variant",
",",
"variant_type",
"=",
"'snv'",
")",
":",
"observations",
"=",
"variant",
".",
"get",
"(",
"'observations'",
",",
"0",
")",
"homozygotes",
"=",
"variant",
".",
"get",
"(",
"'homozygote'",
")",
"hemizygotes",
"=",
"v... | Format the info field for SNV variants
Args:
variant(dict)
variant_type(str): snv or sv
Returns:
vcf_info(str): A VCF formated info field | [
"Format",
"the",
"info",
"field",
"for",
"SNV",
"variants",
"Args",
":",
"variant",
"(",
"dict",
")",
"variant_type",
"(",
"str",
")",
":",
"snv",
"or",
"sv",
"Returns",
":",
"vcf_info",
"(",
"str",
")",
":",
"A",
"VCF",
"formated",
"info",
"field"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/variant.py#L6-L35 |
moonso/loqusdb | loqusdb/utils/variant.py | format_variant | def format_variant(variant, variant_type='snv'):
"""Convert variant information to a VCF formated string
Args:
variant(dict)
variant_type(str)
Returns:
vcf_variant(str)
"""
chrom = variant.get('chrom')
pos = variant.get('start')
ref = variant.get('ref')... | python | def format_variant(variant, variant_type='snv'):
"""Convert variant information to a VCF formated string
Args:
variant(dict)
variant_type(str)
Returns:
vcf_variant(str)
"""
chrom = variant.get('chrom')
pos = variant.get('start')
ref = variant.get('ref')... | [
"def",
"format_variant",
"(",
"variant",
",",
"variant_type",
"=",
"'snv'",
")",
":",
"chrom",
"=",
"variant",
".",
"get",
"(",
"'chrom'",
")",
"pos",
"=",
"variant",
".",
"get",
"(",
"'start'",
")",
"ref",
"=",
"variant",
".",
"get",
"(",
"'ref'",
"... | Convert variant information to a VCF formated string
Args:
variant(dict)
variant_type(str)
Returns:
vcf_variant(str) | [
"Convert",
"variant",
"information",
"to",
"a",
"VCF",
"formated",
"string",
"Args",
":",
"variant",
"(",
"dict",
")",
"variant_type",
"(",
"str",
")",
"Returns",
":",
"vcf_variant",
"(",
"str",
")"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/variant.py#L37-L64 |
yjzhang/uncurl_python | uncurl/state_estimation.py | _create_m_objective | def _create_m_objective(w, X):
"""
Creates an objective function and its derivative for M, given W and X
Args:
w (array): clusters x cells
X (array): genes x cells
"""
clusters, cells = w.shape
genes = X.shape[0]
w_sum = w.sum(1)
def objective(m):
m = m.reshape((... | python | def _create_m_objective(w, X):
"""
Creates an objective function and its derivative for M, given W and X
Args:
w (array): clusters x cells
X (array): genes x cells
"""
clusters, cells = w.shape
genes = X.shape[0]
w_sum = w.sum(1)
def objective(m):
m = m.reshape((... | [
"def",
"_create_m_objective",
"(",
"w",
",",
"X",
")",
":",
"clusters",
",",
"cells",
"=",
"w",
".",
"shape",
"genes",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"w_sum",
"=",
"w",
".",
"sum",
"(",
"1",
")",
"def",
"objective",
"(",
"m",
")",
":",
... | Creates an objective function and its derivative for M, given W and X
Args:
w (array): clusters x cells
X (array): genes x cells | [
"Creates",
"an",
"objective",
"function",
"and",
"its",
"derivative",
"for",
"M",
"given",
"W",
"and",
"X"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L50-L68 |
yjzhang/uncurl_python | uncurl/state_estimation.py | initialize_from_assignments | def initialize_from_assignments(assignments, k, max_assign_weight=0.75):
"""
Creates a weight initialization matrix from Poisson clustering assignments.
Args:
assignments (array): 1D array of integers, of length cells
k (int): number of states/clusters
max_assign_weight (float, opti... | python | def initialize_from_assignments(assignments, k, max_assign_weight=0.75):
"""
Creates a weight initialization matrix from Poisson clustering assignments.
Args:
assignments (array): 1D array of integers, of length cells
k (int): number of states/clusters
max_assign_weight (float, opti... | [
"def",
"initialize_from_assignments",
"(",
"assignments",
",",
"k",
",",
"max_assign_weight",
"=",
"0.75",
")",
":",
"cells",
"=",
"len",
"(",
"assignments",
")",
"init_W",
"=",
"np",
".",
"zeros",
"(",
"(",
"k",
",",
"cells",
")",
")",
"for",
"i",
","... | Creates a weight initialization matrix from Poisson clustering assignments.
Args:
assignments (array): 1D array of integers, of length cells
k (int): number of states/clusters
max_assign_weight (float, optional): between 0 and 1 - how much weight to assign to the highest cluster. Default: 0... | [
"Creates",
"a",
"weight",
"initialization",
"matrix",
"from",
"Poisson",
"clustering",
"assignments",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L70-L91 |
yjzhang/uncurl_python | uncurl/state_estimation.py | initialize_means | def initialize_means(data, clusters, k):
"""
Initializes the M matrix given the data and a set of cluster labels.
Cluster centers are set to the mean of each cluster.
Args:
data (array): genes x cells
clusters (array): 1d array of ints (0...k-1)
k (int): number of clusters
"... | python | def initialize_means(data, clusters, k):
"""
Initializes the M matrix given the data and a set of cluster labels.
Cluster centers are set to the mean of each cluster.
Args:
data (array): genes x cells
clusters (array): 1d array of ints (0...k-1)
k (int): number of clusters
"... | [
"def",
"initialize_means",
"(",
"data",
",",
"clusters",
",",
"k",
")",
":",
"init_w",
"=",
"np",
".",
"zeros",
"(",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
",",
"k",
")",
")",
"if",
"sparse",
".",
"issparse",
"(",
"data",
")",
":",
"for",
"i... | Initializes the M matrix given the data and a set of cluster labels.
Cluster centers are set to the mean of each cluster.
Args:
data (array): genes x cells
clusters (array): 1d array of ints (0...k-1)
k (int): number of clusters | [
"Initializes",
"the",
"M",
"matrix",
"given",
"the",
"data",
"and",
"a",
"set",
"of",
"cluster",
"labels",
".",
"Cluster",
"centers",
"are",
"set",
"to",
"the",
"mean",
"of",
"each",
"cluster",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L93-L119 |
yjzhang/uncurl_python | uncurl/state_estimation.py | initialize_weights_nn | def initialize_weights_nn(data, means, lognorm=True):
"""
Initializes the weights with a nearest-neighbor approach using the means.
"""
# TODO
genes, cells = data.shape
k = means.shape[1]
if lognorm:
data = log1p(cell_normalize(data))
for i in range(cells):
for j in range... | python | def initialize_weights_nn(data, means, lognorm=True):
"""
Initializes the weights with a nearest-neighbor approach using the means.
"""
# TODO
genes, cells = data.shape
k = means.shape[1]
if lognorm:
data = log1p(cell_normalize(data))
for i in range(cells):
for j in range... | [
"def",
"initialize_weights_nn",
"(",
"data",
",",
"means",
",",
"lognorm",
"=",
"True",
")",
":",
"# TODO",
"genes",
",",
"cells",
"=",
"data",
".",
"shape",
"k",
"=",
"means",
".",
"shape",
"[",
"1",
"]",
"if",
"lognorm",
":",
"data",
"=",
"log1p",
... | Initializes the weights with a nearest-neighbor approach using the means. | [
"Initializes",
"the",
"weights",
"with",
"a",
"nearest",
"-",
"neighbor",
"approach",
"using",
"the",
"means",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L121-L132 |
yjzhang/uncurl_python | uncurl/state_estimation.py | initialize_means_weights | def initialize_means_weights(data, clusters, init_means=None, init_weights=None, initialization='tsvd', max_assign_weight=0.75):
"""
Generates initial means and weights for state estimation.
"""
genes, cells = data.shape
if init_means is None:
if init_weights is not None:
if len(... | python | def initialize_means_weights(data, clusters, init_means=None, init_weights=None, initialization='tsvd', max_assign_weight=0.75):
"""
Generates initial means and weights for state estimation.
"""
genes, cells = data.shape
if init_means is None:
if init_weights is not None:
if len(... | [
"def",
"initialize_means_weights",
"(",
"data",
",",
"clusters",
",",
"init_means",
"=",
"None",
",",
"init_weights",
"=",
"None",
",",
"initialization",
"=",
"'tsvd'",
",",
"max_assign_weight",
"=",
"0.75",
")",
":",
"genes",
",",
"cells",
"=",
"data",
".",... | Generates initial means and weights for state estimation. | [
"Generates",
"initial",
"means",
"and",
"weights",
"for",
"state",
"estimation",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L170-L243 |
yjzhang/uncurl_python | uncurl/state_estimation.py | poisson_estimate_state | def poisson_estimate_state(data, clusters, init_means=None, init_weights=None, method='NoLips', max_iters=30, tol=0, disp=False, inner_max_iters=100, normalize=True, initialization='tsvd', parallel=True, threads=4, max_assign_weight=0.75, run_w_first=True, constrain_w=False, regularization=0.0, write_progress_file=None... | python | def poisson_estimate_state(data, clusters, init_means=None, init_weights=None, method='NoLips', max_iters=30, tol=0, disp=False, inner_max_iters=100, normalize=True, initialization='tsvd', parallel=True, threads=4, max_assign_weight=0.75, run_w_first=True, constrain_w=False, regularization=0.0, write_progress_file=None... | [
"def",
"poisson_estimate_state",
"(",
"data",
",",
"clusters",
",",
"init_means",
"=",
"None",
",",
"init_weights",
"=",
"None",
",",
"method",
"=",
"'NoLips'",
",",
"max_iters",
"=",
"30",
",",
"tol",
"=",
"0",
",",
"disp",
"=",
"False",
",",
"inner_max... | Uses a Poisson Covex Mixture model to estimate cell states and
cell state mixing weights.
To lower computational costs, use a sparse matrix, set disp to False, and set tol to 0.
Args:
data (array): genes x cells array or sparse matrix.
clusters (int): number of mixture components
i... | [
"Uses",
"a",
"Poisson",
"Covex",
"Mixture",
"model",
"to",
"estimate",
"cell",
"states",
"and",
"cell",
"state",
"mixing",
"weights",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L245-L350 |
yjzhang/uncurl_python | uncurl/state_estimation.py | update_m | def update_m(data, old_M, old_W, selected_genes, disp=False, inner_max_iters=100, parallel=True, threads=4, write_progress_file=None, tol=0.0, regularization=0.0, **kwargs):
"""
This returns a new M matrix that contains all genes, given an M that was
created from running state estimation with a subset of ge... | python | def update_m(data, old_M, old_W, selected_genes, disp=False, inner_max_iters=100, parallel=True, threads=4, write_progress_file=None, tol=0.0, regularization=0.0, **kwargs):
"""
This returns a new M matrix that contains all genes, given an M that was
created from running state estimation with a subset of ge... | [
"def",
"update_m",
"(",
"data",
",",
"old_M",
",",
"old_W",
",",
"selected_genes",
",",
"disp",
"=",
"False",
",",
"inner_max_iters",
"=",
"100",
",",
"parallel",
"=",
"True",
",",
"threads",
"=",
"4",
",",
"write_progress_file",
"=",
"None",
",",
"tol",... | This returns a new M matrix that contains all genes, given an M that was
created from running state estimation with a subset of genes.
Args:
data (sparse matrix or dense array): data matrix of shape (genes, cells), containing all genes
old_M (array): shape is (selected_genes, k)
old_W (... | [
"This",
"returns",
"a",
"new",
"M",
"matrix",
"that",
"contains",
"all",
"genes",
"given",
"an",
"M",
"that",
"was",
"created",
"from",
"running",
"state",
"estimation",
"with",
"a",
"subset",
"of",
"genes",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/state_estimation.py#L353-L420 |
markperdue/pyvesync | home_assistant/custom_components/__init__.py | setup | def setup(hass, config):
"""Set up the VeSync component."""
from pyvesync.vesync import VeSync
conf = config[DOMAIN]
manager = VeSync(conf.get(CONF_USERNAME), conf.get(CONF_PASSWORD),
time_zone=conf.get(CONF_TIME_ZONE))
if not manager.login():
_LOGGER.error("Unable to... | python | def setup(hass, config):
"""Set up the VeSync component."""
from pyvesync.vesync import VeSync
conf = config[DOMAIN]
manager = VeSync(conf.get(CONF_USERNAME), conf.get(CONF_PASSWORD),
time_zone=conf.get(CONF_TIME_ZONE))
if not manager.login():
_LOGGER.error("Unable to... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"from",
"pyvesync",
".",
"vesync",
"import",
"VeSync",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"manager",
"=",
"VeSync",
"(",
"conf",
".",
"get",
"(",
"CONF_USERNAME",
")",
",",
"conf",
".",
"g... | Set up the VeSync component. | [
"Set",
"up",
"the",
"VeSync",
"component",
"."
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/home_assistant/custom_components/__init__.py#L22-L43 |
yjzhang/uncurl_python | uncurl/ensemble.py | state_estimation_ensemble | def state_estimation_ensemble(data, k, n_runs=10, M_list=[], **se_params):
"""
Runs an ensemble method on the list of M results...
Args:
data: genes x cells array
k: number of classes
n_runs (optional): number of random initializations of state estimation
M_list (optional): ... | python | def state_estimation_ensemble(data, k, n_runs=10, M_list=[], **se_params):
"""
Runs an ensemble method on the list of M results...
Args:
data: genes x cells array
k: number of classes
n_runs (optional): number of random initializations of state estimation
M_list (optional): ... | [
"def",
"state_estimation_ensemble",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"M_list",
"=",
"[",
"]",
",",
"*",
"*",
"se_params",
")",
":",
"if",
"len",
"(",
"M_list",
")",
"==",
"0",
":",
"M_list",
"=",
"[",
"]",
"for",
"i",
"in",
... | Runs an ensemble method on the list of M results...
Args:
data: genes x cells array
k: number of classes
n_runs (optional): number of random initializations of state estimation
M_list (optional): list of M arrays from state estimation
se_params (optional): optional poisson_e... | [
"Runs",
"an",
"ensemble",
"method",
"on",
"the",
"list",
"of",
"M",
"results",
"..."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L22-L47 |
yjzhang/uncurl_python | uncurl/ensemble.py | nmf_ensemble | def nmf_ensemble(data, k, n_runs=10, W_list=[], **nmf_params):
"""
Runs an ensemble method on the list of NMF W matrices...
Args:
data: genes x cells array (should be log + cell-normalized)
k: number of classes
n_runs (optional): number of random initializations of state estimation
... | python | def nmf_ensemble(data, k, n_runs=10, W_list=[], **nmf_params):
"""
Runs an ensemble method on the list of NMF W matrices...
Args:
data: genes x cells array (should be log + cell-normalized)
k: number of classes
n_runs (optional): number of random initializations of state estimation
... | [
"def",
"nmf_ensemble",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"W_list",
"=",
"[",
"]",
",",
"*",
"*",
"nmf_params",
")",
":",
"nmf",
"=",
"NMF",
"(",
"k",
")",
"if",
"len",
"(",
"W_list",
")",
"==",
"0",
":",
"W_list",
"=",
"["... | Runs an ensemble method on the list of NMF W matrices...
Args:
data: genes x cells array (should be log + cell-normalized)
k: number of classes
n_runs (optional): number of random initializations of state estimation
M_list (optional): list of M arrays from state estimation
s... | [
"Runs",
"an",
"ensemble",
"method",
"on",
"the",
"list",
"of",
"NMF",
"W",
"matrices",
"..."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L49-L79 |
yjzhang/uncurl_python | uncurl/ensemble.py | nmf_kfold | def nmf_kfold(data, k, n_runs=10, **nmf_params):
"""
Runs K-fold ensemble topic modeling (Belford et al. 2017)
"""
# TODO
nmf = NMF(k)
W_list = []
kf = KFold(n_splits=n_runs, shuffle=True)
# TODO: randomly divide data into n_runs folds
for train_index, test_index in kf.split(data.T):... | python | def nmf_kfold(data, k, n_runs=10, **nmf_params):
"""
Runs K-fold ensemble topic modeling (Belford et al. 2017)
"""
# TODO
nmf = NMF(k)
W_list = []
kf = KFold(n_splits=n_runs, shuffle=True)
# TODO: randomly divide data into n_runs folds
for train_index, test_index in kf.split(data.T):... | [
"def",
"nmf_kfold",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"*",
"*",
"nmf_params",
")",
":",
"# TODO",
"nmf",
"=",
"NMF",
"(",
"k",
")",
"W_list",
"=",
"[",
"]",
"kf",
"=",
"KFold",
"(",
"n_splits",
"=",
"n_runs",
",",
"shuffle",
... | Runs K-fold ensemble topic modeling (Belford et al. 2017) | [
"Runs",
"K",
"-",
"fold",
"ensemble",
"topic",
"modeling",
"(",
"Belford",
"et",
"al",
".",
"2017",
")"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L81-L101 |
yjzhang/uncurl_python | uncurl/ensemble.py | nmf_init | def nmf_init(data, clusters, k, init='enhanced'):
"""
runs enhanced NMF initialization from clusterings (Gong 2013)
There are 3 options for init:
enhanced - uses EIn-NMF from Gong 2013
basic - uses means for W, assigns H such that the chosen cluster for a given cell has value 0.75 and all o... | python | def nmf_init(data, clusters, k, init='enhanced'):
"""
runs enhanced NMF initialization from clusterings (Gong 2013)
There are 3 options for init:
enhanced - uses EIn-NMF from Gong 2013
basic - uses means for W, assigns H such that the chosen cluster for a given cell has value 0.75 and all o... | [
"def",
"nmf_init",
"(",
"data",
",",
"clusters",
",",
"k",
",",
"init",
"=",
"'enhanced'",
")",
":",
"init_w",
"=",
"np",
".",
"zeros",
"(",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
",",
"k",
")",
")",
"if",
"sparse",
".",
"issparse",
"(",
"da... | runs enhanced NMF initialization from clusterings (Gong 2013)
There are 3 options for init:
enhanced - uses EIn-NMF from Gong 2013
basic - uses means for W, assigns H such that the chosen cluster for a given cell has value 0.75 and all others have 0.25/(k-1).
nmf - uses means for W, and ass... | [
"runs",
"enhanced",
"NMF",
"initialization",
"from",
"clusterings",
"(",
"Gong",
"2013",
")"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L110-L148 |
yjzhang/uncurl_python | uncurl/ensemble.py | nmf_tsne | def nmf_tsne(data, k, n_runs=10, init='enhanced', **params):
"""
runs tsne-consensus-NMF
1. run a bunch of NMFs, get W and H
2. run tsne + km on all WH matrices
3. run consensus clustering on all km results
4. use consensus clustering as initialization for a new run of NMF
5. return the W a... | python | def nmf_tsne(data, k, n_runs=10, init='enhanced', **params):
"""
runs tsne-consensus-NMF
1. run a bunch of NMFs, get W and H
2. run tsne + km on all WH matrices
3. run consensus clustering on all km results
4. use consensus clustering as initialization for a new run of NMF
5. return the W a... | [
"def",
"nmf_tsne",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"init",
"=",
"'enhanced'",
",",
"*",
"*",
"params",
")",
":",
"clusters",
"=",
"[",
"]",
"nmf",
"=",
"NMF",
"(",
"k",
")",
"tsne",
"=",
"TSNE",
"(",
"2",
")",
"km",
"=",... | runs tsne-consensus-NMF
1. run a bunch of NMFs, get W and H
2. run tsne + km on all WH matrices
3. run consensus clustering on all km results
4. use consensus clustering as initialization for a new run of NMF
5. return the W and H from the resulting NMF run | [
"runs",
"tsne",
"-",
"consensus",
"-",
"NMF"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L150-L177 |
yjzhang/uncurl_python | uncurl/ensemble.py | poisson_se_multiclust | def poisson_se_multiclust(data, k, n_runs=10, **se_params):
"""
Initializes state estimation using a consensus of several
fast clustering/dimensionality reduction algorithms.
It does a consensus of 8 truncated SVD - k-means rounds, and uses the
basic nmf_init to create starting points.
"""
... | python | def poisson_se_multiclust(data, k, n_runs=10, **se_params):
"""
Initializes state estimation using a consensus of several
fast clustering/dimensionality reduction algorithms.
It does a consensus of 8 truncated SVD - k-means rounds, and uses the
basic nmf_init to create starting points.
"""
... | [
"def",
"poisson_se_multiclust",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"*",
"*",
"se_params",
")",
":",
"clusters",
"=",
"[",
"]",
"norm_data",
"=",
"cell_normalize",
"(",
"data",
")",
"if",
"sparse",
".",
"issparse",
"(",
"data",
")",
... | Initializes state estimation using a consensus of several
fast clustering/dimensionality reduction algorithms.
It does a consensus of 8 truncated SVD - k-means rounds, and uses the
basic nmf_init to create starting points. | [
"Initializes",
"state",
"estimation",
"using",
"a",
"consensus",
"of",
"several",
"fast",
"clustering",
"/",
"dimensionality",
"reduction",
"algorithms",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L197-L233 |
yjzhang/uncurl_python | uncurl/ensemble.py | poisson_consensus_se | def poisson_consensus_se(data, k, n_runs=10, **se_params):
"""
Initializes Poisson State Estimation using a consensus Poisson clustering.
"""
clusters = []
for i in range(n_runs):
assignments, means = poisson_cluster(data, k)
clusters.append(assignments)
clusterings = np.vstack(... | python | def poisson_consensus_se(data, k, n_runs=10, **se_params):
"""
Initializes Poisson State Estimation using a consensus Poisson clustering.
"""
clusters = []
for i in range(n_runs):
assignments, means = poisson_cluster(data, k)
clusters.append(assignments)
clusterings = np.vstack(... | [
"def",
"poisson_consensus_se",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"*",
"*",
"se_params",
")",
":",
"clusters",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"n_runs",
")",
":",
"assignments",
",",
"means",
"=",
"poisson_cluster",
... | Initializes Poisson State Estimation using a consensus Poisson clustering. | [
"Initializes",
"Poisson",
"State",
"Estimation",
"using",
"a",
"consensus",
"Poisson",
"clustering",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L235-L247 |
yjzhang/uncurl_python | uncurl/ensemble.py | lensNMF | def lensNMF(data, k, ks=1):
"""
Runs L-EnsNMF on the data. (Suh et al. 2016)
"""
# TODO: why is this not working
n_rounds = k/ks
R_i = data.copy()
nmf = NMF(ks)
nmf2 = NMF(ks, init='custom')
w_is = []
h_is = []
rs = []
w_i = np.zeros((data.shape[0], ks))
h_i = np.zero... | python | def lensNMF(data, k, ks=1):
"""
Runs L-EnsNMF on the data. (Suh et al. 2016)
"""
# TODO: why is this not working
n_rounds = k/ks
R_i = data.copy()
nmf = NMF(ks)
nmf2 = NMF(ks, init='custom')
w_is = []
h_is = []
rs = []
w_i = np.zeros((data.shape[0], ks))
h_i = np.zero... | [
"def",
"lensNMF",
"(",
"data",
",",
"k",
",",
"ks",
"=",
"1",
")",
":",
"# TODO: why is this not working",
"n_rounds",
"=",
"k",
"/",
"ks",
"R_i",
"=",
"data",
".",
"copy",
"(",
")",
"nmf",
"=",
"NMF",
"(",
"ks",
")",
"nmf2",
"=",
"NMF",
"(",
"ks... | Runs L-EnsNMF on the data. (Suh et al. 2016) | [
"Runs",
"L",
"-",
"EnsNMF",
"on",
"the",
"data",
".",
"(",
"Suh",
"et",
"al",
".",
"2016",
")"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L274-L315 |
moonso/loqusdb | loqusdb/utils/case.py | get_case | def get_case(family_lines, family_type='ped', vcf_path=None):
"""Return ped_parser case from a family file
Create a dictionary with case data. If no family file is given create from VCF
Args:
family_lines (iterator): The family lines
family_type (str): The format of the family line... | python | def get_case(family_lines, family_type='ped', vcf_path=None):
"""Return ped_parser case from a family file
Create a dictionary with case data. If no family file is given create from VCF
Args:
family_lines (iterator): The family lines
family_type (str): The format of the family line... | [
"def",
"get_case",
"(",
"family_lines",
",",
"family_type",
"=",
"'ped'",
",",
"vcf_path",
"=",
"None",
")",
":",
"family",
"=",
"None",
"LOG",
".",
"info",
"(",
"\"Parsing family information\"",
")",
"family_parser",
"=",
"FamilyParser",
"(",
"family_lines",
... | Return ped_parser case from a family file
Create a dictionary with case data. If no family file is given create from VCF
Args:
family_lines (iterator): The family lines
family_type (str): The format of the family lines
vcf_path(str): Path to VCF
Returns:
family... | [
"Return",
"ped_parser",
"case",
"from",
"a",
"family",
"file",
"Create",
"a",
"dictionary",
"with",
"case",
"data",
".",
"If",
"no",
"family",
"file",
"is",
"given",
"create",
"from",
"VCF",
"Args",
":",
"family_lines",
"(",
"iterator",
")",
":",
"The",
... | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/case.py#L11-L38 |
moonso/loqusdb | loqusdb/utils/case.py | update_case | def update_case(case_obj, existing_case):
"""Update an existing case
This will add paths to VCF files, individuals etc
Args:
case_obj(models.Case)
existing_case(models.Case)
Returns:
updated_case(models.Case): Updated existing case
"""
variant_nrs = ['nr_va... | python | def update_case(case_obj, existing_case):
"""Update an existing case
This will add paths to VCF files, individuals etc
Args:
case_obj(models.Case)
existing_case(models.Case)
Returns:
updated_case(models.Case): Updated existing case
"""
variant_nrs = ['nr_va... | [
"def",
"update_case",
"(",
"case_obj",
",",
"existing_case",
")",
":",
"variant_nrs",
"=",
"[",
"'nr_variants'",
",",
"'nr_sv_variants'",
"]",
"individuals",
"=",
"[",
"(",
"'individuals'",
",",
"'_inds'",
")",
",",
"(",
"'sv_individuals'",
",",
"'_sv_inds'",
... | Update an existing case
This will add paths to VCF files, individuals etc
Args:
case_obj(models.Case)
existing_case(models.Case)
Returns:
updated_case(models.Case): Updated existing case | [
"Update",
"an",
"existing",
"case",
"This",
"will",
"add",
"paths",
"to",
"VCF",
"files",
"individuals",
"etc",
"Args",
":",
"case_obj",
"(",
"models",
".",
"Case",
")",
"existing_case",
"(",
"models",
".",
"Case",
")",
"Returns",
":",
"updated_case",
"(",... | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/case.py#L40-L71 |
fbergmann/libSEDML | examples/python/print_sedml.py | main | def main (args):
"""Usage: print_sedml input-filename
"""
if len(args) != 2:
print(main.__doc__)
sys.exit(1)
doc = libsedml.readSedML(args[1]);
if ( doc.getErrorLog().getNumFailsWithSeverity(libsedml.LIBSEDML_SEV_ERROR) > 0):
print doc.getErrorLog().toString();
sys.exit(2);
print 'The... | python | def main (args):
"""Usage: print_sedml input-filename
"""
if len(args) != 2:
print(main.__doc__)
sys.exit(1)
doc = libsedml.readSedML(args[1]);
if ( doc.getErrorLog().getNumFailsWithSeverity(libsedml.LIBSEDML_SEV_ERROR) > 0):
print doc.getErrorLog().toString();
sys.exit(2);
print 'The... | [
"def",
"main",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
":",
"print",
"(",
"main",
".",
"__doc__",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"doc",
"=",
"libsedml",
".",
"readSedML",
"(",
"args",
"[",
"1",
"]",
")",
"if"... | Usage: print_sedml input-filename | [
"Usage",
":",
"print_sedml",
"input",
"-",
"filename"
] | train | https://github.com/fbergmann/libSEDML/blob/2611274d993cb92c663f8f0296896a6e441f75fd/examples/python/print_sedml.py#L40-L97 |
bachya/py17track | py17track/profile.py | Profile.login | async def login(self, email: str, password: str) -> bool:
"""Login to the profile."""
login_resp = await self._request(
'post',
API_URL_USER,
json={
'version': '1.0',
'method': 'Signin',
'param': {
'E... | python | async def login(self, email: str, password: str) -> bool:
"""Login to the profile."""
login_resp = await self._request(
'post',
API_URL_USER,
json={
'version': '1.0',
'method': 'Signin',
'param': {
'E... | [
"async",
"def",
"login",
"(",
"self",
",",
"email",
":",
"str",
",",
"password",
":",
"str",
")",
"->",
"bool",
":",
"login_resp",
"=",
"await",
"self",
".",
"_request",
"(",
"'post'",
",",
"API_URL_USER",
",",
"json",
"=",
"{",
"'version'",
":",
"'1... | Login to the profile. | [
"Login",
"to",
"the",
"profile",
"."
] | train | https://github.com/bachya/py17track/blob/e6e64f2a79571433df7ee702cb4ebc4127b7ad6d/py17track/profile.py#L22-L45 |
bachya/py17track | py17track/profile.py | Profile.packages | async def packages(
self, package_state: Union[int, str] = '',
show_archived: bool = False) -> list:
"""Get the list of packages associated with the account."""
packages_resp = await self._request(
'post',
API_URL_BUYER,
json={
... | python | async def packages(
self, package_state: Union[int, str] = '',
show_archived: bool = False) -> list:
"""Get the list of packages associated with the account."""
packages_resp = await self._request(
'post',
API_URL_BUYER,
json={
... | [
"async",
"def",
"packages",
"(",
"self",
",",
"package_state",
":",
"Union",
"[",
"int",
",",
"str",
"]",
"=",
"''",
",",
"show_archived",
":",
"bool",
"=",
"False",
")",
"->",
"list",
":",
"packages_resp",
"=",
"await",
"self",
".",
"_request",
"(",
... | Get the list of packages associated with the account. | [
"Get",
"the",
"list",
"of",
"packages",
"associated",
"with",
"the",
"account",
"."
] | train | https://github.com/bachya/py17track/blob/e6e64f2a79571433df7ee702cb4ebc4127b7ad6d/py17track/profile.py#L47-L88 |
bachya/py17track | py17track/profile.py | Profile.summary | async def summary(self, show_archived: bool = False) -> dict:
"""Get a quick summary of how many packages are in an account."""
summary_resp = await self._request(
'post',
API_URL_BUYER,
json={
'version': '1.0',
'method': 'GetIndexData'... | python | async def summary(self, show_archived: bool = False) -> dict:
"""Get a quick summary of how many packages are in an account."""
summary_resp = await self._request(
'post',
API_URL_BUYER,
json={
'version': '1.0',
'method': 'GetIndexData'... | [
"async",
"def",
"summary",
"(",
"self",
",",
"show_archived",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"summary_resp",
"=",
"await",
"self",
".",
"_request",
"(",
"'post'",
",",
"API_URL_BUYER",
",",
"json",
"=",
"{",
"'version'",
":",
"'1.0'",... | Get a quick summary of how many packages are in an account. | [
"Get",
"a",
"quick",
"summary",
"of",
"how",
"many",
"packages",
"are",
"in",
"an",
"account",
"."
] | train | https://github.com/bachya/py17track/blob/e6e64f2a79571433df7ee702cb4ebc4127b7ad6d/py17track/profile.py#L90-L109 |
markperdue/pyvesync | home_assistant/custom_components/switch.py | setup_platform | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the VeSync switch platform."""
if discovery_info is None:
return
switches = []
manager = hass.data[DOMAIN]['manager']
if manager.outlets is not None and manager.outlets:
if len(manager.outlets) == 1:
... | python | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the VeSync switch platform."""
if discovery_info is None:
return
switches = []
manager = hass.data[DOMAIN]['manager']
if manager.outlets is not None and manager.outlets:
if len(manager.outlets) == 1:
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"switches",
"=",
"[",
"]",
"manager",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]... | Set up the VeSync switch platform. | [
"Set",
"up",
"the",
"VeSync",
"switch",
"platform",
"."
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/home_assistant/custom_components/switch.py#L12-L41 |
markperdue/pyvesync | home_assistant/custom_components/switch.py | VeSyncSwitchHA.device_state_attributes | def device_state_attributes(self):
"""Return the state attributes of the device."""
attr = {}
attr['active_time'] = self.smartplug.active_time
attr['voltage'] = self.smartplug.voltage
attr['active_time'] = self.smartplug.active_time
attr['weekly_energy_total'] = self.smar... | python | def device_state_attributes(self):
"""Return the state attributes of the device."""
attr = {}
attr['active_time'] = self.smartplug.active_time
attr['voltage'] = self.smartplug.voltage
attr['active_time'] = self.smartplug.active_time
attr['weekly_energy_total'] = self.smar... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"attr",
"[",
"'active_time'",
"]",
"=",
"self",
".",
"smartplug",
".",
"active_time",
"attr",
"[",
"'voltage'",
"]",
"=",
"self",
".",
"smartplug",
".",
"voltage",
"attr",
"[... | Return the state attributes of the device. | [
"Return",
"the",
"state",
"attributes",
"of",
"the",
"device",
"."
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/home_assistant/custom_components/switch.py#L62-L71 |
moonso/loqusdb | loqusdb/plugins/mongo/variant.py | VariantMixin._get_update | def _get_update(self, variant):
"""Convert a variant to a proper update
Args:
variant(dict)
Returns:
update(dict)
"""
update = {
'$inc': {
'homozygote': variant.get('homozygote', 0),
... | python | def _get_update(self, variant):
"""Convert a variant to a proper update
Args:
variant(dict)
Returns:
update(dict)
"""
update = {
'$inc': {
'homozygote': variant.get('homozygote', 0),
... | [
"def",
"_get_update",
"(",
"self",
",",
"variant",
")",
":",
"update",
"=",
"{",
"'$inc'",
":",
"{",
"'homozygote'",
":",
"variant",
".",
"get",
"(",
"'homozygote'",
",",
"0",
")",
",",
"'hemizygote'",
":",
"variant",
".",
"get",
"(",
"'hemizygote'",
"... | Convert a variant to a proper update
Args:
variant(dict)
Returns:
update(dict) | [
"Convert",
"a",
"variant",
"to",
"a",
"proper",
"update",
"Args",
":",
"variant",
"(",
"dict",
")",
"Returns",
":",
"update",
"(",
"dict",
")"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L14-L44 |
moonso/loqusdb | loqusdb/plugins/mongo/variant.py | VariantMixin.add_variant | def add_variant(self, variant):
"""Add a variant to the variant collection
If the variant exists we update the count else we insert a new variant object.
Args:
variant (dict): A variant dictionary
"""
LOG.debug("Upserting variant... | python | def add_variant(self, variant):
"""Add a variant to the variant collection
If the variant exists we update the count else we insert a new variant object.
Args:
variant (dict): A variant dictionary
"""
LOG.debug("Upserting variant... | [
"def",
"add_variant",
"(",
"self",
",",
"variant",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Upserting variant: {0}\"",
".",
"format",
"(",
"variant",
".",
"get",
"(",
"'_id'",
")",
")",
")",
"update",
"=",
"self",
".",
"_get_update",
"(",
"variant",
")",
... | Add a variant to the variant collection
If the variant exists we update the count else we insert a new variant object.
Args:
variant (dict): A variant dictionary | [
"Add",
"a",
"variant",
"to",
"the",
"variant",
"collection",
"If",
"the",
"variant",
"exists",
"we",
"update",
"the",
"count",
"else",
"we",
"insert",
"a",
"new",
"variant",
"object",
".",
"Args",
":",
"variant",
"(",
"dict",
")",
":",
"A",
"variant",
... | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L46-L68 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.