id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
221,200 | openstack/horizon | openstack_dashboard/api/neutron.py | network_create | def network_create(request, **kwargs):
"""Create a network object.
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
:returns: Network object
"""
LOG.debug("network_create(): kwargs = %s", kwarg... | python | def network_create(request, **kwargs):
"""Create a network object.
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
:returns: Network object
"""
LOG.debug("network_create(): kwargs = %s", kwarg... | [
"def",
"network_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"network_create(): kwargs = %s\"",
",",
"kwargs",
")",
"if",
"'tenant_id'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'tenant_id'",
"]",
"=",
"request",... | Create a network object.
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
:returns: Network object | [
"Create",
"a",
"network",
"object",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1129-L1142 |
221,201 | openstack/horizon | openstack_dashboard/api/neutron.py | subnet_create | def subnet_create(request, network_id, **kwargs):
"""Create a subnet on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: (optional) subnet IP address range
:param ip_version: (optional) IP version (4 or 6)
:param gateway_ip: ... | python | def subnet_create(request, network_id, **kwargs):
"""Create a subnet on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: (optional) subnet IP address range
:param ip_version: (optional) IP version (4 or 6)
:param gateway_ip: ... | [
"def",
"subnet_create",
"(",
"request",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"subnet_create(): netid=%(network_id)s, kwargs=%(kwargs)s\"",
",",
"{",
"'network_id'",
":",
"network_id",
",",
"'kwargs'",
":",
"kwargs",
"}"... | Create a subnet on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: (optional) subnet IP address range
:param ip_version: (optional) IP version (4 or 6)
:param gateway_ip: (optional) IP address of gateway
:param tenant_id: (o... | [
"Create",
"a",
"subnet",
"on",
"a",
"specified",
"network",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1179-L1204 |
221,202 | openstack/horizon | openstack_dashboard/api/neutron.py | subnetpool_create | def subnetpool_create(request, name, prefixes, **kwargs):
"""Create a subnetpool.
ip_version is auto-detected in back-end.
Parameters:
request -- Request context
name -- Name for subnetpool
prefixes -- List of prefixes for pool
Keyword Arguments (optional):... | python | def subnetpool_create(request, name, prefixes, **kwargs):
"""Create a subnetpool.
ip_version is auto-detected in back-end.
Parameters:
request -- Request context
name -- Name for subnetpool
prefixes -- List of prefixes for pool
Keyword Arguments (optional):... | [
"def",
"subnetpool_create",
"(",
"request",
",",
"name",
",",
"prefixes",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"subnetpool_create(): name=%(name)s, prefixes=%(prefixes)s, \"",
"\"kwargs=%(kwargs)s\"",
",",
"{",
"'name'",
":",
"name",
",",
... | Create a subnetpool.
ip_version is auto-detected in back-end.
Parameters:
request -- Request context
name -- Name for subnetpool
prefixes -- List of prefixes for pool
Keyword Arguments (optional):
min_prefixlen -- Minimum prefix length for allocations f... | [
"Create",
"a",
"subnetpool",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1243-L1277 |
221,203 | openstack/horizon | openstack_dashboard/api/neutron.py | port_list_with_trunk_types | def port_list_with_trunk_types(request, **params):
"""List neutron Ports for this tenant with possible TrunkPort indicated
:param request: request context
NOTE Performing two API calls is not atomic, but this is not worse
than the original idea when we call port_list repeatedly for
each ... | python | def port_list_with_trunk_types(request, **params):
"""List neutron Ports for this tenant with possible TrunkPort indicated
:param request: request context
NOTE Performing two API calls is not atomic, but this is not worse
than the original idea when we call port_list repeatedly for
each ... | [
"def",
"port_list_with_trunk_types",
"(",
"request",
",",
"*",
"*",
"params",
")",
":",
"LOG",
".",
"debug",
"(",
"\"port_list_with_trunk_types(): params=%s\"",
",",
"params",
")",
"# When trunk feature is disabled in neutron, we have no need to fetch",
"# trunk information and... | List neutron Ports for this tenant with possible TrunkPort indicated
:param request: request context
NOTE Performing two API calls is not atomic, but this is not worse
than the original idea when we call port_list repeatedly for
each network to perform identification run-time. We should
... | [
"List",
"neutron",
"Ports",
"for",
"this",
"tenant",
"with",
"possible",
"TrunkPort",
"indicated"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1308-L1348 |
221,204 | openstack/horizon | openstack_dashboard/api/neutron.py | port_create | def port_create(request, network_id, **kwargs):
"""Create a port on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
:param tenant_id: (optional) tenant id of the port created
:p... | python | def port_create(request, network_id, **kwargs):
"""Create a port on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
:param tenant_id: (optional) tenant id of the port created
:p... | [
"def",
"port_create",
"(",
"request",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"port_create(): netid=%(network_id)s, kwargs=%(kwargs)s\"",
",",
"{",
"'network_id'",
":",
"network_id",
",",
"'kwargs'",
":",
"kwargs",
"}",
... | Create a port on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
:param tenant_id: (optional) tenant id of the port created
:param name: (optional) name of the port created
:ret... | [
"Create",
"a",
"port",
"on",
"a",
"specified",
"network",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1367-L1385 |
221,205 | openstack/horizon | openstack_dashboard/api/neutron.py | list_extensions | def list_extensions(request):
"""List neutron extensions.
:param request: django request object
"""
neutron_api = neutronclient(request)
try:
extensions_list = neutron_api.list_extensions()
except exceptions.ServiceCatalogException:
return {}
if 'extensions' in extensions_li... | python | def list_extensions(request):
"""List neutron extensions.
:param request: django request object
"""
neutron_api = neutronclient(request)
try:
extensions_list = neutron_api.list_extensions()
except exceptions.ServiceCatalogException:
return {}
if 'extensions' in extensions_li... | [
"def",
"list_extensions",
"(",
"request",
")",
":",
"neutron_api",
"=",
"neutronclient",
"(",
"request",
")",
"try",
":",
"extensions_list",
"=",
"neutron_api",
".",
"list_extensions",
"(",
")",
"except",
"exceptions",
".",
"ServiceCatalogException",
":",
"return"... | List neutron extensions.
:param request: django request object | [
"List",
"neutron",
"extensions",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1795-L1808 |
221,206 | openstack/horizon | openstack_dashboard/api/neutron.py | is_extension_supported | def is_extension_supported(request, extension_alias):
"""Check if a specified extension is supported.
:param request: django request object
:param extension_alias: neutron extension alias
"""
extensions = list_extensions(request)
for extension in extensions:
if extension['alias'] == ext... | python | def is_extension_supported(request, extension_alias):
"""Check if a specified extension is supported.
:param request: django request object
:param extension_alias: neutron extension alias
"""
extensions = list_extensions(request)
for extension in extensions:
if extension['alias'] == ext... | [
"def",
"is_extension_supported",
"(",
"request",
",",
"extension_alias",
")",
":",
"extensions",
"=",
"list_extensions",
"(",
"request",
")",
"for",
"extension",
"in",
"extensions",
":",
"if",
"extension",
"[",
"'alias'",
"]",
"==",
"extension_alias",
":",
"retu... | Check if a specified extension is supported.
:param request: django request object
:param extension_alias: neutron extension alias | [
"Check",
"if",
"a",
"specified",
"extension",
"is",
"supported",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1812-L1823 |
221,207 | openstack/horizon | openstack_dashboard/api/neutron.py | get_feature_permission | def get_feature_permission(request, feature, operation=None):
"""Check if a feature-specific field can be displayed.
This method check a permission for a feature-specific field.
Such field is usually provided through Neutron extension.
:param request: Request Object
:param feature: feature name de... | python | def get_feature_permission(request, feature, operation=None):
"""Check if a feature-specific field can be displayed.
This method check a permission for a feature-specific field.
Such field is usually provided through Neutron extension.
:param request: Request Object
:param feature: feature name de... | [
"def",
"get_feature_permission",
"(",
"request",
",",
"feature",
",",
"operation",
"=",
"None",
")",
":",
"network_config",
"=",
"getattr",
"(",
"settings",
",",
"'OPENSTACK_NEUTRON_NETWORK'",
",",
"{",
"}",
")",
"feature_info",
"=",
"FEATURE_MAP",
".",
"get",
... | Check if a feature-specific field can be displayed.
This method check a permission for a feature-specific field.
Such field is usually provided through Neutron extension.
:param request: Request Object
:param feature: feature name defined in FEATURE_MAP
:param operation (optional): Operation type.... | [
"Check",
"if",
"a",
"feature",
"-",
"specific",
"field",
"can",
"be",
"displayed",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1889-L1940 |
221,208 | openstack/horizon | openstack_dashboard/api/neutron.py | policy_create | def policy_create(request, **kwargs):
"""Create a QoS Policy.
:param request: request context
:param name: name of the policy
:param description: description of policy
:param shared: boolean (true or false)
:return: QoSPolicy object
"""
body = {'policy': kwargs}
policy = neutronclie... | python | def policy_create(request, **kwargs):
"""Create a QoS Policy.
:param request: request context
:param name: name of the policy
:param description: description of policy
:param shared: boolean (true or false)
:return: QoSPolicy object
"""
body = {'policy': kwargs}
policy = neutronclie... | [
"def",
"policy_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"{",
"'policy'",
":",
"kwargs",
"}",
"policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"create_qos_policy",
"(",
"body",
"=",
"body",
")",
".",
"get",
"(",
... | Create a QoS Policy.
:param request: request context
:param name: name of the policy
:param description: description of policy
:param shared: boolean (true or false)
:return: QoSPolicy object | [
"Create",
"a",
"QoS",
"Policy",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1950-L1961 |
221,209 | openstack/horizon | openstack_dashboard/api/neutron.py | policy_list | def policy_list(request, **kwargs):
"""List of QoS Policies."""
policies = neutronclient(request).list_qos_policies(
**kwargs).get('policies')
return [QoSPolicy(p) for p in policies] | python | def policy_list(request, **kwargs):
"""List of QoS Policies."""
policies = neutronclient(request).list_qos_policies(
**kwargs).get('policies')
return [QoSPolicy(p) for p in policies] | [
"def",
"policy_list",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"policies",
"=",
"neutronclient",
"(",
"request",
")",
".",
"list_qos_policies",
"(",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'policies'",
")",
"return",
"[",
"QoSPolicy",
"(",
... | List of QoS Policies. | [
"List",
"of",
"QoS",
"Policies",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1964-L1968 |
221,210 | openstack/horizon | openstack_dashboard/api/neutron.py | policy_get | def policy_get(request, policy_id, **kwargs):
"""Get QoS policy for a given policy id."""
policy = neutronclient(request).show_qos_policy(
policy_id, **kwargs).get('policy')
return QoSPolicy(policy) | python | def policy_get(request, policy_id, **kwargs):
"""Get QoS policy for a given policy id."""
policy = neutronclient(request).show_qos_policy(
policy_id, **kwargs).get('policy')
return QoSPolicy(policy) | [
"def",
"policy_get",
"(",
"request",
",",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
":",
"policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"show_qos_policy",
"(",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'policy'",
")",
"re... | Get QoS policy for a given policy id. | [
"Get",
"QoS",
"policy",
"for",
"a",
"given",
"policy",
"id",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1972-L1976 |
221,211 | openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_create | def rbac_policy_create(request, **kwargs):
"""Create a RBAC Policy.
:param request: request context
:param target_tenant: target tenant of the policy
:param tenant_id: owner tenant of the policy(Not recommended)
:param object_type: network or qos_policy
:param object_id: object id of policy
... | python | def rbac_policy_create(request, **kwargs):
"""Create a RBAC Policy.
:param request: request context
:param target_tenant: target tenant of the policy
:param tenant_id: owner tenant of the policy(Not recommended)
:param object_type: network or qos_policy
:param object_id: object id of policy
... | [
"def",
"rbac_policy_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"{",
"'rbac_policy'",
":",
"kwargs",
"}",
"rbac_policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"create_rbac_policy",
"(",
"body",
"=",
"body",
")",
".",
... | Create a RBAC Policy.
:param request: request context
:param target_tenant: target tenant of the policy
:param tenant_id: owner tenant of the policy(Not recommended)
:param object_type: network or qos_policy
:param object_id: object id of policy
:param action: access_as_shared or access_as_exte... | [
"Create",
"a",
"RBAC",
"Policy",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2001-L2015 |
221,212 | openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_list | def rbac_policy_list(request, **kwargs):
"""List of RBAC Policies."""
policies = neutronclient(request).list_rbac_policies(
**kwargs).get('rbac_policies')
return [RBACPolicy(p) for p in policies] | python | def rbac_policy_list(request, **kwargs):
"""List of RBAC Policies."""
policies = neutronclient(request).list_rbac_policies(
**kwargs).get('rbac_policies')
return [RBACPolicy(p) for p in policies] | [
"def",
"rbac_policy_list",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"policies",
"=",
"neutronclient",
"(",
"request",
")",
".",
"list_rbac_policies",
"(",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'rbac_policies'",
")",
"return",
"[",
"RBACPolic... | List of RBAC Policies. | [
"List",
"of",
"RBAC",
"Policies",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2018-L2022 |
221,213 | openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_update | def rbac_policy_update(request, policy_id, **kwargs):
"""Update a RBAC Policy.
:param request: request context
:param policy_id: target policy id
:param target_tenant: target tenant of the policy
:return: RBACPolicy object
"""
body = {'rbac_policy': kwargs}
rbac_policy = neutronclient(r... | python | def rbac_policy_update(request, policy_id, **kwargs):
"""Update a RBAC Policy.
:param request: request context
:param policy_id: target policy id
:param target_tenant: target tenant of the policy
:return: RBACPolicy object
"""
body = {'rbac_policy': kwargs}
rbac_policy = neutronclient(r... | [
"def",
"rbac_policy_update",
"(",
"request",
",",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"{",
"'rbac_policy'",
":",
"kwargs",
"}",
"rbac_policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"update_rbac_policy",
"(",
"policy_id",
",... | Update a RBAC Policy.
:param request: request context
:param policy_id: target policy id
:param target_tenant: target tenant of the policy
:return: RBACPolicy object | [
"Update",
"a",
"RBAC",
"Policy",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2025-L2036 |
221,214 | openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_get | def rbac_policy_get(request, policy_id, **kwargs):
"""Get RBAC policy for a given policy id."""
policy = neutronclient(request).show_rbac_policy(
policy_id, **kwargs).get('rbac_policy')
return RBACPolicy(policy) | python | def rbac_policy_get(request, policy_id, **kwargs):
"""Get RBAC policy for a given policy id."""
policy = neutronclient(request).show_rbac_policy(
policy_id, **kwargs).get('rbac_policy')
return RBACPolicy(policy) | [
"def",
"rbac_policy_get",
"(",
"request",
",",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
":",
"policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"show_rbac_policy",
"(",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'rbac_policy'",
... | Get RBAC policy for a given policy id. | [
"Get",
"RBAC",
"policy",
"for",
"a",
"given",
"policy",
"id",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2040-L2044 |
221,215 | openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.list | def list(self, **params):
"""Fetches a list all security groups.
:returns: List of SecurityGroup objects
"""
# This is to ensure tenant_id key is not populated
# if tenant_id=None is specified.
tenant_id = params.pop('tenant_id', self.request.user.tenant_id)
if t... | python | def list(self, **params):
"""Fetches a list all security groups.
:returns: List of SecurityGroup objects
"""
# This is to ensure tenant_id key is not populated
# if tenant_id=None is specified.
tenant_id = params.pop('tenant_id', self.request.user.tenant_id)
if t... | [
"def",
"list",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"# This is to ensure tenant_id key is not populated",
"# if tenant_id=None is specified.",
"tenant_id",
"=",
"params",
".",
"pop",
"(",
"'tenant_id'",
",",
"self",
".",
"request",
".",
"user",
".",
"te... | Fetches a list all security groups.
:returns: List of SecurityGroup objects | [
"Fetches",
"a",
"list",
"all",
"security",
"groups",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L361-L371 |
221,216 | openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager._sg_name_dict | def _sg_name_dict(self, sg_id, rules):
"""Create a mapping dict from secgroup id to its name."""
related_ids = set([sg_id])
related_ids |= set(filter(None, [r['remote_group_id'] for r in rules]))
related_sgs = self.client.list_security_groups(id=related_ids,
... | python | def _sg_name_dict(self, sg_id, rules):
"""Create a mapping dict from secgroup id to its name."""
related_ids = set([sg_id])
related_ids |= set(filter(None, [r['remote_group_id'] for r in rules]))
related_sgs = self.client.list_security_groups(id=related_ids,
... | [
"def",
"_sg_name_dict",
"(",
"self",
",",
"sg_id",
",",
"rules",
")",
":",
"related_ids",
"=",
"set",
"(",
"[",
"sg_id",
"]",
")",
"related_ids",
"|=",
"set",
"(",
"filter",
"(",
"None",
",",
"[",
"r",
"[",
"'remote_group_id'",
"]",
"for",
"r",
"in",... | Create a mapping dict from secgroup id to its name. | [
"Create",
"a",
"mapping",
"dict",
"from",
"secgroup",
"id",
"to",
"its",
"name",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L373-L380 |
221,217 | openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.get | def get(self, sg_id):
"""Fetches the security group.
:returns: SecurityGroup object corresponding to sg_id
"""
secgroup = self.client.show_security_group(sg_id).get('security_group')
sg_dict = self._sg_name_dict(sg_id, secgroup['security_group_rules'])
return SecurityGro... | python | def get(self, sg_id):
"""Fetches the security group.
:returns: SecurityGroup object corresponding to sg_id
"""
secgroup = self.client.show_security_group(sg_id).get('security_group')
sg_dict = self._sg_name_dict(sg_id, secgroup['security_group_rules'])
return SecurityGro... | [
"def",
"get",
"(",
"self",
",",
"sg_id",
")",
":",
"secgroup",
"=",
"self",
".",
"client",
".",
"show_security_group",
"(",
"sg_id",
")",
".",
"get",
"(",
"'security_group'",
")",
"sg_dict",
"=",
"self",
".",
"_sg_name_dict",
"(",
"sg_id",
",",
"secgroup... | Fetches the security group.
:returns: SecurityGroup object corresponding to sg_id | [
"Fetches",
"the",
"security",
"group",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L383-L390 |
221,218 | openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.rule_create | def rule_create(self, parent_group_id,
direction=None, ethertype=None,
ip_protocol=None, from_port=None, to_port=None,
cidr=None, group_id=None, description=None):
"""Create a new security group rule.
:param parent_group_id: security group id ... | python | def rule_create(self, parent_group_id,
direction=None, ethertype=None,
ip_protocol=None, from_port=None, to_port=None,
cidr=None, group_id=None, description=None):
"""Create a new security group rule.
:param parent_group_id: security group id ... | [
"def",
"rule_create",
"(",
"self",
",",
"parent_group_id",
",",
"direction",
"=",
"None",
",",
"ethertype",
"=",
"None",
",",
"ip_protocol",
"=",
"None",
",",
"from_port",
"=",
"None",
",",
"to_port",
"=",
"None",
",",
"cidr",
"=",
"None",
",",
"group_id... | Create a new security group rule.
:param parent_group_id: security group id a rule is created to
:param direction: ``ingress`` or ``egress``
:param ethertype: ``IPv4`` or ``IPv6``
:param ip_protocol: tcp, udp, icmp
:param from_port: L4 port range min
:param to_port: L4 p... | [
"Create",
"a",
"new",
"security",
"group",
"rule",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L417-L463 |
221,219 | openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.list_by_instance | def list_by_instance(self, instance_id):
"""Gets security groups of an instance.
:returns: List of SecurityGroup objects associated with the instance
"""
ports = port_list(self.request, device_id=instance_id)
sg_ids = []
for p in ports:
sg_ids += p.security_g... | python | def list_by_instance(self, instance_id):
"""Gets security groups of an instance.
:returns: List of SecurityGroup objects associated with the instance
"""
ports = port_list(self.request, device_id=instance_id)
sg_ids = []
for p in ports:
sg_ids += p.security_g... | [
"def",
"list_by_instance",
"(",
"self",
",",
"instance_id",
")",
":",
"ports",
"=",
"port_list",
"(",
"self",
".",
"request",
",",
"device_id",
"=",
"instance_id",
")",
"sg_ids",
"=",
"[",
"]",
"for",
"p",
"in",
"ports",
":",
"sg_ids",
"+=",
"p",
".",
... | Gets security groups of an instance.
:returns: List of SecurityGroup objects associated with the instance | [
"Gets",
"security",
"groups",
"of",
"an",
"instance",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L471-L480 |
221,220 | openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.update_instance_security_group | def update_instance_security_group(self, instance_id,
new_security_group_ids):
"""Update security groups of a specified instance."""
ports = port_list(self.request, device_id=instance_id)
for p in ports:
params = {'security_groups': new_security... | python | def update_instance_security_group(self, instance_id,
new_security_group_ids):
"""Update security groups of a specified instance."""
ports = port_list(self.request, device_id=instance_id)
for p in ports:
params = {'security_groups': new_security... | [
"def",
"update_instance_security_group",
"(",
"self",
",",
"instance_id",
",",
"new_security_group_ids",
")",
":",
"ports",
"=",
"port_list",
"(",
"self",
".",
"request",
",",
"device_id",
"=",
"instance_id",
")",
"for",
"p",
"in",
"ports",
":",
"params",
"=",... | Update security groups of a specified instance. | [
"Update",
"security",
"groups",
"of",
"a",
"specified",
"instance",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L483-L489 |
221,221 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list_pools | def list_pools(self):
"""Fetches a list of all floating IP pools.
:returns: List of FloatingIpPool objects
"""
search_opts = {'router:external': True}
return [FloatingIpPool(pool) for pool
in self.client.list_networks(**search_opts).get('networks')] | python | def list_pools(self):
"""Fetches a list of all floating IP pools.
:returns: List of FloatingIpPool objects
"""
search_opts = {'router:external': True}
return [FloatingIpPool(pool) for pool
in self.client.list_networks(**search_opts).get('networks')] | [
"def",
"list_pools",
"(",
"self",
")",
":",
"search_opts",
"=",
"{",
"'router:external'",
":",
"True",
"}",
"return",
"[",
"FloatingIpPool",
"(",
"pool",
")",
"for",
"pool",
"in",
"self",
".",
"client",
".",
"list_networks",
"(",
"*",
"*",
"search_opts",
... | Fetches a list of all floating IP pools.
:returns: List of FloatingIpPool objects | [
"Fetches",
"a",
"list",
"of",
"all",
"floating",
"IP",
"pools",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L553-L560 |
221,222 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list | def list(self, all_tenants=False, **search_opts):
"""Fetches a list of all floating IPs.
:returns: List of FloatingIp object
"""
if not all_tenants:
tenant_id = self.request.user.tenant_id
# In Neutron, list_floatingips returns Floating IPs from
# all... | python | def list(self, all_tenants=False, **search_opts):
"""Fetches a list of all floating IPs.
:returns: List of FloatingIp object
"""
if not all_tenants:
tenant_id = self.request.user.tenant_id
# In Neutron, list_floatingips returns Floating IPs from
# all... | [
"def",
"list",
"(",
"self",
",",
"all_tenants",
"=",
"False",
",",
"*",
"*",
"search_opts",
")",
":",
"if",
"not",
"all_tenants",
":",
"tenant_id",
"=",
"self",
".",
"request",
".",
"user",
".",
"tenant_id",
"# In Neutron, list_floatingips returns Floating IPs f... | Fetches a list of all floating IPs.
:returns: List of FloatingIp object | [
"Fetches",
"a",
"list",
"of",
"all",
"floating",
"IPs",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L580-L602 |
221,223 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.get | def get(self, floating_ip_id):
"""Fetches the floating IP.
:returns: FloatingIp object corresponding to floating_ip_id
"""
fip = self.client.show_floatingip(floating_ip_id).get('floatingip')
self._set_instance_info(fip)
return FloatingIp(fip) | python | def get(self, floating_ip_id):
"""Fetches the floating IP.
:returns: FloatingIp object corresponding to floating_ip_id
"""
fip = self.client.show_floatingip(floating_ip_id).get('floatingip')
self._set_instance_info(fip)
return FloatingIp(fip) | [
"def",
"get",
"(",
"self",
",",
"floating_ip_id",
")",
":",
"fip",
"=",
"self",
".",
"client",
".",
"show_floatingip",
"(",
"floating_ip_id",
")",
".",
"get",
"(",
"'floatingip'",
")",
"self",
".",
"_set_instance_info",
"(",
"fip",
")",
"return",
"Floating... | Fetches the floating IP.
:returns: FloatingIp object corresponding to floating_ip_id | [
"Fetches",
"the",
"floating",
"IP",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L605-L612 |
221,224 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.allocate | def allocate(self, pool, tenant_id=None, **params):
"""Allocates a floating IP to the tenant.
You must provide a pool name or id for which you would like to
allocate a floating IP.
:returns: FloatingIp object corresponding to an allocated floating IP
"""
if not tenant_i... | python | def allocate(self, pool, tenant_id=None, **params):
"""Allocates a floating IP to the tenant.
You must provide a pool name or id for which you would like to
allocate a floating IP.
:returns: FloatingIp object corresponding to an allocated floating IP
"""
if not tenant_i... | [
"def",
"allocate",
"(",
"self",
",",
"pool",
",",
"tenant_id",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"if",
"not",
"tenant_id",
":",
"tenant_id",
"=",
"self",
".",
"request",
".",
"user",
".",
"project_id",
"create_dict",
"=",
"{",
"'floating_... | Allocates a floating IP to the tenant.
You must provide a pool name or id for which you would like to
allocate a floating IP.
:returns: FloatingIp object corresponding to an allocated floating IP | [
"Allocates",
"a",
"floating",
"IP",
"to",
"the",
"tenant",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L615-L640 |
221,225 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.associate | def associate(self, floating_ip_id, port_id):
"""Associates the floating IP to the port.
``port_id`` represents a VNIC of an instance.
``port_id`` argument is different from a normal neutron port ID.
A value passed as ``port_id`` must be one of target_id returned by
``list_targe... | python | def associate(self, floating_ip_id, port_id):
"""Associates the floating IP to the port.
``port_id`` represents a VNIC of an instance.
``port_id`` argument is different from a normal neutron port ID.
A value passed as ``port_id`` must be one of target_id returned by
``list_targe... | [
"def",
"associate",
"(",
"self",
",",
"floating_ip_id",
",",
"port_id",
")",
":",
"# NOTE: In Neutron Horizon floating IP support, port_id is",
"# \"<port_id>_<ip_address>\" format to identify multiple ports.",
"pid",
",",
"ip_address",
"=",
"port_id",
".",
"split",
"(",
"'_'... | Associates the floating IP to the port.
``port_id`` represents a VNIC of an instance.
``port_id`` argument is different from a normal neutron port ID.
A value passed as ``port_id`` must be one of target_id returned by
``list_targets``, ``get_target_by_instance`` or
``list_target... | [
"Associates",
"the",
"floating",
"IP",
"to",
"the",
"port",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L648-L663 |
221,226 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list_targets | def list_targets(self):
"""Returns a list of association targets of instance VIFs.
Each association target is represented as FloatingIpTarget object.
FloatingIpTarget is a APIResourceWrapper/APIDictWrapper and
'id' and 'name' attributes must be defined in each object.
FloatingIp... | python | def list_targets(self):
"""Returns a list of association targets of instance VIFs.
Each association target is represented as FloatingIpTarget object.
FloatingIpTarget is a APIResourceWrapper/APIDictWrapper and
'id' and 'name' attributes must be defined in each object.
FloatingIp... | [
"def",
"list_targets",
"(",
"self",
")",
":",
"tenant_id",
"=",
"self",
".",
"request",
".",
"user",
".",
"tenant_id",
"ports",
"=",
"port_list",
"(",
"self",
".",
"request",
",",
"tenant_id",
"=",
"tenant_id",
")",
"servers",
",",
"has_more",
"=",
"nova... | Returns a list of association targets of instance VIFs.
Each association target is represented as FloatingIpTarget object.
FloatingIpTarget is a APIResourceWrapper/APIDictWrapper and
'id' and 'name' attributes must be defined in each object.
FloatingIpTarget.id can be passed as port_id ... | [
"Returns",
"a",
"list",
"of",
"association",
"targets",
"of",
"instance",
"VIFs",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L700-L731 |
221,227 | openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list_targets_by_instance | def list_targets_by_instance(self, instance_id, target_list=None):
"""Returns a list of FloatingIpTarget objects of FIP association.
:param instance_id: ID of target VM instance
:param target_list: (optional) a list returned by list_targets().
If specified, looking up is done agains... | python | def list_targets_by_instance(self, instance_id, target_list=None):
"""Returns a list of FloatingIpTarget objects of FIP association.
:param instance_id: ID of target VM instance
:param target_list: (optional) a list returned by list_targets().
If specified, looking up is done agains... | [
"def",
"list_targets_by_instance",
"(",
"self",
",",
"instance_id",
",",
"target_list",
"=",
"None",
")",
":",
"if",
"target_list",
"is",
"not",
"None",
":",
"# We assume that target_list was returned by list_targets()",
"# so we can assume checks for subnet reachability and IP... | Returns a list of FloatingIpTarget objects of FIP association.
:param instance_id: ID of target VM instance
:param target_list: (optional) a list returned by list_targets().
If specified, looking up is done against the specified list
to save extra API calls to a back-end. Otherw... | [
"Returns",
"a",
"list",
"of",
"FloatingIpTarget",
"objects",
"of",
"FIP",
"association",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L740-L769 |
221,228 | openstack/horizon | horizon/decorators.py | require_perms | def require_perms(view_func, required):
"""Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_... | python | def require_perms(view_func, required):
"""Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_... | [
"def",
"require_perms",
"(",
"view_func",
",",
"required",
")",
":",
"from",
"horizon",
".",
"exceptions",
"import",
"NotAuthorized",
"# We only need to check each permission once for a view, so we'll use a set",
"current_perms",
"=",
"getattr",
"(",
"view_func",
",",
"'_re... | Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_perms
@require_perms(['foo.admin', 'f... | [
"Enforces",
"permission",
"-",
"based",
"access",
"controls",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/decorators.py#L57-L92 |
221,229 | openstack/horizon | horizon/decorators.py | require_component_access | def require_component_access(view_func, component):
"""Perform component can_access check to access the view.
:param component containing the view (panel or dashboard).
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
user cannot access the component containing the view.
By examp... | python | def require_component_access(view_func, component):
"""Perform component can_access check to access the view.
:param component containing the view (panel or dashboard).
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
user cannot access the component containing the view.
By examp... | [
"def",
"require_component_access",
"(",
"view_func",
",",
"component",
")",
":",
"from",
"horizon",
".",
"exceptions",
"import",
"NotAuthorized",
"@",
"functools",
".",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_func",
")",
")... | Perform component can_access check to access the view.
:param component containing the view (panel or dashboard).
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
user cannot access the component containing the view.
By example the check of component policy rules will be applied to i... | [
"Perform",
"component",
"can_access",
"check",
"to",
"access",
"the",
"view",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/decorators.py#L95-L115 |
221,230 | openstack/horizon | openstack_dashboard/api/glance.py | image_get | def image_get(request, image_id):
"""Returns an Image object populated with metadata for a given image."""
image = glanceclient(request).images.get(image_id)
return Image(image) | python | def image_get(request, image_id):
"""Returns an Image object populated with metadata for a given image."""
image = glanceclient(request).images.get(image_id)
return Image(image) | [
"def",
"image_get",
"(",
"request",
",",
"image_id",
")",
":",
"image",
"=",
"glanceclient",
"(",
"request",
")",
".",
"images",
".",
"get",
"(",
"image_id",
")",
"return",
"Image",
"(",
"image",
")"
] | Returns an Image object populated with metadata for a given image. | [
"Returns",
"an",
"Image",
"object",
"populated",
"with",
"metadata",
"for",
"a",
"given",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L263-L266 |
221,231 | openstack/horizon | openstack_dashboard/api/glance.py | image_list_detailed | def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs):
"""Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward ... | python | def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs):
"""Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward ... | [
"def",
"image_list_detailed",
"(",
"request",
",",
"marker",
"=",
"None",
",",
"sort_dir",
"=",
"'desc'",
",",
"sort_key",
"=",
"'created_at'",
",",
"filters",
"=",
"None",
",",
"paginate",
"=",
"False",
",",
"reversed_order",
"=",
"False",
",",
"*",
"*",
... | Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward on top of ascetic
OpenStack pagination API - which natively supports only iterating forward
through the entries. Thus in order to retrieve list of objects at previous
page, a request with the ... | [
"Thin",
"layer",
"above",
"glanceclient",
"for",
"handling",
"pagination",
"issues",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L283-L386 |
221,232 | openstack/horizon | openstack_dashboard/api/glance.py | create_image_metadata | def create_image_metadata(data):
"""Generate metadata dict for a new image from a given form data."""
# Default metadata
meta = {'protected': data.get('protected', False),
'disk_format': data.get('disk_format', 'raw'),
'container_format': data.get('container_format', 'bare'),
... | python | def create_image_metadata(data):
"""Generate metadata dict for a new image from a given form data."""
# Default metadata
meta = {'protected': data.get('protected', False),
'disk_format': data.get('disk_format', 'raw'),
'container_format': data.get('container_format', 'bare'),
... | [
"def",
"create_image_metadata",
"(",
"data",
")",
":",
"# Default metadata",
"meta",
"=",
"{",
"'protected'",
":",
"data",
".",
"get",
"(",
"'protected'",
",",
"False",
")",
",",
"'disk_format'",
":",
"data",
".",
"get",
"(",
"'disk_format'",
",",
"'raw'",
... | Generate metadata dict for a new image from a given form data. | [
"Generate",
"metadata",
"dict",
"for",
"a",
"new",
"image",
"from",
"a",
"given",
"form",
"data",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L451-L506 |
221,233 | openstack/horizon | openstack_dashboard/api/glance.py | image_create | def image_create(request, **kwargs):
"""Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image alr... | python | def image_create(request, **kwargs):
"""Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image alr... | [
"def",
"image_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"pop",
"(",
"'data'",
",",
"None",
")",
"location",
"=",
"None",
"if",
"VERSIONS",
".",
"active",
">=",
"2",
":",
"location",
"=",
"kwargs",
".",
... | Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image already resides.
In the case of 'copy_from... | [
"Create",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L521-L581 |
221,234 | openstack/horizon | openstack_dashboard/api/glance.py | image_update_properties | def image_update_properties(request, image_id, remove_props=None, **kwargs):
"""Add or update a custom property of an image."""
return glanceclient(request, '2').images.update(image_id,
remove_props,
**kwargs... | python | def image_update_properties(request, image_id, remove_props=None, **kwargs):
"""Add or update a custom property of an image."""
return glanceclient(request, '2').images.update(image_id,
remove_props,
**kwargs... | [
"def",
"image_update_properties",
"(",
"request",
",",
"image_id",
",",
"remove_props",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"glanceclient",
"(",
"request",
",",
"'2'",
")",
".",
"images",
".",
"update",
"(",
"image_id",
",",
"remove_p... | Add or update a custom property of an image. | [
"Add",
"or",
"update",
"a",
"custom",
"property",
"of",
"an",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L585-L589 |
221,235 | openstack/horizon | openstack_dashboard/api/glance.py | image_delete_properties | def image_delete_properties(request, image_id, keys):
"""Delete custom properties for an image."""
return glanceclient(request, '2').images.update(image_id, keys) | python | def image_delete_properties(request, image_id, keys):
"""Delete custom properties for an image."""
return glanceclient(request, '2').images.update(image_id, keys) | [
"def",
"image_delete_properties",
"(",
"request",
",",
"image_id",
",",
"keys",
")",
":",
"return",
"glanceclient",
"(",
"request",
",",
"'2'",
")",
".",
"images",
".",
"update",
"(",
"image_id",
",",
"keys",
")"
] | Delete custom properties for an image. | [
"Delete",
"custom",
"properties",
"for",
"an",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L593-L595 |
221,236 | openstack/horizon | openstack_dashboard/api/glance.py | filter_properties_target | def filter_properties_target(namespaces_iter,
resource_types,
properties_target):
"""Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:para... | python | def filter_properties_target(namespaces_iter,
resource_types,
properties_target):
"""Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:para... | [
"def",
"filter_properties_target",
"(",
"namespaces_iter",
",",
"resource_types",
",",
"properties_target",
")",
":",
"def",
"filter_namespace",
"(",
"namespace",
")",
":",
"for",
"asn",
"in",
"namespace",
".",
"get",
"(",
"'resource_type_associations'",
")",
":",
... | Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:param resource_types: List of resource type names.
:param properties_target: Name of the properties target. | [
"Filter",
"metadata",
"namespaces",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L634-L651 |
221,237 | openstack/horizon | openstack_dashboard/api/glance.py | metadefs_namespace_list | def metadefs_namespace_list(request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False):
"""Retrieve a listing of Namespaces
:param paginate:... | python | def metadefs_namespace_list(request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False):
"""Retrieve a listing of Namespaces
:param paginate:... | [
"def",
"metadefs_namespace_list",
"(",
"request",
",",
"filters",
"=",
"None",
",",
"sort_dir",
"=",
"'asc'",
",",
"sort_key",
"=",
"'namespace'",
",",
"marker",
"=",
"None",
",",
"paginate",
"=",
"False",
")",
":",
"# Listing namespaces requires the v2 API. If no... | Retrieve a listing of Namespaces
:param paginate: If true will perform pagination based on settings.
:param marker: Specifies the namespace of the last-seen namespace.
The typical pattern of limit and marker is to make an
initial limited request and then to use the last
n... | [
"Retrieve",
"a",
"listing",
"of",
"Namespaces"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L668-L751 |
221,238 | openstack/horizon | horizon/utils/file_discovery.py | discover_files | def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
"""Discovers all files with certain extension in given paths."""
file_list = []
for root, dirs, files in walk(path.join(base_path, sub_path)):
if trim_base_path:
root = path.relpath(root, base_path)
file_li... | python | def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
"""Discovers all files with certain extension in given paths."""
file_list = []
for root, dirs, files in walk(path.join(base_path, sub_path)):
if trim_base_path:
root = path.relpath(root, base_path)
file_li... | [
"def",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"''",
",",
"ext",
"=",
"''",
",",
"trim_base_path",
"=",
"False",
")",
":",
"file_list",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"walk",
"(",
"path",
".",
"join",... | Discovers all files with certain extension in given paths. | [
"Discovers",
"all",
"files",
"with",
"certain",
"extension",
"in",
"given",
"paths",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L25-L34 |
221,239 | openstack/horizon | horizon/utils/file_discovery.py | sort_js_files | def sort_js_files(js_files):
"""Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be... | python | def sort_js_files(js_files):
"""Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be... | [
"def",
"sort_js_files",
"(",
"js_files",
")",
":",
"modules",
"=",
"[",
"f",
"for",
"f",
"in",
"js_files",
"if",
"f",
".",
"endswith",
"(",
"MODULE_EXT",
")",
"]",
"mocks",
"=",
"[",
"f",
"for",
"f",
"in",
"js_files",
"if",
"f",
".",
"endswith",
"(... | Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be listed in the below order:
-... | [
"Sorts",
"JavaScript",
"files",
"in",
"js_files",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L37-L72 |
221,240 | openstack/horizon | horizon/utils/file_discovery.py | discover_static_files | def discover_static_files(base_path, sub_path=''):
"""Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists.
"""
js_files = discover_files(base_path, sub_path=sub_path,
ext='.js', trim_base_path=True... | python | def discover_static_files(base_path, sub_path=''):
"""Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists.
"""
js_files = discover_files(base_path, sub_path=sub_path,
ext='.js', trim_base_path=True... | [
"def",
"discover_static_files",
"(",
"base_path",
",",
"sub_path",
"=",
"''",
")",
":",
"js_files",
"=",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"sub_path",
",",
"ext",
"=",
"'.js'",
",",
"trim_base_path",
"=",
"True",
")",
"sources",
",",
... | Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists. | [
"Discovers",
"static",
"files",
"in",
"given",
"paths",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L75-L93 |
221,241 | openstack/horizon | horizon/utils/file_discovery.py | _log | def _log(file_list, list_name, in_path):
"""Logs result at debug level"""
file_names = '\n'.join(file_list)
LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n"
"%(files)s\n",
{'size': len(file_list), 'name': list_name, 'path': in_path,
'files': file_n... | python | def _log(file_list, list_name, in_path):
"""Logs result at debug level"""
file_names = '\n'.join(file_list)
LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n"
"%(files)s\n",
{'size': len(file_list), 'name': list_name, 'path': in_path,
'files': file_n... | [
"def",
"_log",
"(",
"file_list",
",",
"list_name",
",",
"in_path",
")",
":",
"file_names",
"=",
"'\\n'",
".",
"join",
"(",
"file_list",
")",
"LOG",
".",
"debug",
"(",
"\"\\nDiscovered %(size)d %(name)s file(s) in %(path)s:\\n\"",
"\"%(files)s\\n\"",
",",
"{",
"'si... | Logs result at debug level | [
"Logs",
"result",
"at",
"debug",
"level"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L110-L116 |
221,242 | openstack/horizon | horizon/browsers/base.py | ResourceBrowser.set_tables | def set_tables(self, tables):
"""Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView).
"""
self.navigation_table = tables[self.navigation_tabl... | python | def set_tables(self, tables):
"""Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView).
"""
self.navigation_table = tables[self.navigation_tabl... | [
"def",
"set_tables",
"(",
"self",
",",
"tables",
")",
":",
"self",
".",
"navigation_table",
"=",
"tables",
"[",
"self",
".",
"navigation_table_class",
".",
"_meta",
".",
"name",
"]",
"self",
".",
"content_table",
"=",
"tables",
"[",
"self",
".",
"content_t... | Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView). | [
"Sets",
"the",
"table",
"instances",
"on",
"the",
"browser",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/browsers/base.py#L121-L133 |
221,243 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_account_history | def get_account_history(self, account_id, **kwargs):
""" List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as ... | python | def get_account_history(self, account_id, **kwargs):
""" List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as ... | [
"def",
"get_account_history",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"'/accounts/{}/ledger'",
".",
"format",
"(",
"account_id",
")",
"return",
"self",
".",
"_send_paginated_message",
"(",
"endpoint",
",",
"params",
... | List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as a result of a trade
* fee: Fee as a result of a trade... | [
"List",
"account",
"activity",
".",
"Account",
"activity",
"either",
"increases",
"or",
"decreases",
"your",
"account",
"balance",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L91-L129 |
221,244 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_account_holds | def get_account_holds(self, account_id, **kwargs):
""" Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order ... | python | def get_account_holds(self, account_id, **kwargs):
""" Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order ... | [
"def",
"get_account_holds",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"'/accounts/{}/holds'",
".",
"format",
"(",
"account_id",
")",
"return",
"self",
".",
"_send_paginated_message",
"(",
"endpoint",
",",
"params",
"="... | Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order is filled, the hold amount is updated. If an order
is c... | [
"Get",
"holds",
"on",
"an",
"account",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L131-L174 |
221,245 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.buy | def buy(self, product_id, order_type, **kwargs):
"""Place a buy order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
p... | python | def buy(self, product_id, order_type, **kwargs):
"""Place a buy order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
p... | [
"def",
"buy",
"(",
"self",
",",
"product_id",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"place_order",
"(",
"product_id",
",",
"'buy'",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")"
] | Place a buy order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
place_market_order, and place_stop_order.
Args:
... | [
"Place",
"a",
"buy",
"order",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L258-L276 |
221,246 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.sell | def sell(self, product_id, order_type, **kwargs):
"""Place a sell order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
... | python | def sell(self, product_id, order_type, **kwargs):
"""Place a sell order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
... | [
"def",
"sell",
"(",
"self",
",",
"product_id",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"place_order",
"(",
"product_id",
",",
"'sell'",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")"
] | Place a sell order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
place_market_order, and place_stop_order.
Args:
... | [
"Place",
"a",
"sell",
"order",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L278-L296 |
221,247 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.place_market_order | def place_market_order(self, product_id, side, size=None, funds=None,
client_oid=None,
stp=None,
overdraft_enabled=None,
funding_amount=None):
""" Place market order.
Args:
product_id... | python | def place_market_order(self, product_id, side, size=None, funds=None,
client_oid=None,
stp=None,
overdraft_enabled=None,
funding_amount=None):
""" Place market order.
Args:
product_id... | [
"def",
"place_market_order",
"(",
"self",
",",
"product_id",
",",
"side",
",",
"size",
"=",
"None",
",",
"funds",
"=",
"None",
",",
"client_oid",
"=",
"None",
",",
"stp",
"=",
"None",
",",
"overdraft_enabled",
"=",
"None",
",",
"funding_amount",
"=",
"No... | Place market order.
Args:
product_id (str): Product to order (eg. 'BTC-USD')
side (str): Order side ('buy' or 'sell)
size (Optional[Decimal]): Desired amount in crypto. Specify this or
`funds`.
funds (Optional[Decimal]): Desired amount of quote cu... | [
"Place",
"market",
"order",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L354-L393 |
221,248 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.cancel_all | def cancel_all(self, product_id=None):
""" With best effort, cancel all open orders.
Args:
product_id (Optional[str]): Only cancel orders for this
product_id
Returns:
list: A list of ids of the canceled orders. Example::
[
... | python | def cancel_all(self, product_id=None):
""" With best effort, cancel all open orders.
Args:
product_id (Optional[str]): Only cancel orders for this
product_id
Returns:
list: A list of ids of the canceled orders. Example::
[
... | [
"def",
"cancel_all",
"(",
"self",
",",
"product_id",
"=",
"None",
")",
":",
"if",
"product_id",
"is",
"not",
"None",
":",
"params",
"=",
"{",
"'product_id'",
":",
"product_id",
"}",
"else",
":",
"params",
"=",
"None",
"return",
"self",
".",
"_send_messag... | With best effort, cancel all open orders.
Args:
product_id (Optional[str]): Only cancel orders for this
product_id
Returns:
list: A list of ids of the canceled orders. Example::
[
"144c6f8e-713f-4682-8435-5280fbe8b2b4",
... | [
"With",
"best",
"effort",
"cancel",
"all",
"open",
"orders",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L460-L482 |
221,249 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_orders | def get_orders(self, product_id=None, status=None, **kwargs):
""" List your current open orders.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Only open or un-settled orders are returned. As soon as an
order is no longer open ... | python | def get_orders(self, product_id=None, status=None, **kwargs):
""" List your current open orders.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Only open or un-settled orders are returned. As soon as an
order is no longer open ... | [
"def",
"get_orders",
"(",
"self",
",",
"product_id",
"=",
"None",
",",
"status",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"kwargs",
"if",
"product_id",
"is",
"not",
"None",
":",
"params",
"[",
"'product_id'",
"]",
"=",
"product_id... | List your current open orders.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Only open or un-settled orders are returned. As soon as an
order is no longer open and settled, it will no longer appear
in the default request.
... | [
"List",
"your",
"current",
"open",
"orders",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L519-L582 |
221,250 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_fundings | def get_fundings(self, status=None, **kwargs):
""" Every order placed with a margin profile that draws funding
will create a funding record.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
status (list/str): Li... | python | def get_fundings(self, status=None, **kwargs):
""" Every order placed with a margin profile that draws funding
will create a funding record.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
status (list/str): Li... | [
"def",
"get_fundings",
"(",
"self",
",",
"status",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"if",
"status",
"is",
"not",
"None",
":",
"params",
"[",
"'status'",
"]",
"=",
"status",
"params",
".",
"update",
"(",
"kwar... | Every order placed with a margin profile that draws funding
will create a funding record.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
status (list/str): Limit funding records to these statuses.
** O... | [
"Every",
"order",
"placed",
"with",
"a",
"margin",
"profile",
"that",
"draws",
"funding",
"will",
"create",
"a",
"funding",
"record",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L642-L679 |
221,251 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.repay_funding | def repay_funding(self, amount, currency):
""" Repay funding. Repays the older funding records first.
Args:
amount (int): Amount of currency to repay
currency (str): The currency, example USD
Returns:
Not specified by cbpro.
"""
params = {
... | python | def repay_funding(self, amount, currency):
""" Repay funding. Repays the older funding records first.
Args:
amount (int): Amount of currency to repay
currency (str): The currency, example USD
Returns:
Not specified by cbpro.
"""
params = {
... | [
"def",
"repay_funding",
"(",
"self",
",",
"amount",
",",
"currency",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
"# example: USD",
"}",
"return",
"self",
".",
"_send_message",
"(",
"'post'",
",",
"'/funding/re... | Repay funding. Repays the older funding records first.
Args:
amount (int): Amount of currency to repay
currency (str): The currency, example USD
Returns:
Not specified by cbpro. | [
"Repay",
"funding",
".",
"Repays",
"the",
"older",
"funding",
"records",
"first",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L681-L697 |
221,252 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.margin_transfer | def margin_transfer(self, margin_profile_id, transfer_type, currency,
amount):
""" Transfer funds between your standard profile and a margin profile.
Args:
margin_profile_id (str): Margin profile ID to withdraw or deposit
from.
transfer_ty... | python | def margin_transfer(self, margin_profile_id, transfer_type, currency,
amount):
""" Transfer funds between your standard profile and a margin profile.
Args:
margin_profile_id (str): Margin profile ID to withdraw or deposit
from.
transfer_ty... | [
"def",
"margin_transfer",
"(",
"self",
",",
"margin_profile_id",
",",
"transfer_type",
",",
"currency",
",",
"amount",
")",
":",
"params",
"=",
"{",
"'margin_profile_id'",
":",
"margin_profile_id",
",",
"'type'",
":",
"transfer_type",
",",
"'currency'",
":",
"cu... | Transfer funds between your standard profile and a margin profile.
Args:
margin_profile_id (str): Margin profile ID to withdraw or deposit
from.
transfer_type (str): 'deposit' or 'withdraw'
currency (str): Currency to transfer (eg. 'USD')
amount (... | [
"Transfer",
"funds",
"between",
"your",
"standard",
"profile",
"and",
"a",
"margin",
"profile",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L699-L734 |
221,253 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.close_position | def close_position(self, repay_only):
""" Close position.
Args:
repay_only (bool): Undocumented by cbpro.
Returns:
Undocumented
"""
params = {'repay_only': repay_only}
return self._send_message('post', '/position/close',
... | python | def close_position(self, repay_only):
""" Close position.
Args:
repay_only (bool): Undocumented by cbpro.
Returns:
Undocumented
"""
params = {'repay_only': repay_only}
return self._send_message('post', '/position/close',
... | [
"def",
"close_position",
"(",
"self",
",",
"repay_only",
")",
":",
"params",
"=",
"{",
"'repay_only'",
":",
"repay_only",
"}",
"return",
"self",
".",
"_send_message",
"(",
"'post'",
",",
"'/position/close'",
",",
"data",
"=",
"json",
".",
"dumps",
"(",
"pa... | Close position.
Args:
repay_only (bool): Undocumented by cbpro.
Returns:
Undocumented | [
"Close",
"position",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L745-L757 |
221,254 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.withdraw | def withdraw(self, amount, currency, payment_method_id):
""" Withdraw funds to a payment method.
See AuthenticatedClient.get_payment_methods() to receive
information regarding payment methods.
Args:
amount (Decimal): The amount to withdraw.
currency (str): Curre... | python | def withdraw(self, amount, currency, payment_method_id):
""" Withdraw funds to a payment method.
See AuthenticatedClient.get_payment_methods() to receive
information regarding payment methods.
Args:
amount (Decimal): The amount to withdraw.
currency (str): Curre... | [
"def",
"withdraw",
"(",
"self",
",",
"amount",
",",
"currency",
",",
"payment_method_id",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
",",
"'payment_method_id'",
":",
"payment_method_id",
"}",
"return",
"self",
... | Withdraw funds to a payment method.
See AuthenticatedClient.get_payment_methods() to receive
information regarding payment methods.
Args:
amount (Decimal): The amount to withdraw.
currency (str): Currency type (eg. 'BTC')
payment_method_id (str): ID of the p... | [
"Withdraw",
"funds",
"to",
"a",
"payment",
"method",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L816-L841 |
221,255 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.coinbase_withdraw | def coinbase_withdraw(self, amount, currency, coinbase_account_id):
""" Withdraw funds to a coinbase account.
You can move funds between your Coinbase accounts and your cbpro
trading accounts within your daily limits. Moving funds between
Coinbase and cbpro is instant and free.
... | python | def coinbase_withdraw(self, amount, currency, coinbase_account_id):
""" Withdraw funds to a coinbase account.
You can move funds between your Coinbase accounts and your cbpro
trading accounts within your daily limits. Moving funds between
Coinbase and cbpro is instant and free.
... | [
"def",
"coinbase_withdraw",
"(",
"self",
",",
"amount",
",",
"currency",
",",
"coinbase_account_id",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
",",
"'coinbase_account_id'",
":",
"coinbase_account_id",
"}",
"retu... | Withdraw funds to a coinbase account.
You can move funds between your Coinbase accounts and your cbpro
trading accounts within your daily limits. Moving funds between
Coinbase and cbpro is instant and free.
See AuthenticatedClient.get_coinbase_accounts() to receive
information ... | [
"Withdraw",
"funds",
"to",
"a",
"coinbase",
"account",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L843-L871 |
221,256 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.crypto_withdraw | def crypto_withdraw(self, amount, currency, crypto_address):
""" Withdraw funds to a crypto address.
Args:
amount (Decimal): The amount to withdraw
currency (str): The type of currency (eg. 'BTC')
crypto_address (str): Crypto address to withdraw to.
Returns:... | python | def crypto_withdraw(self, amount, currency, crypto_address):
""" Withdraw funds to a crypto address.
Args:
amount (Decimal): The amount to withdraw
currency (str): The type of currency (eg. 'BTC')
crypto_address (str): Crypto address to withdraw to.
Returns:... | [
"def",
"crypto_withdraw",
"(",
"self",
",",
"amount",
",",
"currency",
",",
"crypto_address",
")",
":",
"params",
"=",
"{",
"'amount'",
":",
"amount",
",",
"'currency'",
":",
"currency",
",",
"'crypto_address'",
":",
"crypto_address",
"}",
"return",
"self",
... | Withdraw funds to a crypto address.
Args:
amount (Decimal): The amount to withdraw
currency (str): The type of currency (eg. 'BTC')
crypto_address (str): Crypto address to withdraw to.
Returns:
dict: Withdraw details. Example::
{
... | [
"Withdraw",
"funds",
"to",
"a",
"crypto",
"address",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L873-L894 |
221,257 | danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.create_report | def create_report(self, report_type, start_date, end_date, product_id=None,
account_id=None, report_format='pdf', email=None):
""" Create report of historic information about your account.
The report will be generated when resources are available. Report status
can be quer... | python | def create_report(self, report_type, start_date, end_date, product_id=None,
account_id=None, report_format='pdf', email=None):
""" Create report of historic information about your account.
The report will be generated when resources are available. Report status
can be quer... | [
"def",
"create_report",
"(",
"self",
",",
"report_type",
",",
"start_date",
",",
"end_date",
",",
"product_id",
"=",
"None",
",",
"account_id",
"=",
"None",
",",
"report_format",
"=",
"'pdf'",
",",
"email",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'ty... | Create report of historic information about your account.
The report will be generated when resources are available. Report status
can be queried via `get_report(report_id)`.
Args:
report_type (str): 'fills' or 'account'
start_date (str): Starting date for the report in... | [
"Create",
"report",
"of",
"historic",
"information",
"about",
"your",
"account",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L914-L961 |
221,258 | danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient.get_product_order_book | def get_product_order_book(self, product_id, level=1):
"""Get a list of open orders for a product.
The amount of detail shown can be customized with the `level`
parameter:
* 1: Only the best bid and ask
* 2: Top 50 bids and asks (aggregated)
* 3: Full order book (non agg... | python | def get_product_order_book(self, product_id, level=1):
"""Get a list of open orders for a product.
The amount of detail shown can be customized with the `level`
parameter:
* 1: Only the best bid and ask
* 2: Top 50 bids and asks (aggregated)
* 3: Full order book (non agg... | [
"def",
"get_product_order_book",
"(",
"self",
",",
"product_id",
",",
"level",
"=",
"1",
")",
":",
"params",
"=",
"{",
"'level'",
":",
"level",
"}",
"return",
"self",
".",
"_send_message",
"(",
"'get'",
",",
"'/products/{}/book'",
".",
"format",
"(",
"prod... | Get a list of open orders for a product.
The amount of detail shown can be customized with the `level`
parameter:
* 1: Only the best bid and ask
* 2: Top 50 bids and asks (aggregated)
* 3: Full order book (non aggregated)
Level 1 and Level 2 are recommended for polling.... | [
"Get",
"a",
"list",
"of",
"open",
"orders",
"for",
"a",
"product",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L52-L90 |
221,259 | danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient.get_product_trades | def get_product_trades(self, product_id, before='', after='', limit=None, result=None):
"""List the latest trades for a product.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
product_id (str): Product
b... | python | def get_product_trades(self, product_id, before='', after='', limit=None, result=None):
"""List the latest trades for a product.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
product_id (str): Product
b... | [
"def",
"get_product_trades",
"(",
"self",
",",
"product_id",
",",
"before",
"=",
"''",
",",
"after",
"=",
"''",
",",
"limit",
"=",
"None",
",",
"result",
"=",
"None",
")",
":",
"return",
"self",
".",
"_send_paginated_message",
"(",
"'/products/{}/trades'",
... | List the latest trades for a product.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Args:
product_id (str): Product
before (Optional[str]): start time in ISO 8601
after (Optional[str]): end time in ISO 8... | [
"List",
"the",
"latest",
"trades",
"for",
"a",
"product",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L117-L147 |
221,260 | danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient.get_product_historic_rates | def get_product_historic_rates(self, product_id, start=None, end=None,
granularity=None):
"""Historic rates for a product.
Rates are returned in grouped buckets based on requested
`granularity`. If start, end, and granularity aren't provided,
the excha... | python | def get_product_historic_rates(self, product_id, start=None, end=None,
granularity=None):
"""Historic rates for a product.
Rates are returned in grouped buckets based on requested
`granularity`. If start, end, and granularity aren't provided,
the excha... | [
"def",
"get_product_historic_rates",
"(",
"self",
",",
"product_id",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"granularity",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"start",
"is",
"not",
"None",
":",
"params",
"[",
"'start... | Historic rates for a product.
Rates are returned in grouped buckets based on requested
`granularity`. If start, end, and granularity aren't provided,
the exchange will assume some (currently unknown) default values.
Historical rate data may be incomplete. No data is published for
... | [
"Historic",
"rates",
"for",
"a",
"product",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L149-L200 |
221,261 | danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient._send_message | def _send_message(self, method, endpoint, params=None, data=None):
"""Send API request.
Args:
method (str): HTTP method (get, post, delete, etc.)
endpoint (str): Endpoint (to be added to base URL)
params (Optional[dict]): HTTP request parameters
data (Opt... | python | def _send_message(self, method, endpoint, params=None, data=None):
"""Send API request.
Args:
method (str): HTTP method (get, post, delete, etc.)
endpoint (str): Endpoint (to be added to base URL)
params (Optional[dict]): HTTP request parameters
data (Opt... | [
"def",
"_send_message",
"(",
"self",
",",
"method",
",",
"endpoint",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"url",
"+",
"endpoint",
"r",
"=",
"self",
".",
"session",
".",
"request",
"(",
"method",
"... | Send API request.
Args:
method (str): HTTP method (get, post, delete, etc.)
endpoint (str): Endpoint (to be added to base URL)
params (Optional[dict]): HTTP request parameters
data (Optional[str]): JSON-encoded string payload for POST
Returns:
... | [
"Send",
"API",
"request",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L254-L270 |
221,262 | danpaquin/coinbasepro-python | cbpro/public_client.py | PublicClient._send_paginated_message | def _send_paginated_message(self, endpoint, params=None):
""" Send API message that results in a paginated response.
The paginated responses are abstracted away by making API requests on
demand as the response is iterated over.
Paginated API messages support 3 additional parameters: `b... | python | def _send_paginated_message(self, endpoint, params=None):
""" Send API message that results in a paginated response.
The paginated responses are abstracted away by making API requests on
demand as the response is iterated over.
Paginated API messages support 3 additional parameters: `b... | [
"def",
"_send_paginated_message",
"(",
"self",
",",
"endpoint",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"dict",
"(",
")",
"url",
"=",
"self",
".",
"url",
"+",
"endpoint",
"while",
"True",
":",
"r",
"=",... | Send API message that results in a paginated response.
The paginated responses are abstracted away by making API requests on
demand as the response is iterated over.
Paginated API messages support 3 additional parameters: `before`,
`after`, and `limit`. `before` and `after` are mutuall... | [
"Send",
"API",
"message",
"that",
"results",
"in",
"a",
"paginated",
"response",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/public_client.py#L272-L311 |
221,263 | dask/dask-ml | dask_ml/model_selection/_search.py | check_cv | def check_cv(cv=3, y=None, classifier=False):
"""Dask aware version of ``sklearn.model_selection.check_cv``
Same as the scikit-learn version, but works if ``y`` is a dask object.
"""
if cv is None:
cv = 3
# If ``cv`` is not an integer, the scikit-learn implementation doesn't
# touch th... | python | def check_cv(cv=3, y=None, classifier=False):
"""Dask aware version of ``sklearn.model_selection.check_cv``
Same as the scikit-learn version, but works if ``y`` is a dask object.
"""
if cv is None:
cv = 3
# If ``cv`` is not an integer, the scikit-learn implementation doesn't
# touch th... | [
"def",
"check_cv",
"(",
"cv",
"=",
"3",
",",
"y",
"=",
"None",
",",
"classifier",
"=",
"False",
")",
":",
"if",
"cv",
"is",
"None",
":",
"cv",
"=",
"3",
"# If ``cv`` is not an integer, the scikit-learn implementation doesn't",
"# touch the ``y`` object, so passing o... | Dask aware version of ``sklearn.model_selection.check_cv``
Same as the scikit-learn version, but works if ``y`` is a dask object. | [
"Dask",
"aware",
"version",
"of",
"sklearn",
".",
"model_selection",
".",
"check_cv"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L900-L918 |
221,264 | dask/dask-ml | dask_ml/model_selection/_search.py | compute_n_splits | def compute_n_splits(cv, X, y=None, groups=None):
"""Return the number of splits.
Parameters
----------
cv : BaseCrossValidator
X, y, groups : array_like, dask object, or None
Returns
-------
n_splits : int
"""
if not any(is_dask_collection(i) for i in (X, y, groups)):
... | python | def compute_n_splits(cv, X, y=None, groups=None):
"""Return the number of splits.
Parameters
----------
cv : BaseCrossValidator
X, y, groups : array_like, dask object, or None
Returns
-------
n_splits : int
"""
if not any(is_dask_collection(i) for i in (X, y, groups)):
... | [
"def",
"compute_n_splits",
"(",
"cv",
",",
"X",
",",
"y",
"=",
"None",
",",
"groups",
"=",
"None",
")",
":",
"if",
"not",
"any",
"(",
"is_dask_collection",
"(",
"i",
")",
"for",
"i",
"in",
"(",
"X",
",",
"y",
",",
"groups",
")",
")",
":",
"retu... | Return the number of splits.
Parameters
----------
cv : BaseCrossValidator
X, y, groups : array_like, dask object, or None
Returns
-------
n_splits : int | [
"Return",
"the",
"number",
"of",
"splits",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L921-L956 |
221,265 | dask/dask-ml | dask_ml/model_selection/_search.py | StaticDaskSearchMixin.visualize | def visualize(self, filename="mydask", format=None, **kwargs):
"""Render the task graph for this parameter search using ``graphviz``.
Requires ``graphviz`` to be installed.
Parameters
----------
filename : str or None, optional
The name (without an extension) of the... | python | def visualize(self, filename="mydask", format=None, **kwargs):
"""Render the task graph for this parameter search using ``graphviz``.
Requires ``graphviz`` to be installed.
Parameters
----------
filename : str or None, optional
The name (without an extension) of the... | [
"def",
"visualize",
"(",
"self",
",",
"filename",
"=",
"\"mydask\"",
",",
"format",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"dask_graph_\"",
")",
"return",
"dask",
".",
"visualize",
"(",
"self",
".",
"dask_g... | Render the task graph for this parameter search using ``graphviz``.
Requires ``graphviz`` to be installed.
Parameters
----------
filename : str or None, optional
The name (without an extension) of the file to write to disk. If
`filename` is None, no file will b... | [
"Render",
"the",
"task",
"graph",
"for",
"this",
"parameter",
"search",
"using",
"graphviz",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L975-L1000 |
221,266 | dask/dask-ml | dask_ml/model_selection/_search.py | DaskBaseSearchCV.fit | def fit(self, X, y=None, groups=None, **fit_params):
"""Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
... | python | def fit(self, X, y=None, groups=None, **fit_params):
"""Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"groups",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"estimator",
"=",
"self",
".",
"estimator",
"from",
"sklearn",
".",
"metrics",
".",
"scorer",
"import",
"_check_multimetric_s... | Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array-like, shape = [n_samples] or [n_samples, n_out... | [
"Run",
"fit",
"with",
"all",
"sets",
"of",
"parameters",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L1117-L1212 |
221,267 | dask/dask-ml | dask_ml/model_selection/_search.py | RandomizedSearchCV._get_param_iterator | def _get_param_iterator(self):
"""Return ParameterSampler instance for the given distributions"""
return model_selection.ParameterSampler(
self.param_distributions, self.n_iter, random_state=self.random_state
) | python | def _get_param_iterator(self):
"""Return ParameterSampler instance for the given distributions"""
return model_selection.ParameterSampler(
self.param_distributions, self.n_iter, random_state=self.random_state
) | [
"def",
"_get_param_iterator",
"(",
"self",
")",
":",
"return",
"model_selection",
".",
"ParameterSampler",
"(",
"self",
".",
"param_distributions",
",",
"self",
".",
"n_iter",
",",
"random_state",
"=",
"self",
".",
"random_state",
")"
] | Return ParameterSampler instance for the given distributions | [
"Return",
"ParameterSampler",
"instance",
"for",
"the",
"given",
"distributions"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_search.py#L1605-L1609 |
221,268 | dask/dask-ml | dask_ml/model_selection/_incremental.py | _partial_fit | def _partial_fit(model_and_meta, X, y, fit_params):
"""
Call partial_fit on a classifiers with training data X and y
Arguments
---------
model_and_meta : Tuple[Estimator, dict]
X, y : np.ndarray, np.ndarray
Training data
fit_params : dict
Extra keyword arguments to pass to p... | python | def _partial_fit(model_and_meta, X, y, fit_params):
"""
Call partial_fit on a classifiers with training data X and y
Arguments
---------
model_and_meta : Tuple[Estimator, dict]
X, y : np.ndarray, np.ndarray
Training data
fit_params : dict
Extra keyword arguments to pass to p... | [
"def",
"_partial_fit",
"(",
"model_and_meta",
",",
"X",
",",
"y",
",",
"fit_params",
")",
":",
"with",
"log_errors",
"(",
")",
":",
"start",
"=",
"time",
"(",
")",
"model",
",",
"meta",
"=",
"model_and_meta",
"if",
"len",
"(",
"X",
")",
":",
"model",... | Call partial_fit on a classifiers with training data X and y
Arguments
---------
model_and_meta : Tuple[Estimator, dict]
X, y : np.ndarray, np.ndarray
Training data
fit_params : dict
Extra keyword arguments to pass to partial_fit
Returns
-------
Results
A namedt... | [
"Call",
"partial_fit",
"on",
"a",
"classifiers",
"with",
"training",
"data",
"X",
"and",
"y"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L30-L86 |
221,269 | dask/dask-ml | dask_ml/model_selection/_incremental.py | _create_model | def _create_model(model, ident, **params):
""" Create a model by cloning and then setting params """
with log_errors(pdb=True):
model = clone(model).set_params(**params)
return model, {"model_id": ident, "params": params, "partial_fit_calls": 0} | python | def _create_model(model, ident, **params):
""" Create a model by cloning and then setting params """
with log_errors(pdb=True):
model = clone(model).set_params(**params)
return model, {"model_id": ident, "params": params, "partial_fit_calls": 0} | [
"def",
"_create_model",
"(",
"model",
",",
"ident",
",",
"*",
"*",
"params",
")",
":",
"with",
"log_errors",
"(",
"pdb",
"=",
"True",
")",
":",
"model",
"=",
"clone",
"(",
"model",
")",
".",
"set_params",
"(",
"*",
"*",
"params",
")",
"return",
"mo... | Create a model by cloning and then setting params | [
"Create",
"a",
"model",
"by",
"cloning",
"and",
"then",
"setting",
"params"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L102-L106 |
221,270 | dask/dask-ml | dask_ml/model_selection/_incremental.py | fit | def fit(
model,
params,
X_train,
y_train,
X_test,
y_test,
additional_calls,
fit_params=None,
scorer=None,
random_state=None,
):
""" Find a good model and search among a space of hyper-parameters
This does a hyper-parameter search by creating many models and then fitting
... | python | def fit(
model,
params,
X_train,
y_train,
X_test,
y_test,
additional_calls,
fit_params=None,
scorer=None,
random_state=None,
):
""" Find a good model and search among a space of hyper-parameters
This does a hyper-parameter search by creating many models and then fitting
... | [
"def",
"fit",
"(",
"model",
",",
"params",
",",
"X_train",
",",
"y_train",
",",
"X_test",
",",
"y_test",
",",
"additional_calls",
",",
"fit_params",
"=",
"None",
",",
"scorer",
"=",
"None",
",",
"random_state",
"=",
"None",
",",
")",
":",
"return",
"de... | Find a good model and search among a space of hyper-parameters
This does a hyper-parameter search by creating many models and then fitting
them incrementally on batches of data and reducing the number of models based
on the scores computed during training. Over time fewer and fewer models
remain. We ... | [
"Find",
"a",
"good",
"model",
"and",
"search",
"among",
"a",
"space",
"of",
"hyper",
"-",
"parameters"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L273-L402 |
221,271 | dask/dask-ml | dask_ml/model_selection/_incremental.py | BaseIncrementalSearchCV._check_array | def _check_array(self, X, **kwargs):
"""Validate the data arguments X and y.
By default, NumPy arrays are converted to 1-block dask arrays.
Parameters
----------
X, y : array-like
"""
if isinstance(X, np.ndarray):
X = da.from_array(X, X.shape)
... | python | def _check_array(self, X, **kwargs):
"""Validate the data arguments X and y.
By default, NumPy arrays are converted to 1-block dask arrays.
Parameters
----------
X, y : array-like
"""
if isinstance(X, np.ndarray):
X = da.from_array(X, X.shape)
... | [
"def",
"_check_array",
"(",
"self",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"X",
"=",
"da",
".",
"from_array",
"(",
"X",
",",
"X",
".",
"shape",
")",
"X",
"=",
"check_array... | Validate the data arguments X and y.
By default, NumPy arrays are converted to 1-block dask arrays.
Parameters
----------
X, y : array-like | [
"Validate",
"the",
"data",
"arguments",
"X",
"and",
"y",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L432-L444 |
221,272 | dask/dask-ml | dask_ml/model_selection/_incremental.py | BaseIncrementalSearchCV.fit | def fit(self, X, y, **fit_params):
"""Find the best parameters for a particular model.
Parameters
----------
X, y : array-like
**fit_params
Additional partial fit keyword arguments for the estimator.
"""
return default_client().sync(self._fit, X, y, *... | python | def fit(self, X, y, **fit_params):
"""Find the best parameters for a particular model.
Parameters
----------
X, y : array-like
**fit_params
Additional partial fit keyword arguments for the estimator.
"""
return default_client().sync(self._fit, X, y, *... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"*",
"*",
"fit_params",
")",
":",
"return",
"default_client",
"(",
")",
".",
"sync",
"(",
"self",
".",
"_fit",
",",
"X",
",",
"y",
",",
"*",
"*",
"fit_params",
")"
] | Find the best parameters for a particular model.
Parameters
----------
X, y : array-like
**fit_params
Additional partial fit keyword arguments for the estimator. | [
"Find",
"the",
"best",
"parameters",
"for",
"a",
"particular",
"model",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_incremental.py#L569-L578 |
221,273 | dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit._check_array | def _check_array(self, X):
"""Validate an array for post-fit tasks.
Parameters
----------
X : Union[Array, DataFrame]
Returns
-------
same type as 'X'
Notes
-----
The following checks are applied.
- Ensure that the array is bloc... | python | def _check_array(self, X):
"""Validate an array for post-fit tasks.
Parameters
----------
X : Union[Array, DataFrame]
Returns
-------
same type as 'X'
Notes
-----
The following checks are applied.
- Ensure that the array is bloc... | [
"def",
"_check_array",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"da",
".",
"Array",
")",
":",
"if",
"X",
".",
"ndim",
"==",
"2",
"and",
"X",
".",
"numblocks",
"[",
"1",
"]",
">",
"1",
":",
"logger",
".",
"debug",
"(... | Validate an array for post-fit tasks.
Parameters
----------
X : Union[Array, DataFrame]
Returns
-------
same type as 'X'
Notes
-----
The following checks are applied.
- Ensure that the array is blocked only along the samples. | [
"Validate",
"an",
"array",
"for",
"post",
"-",
"fit",
"tasks",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L122-L146 |
221,274 | dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.transform | def transform(self, X):
"""Transform block or partition-wise for dask inputs.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does no... | python | def transform(self, X):
"""Transform block or partition-wise for dask inputs.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does no... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_check_method",
"(",
"\"transform\"",
")",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"isinstance",
"(",
"X",
",",
"da",
".",
"Array",
")",
":",
"return",
"X",
".",... | Transform block or partition-wise for dask inputs.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``transform`` method, then... | [
"Transform",
"block",
"or",
"partition",
"-",
"wise",
"for",
"dask",
"inputs",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L185-L211 |
221,275 | dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.score | def score(self, X, y, compute=True):
"""Returns the score on the given data.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input data, where n_samples is the number of samples and
n_features is the number of features.
y : array-li... | python | def score(self, X, y, compute=True):
"""Returns the score on the given data.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input data, where n_samples is the number of samples and
n_features is the number of features.
y : array-li... | [
"def",
"score",
"(",
"self",
",",
"X",
",",
"y",
",",
"compute",
"=",
"True",
")",
":",
"scoring",
"=",
"self",
".",
"scoring",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"y",
"=",
"self",
".",
"_check_array",
"(",
"y",
")",
"if",
"n... | Returns the score on the given data.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input data, where n_samples is the number of samples and
n_features is the number of features.
y : array-like, shape = [n_samples] or [n_samples, n_output]... | [
"Returns",
"the",
"score",
"on",
"the",
"given",
"data",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L213-L253 |
221,276 | dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.predict | def predict(self, X):
"""Predict for X.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
Parameters
----------
X : array-like
Returns
... | python | def predict(self, X):
"""Predict for X.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
Parameters
----------
X : array-like
Returns
... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_check_method",
"(",
"\"predict\"",
")",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"isinstance",
"(",
"X",
",",
"da",
".",
"Array",
")",
":",
"result",
"=",
"X",
"... | Predict for X.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
Parameters
----------
X : array-like
Returns
-------
y : array-li... | [
"Predict",
"for",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L255-L285 |
221,277 | dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit.predict_log_proba | def predict_log_proba(self, X):
"""Log of proability estimates.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``pre... | python | def predict_log_proba(self, X):
"""Log of proability estimates.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``pre... | [
"def",
"predict_log_proba",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_check_method",
"(",
"\"predict_log_proba\"",
")",
"return",
"da",
".",
"log",
"(",
"self",
".",
"predict_proba",
"(",
"X",
")",
")"
] | Log of proability estimates.
For dask inputs, a dask array or dataframe is returned. For other
inputs (NumPy array, pandas dataframe, scipy sparse matrix), the
regular return value is returned.
If the underlying estimator does not have a ``predict_proba``
method, then an ``Attr... | [
"Log",
"of",
"proability",
"estimates",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L322-L341 |
221,278 | dask/dask-ml | dask_ml/wrappers.py | ParallelPostFit._check_method | def _check_method(self, method):
"""Check if self.estimator has 'method'.
Raises
------
AttributeError
"""
estimator = self._postfit_estimator
if not hasattr(estimator, method):
msg = "The wrapped estimator '{}' does not have a '{}' method.".format(
... | python | def _check_method(self, method):
"""Check if self.estimator has 'method'.
Raises
------
AttributeError
"""
estimator = self._postfit_estimator
if not hasattr(estimator, method):
msg = "The wrapped estimator '{}' does not have a '{}' method.".format(
... | [
"def",
"_check_method",
"(",
"self",
",",
"method",
")",
":",
"estimator",
"=",
"self",
".",
"_postfit_estimator",
"if",
"not",
"hasattr",
"(",
"estimator",
",",
"method",
")",
":",
"msg",
"=",
"\"The wrapped estimator '{}' does not have a '{}' method.\"",
".",
"f... | Check if self.estimator has 'method'.
Raises
------
AttributeError | [
"Check",
"if",
"self",
".",
"estimator",
"has",
"method",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L343-L356 |
221,279 | dask/dask-ml | dask_ml/linear_model/glm.py | _GLM.fit | def fit(self, X, y=None):
"""Fit the model on the training data
Parameters
----------
X: array-like, shape (n_samples, n_features)
y : array-like, shape (n_samples,)
Returns
-------
self : objectj
"""
X = self._check_array(X)
sol... | python | def fit(self, X, y=None):
"""Fit the model on the training data
Parameters
----------
X: array-like, shape (n_samples, n_features)
y : array-like, shape (n_samples,)
Returns
-------
self : objectj
"""
X = self._check_array(X)
sol... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"solver_kwargs",
"=",
"self",
".",
"_get_solver_kwargs",
"(",
")",
"self",
".",
"_coef",
"=",
"algorithms",
".",
"_solvers",
... | Fit the model on the training data
Parameters
----------
X: array-like, shape (n_samples, n_features)
y : array-like, shape (n_samples,)
Returns
-------
self : objectj | [
"Fit",
"the",
"model",
"on",
"the",
"training",
"data"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/linear_model/glm.py#L171-L193 |
221,280 | dask/dask-ml | dask_ml/linear_model/glm.py | LogisticRegression.predict_proba | def predict_proba(self, X):
"""Probability estimates for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
The probability of the sample for each class i... | python | def predict_proba(self, X):
"""Probability estimates for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
The probability of the sample for each class i... | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
")",
":",
"X_",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"return",
"sigmoid",
"(",
"dot",
"(",
"X_",
",",
"self",
".",
"_coef",
")",
")"
] | Probability estimates for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
The probability of the sample for each class in the model. | [
"Probability",
"estimates",
"for",
"samples",
"in",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/linear_model/glm.py#L235-L248 |
221,281 | dask/dask-ml | dask_ml/linear_model/glm.py | PoissonRegression.predict | def predict(self, X):
"""Predict count for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
C : array, shape = [n_samples,]
Predicted count for each sample
"""
X_ = self._check_array(... | python | def predict(self, X):
"""Predict count for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
C : array, shape = [n_samples,]
Predicted count for each sample
"""
X_ = self._check_array(... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"X_",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"return",
"exp",
"(",
"dot",
"(",
"X_",
",",
"self",
".",
"_coef",
")",
")"
] | Predict count for samples in X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
C : array, shape = [n_samples,]
Predicted count for each sample | [
"Predict",
"count",
"for",
"samples",
"in",
"X",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/linear_model/glm.py#L348-L361 |
221,282 | dask/dask-ml | dask_ml/cluster/k_means.py | k_means | def k_means(
X,
n_clusters,
init="k-means||",
precompute_distances="auto",
n_init=1,
max_iter=300,
verbose=False,
tol=1e-4,
random_state=None,
copy_x=True,
n_jobs=-1,
algorithm="full",
return_n_iter=False,
oversampling_factor=2,
init_max_iter=None,
):
"""K... | python | def k_means(
X,
n_clusters,
init="k-means||",
precompute_distances="auto",
n_init=1,
max_iter=300,
verbose=False,
tol=1e-4,
random_state=None,
copy_x=True,
n_jobs=-1,
algorithm="full",
return_n_iter=False,
oversampling_factor=2,
init_max_iter=None,
):
"""K... | [
"def",
"k_means",
"(",
"X",
",",
"n_clusters",
",",
"init",
"=",
"\"k-means||\"",
",",
"precompute_distances",
"=",
"\"auto\"",
",",
"n_init",
"=",
"1",
",",
"max_iter",
"=",
"300",
",",
"verbose",
"=",
"False",
",",
"tol",
"=",
"1e-4",
",",
"random_stat... | K-means algorithm for clustering
Differences from scikit-learn:
* init='k-means||'
* oversampling_factor keyword
* n_jobs=-1 | [
"K",
"-",
"means",
"algorithm",
"for",
"clustering"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L236-L275 |
221,283 | dask/dask-ml | dask_ml/cluster/k_means.py | k_init | def k_init(
X,
n_clusters,
init="k-means||",
random_state=None,
max_iter=None,
oversampling_factor=2,
):
"""Choose the initial centers for K-Means.
Parameters
----------
X : da.Array (n_samples, n_features)
n_clusters : int
Number of clusters to end up with
init ... | python | def k_init(
X,
n_clusters,
init="k-means||",
random_state=None,
max_iter=None,
oversampling_factor=2,
):
"""Choose the initial centers for K-Means.
Parameters
----------
X : da.Array (n_samples, n_features)
n_clusters : int
Number of clusters to end up with
init ... | [
"def",
"k_init",
"(",
"X",
",",
"n_clusters",
",",
"init",
"=",
"\"k-means||\"",
",",
"random_state",
"=",
"None",
",",
"max_iter",
"=",
"None",
",",
"oversampling_factor",
"=",
"2",
",",
")",
":",
"if",
"isinstance",
"(",
"init",
",",
"np",
".",
"ndar... | Choose the initial centers for K-Means.
Parameters
----------
X : da.Array (n_samples, n_features)
n_clusters : int
Number of clusters to end up with
init : {'k-means||', 'k-means++', 'random'} or numpy.ndarray
Initialization method, or pass a NumPy array to use
random_state : i... | [
"Choose",
"the",
"initial",
"centers",
"for",
"K",
"-",
"Means",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L291-L369 |
221,284 | dask/dask-ml | dask_ml/cluster/k_means.py | init_pp | def init_pp(X, n_clusters, random_state):
"""K-means initialization using k-means++
This uses scikit-learn's implementation.
"""
x_squared_norms = row_norms(X, squared=True).compute()
logger.info("Initializing with k-means++")
with _timer("initialization of %2d centers" % n_clusters, _logger=lo... | python | def init_pp(X, n_clusters, random_state):
"""K-means initialization using k-means++
This uses scikit-learn's implementation.
"""
x_squared_norms = row_norms(X, squared=True).compute()
logger.info("Initializing with k-means++")
with _timer("initialization of %2d centers" % n_clusters, _logger=lo... | [
"def",
"init_pp",
"(",
"X",
",",
"n_clusters",
",",
"random_state",
")",
":",
"x_squared_norms",
"=",
"row_norms",
"(",
"X",
",",
"squared",
"=",
"True",
")",
".",
"compute",
"(",
")",
"logger",
".",
"info",
"(",
"\"Initializing with k-means++\"",
")",
"wi... | K-means initialization using k-means++
This uses scikit-learn's implementation. | [
"K",
"-",
"means",
"initialization",
"using",
"k",
"-",
"means",
"++"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L372-L384 |
221,285 | dask/dask-ml | dask_ml/cluster/k_means.py | init_random | def init_random(X, n_clusters, random_state):
"""K-means initialization using randomly chosen points"""
logger.info("Initializing randomly")
idx = sorted(draw_seed(random_state, 0, len(X), size=n_clusters))
centers = X[idx].compute()
return centers | python | def init_random(X, n_clusters, random_state):
"""K-means initialization using randomly chosen points"""
logger.info("Initializing randomly")
idx = sorted(draw_seed(random_state, 0, len(X), size=n_clusters))
centers = X[idx].compute()
return centers | [
"def",
"init_random",
"(",
"X",
",",
"n_clusters",
",",
"random_state",
")",
":",
"logger",
".",
"info",
"(",
"\"Initializing randomly\"",
")",
"idx",
"=",
"sorted",
"(",
"draw_seed",
"(",
"random_state",
",",
"0",
",",
"len",
"(",
"X",
")",
",",
"size",... | K-means initialization using randomly chosen points | [
"K",
"-",
"means",
"initialization",
"using",
"randomly",
"chosen",
"points"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L388-L393 |
221,286 | dask/dask-ml | dask_ml/cluster/k_means.py | init_scalable | def init_scalable(
X, n_clusters, random_state=None, max_iter=None, oversampling_factor=2
):
"""K-Means initialization using k-means||
This is algorithm 2 in Scalable K-Means++ (2012).
"""
logger.info("Initializing with k-means||")
# Step 1: Initialize Centers
idx = 0
centers = da.comp... | python | def init_scalable(
X, n_clusters, random_state=None, max_iter=None, oversampling_factor=2
):
"""K-Means initialization using k-means||
This is algorithm 2 in Scalable K-Means++ (2012).
"""
logger.info("Initializing with k-means||")
# Step 1: Initialize Centers
idx = 0
centers = da.comp... | [
"def",
"init_scalable",
"(",
"X",
",",
"n_clusters",
",",
"random_state",
"=",
"None",
",",
"max_iter",
"=",
"None",
",",
"oversampling_factor",
"=",
"2",
")",
":",
"logger",
".",
"info",
"(",
"\"Initializing with k-means||\"",
")",
"# Step 1: Initialize Centers",... | K-Means initialization using k-means||
This is algorithm 2 in Scalable K-Means++ (2012). | [
"K",
"-",
"Means",
"initialization",
"using",
"k",
"-",
"means||"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L397-L467 |
221,287 | dask/dask-ml | dask_ml/cluster/k_means.py | _sample_points | def _sample_points(X, centers, oversampling_factor, random_state):
r"""
Sample points independently with probability
.. math::
p_x = \frac{\ell \cdot d^2(x, \mathcal{C})}{\phi_X(\mathcal{C})}
"""
# re-implement evaluate_cost here, to avoid redundant computation
distances = pairwise_di... | python | def _sample_points(X, centers, oversampling_factor, random_state):
r"""
Sample points independently with probability
.. math::
p_x = \frac{\ell \cdot d^2(x, \mathcal{C})}{\phi_X(\mathcal{C})}
"""
# re-implement evaluate_cost here, to avoid redundant computation
distances = pairwise_di... | [
"def",
"_sample_points",
"(",
"X",
",",
"centers",
",",
"oversampling_factor",
",",
"random_state",
")",
":",
"# re-implement evaluate_cost here, to avoid redundant computation",
"distances",
"=",
"pairwise_distances",
"(",
"X",
",",
"centers",
")",
".",
"min",
"(",
"... | r"""
Sample points independently with probability
.. math::
p_x = \frac{\ell \cdot d^2(x, \mathcal{C})}{\phi_X(\mathcal{C})} | [
"r",
"Sample",
"points",
"independently",
"with",
"probability"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/k_means.py#L476-L495 |
221,288 | dask/dask-ml | dask_ml/preprocessing/data.py | RobustScaler.transform | def transform(self, X):
"""Center and scale the data.
Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.
Parameters
----------
X : {array-like, sparse matrix}
The data used to scale alon... | python | def transform(self, X):
"""Center and scale the data.
Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.
Parameters
----------
X : {array-like, sparse matrix}
The data used to scale alon... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"with_centering",
":",
"check_is_fitted",
"(",
"self",
",",
"\"center_\"",
")",
"if",
"self",
".",
"with_scaling",
":",
"check_is_fitted",
"(",
"self",
",",
"\"scale_\"",
")",
"X",
"... | Center and scale the data.
Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.
Parameters
----------
X : {array-like, sparse matrix}
The data used to scale along the specified axis.
This... | [
"Center",
"and",
"scale",
"the",
"data",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L168-L198 |
221,289 | dask/dask-ml | dask_ml/preprocessing/data.py | RobustScaler.inverse_transform | def inverse_transform(self, X):
"""Scale back the data to the original representation
Parameters
----------
X : array-like
The data used to scale along the specified axis.
This implementation was copied and modified from Scikit-Learn.
See License informatio... | python | def inverse_transform(self, X):
"""Scale back the data to the original representation
Parameters
----------
X : array-like
The data used to scale along the specified axis.
This implementation was copied and modified from Scikit-Learn.
See License informatio... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"center_\"",
",",
"\"scale_\"",
")",
"# if sparse.issparse(X):",
"# if self.with_scaling:",
"# inplace_column_scale(X, self.scale_)",
"# else:",
"if",
"self",
"... | Scale back the data to the original representation
Parameters
----------
X : array-like
The data used to scale along the specified axis.
This implementation was copied and modified from Scikit-Learn.
See License information here:
https://github.com/scikit-l... | [
"Scale",
"back",
"the",
"data",
"to",
"the",
"original",
"representation"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L200-L223 |
221,290 | dask/dask-ml | dask_ml/preprocessing/data.py | Categorizer.fit | def fit(self, X, y=None):
"""Find the categorical columns.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
self
"""
X = self._check_array(X)
if self.categories is not None:
# s... | python | def fit(self, X, y=None):
"""Find the categorical columns.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
self
"""
X = self._check_array(X)
if self.categories is not None:
# s... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
"if",
"self",
".",
"categories",
"is",
"not",
"None",
":",
"# some basic validation",
"columns",
"=",
"pd",
".",
"Index",
"(... | Find the categorical columns.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
self | [
"Find",
"the",
"categorical",
"columns",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L401-L427 |
221,291 | dask/dask-ml | dask_ml/preprocessing/data.py | Categorizer.transform | def transform(self, X, y=None):
"""Transform the columns in ``X`` according to ``self.categories_``.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
X_trn : pandas.DataFrame or dask.DataFrame
Same type... | python | def transform(self, X, y=None):
"""Transform the columns in ``X`` according to ``self.categories_``.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
X_trn : pandas.DataFrame or dask.DataFrame
Same type... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"\"categories_\"",
")",
"X",
"=",
"self",
".",
"_check_array",
"(",
"X",
")",
".",
"copy",
"(",
")",
"categories",
"=",
"self",
".",
"c... | Transform the columns in ``X`` according to ``self.categories_``.
Parameters
----------
X : pandas.DataFrame or dask.DataFrame
y : ignored
Returns
-------
X_trn : pandas.DataFrame or dask.DataFrame
Same type as the input. The columns in ``self.catego... | [
"Transform",
"the",
"columns",
"in",
"X",
"according",
"to",
"self",
".",
"categories_",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L455-L482 |
221,292 | dask/dask-ml | dask_ml/preprocessing/data.py | DummyEncoder.fit | def fit(self, X, y=None):
"""Determine the categorical columns to be dummy encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = se... | python | def fit(self, X, y=None):
"""Determine the categorical columns to be dummy encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = se... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"self",
".",
"columns_",
"=",
"X",
".",
"columns",
"columns",
"=",
"self",
".",
"columns",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"X",
".",
"select_dtypes",
"(",
"... | Determine the categorical columns to be dummy encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self | [
"Determine",
"the",
"categorical",
"columns",
"to",
"be",
"dummy",
"encoded",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L570-L617 |
221,293 | dask/dask-ml | dask_ml/preprocessing/data.py | DummyEncoder.transform | def transform(self, X, y=None):
"""Dummy encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | python | def transform(self, X, y=None):
"""Dummy encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"X",
".",
"columns",
".",
"equals",
"(",
"self",
".",
"columns_",
")",
":",
"raise",
"ValueError",
"(",
"\"Columns of 'X' do not match the training \"",
"\"columns. Got ... | Dummy encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input | [
"Dummy",
"encode",
"the",
"categorical",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L619-L642 |
221,294 | dask/dask-ml | dask_ml/preprocessing/data.py | DummyEncoder.inverse_transform | def inverse_transform(self, X):
"""Inverse dummy-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask ... | python | def inverse_transform(self, X):
"""Inverse dummy-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask ... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"X",
"=",
"pd",
".",
"DataFrame",
"(",
"X",
",",
"columns",
"=",
"self",
".",
"transformed_columns_",
")",
"elif",
"isinst... | Inverse dummy-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask DataFrame.
Numpy array or panda... | [
"Inverse",
"dummy",
"-",
"encode",
"the",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L644-L729 |
221,295 | dask/dask-ml | dask_ml/preprocessing/data.py | OrdinalEncoder.fit | def fit(self, X, y=None):
"""Determine the categorical columns to be encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = self.col... | python | def fit(self, X, y=None):
"""Determine the categorical columns to be encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self
"""
self.columns_ = X.columns
columns = self.col... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"self",
".",
"columns_",
"=",
"X",
".",
"columns",
"columns",
"=",
"self",
".",
"columns",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"X",
".",
"select_dtypes",
"(",
"... | Determine the categorical columns to be encoded.
Parameters
----------
X : pandas.DataFrame or dask.dataframe.DataFrame
y : ignored
Returns
-------
self | [
"Determine",
"the",
"categorical",
"columns",
"to",
"be",
"encoded",
"."
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L804-L835 |
221,296 | dask/dask-ml | dask_ml/preprocessing/data.py | OrdinalEncoder.transform | def transform(self, X, y=None):
"""Ordinal encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | python | def transform(self, X, y=None):
"""Ordinal encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input
"""
... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"X",
".",
"columns",
".",
"equals",
"(",
"self",
".",
"columns_",
")",
":",
"raise",
"ValueError",
"(",
"\"Columns of 'X' do not match the training \"",
"\"columns. Got ... | Ordinal encode the categorical columns in X
Parameters
----------
X : pd.DataFrame or dd.DataFrame
y : ignored
Returns
-------
transformed : pd.DataFrame or dd.DataFrame
Same type as the input | [
"Ordinal",
"encode",
"the",
"categorical",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L837-L861 |
221,297 | dask/dask-ml | dask_ml/preprocessing/data.py | OrdinalEncoder.inverse_transform | def inverse_transform(self, X):
"""Inverse ordinal-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Das... | python | def inverse_transform(self, X):
"""Inverse ordinal-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Das... | [
"def",
"inverse_transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"X",
"=",
"pd",
".",
"DataFrame",
"(",
"X",
",",
"columns",
"=",
"self",
".",
"columns_",
")",
"elif",
"isinstance",
"("... | Inverse ordinal-encode the columns in `X`
Parameters
----------
X : array or dataframe
Either the NumPy, dask, or pandas version
Returns
-------
data : DataFrame
Dask array or dataframe will return a Dask DataFrame.
Numpy array or pan... | [
"Inverse",
"ordinal",
"-",
"encode",
"the",
"columns",
"in",
"X"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/data.py#L863-L933 |
221,298 | dask/dask-ml | dask_ml/_partial.py | fit | def fit(model, x, y, compute=True, shuffle_blocks=True, random_state=None, **kwargs):
""" Fit scikit learn model against dask arrays
Model must support the ``partial_fit`` interface for online or batch
learning.
Ideally your rows are independent and identically distributed. By default,
this functi... | python | def fit(model, x, y, compute=True, shuffle_blocks=True, random_state=None, **kwargs):
""" Fit scikit learn model against dask arrays
Model must support the ``partial_fit`` interface for online or batch
learning.
Ideally your rows are independent and identically distributed. By default,
this functi... | [
"def",
"fit",
"(",
"model",
",",
"x",
",",
"y",
",",
"compute",
"=",
"True",
",",
"shuffle_blocks",
"=",
"True",
",",
"random_state",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"x",
",",
"\"chunks\"",
")",
"and",
... | Fit scikit learn model against dask arrays
Model must support the ``partial_fit`` interface for online or batch
learning.
Ideally your rows are independent and identically distributed. By default,
this function will step through chunks of the arrays in random order.
Parameters
----------
... | [
"Fit",
"scikit",
"learn",
"model",
"against",
"dask",
"arrays"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/_partial.py#L109-L217 |
221,299 | dask/dask-ml | dask_ml/_partial.py | predict | def predict(model, x):
""" Predict with a scikit learn model
Parameters
----------
model : scikit learn classifier
x : dask Array
See docstring for ``da.learn.fit``
"""
if not hasattr(x, "chunks") and hasattr(x, "to_dask_array"):
x = x.to_dask_array()
assert x.ndim == 2
... | python | def predict(model, x):
""" Predict with a scikit learn model
Parameters
----------
model : scikit learn classifier
x : dask Array
See docstring for ``da.learn.fit``
"""
if not hasattr(x, "chunks") and hasattr(x, "to_dask_array"):
x = x.to_dask_array()
assert x.ndim == 2
... | [
"def",
"predict",
"(",
"model",
",",
"x",
")",
":",
"if",
"not",
"hasattr",
"(",
"x",
",",
"\"chunks\"",
")",
"and",
"hasattr",
"(",
"x",
",",
"\"to_dask_array\"",
")",
":",
"x",
"=",
"x",
".",
"to_dask_array",
"(",
")",
"assert",
"x",
".",
"ndim",... | Predict with a scikit learn model
Parameters
----------
model : scikit learn classifier
x : dask Array
See docstring for ``da.learn.fit`` | [
"Predict",
"with",
"a",
"scikit",
"learn",
"model"
] | cc4837c2c2101f9302cac38354b55754263cd1f3 | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/_partial.py#L224-L242 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.