uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
173650f82acc6b98acdf193e
train
function
def cli_managementgroups_group_list(cmd, client): _register_rp(cmd.cli_ctx) return client.list()
def cli_managementgroups_group_list(cmd, client):
_register_rp(cmd.cli_ctx) return client.list()
or _is_management_group_scope(parent): return parent return "/providers/Microsoft.Management/managementGroups/" + parent def _is_management_group_scope(scope): return scope is not None and scope.lower().startswith("/providers/microsoft.management/managementgroups") def cli_managementgroups_group_list...
64
64
24
10
54
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
cli_managementgroups_group_list
cli_managementgroups_group_list
2,678
2,680
2,678
2,678
9643b6c5a432377e202f47ea6d02a9d64ae7fd44
bigcode/the-stack
train
69f175b040f97f5bd9b2c19c
train
function
def export_deployment_as_template(cmd, resource_group_name, deployment_name): smc = _resource_client_factory(cmd.cli_ctx) result = smc.deployments.export_template(resource_group_name, deployment_name) print(json.dumps(result.template, indent=2)) # pylint: disable=no-member
def export_deployment_as_template(cmd, resource_group_name, deployment_name):
smc = _resource_client_factory(cmd.cli_ctx) result = smc.deployments.export_template(resource_group_name, deployment_name) print(json.dumps(result.template, indent=2)) # pylint: disable=no-member
): rcf = _resource_client_factory(cmd.cli_ctx) result = rcf.deployments.export_template_at_tenant_scope(deployment_name) print(json.dumps(result.template, indent=2)) # pylint: disable=no-member def export_deployment_as_template(cmd, resource_group_name, deployment_name):
64
64
62
15
48
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
export_deployment_as_template
export_deployment_as_template
1,555
1,558
1,555
1,555
e7524ce873e72e43d2fd1e49d8e176290e26f17f
bigcode/the-stack
train
542c172c3dc3e4268e0ec845
train
function
def show_policy_assignment(cmd, name, resource_group_name=None, scope=None): policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) return policy_client.policy_assignments.ge...
def show_policy_assignment(cmd, name, resource_group_name=None, scope=None):
policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) return policy_client.policy_assignments.get(scope, name)
= _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) policy_client.policy_assignments.delete(scope, name) def show_policy_assignment(cmd, name, resource_group_name=None, scope=None):
64
64
68
16
48
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
show_policy_assignment
show_policy_assignment
2,224
2,228
2,224
2,224
ee3b635b783d7e5e4b0dbdddfdd5b5342cae650f
bigcode/the-stack
train
f095851eef3ff73a8fdb4cb1
train
function
def export_template_spec(cmd, output_folder, resource_group_name=None, name=None, version=None, template_spec=None): rcf = _resource_templatespecs_client_factory(cmd.cli_ctx) if template_spec: id_parts = parse_resource_id(template_spec) resource_group_name = id_parts.get('resource_group') ...
def export_template_spec(cmd, output_folder, resource_group_name=None, name=None, version=None, template_spec=None):
rcf = _resource_templatespecs_client_factory(cmd.cli_ctx) if template_spec: id_parts = parse_resource_id(template_spec) resource_group_name = id_parts.get('resource_group') name = id_parts.get('name') version = id_parts.get('resource_name') if version == name: ...
_template = TemplateSpec(location=location, description=description, display_name=display_name, tags=tags) return rcf.template_specs.create_or_update(resource_group_name, name, root_template) def export_template_spec(cmd, output_folder, resource_group_name=None, name=None, version=None, template_spec=None):
64
64
168
24
40
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
export_template_spec
export_template_spec
1,934
1,947
1,934
1,934
dd60fe83b3839e39f339933c4ce407ca3ef4b3ed
bigcode/the-stack
train
211af0f991a5fb6957e2def4
train
function
def _is_management_group_scope(scope): return scope is not None and scope.lower().startswith("/providers/microsoft.management/managementgroups")
def _is_management_group_scope(scope):
return scope is not None and scope.lower().startswith("/providers/microsoft.management/managementgroups")
id'] raise CLIError("Subscription not found in the current context.") def _get_parent_id_from_parent(parent): if parent is None or _is_management_group_scope(parent): return parent return "/providers/Microsoft.Management/managementGroups/" + parent def _is_management_group_scope(scope):
64
64
28
8
55
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_is_management_group_scope
_is_management_group_scope
2,674
2,675
2,674
2,674
d7e3c2cf23668d469aa70f57ba90210b016d4a40
bigcode/the-stack
train
45c5675f9e2bf0c6c8403410
train
function
def decompile_bicep_file(cmd, file): run_bicep_command(["decompile", file])
def decompile_bicep_file(cmd, file):
run_bicep_command(["decompile", file])
["build", file] if outdir: args += ["--outdir", outdir] if outfile: args += ["--outfile", outfile] if stdout: args += ["--stdout"] run_bicep_command(args) def decompile_bicep_file(cmd, file):
64
64
23
11
53
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
decompile_bicep_file
decompile_bicep_file
3,432
3,433
3,432
3,432
9206968c512eaa5fd80ade782ec0787ab3600171
bigcode/the-stack
train
2c4256cb4a54ec5c9294bbb4
train
function
def _get_rsrc_util_from_parsed_id(cli_ctx, parsed_id, api_version, latest_include_preview=False): return _ResourceUtils(cli_ctx, parsed_id.get('resource_group', None), parsed_id.get('resource_namespace', None), parsed_id.get('resource_par...
def _get_rsrc_util_from_parsed_id(cli_ctx, parsed_id, api_version, latest_include_preview=False):
return _ResourceUtils(cli_ctx, parsed_id.get('resource_group', None), parsed_id.get('resource_namespace', None), parsed_id.get('resource_parent', None), parsed_id.get('resource_type', None), ...
CLIError('az resource: error: argument --ids: invalid ResourceId value: \'%s\'' % rid) return ({'resource_id': rid} for rid in resource_ids) def _get_rsrc_util_from_parsed_id(cli_ctx, parsed_id, api_version, latest_include_preview=False):
64
64
105
24
40
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_get_rsrc_util_from_parsed_id
_get_rsrc_util_from_parsed_id
1,586
1,595
1,586
1,586
17fa17e3d90d540356e9164cce574f7dcd875d15
bigcode/the-stack
train
c3e7dc205fb3e5ef6e28a43c
train
class
class JSONSerializer(Serializer): def body(self, data, data_type, **kwargs): if data_type in ('Deployment', 'ScopedDeployment', 'DeploymentWhatIf', 'ScopedDeploymentWhatIf'): # Be sure to pass a DeploymentProperties template = data.properties.template if template: ...
class JSONSerializer(Serializer):
def body(self, data, data_type, **kwargs): if data_type in ('Deployment', 'ScopedDeployment', 'DeploymentWhatIf', 'ScopedDeploymentWhatIf'): # Be sure to pass a DeploymentProperties template = data.properties.template if template: data_as_dict = data.seria...
_only: return validation_result return sdk_no_wait(no_wait, deployment_client.begin_create_or_update, resource_group_name, deployment_name, deployment) class JsonCTemplate: def __init__(self, template_as_bytes): self.template_as_bytes = template_as_bytes class JSONSeria...
64
64
109
6
57
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
JSONSerializer
JSONSerializer
389
399
389
389
ebdb3281449e42417a3ae19dcf5fa7b1d4e095ce
bigcode/the-stack
train
0988527a76632c638ab719cc
train
function
def _ssl_context(): if sys.version_info < (3, 4): return ssl.SSLContext(ssl.PROTOCOL_TLSv1) return ssl.create_default_context()
def _ssl_context():
if sys.version_info < (3, 4): return ssl.SSLContext(ssl.PROTOCOL_TLSv1) return ssl.create_default_context()
(missing) for param_name in prompt_parameters: parameters[param_name] = { "value": prompt_parameters[param_name] } except NoTTYException: raise CLIError("Missing input parameters: {}".format(', '.join(sorted(miss...
64
64
38
5
58
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_ssl_context
_ssl_context
272
276
272
272
3185fa8603d7e13551b19a848efa594df1c044b9
bigcode/the-stack
train
87d0ba646180c8e8a6bcafd2
train
function
def _resolve_policy_id(cmd, policy, policy_set_definition, client): policy_id = policy or policy_set_definition if not is_valid_resource_id(policy_id): if policy: policy_def = _get_custom_or_builtin_policy(cmd, client, policy) policy_id = policy_def.id else: p...
def _resolve_policy_id(cmd, policy, policy_set_definition, client):
policy_id = policy or policy_set_definition if not is_valid_resource_id(policy_id): if policy: policy_def = _get_custom_or_builtin_policy(cmd, client, policy) policy_id = policy_def.id else: policy_set_def = _get_custom_or_builtin_policy(cmd, client, policy_se...
scope' is supplied" raise CLIError(err.format(resource_group_name)) elif resource_group_name: scope = subscription_scope + '/resourceGroups/' + resource_group_name else: scope = subscription_scope return scope def _resolve_policy_id(cmd, policy, policy_set_definition, client):
64
64
105
15
48
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_resolve_policy_id
_resolve_policy_id
1,063
1,072
1,063
1,063
bbec409963239a8d6ce34710db71aaeb8744b0ca
bigcode/the-stack
train
abc71725f3cc39147feb3021
train
function
def _extract_lock_params(resource_group_name, resource_provider_namespace, resource_type, resource_name): if resource_group_name is None: return (None, None, None, None) if resource_name is None: return (resource_group_name, None, None, None) parts = resource_type....
def _extract_lock_params(resource_group_name, resource_provider_namespace, resource_type, resource_name):
if resource_group_name is None: return (None, None, None, None) if resource_name is None: return (resource_group_name, None, None, None) parts = resource_type.split('/', 2) if resource_provider_namespace is None and len(parts) == 2: resource_provider_namespace = parts[0] ...
args): if cmd.supported_api_version(max_api='2015-01-01'): return lock_client.management_locks.get(*args) return lock_client.management_locks.get_at_subscription_level(*args) def _extract_lock_params(resource_group_name, resource_provider_namespace, resource_type, resource_name)...
64
64
118
20
44
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_extract_lock_params
_extract_lock_params
1,147
1,159
1,147
1,148
81adcb136770086432ce5678a835c8b2e275e588
bigcode/the-stack
train
1c25578bc795d99b6011d6fb
train
function
def _validate_resource_inputs(resource_group_name, resource_provider_namespace, resource_type, resource_name): if resource_group_name is None: raise CLIError('--resource-group/-g is required.') if resource_type is None: raise CLIError('--resource-type is required') ...
def _validate_resource_inputs(resource_group_name, resource_provider_namespace, resource_type, resource_name):
if resource_group_name is None: raise CLIError('--resource-group/-g is required.') if resource_type is None: raise CLIError('--resource-type is required') if resource_name is None: raise CLIError('--name/-n is required') if resource_provider_namespace is None: raise CLIEr...
resource_provider_namespace, resource_type) def _update_lock_parameters(parameters, level, notes): if level is not None: parameters.level = level if notes is not None: parameters.notes = notes def _validate_resource_inputs(resource_group_name, resource_provider_namespace, ...
64
64
92
20
43
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_validate_resource_inputs
_validate_resource_inputs
1,169
1,178
1,169
1,170
518f3d731ca709836b1c06e2ae9239e29252195f
bigcode/the-stack
train
0bd53b4866662e334a515bec
train
function
def get_policy_exemption(cmd, name, resource_group_name=None, scope=None): policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) return policy_client.policy_exemptions.get(s...
def get_policy_exemption(cmd, name, resource_group_name=None, scope=None):
policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) return policy_client.policy_exemptions.get(scope, name)
resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) policy_client.policy_exemptions.delete(scope, name) def get_policy_exemption(cmd, name, resource_group_name=None, scope=None):
64
64
70
17
47
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
get_policy_exemption
get_policy_exemption
2,602
2,606
2,602
2,602
f18757559e2390d230ed3b5710bdad0a7201885e
bigcode/the-stack
train
c340858afb9add48d768ff6b
train
function
def list_policy_exemption(cmd, disable_scope_strict_match=None, resource_group_name=None, scope=None): policy_client = _resource_policy_client_factory(cmd.cli_ctx) _scope = _build_policy_scope(get_subscription_id(cmd.cli_ctx), resource_group_name, scope) id_parts = parse_res...
def list_policy_exemption(cmd, disable_scope_strict_match=None, resource_group_name=None, scope=None):
policy_client = _resource_policy_client_factory(cmd.cli_ctx) _scope = _build_policy_scope(get_subscription_id(cmd.cli_ctx), resource_group_name, scope) id_parts = parse_resource_id(_scope) subscription = id_parts.get('subscription') resource_group = id_parts.get('res...
_policy_scope(subscription_id, resource_group_name, scope) policy_client.policy_exemptions.delete(scope, name) def get_policy_exemption(cmd, name, resource_group_name=None, scope=None): policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scop...
115
115
386
22
93
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
list_policy_exemption
list_policy_exemption
2,609
2,640
2,609
2,609
83a631bf59b05a8165fa9d713303204952065867
bigcode/the-stack
train
ff9a94a2b7027d27d93a0c6d
train
function
def list_deployments_at_management_group(cmd, management_group_id, filter_string=None): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.list_at_management_group_scope(management_group_id, filter=filter_string)
def list_deployments_at_management_group(cmd, management_group_id, filter_string=None):
rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.list_at_management_group_scope(management_group_id, filter=filter_string)
ployments_at_resource_group(cmd, resource_group_name, filter_string=None): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.list_by_resource_group(resource_group_name, filter=filter_string) def list_deployments_at_management_group(cmd, management_group_id, filter_string=None):
64
64
51
18
46
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
list_deployments_at_management_group
list_deployments_at_management_group
1,434
1,436
1,434
1,434
6bf51ca814c2da3e159a86652861855d41a2e7f9
bigcode/the-stack
train
1f375227644b250a181ef480
train
function
def get_deployment_at_subscription_scope(cmd, deployment_name): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.get_at_subscription_scope(deployment_name)
def get_deployment_at_subscription_scope(cmd, deployment_name):
rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.get_at_subscription_scope(deployment_name)
agement_group_id, filter=filter_string) def list_deployments_at_tenant_scope(cmd, filter_string=None): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.list_at_tenant_scope(filter=filter_string) def get_deployment_at_subscription_scope(cmd, deployment_name):
64
64
38
12
52
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
get_deployment_at_subscription_scope
get_deployment_at_subscription_scope
1,444
1,446
1,444
1,444
14792148c96b6185d60c3c686d1b53c50c2eb5ee
bigcode/the-stack
train
ebd7d6ef246d42d082135c89
train
function
def get_deployment_script(cmd, resource_group_name, name): rcf = _resource_deploymentscripts_client_factory(cmd.cli_ctx) return rcf.deployment_scripts.get(resource_group_name, name)
def get_deployment_script(cmd, resource_group_name, name):
rcf = _resource_deploymentscripts_client_factory(cmd.cli_ctx) return rcf.deployment_scripts.get(resource_group_name, name)
rcf = _resource_deploymentscripts_client_factory(cmd.cli_ctx) if resource_group_name is not None: return rcf.deployment_scripts.list_by_resource_group(resource_group_name) return rcf.deployment_scripts.list_by_subscription() def get_deployment_script(cmd, resource_group_name, name):
64
64
43
13
51
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
get_deployment_script
get_deployment_script
1,788
1,790
1,788
1,788
20092d6bdd2dc71fbf332a9139ea209b04fd162c
bigcode/the-stack
train
c0a5084e0ad9315f96ca0709
train
function
def deploy_arm_template_at_resource_group(cmd, resource_group_name=None, template_file=None, template_uri=None, parameters=None, deployment_name=None, mode=None, rollback_on_error=None, ...
def deploy_arm_template_at_resource_group(cmd, resource_group_name=None, template_file=None, template_uri=None, parameters=None, deployment_name=None, mode=None, rollback_on_error=None, ...
if confirm_with_what_if: what_if_deploy_arm_template_at_resource_group(cmd, resource_group_name=resource_group_name, template_file=template_file, template_uri=template_uri, ...
-argument def deploy_arm_template_at_resource_group(cmd, resource_group_name=None, template_file=None, template_uri=None, parameters=None, deployment_name=None, mode=None, rollback_on_error=None...
100
100
335
97
2
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
deploy_arm_template_at_resource_group
deploy_arm_template_at_resource_group
496
523
496
503
482191c8fdc404f81dd9319a9a8c2198b1e85b62
bigcode/the-stack
train
8d6ceb8c25a2041177358536
train
function
def export_group_as_template( cmd, resource_group_name, include_comments=False, include_parameter_default_value=False, resource_ids=None, skip_resource_name_params=False, skip_all_params=False): """Captures a resource group as a template. :param str resource_group_name: the name of the resource group. ...
def export_group_as_template( cmd, resource_group_name, include_comments=False, include_parameter_default_value=False, resource_ids=None, skip_resource_name_params=False, skip_all_params=False):
"""Captures a resource group as a template. :param str resource_group_name: the name of the resource group. :param resource_ids: space-separated resource ids to filter the export by. To export all resources, do not specify this argument or supply "*". :param bool include_comments: export template with c...
:param str tags:tags in 'a=b c' format """ rcf = _resource_client_factory(cmd.cli_ctx) ResourceGroup = cmd.get_models('ResourceGroup') parameters = ResourceGroup( location=location, tags=tags ) if cmd.supported_api_version(min_api='2016-09-01'): parameters.managed_...
164
164
548
38
125
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
export_group_as_template
export_group_as_template
1,229
1,286
1,229
1,230
e9dc41e19b4b004ecc2e8c2bfe5f5da5da3771c3
bigcode/the-stack
train
7ebadfd5f3c8e3e0ac8a6906
train
function
def _get_deployment_management_client(cli_ctx, aux_subscriptions=None, aux_tenants=None, plug_pipeline=True): smc = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, aux_subscriptions=aux_subscriptions, aux_tenants=aux_tenants) deployment_client = smc.dep...
def _get_deployment_management_client(cli_ctx, aux_subscriptions=None, aux_tenants=None, plug_pipeline=True):
smc = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, aux_subscriptions=aux_subscriptions, aux_tenants=aux_tenants) deployment_client = smc.deployments # This solves the multi-api for you if not plug_pipeline: return deployment_client ...
deployment_properties.parameters, mode=deployment_properties.mode, what_if_settings=DeploymentWhatIfSettings(result_format=result_format)) return deployment_what_if_properties # pylint: disable=protected-access def _get_deployment_management_client(c...
64
64
211
24
39
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_get_deployment_management_client
_get_deployment_management_client
927
950
927
928
4fab1015135e2c2ba4998d6b2149993e069e0f5f
bigcode/the-stack
train
2228dae6652a64d557456f87
train
function
def validate_arm_template_at_tenant_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=False, handle_extended_json_format=...
def validate_arm_template_at_tenant_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=False, handle_extended_json_format=...
return _deploy_arm_template_at_tenant_scope(cmd=cmd, template_file=template_file, template_uri=template_uri, parameters=parameters, deployment_name=deployment_name, deployment_location=deployment_location, ...
) # pylint: disable=unused-argument def validate_arm_template_at_tenant_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wa...
64
64
125
54
9
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
validate_arm_template_at_tenant_scope
validate_arm_template_at_tenant_scope
685
693
685
688
a71743d875927c80bed3db8a3ca6c89d55cd55be
bigcode/the-stack
train
2b4d7c70f7671fcd369fe42a
train
function
def list_provider_permissions(cmd, resource_provider_namespace): client = cf_providers(cmd.cli_ctx, None, api_version='2021-04-01') return client.provider_permissions(resource_provider_namespace)
def list_provider_permissions(cmd, resource_provider_namespace):
client = cf_providers(cmd.cli_ctx, None, api_version='2021-04-01') return client.provider_permissions(resource_provider_namespace)
, resource_provider_namespace, wait=False): _update_provider(cmd.cli_ctx, resource_provider_namespace, registering=False, wait=wait) def list_provider_operations(cmd): auth_client = _authorization_management_client(cmd.cli_ctx) return auth_client.provider_operations_metadata.list() def list_provider_permi...
64
64
41
10
54
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
list_provider_permissions
list_provider_permissions
2,047
2,049
2,047
2,047
557d6788d106ee50c99c9a3404f9dc3f8f6b9f3f
bigcode/the-stack
train
1790eec5594786c029460cea
train
function
def export_template_at_tenant_scope(cmd, deployment_name): rcf = _resource_client_factory(cmd.cli_ctx) result = rcf.deployments.export_template_at_tenant_scope(deployment_name) print(json.dumps(result.template, indent=2)) # pylint: disable=no-member
def export_template_at_tenant_scope(cmd, deployment_name):
rcf = _resource_client_factory(cmd.cli_ctx) result = rcf.deployments.export_template_at_tenant_scope(deployment_name) print(json.dumps(result.template, indent=2)) # pylint: disable=no-member
rcf = _resource_client_factory(cmd.cli_ctx) result = rcf.deployments.export_template_at_management_group_scope(management_group_id, deployment_name) print(json.dumps(result.template, indent=2)) # pylint: disable=no-member def export_template_at_tenant_scope(cmd, deployment_name):
64
64
60
12
51
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
export_template_at_tenant_scope
export_template_at_tenant_scope
1,548
1,552
1,548
1,548
b02028802f34227922fd12351d1771467f4a7637
bigcode/the-stack
train
bd6372638114fa3db4d29e61
train
function
def list_features(client, resource_provider_namespace=None): if resource_provider_namespace: return client.list(resource_provider_namespace=resource_provider_namespace) return client.list_all()
def list_features(client, resource_provider_namespace=None):
if resource_provider_namespace: return client.list(resource_provider_namespace=resource_provider_namespace) return client.list_all()
_group) ResourcesMoveInfo = cmd.get_models('ResourcesMoveInfo') resources_move_info = ResourcesMoveInfo(resources=ids, target_resource_group=target) return rcf.resources.begin_move_resources(resources[0]['resource_group'], parameters=resources_move_info) def list_features(client, resource_provider_namespac...
64
64
34
10
54
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
list_features
list_features
2,090
2,093
2,090
2,090
dd53c5abd776532844504b5d01f07add2f2974ae
bigcode/the-stack
train
cdee1e01112c6c9d69417f2b
train
function
def validate_arm_template(cmd, resource_group_name, template_file=None, template_uri=None, parameters=None, mode=None, rollback_on_error=None, handle_extended_json_format=None, no_prompt=False): return _deploy_arm_template_core_unmodified(cmd, resource_group_name,...
def validate_arm_template(cmd, resource_group_name, template_file=None, template_uri=None, parameters=None, mode=None, rollback_on_error=None, handle_extended_json_format=None, no_prompt=False):
return _deploy_arm_template_core_unmodified(cmd, resource_group_name, template_file, template_uri, 'deployment_dry_run', parameters, mode, rollback_on_error, validate_only=True, no_prompt=no_prompt)
aux_tenants=aux_tenants, no_prompt=no_prompt) # pylint: disable=unused-argument def validate_arm_template(cmd, resource_group_name, template_file=None, template_uri=None, parameters=None, mode=None, rollback_on_error=None, handle_extended_json...
64
64
87
41
22
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
validate_arm_template
validate_arm_template
1,519
1,524
1,519
1,521
dc091f1202c31a434286ac6ead05621bc53b0ffd
bigcode/the-stack
train
294fc7589f28a221ecd09219
train
function
def deploy_arm_template_at_subscription_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=False, handle_exten...
def deploy_arm_template_at_subscription_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=False, handle_exten...
if confirm_with_what_if: what_if_deploy_arm_template_at_subscription_scope(cmd, template_file=template_file, template_uri=template_uri, parameters=parameters, deployment_name=deployment_name, ...
unused-argument def deploy_arm_template_at_subscription_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=Fal...
80
80
268
76
3
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
deploy_arm_template_at_subscription_scope
deploy_arm_template_at_subscription_scope
423
446
423
428
ad758cf4a1c9c0fe2347c00ee51305f4e7a29808
bigcode/the-stack
train
0ecd9d3f205699b101bbb094
train
function
def _deploy_arm_template_at_resource_group(cmd, resource_group_name=None, template_file=None, template_uri=None, parameters=None, deployment_name=None, mode=None, rollback_on_error=None, ...
def _deploy_arm_template_at_resource_group(cmd, resource_group_name=None, template_file=None, template_uri=None, parameters=None, deployment_name=None, mode=None, rollback_on_error=None, ...
deployment_properties = _prepare_deployment_properties_unmodified(cmd, 'resourceGroup', template_file=template_file, template_uri=template_uri, parameters=parameters, mode=mode...
deployment_name=deployment_name, mode=mode, rollback_on_error=rollback_on_error, validate_only=True, no_wait=no_wait, no_prompt=no_prompt, template_spec=template_spec, query_string=query_string) def _deploy_arm_template...
118
118
394
73
45
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_deploy_arm_template_at_resource_group
_deploy_arm_template_at_resource_group
540
573
540
545
b4fadabc9f1c6b3ef66b61c0bae66842ac87502b
bigcode/the-stack
train
7340f7c5faa1c53340f116ad
train
function
def delete_policy_non_compliance_message(cmd, name, message, scope=None, resource_group_name=None, policy_definition_reference_id=None): policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_pol...
def delete_policy_non_compliance_message(cmd, name, message, scope=None, resource_group_name=None, policy_definition_reference_id=None):
policy_client = _resource_policy_client_factory(cmd.cli_ctx) subscription_id = get_subscription_id(cmd.cli_ctx) scope = _build_policy_scope(subscription_id, resource_group_name, scope) assignment = policy_client.policy_assignments.get(scope, name) NonComplianceMessage = cmd.get_models('NonComplian...
assignment.non_compliance_messages = [] assignment.non_compliance_messages.append(created_message) return policy_client.policy_assignments.create(scope, name, assignment).non_compliance_messages def delete_policy_non_compliance_message(cmd, name, message, scope=None, resource_group_name=None, ...
64
64
179
28
35
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
delete_policy_non_compliance_message
delete_policy_non_compliance_message
2,289
2,302
2,289
2,290
d16a3833896d007be0977761a0d20b99a7b0b30a
bigcode/the-stack
train
3af4f49deed020052be9343b
train
function
def _list_resources_odata_filter_builder(resource_group_name=None, resource_provider_namespace=None, resource_type=None, name=None, tag=None, location=None): """Build up OData filter string from parameters """ if tag is not None: if resource_group_name: ...
def _list_resources_odata_filter_builder(resource_group_name=None, resource_provider_namespace=None, resource_type=None, name=None, tag=None, location=None):
"""Build up OData filter string from parameters """ if tag is not None: if resource_group_name: raise IncorrectUsageError('you cannot use \'--tag\' with \'--resource-group\'' '(If the default value for resource group is set, please use \'az configure --d...
_pipeline: return deployment_client deployment_client._serialize = JSONSerializer( deployment_client._serialize.dependencies ) # Plug this as default HTTP pipeline from azure.core.pipeline import Pipeline smc._client._pipeline._impl_policies.append(JsonCTemplatePolicy()) # Beca...
160
160
535
32
127
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_list_resources_odata_filter_builder
_list_resources_odata_filter_builder
953
1,006
953
954
83378f19c4a048c454084043ded78dc169e60ddf
bigcode/the-stack
train
dd9a0166a82e824c935bd237
train
function
def get_deployment_operation_at_management_group(cmd, management_group_id, deployment_name, op_id): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployment_operations.get_at_management_group_scope(management_group_id, deployment_name, op_id)
def get_deployment_operation_at_management_group(cmd, management_group_id, deployment_name, op_id):
rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployment_operations.get_at_management_group_scope(management_group_id, deployment_name, op_id)
_resource_group(cmd, resource_group_name, deployment_name, op_id): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployment_operations.get(resource_group_name, deployment_name, op_id) def get_deployment_operation_at_management_group(cmd, management_group_id, deployment_name, op_id):
64
64
55
20
44
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
get_deployment_operation_at_management_group
get_deployment_operation_at_management_group
2,003
2,005
2,003
2,003
397594106108ee5d632b5af150531d034f59f5e3
bigcode/the-stack
train
5e4d9bf5293ba72c4f946831
train
function
def cancel_deployment_at_management_group(cmd, management_group_id, deployment_name): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.cancel_at_management_group_scope(management_group_id, deployment_name)
def cancel_deployment_at_management_group(cmd, management_group_id, deployment_name):
rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.cancel_at_management_group_scope(management_group_id, deployment_name)
_subscription_scope(deployment_name) def cancel_deployment_at_resource_group(cmd, resource_group_name, deployment_name): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.cancel(resource_group_name, deployment_name) def cancel_deployment_at_management_group(cmd, management_group_id, deploymen...
64
64
47
16
48
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
cancel_deployment_at_management_group
cancel_deployment_at_management_group
1,494
1,496
1,494
1,494
3ad5aa3fbbae1a5e83c8d6d0e28734c434977cda
bigcode/the-stack
train
3527340509585f8456a0a240
train
function
def get_deployment_at_management_group(cmd, management_group_id, deployment_name): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.get_at_management_group_scope(management_group_id, deployment_name)
def get_deployment_at_management_group(cmd, management_group_id, deployment_name):
rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.get_at_management_group_scope(management_group_id, deployment_name)
_subscription_scope(deployment_name) def get_deployment_at_resource_group(cmd, resource_group_name, deployment_name): rcf = _resource_client_factory(cmd.cli_ctx) return rcf.deployments.get(resource_group_name, deployment_name) def get_deployment_at_management_group(cmd, management_group_id, deployment_name):
64
64
47
16
48
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
get_deployment_at_management_group
get_deployment_at_management_group
1,454
1,456
1,454
1,454
3ac81ad80849e6230b60051d64e4d2d489b57ef1
bigcode/the-stack
train
c6d3fedf7f0f2c43d6ba097f
train
function
def list_provider_operations(cmd): auth_client = _authorization_management_client(cmd.cli_ctx) return auth_client.provider_operations_metadata.list()
def list_provider_operations(cmd):
auth_client = _authorization_management_client(cmd.cli_ctx) return auth_client.provider_operations_metadata.list()
, resource_provider_namespace, registering=True, wait=wait, properties=properties, mg_id=mg, accept_terms=accept_terms) def unregister_provider(cmd, resource_provider_namespace, wait=False): _update_provider(cmd.cli_ctx, resource_provider_namespace, registering=False, wait=wait) def list_provider_operations(cmd):...
64
64
27
6
58
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
list_provider_operations
list_provider_operations
2,042
2,044
2,042
2,042
3aedecee2ea01dc121d22b9596e18ba6305dc987
bigcode/the-stack
train
ccec1174241263ac4a0a6c45
train
function
def validate_arm_template_at_subscription_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=False, hand...
def validate_arm_template_at_subscription_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, no_wait=False, hand...
return _deploy_arm_template_at_subscription_scope(cmd=cmd, template_file=template_file, template_uri=template_uri, parameters=parameters, deployment_name=deployment_name, deployment_location=deployment_locati...
) # pylint: disable=unused-argument def validate_arm_template_at_subscription_scope(cmd, template_file=None, template_uri=None, parameters=None, deployment_name=None, deployment_location=None, ...
64
64
124
54
9
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
validate_arm_template_at_subscription_scope
validate_arm_template_at_subscription_scope
450
459
450
454
754c5bbc1483c0ab76dc2cb615af74ec5ae9d04d
bigcode/the-stack
train
7ab23a130eebc40b4f9ad7c4
train
function
def create_or_update_applicationdefinition(cmd, resource_group_name, application_definition_name, lock_level, authorizations, description, display_name, ...
def create_or_update_applicationdefinition(cmd, resource_group_name, application_definition_name, lock_level, authorizations, description, display_name, ...
""" Create or update a new managed application definition. :param str resource_group_name:the desired resource group name :param str application_definition_name:the managed application definition name :param str description:the managed application definition description :param str display_name:the m...
""" racf = _resource_managedapps_client_factory(cmd.cli_ctx) return racf.applications.get(resource_group_name, application_name) def show_applicationdefinition(cmd, resource_group_name=None, application_definition_name=None): """ Gets a managed application definition. :param str resource_group_nam...
167
167
558
52
115
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
create_or_update_applicationdefinition
create_or_update_applicationdefinition
1,359
1,411
1,359
1,364
7980e46ea1261d031ed792e795925b2acbb78dfb
bigcode/the-stack
train
2c6b6670037008bf06469f7e
train
function
def create_policy_setdefinition(cmd, name, definitions, params=None, display_name=None, description=None, subscription=None, management_group=None, definition_groups=None, metadata=None): definitions = _load_file_string_or_uri(definitions, 'definitions') params = _load_file_stri...
def create_policy_setdefinition(cmd, name, definitions, params=None, display_name=None, description=None, subscription=None, management_group=None, definition_groups=None, metadata=None):
definitions = _load_file_string_or_uri(definitions, 'definitions') params = _load_file_string_or_uri(params, 'params', False) definition_groups = _load_file_string_or_uri(definition_groups, 'definition_groups', False) PolicySetDefinition = cmd.get_models('PolicySetDefinition') parameters = PolicySe...
.cli_ctx, ResourceType.MGMT_RESOURCE_POLICY, subscription_id=subscription_id) return policy_client.policy_definitions.create_or_update(name, parameters) policy_client = _resource_policy_client_factory(cmd.cli_ctx) return policy_client.policy_defin...
94
94
314
36
58
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
create_policy_setdefinition
create_policy_setdefinition
2,383
2,408
2,383
2,385
1d4193b41fd08fbc3465a5af5a575637e62f12e7
bigcode/the-stack
train
a43273cddf02a364797363c3
train
function
def _prepare_deployment_what_if_properties(cmd, deployment_scope, template_file, template_uri, parameters, mode, result_format, no_prompt, template_spec, query_string): DeploymentWhatIfProperties, DeploymentWhatIfSettings = get_sdk(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_R...
def _prepare_deployment_what_if_properties(cmd, deployment_scope, template_file, template_uri, parameters, mode, result_format, no_prompt, template_spec, query_string):
DeploymentWhatIfProperties, DeploymentWhatIfSettings = get_sdk(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'DeploymentWhatIfProperties', 'DeploymentWhatIfSettings', mod='model...
=template_link, parameters=parameters, mode=mode, on_error_deployment=on_error_deployment) return properties def _prepare_deployment_what_if_properties(cmd, deployment_scope, template_file, template_uri, parameters, mode, result_format...
64
64
193
37
26
major/azure-cli
src/azure-cli/azure/cli/command_modules/resource/custom.py
Python
_prepare_deployment_what_if_properties
_prepare_deployment_what_if_properties
911
923
911
912
b7258c72c76b6a23cebfcefcb4accb4169496b4a
bigcode/the-stack
train
b6155c3919150cf179f1a70b
train
class
class SystemConfigBranding(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ """ Attributes: swagger_types (dict): The key is attribute name and the value is attribute type. attribute_ma...
class SystemConfigBranding(object):
"""NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ """ Attributes: swagger_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name ...
# coding: utf-8 """ VPlex REST API A definition for the next-gen VPlex API # noqa: E501 OpenAPI spec version: 0.1 Generated by: https://github.com/swagger-api/swagger-codegen.git """ import pprint import re # noqa: F401 import six class SystemConfigBranding(object):
80
256
861
7
72
dell/python-vplex
vplexapi-7.0.0/vplexapi/models/system_config_branding.py
Python
SystemConfigBranding
SystemConfigBranding
20
147
20
20
05aeeeef93cc96e09c91b1b23d45b4fe555b7151
bigcode/the-stack
train
49c1d2ee54c17dc10656ec64
train
function
def chunks2section(trigger, tk, o_r, o_c, l_rows, l_cols, out_rows, out_cols, parameter_object): """ Reshapes section chunks to the full section trigger (str) tk (list of 1d arrays): List of returned features. o_c (list): List of chunk columns. l_rows (int): Input section rows used...
def chunks2section(trigger, tk, o_r, o_c, l_rows, l_cols, out_rows, out_cols, parameter_object):
""" Reshapes section chunks to the full section trigger (str) tk (list of 1d arrays): List of returned features. o_c (list): List of chunk columns. l_rows (int): Input section rows used in feature processing. This is probably overkill, and we could just use out_rows. l_cols (int)...
import division from ..errors import logger try: import numpy as np except ImportError: raise ImportError('NumPy must be installed') def reshape_feature_list(features2reshape, out_rows, out_cols, parameter_object): """ Reshapes a feature statistic list Args: features2r...
256
256
1,111
29
226
siu-panh/mapeo-uso-del-suelo
spfeas/spfeas/sphelpers/spreshape.py
Python
chunks2section
chunks2section
44
175
44
45
abd2c88a1c3f894450c61dd5f8152c58d1c6af9a
bigcode/the-stack
train
8c62cc8bf7d8a923e3e0d8d4
train
function
def reshape_feature_list(features2reshape, out_rows, out_cols, parameter_object): """ Reshapes a feature statistic list Args: features2reshape (1d array) out_rows (int) out_cols (int) parameter_object (class object) """ logger.info(' Reshaping features...
def reshape_feature_list(features2reshape, out_rows, out_cols, parameter_object):
""" Reshapes a feature statistic list Args: features2reshape (1d array) out_rows (int) out_cols (int) parameter_object (class object) """ logger.info(' Reshaping features ...') # The number of dimensions # for the current feature. out_d...
: 7/2/2013 """ from __future__ import division from ..errors import logger try: import numpy as np except ImportError: raise ImportError('NumPy must be installed') def reshape_feature_list(features2reshape, out_rows, out_cols, parameter_object):
63
64
194
17
46
siu-panh/mapeo-uso-del-suelo
spfeas/spfeas/sphelpers/spreshape.py
Python
reshape_feature_list
reshape_feature_list
16
41
16
17
81c6a02028eee0c72e5faa47ed398e925983f8d0
bigcode/the-stack
train
7528592e8fd6aa507c83583a
train
function
@ti.test() def test_return_inside_non_static_for(): with pytest.raises( ti.TaichiCompilationError, match='Return inside non-static if/for is not supported'): @ti.kernel def foo() -> ti.i32: for i in range(10): return i foo()
@ti.test() def test_return_inside_non_static_for():
with pytest.raises( ti.TaichiCompilationError, match='Return inside non-static if/for is not supported'): @ti.kernel def foo() -> ti.i32: for i in range(10): return i foo()
def foo() -> ti.i32: a = 0 for i in ti.static(range(10)): a += i * i if ti.static(i == 8): return a assert foo() == 204 @ti.test() def test_return_inside_non_static_for():
64
64
69
12
51
sjwsl/taichi
tests/python/test_return.py
Python
test_return_inside_non_static_for
test_return_inside_non_static_for
106
117
106
107
123e2aa47e0aedc1c2c2d3d2d5bda0afecf88f0a
bigcode/the-stack
train
d4c1a83c97be1d54692ce1d2
train
function
def test_const_func_ret(): ti.init() @ti.kernel def func1() -> ti.f32: return 3 @ti.kernel def func2() -> ti.i32: return 3.3 # return type mismatch, will be auto-casted into ti.i32 assert func1() == approx(3) assert func2() == 3
def test_const_func_ret():
ti.init() @ti.kernel def func1() -> ti.f32: return 3 @ti.kernel def func2() -> ti.i32: return 3.3 # return type mismatch, will be auto-casted into ti.i32 assert func1() == approx(3) assert func2() == 3
import pytest import taichi as ti from taichi import approx @ti.test() @ti.must_throw(ti.TaichiCompilationError) def test_return_without_type_hint(): @ti.kernel def kernel(): return 1 kernel() def test_const_func_ret():
61
64
86
6
55
sjwsl/taichi
tests/python/test_return.py
Python
test_const_func_ret
test_const_func_ret
17
29
17
17
7d6e7ba0184eaa5e6faac5a889b1703829f30545
bigcode/the-stack
train
e04305834f85855ae5a0c38a
train
function
@ti.test() def test_kernel_no_return(): with pytest.raises( ti.TaichiSyntaxError, match= "Kernel has a return type but does not have a return statement"): @ti.kernel def foo() -> ti.i32: pass foo()
@ti.test() def test_kernel_no_return():
with pytest.raises( ti.TaichiSyntaxError, match= "Kernel has a return type but does not have a return statement"): @ti.kernel def foo() -> ti.i32: pass foo()
.raises( ti.TaichiCompilationError, match='Return inside non-static if/for is not supported'): @ti.kernel def foo() -> ti.i32: for i in range(10): return i foo() @ti.test() def test_kernel_no_return():
64
64
62
10
54
sjwsl/taichi
tests/python/test_return.py
Python
test_kernel_no_return
test_kernel_no_return
120
131
120
121
1867b1979566ac637c33e2d4f86b7e379115c53f
bigcode/the-stack
train
4d658a7e8b4ffb0f3682a50a
train
function
@ti.test() def test_return_in_static_if(): @ti.kernel def foo(a: ti.template()) -> ti.i32: if ti.static(a == 1): return 1 elif ti.static(a == 2): return 2 return 3 assert foo(1) == 1 assert foo(2) == 2 assert foo(123) == 3
@ti.test() def test_return_in_static_if(): @ti.kernel
def foo(a: ti.template()) -> ti.i32: if ti.static(a == 1): return 1 elif ti.static(a == 2): return 2 return 3 assert foo(1) == 1 assert foo(2) == 2 assert foo(123) == 3
ti.f32, float) _test_binary_func_ret(ti.i32, ti.f32, ti.i32, int) _test_binary_func_ret(ti.f32, ti.i32, ti.i32, int) @ti.test() def test_return_in_static_if(): @ti.kernel
64
64
92
16
48
sjwsl/taichi
tests/python/test_return.py
Python
test_return_in_static_if
test_return_in_static_if
59
71
59
61
c6301bd1f113a6523a180ea8dff5a8a9927e4462
bigcode/the-stack
train
3fb9a090b2f892329f1ff617
train
function
@ti.test() def test_func_no_return(): with pytest.raises( ti.TaichiCompilationError, match= "Function has a return type but does not have a return statement"): @ti.func def bar() -> ti.i32: pass @ti.kernel def foo() -> ti.i32: ...
@ti.test() def test_func_no_return():
with pytest.raises( ti.TaichiCompilationError, match= "Function has a return type but does not have a return statement"): @ti.func def bar() -> ti.i32: pass @ti.kernel def foo() -> ti.i32: return bar() foo()
_return(): with pytest.raises( ti.TaichiSyntaxError, match= "Kernel has a return type but does not have a return statement"): @ti.kernel def foo() -> ti.i32: pass foo() @ti.test() def test_func_no_return():
64
64
80
10
54
sjwsl/taichi
tests/python/test_return.py
Python
test_func_no_return
test_func_no_return
134
149
134
135
bf7f4809c058eac6309b09e2e717c974a241fed5
bigcode/the-stack
train
93cd687fee40e5564c89cb15
train
function
@ti.test() def _test_binary_func_ret(dt1, dt2, dt3, castor): @ti.kernel def func(a: dt1, b: dt2) -> dt3: return a * b if ti.types.is_integral(dt1): xs = list(range(4)) else: xs = [0.2, 0.4, 0.8, 1.0] if ti.types.is_integral(dt2): ys = list(range(4)) else: ...
@ti.test() def _test_binary_func_ret(dt1, dt2, dt3, castor): @ti.kernel
def func(a: dt1, b: dt2) -> dt3: return a * b if ti.types.is_integral(dt1): xs = list(range(4)) else: xs = [0.2, 0.4, 0.8, 1.0] if ti.types.is_integral(dt2): ys = list(range(4)) else: ys = [0.2, 0.4, 0.8, 1.0] for x, y in zip(xs, ys): assert fun...
.3 # return type mismatch, will be auto-casted into ti.i32 assert func1() == approx(3) assert func2() == 3 @ti.test() def _test_binary_func_ret(dt1, dt2, dt3, castor): @ti.kernel
64
64
165
27
36
sjwsl/taichi
tests/python/test_return.py
Python
_test_binary_func_ret
_test_binary_func_ret
32
49
32
34
a25bc234c4468bbb46e1b9d0cfae18ba889507d7
bigcode/the-stack
train
f3178687b00a71dcf70d9757
train
function
@ti.test() def test_func_multiple_return(): @ti.func def safe_sqrt(a): if a > 0: return ti.sqrt(a) else: return 0.0 @ti.kernel def kern(a: float): print(safe_sqrt(a)) with pytest.raises( ti.TaichiCompilationError, match='Retur...
@ti.test() def test_func_multiple_return(): @ti.func
def safe_sqrt(a): if a > 0: return ti.sqrt(a) else: return 0.0 @ti.kernel def kern(a: float): print(safe_sqrt(a)) with pytest.raises( ti.TaichiCompilationError, match='Return inside non-static if/for is not supported'): ke...
elif ti.static(a == 2): return 2 return 3 assert foo(1) == 1 assert foo(2) == 2 assert foo(123) == 3 @ti.test() def test_func_multiple_return(): @ti.func
64
64
97
15
48
sjwsl/taichi
tests/python/test_return.py
Python
test_func_multiple_return
test_func_multiple_return
74
90
74
76
5bafc6fe4d2ecade8b4340f0f374e20e36e8c55e
bigcode/the-stack
train
676b3769455e663759409cd3
train
function
@ti.test() @ti.must_throw(ti.TaichiCompilationError) def test_return_without_type_hint(): @ti.kernel def kernel(): return 1 kernel()
@ti.test() @ti.must_throw(ti.TaichiCompilationError) def test_return_without_type_hint(): @ti.kernel
def kernel(): return 1 kernel()
import pytest import taichi as ti from taichi import approx @ti.test() @ti.must_throw(ti.TaichiCompilationError) def test_return_without_type_hint(): @ti.kernel
43
64
40
28
14
sjwsl/taichi
tests/python/test_return.py
Python
test_return_without_type_hint
test_return_without_type_hint
7
14
7
10
d3db51843a9aad6e2e89da917cb5243db8ba8a97
bigcode/the-stack
train
44b32845d96e5797ee0cc602
train
function
@ti.test() def test_return_inside_static_for(): @ti.kernel def foo() -> ti.i32: a = 0 for i in ti.static(range(10)): a += i * i if ti.static(i == 8): return a assert foo() == 204
@ti.test() def test_return_inside_static_for(): @ti.kernel
def foo() -> ti.i32: a = 0 for i in ti.static(range(10)): a += i * i if ti.static(i == 8): return a assert foo() == 204
def kern(a: float): print(safe_sqrt(a)) with pytest.raises( ti.TaichiCompilationError, match='Return inside non-static if/for is not supported'): kern(-233) @ti.test() def test_return_inside_static_for(): @ti.kernel
64
64
69
16
48
sjwsl/taichi
tests/python/test_return.py
Python
test_return_inside_static_for
test_return_inside_static_for
93
103
93
95
53392458094379d60c13dda3e11dced35a993fbc
bigcode/the-stack
train
22f86d177c1f6bb3a3d395bb
train
function
def test_binary_func_ret(): _test_binary_func_ret(ti.i32, ti.f32, ti.f32, float) _test_binary_func_ret(ti.f32, ti.i32, ti.f32, float) _test_binary_func_ret(ti.i32, ti.f32, ti.i32, int) _test_binary_func_ret(ti.f32, ti.i32, ti.i32, int)
def test_binary_func_ret():
_test_binary_func_ret(ti.i32, ti.f32, ti.f32, float) _test_binary_func_ret(ti.f32, ti.i32, ti.f32, float) _test_binary_func_ret(ti.i32, ti.f32, ti.i32, int) _test_binary_func_ret(ti.f32, ti.i32, ti.i32, int)
list(range(4)) else: ys = [0.2, 0.4, 0.8, 1.0] for x, y in zip(xs, ys): assert func(x, y) == approx(castor(x * y)) def test_binary_func_ret():
64
64
90
6
58
sjwsl/taichi
tests/python/test_return.py
Python
test_binary_func_ret
test_binary_func_ret
52
56
52
52
63487cc32dcb7db42fca9d49325ed02469b70058
bigcode/the-stack
train
ae308f1950f5e356ae7880b0
train
class
class GreedyDecoder(BaseDecoder): def __init__(self, letters, *args, **kwargs): super(GreedyDecoder, self).__init__(letters, *args, **kwargs) def __call__(self, output): return torch.argmax(output, dim=2).permute(1, 0)
class GreedyDecoder(BaseDecoder):
def __init__(self, letters, *args, **kwargs): super(GreedyDecoder, self).__init__(letters, *args, **kwargs) def __call__(self, output): return torch.argmax(output, dim=2).permute(1, 0)
import torch from src.decoders.base_decoder import BaseDecoder class GreedyDecoder(BaseDecoder):
21
64
68
7
13
rproskuryakov/ai-journey-2020
src/decoders/greedy_decoder.py
Python
GreedyDecoder
GreedyDecoder
6
12
6
7
698d6edcc81601ee878f507312291f40ecb21904
bigcode/the-stack
train
d62de3a0d2b634f6a056c557
train
class
class MailFrontendService(striga.server.service.Service): # Intentionally not inherited from striga.server.frontendservice.FrontendService - there is very little functionality reusable def __init__(self, parent, name = 'MailFrontend', startstoppriority = 2000): striga.server.service.Service.__init__(self, parent, ...
class MailFrontendService(striga.server.service.Service): # Intentionally not inherited from striga.server.frontendservice.FrontendService - there is very little functionality reusable
def __init__(self, parent, name = 'MailFrontend', startstoppriority = 2000): striga.server.service.Service.__init__(self, parent, name, startstoppriority) self.ApplicationRef = weakref.ref(striga.server.application.GetInstance()) self.SiteBusRef = None self.SiteBusName = 'SiteBus' self.SMTPConnection = None ...
import smtplib, weakref, logging import striga.server.application, striga.server.service import striga.core.exception import striga.protocol._stpro_mail as mail ### L = logging.getLogger('MailFrontend') ### class MailFrontendService(striga.server.service.Service): # Intentionally not inherited from striga.server....
84
256
1,067
35
49
ateska/striga
src/striga/service/frontend_mail/_mailfrd_service.py
Python
MailFrontendService
MailFrontendService
14
143
14
16
d7a0ae28c0f7dd8f655c697de1e3fbbaf05de370
bigcode/the-stack
train
57a39e693762365f27e7ac52
train
function
def main(): args = docopt(""" Usage: train_gensim.py [options] <corpus_name> <model_name> Options: --random Use random seed --dim NUM Number of dimensions [default: 300] --threads NUM Number of threads [default: 10] --window N...
def main():
args = docopt(""" Usage: train_gensim.py [options] <corpus_name> <model_name> Options: --random Use random seed --dim NUM Number of dimensions [default: 300] --threads NUM Number of threads [default: 10] --window NUM Size of...
from docopt import docopt import random from collections import defaultdict from gensim.models.word2vec import LineSentence, Word2Vec def main():
33
84
283
3
29
hellrich/sgns_implementation_comparison
train_gensim.py
Python
main
main
7
30
7
7
a9ae732993b6d6e6a2386777739710fe600b9a2a
bigcode/the-stack
train
5d6c927e8741390af6f43cae
train
class
class AporteConfig(AppConfig): name = 'aporte'
class AporteConfig(AppConfig):
name = 'aporte'
from django.apps import AppConfig class AporteConfig(AppConfig):
14
64
13
7
6
felipemaion/financial-management-gate-django
backend/aporte/apps.py
Python
AporteConfig
AporteConfig
4
5
4
4
07103ef373da785ead59765f5cd3fbe24d30912d
bigcode/the-stack
train
c3a4178b9d7ae4ec86df890f
train
function
def test_piecewise_interval(): p1 = Piecewise((x, Interval(0, 1).contains(x)), (0, True)) assert p1.subs(x, -0.5) == 0 assert p1.subs(x, 0.5) == 0.5 assert p1.diff(x) == Piecewise((1, Interval(0, 1).contains(x)), (0, True)) assert integrate( p1, x) == Piecewise((x**2/2, Interval(0, 1).contai...
def test_piecewise_interval():
p1 = Piecewise((x, Interval(0, 1).contains(x)), (0, True)) assert p1.subs(x, -0.5) == 0 assert p1.subs(x, 0.5) == 0.5 assert p1.diff(x) == Piecewise((1, Interval(0, 1).contains(x)), (0, True)) assert integrate( p1, x) == Piecewise((x**2/2, Interval(0, 1).contains(x)), (0, True))
p2 = Piecewise((x, x < 1), (Integral(2 * x), -1 <= x), (x, 3 < x)) assert p2.doit() == p1 assert p2.doit(deep=False) == p2 def test_piecewise_interval():
64
64
129
6
57
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_interval
test_piecewise_interval
358
364
358
358
7a0f6c0f2b97556f233324138ac221f9720f20bd
bigcode/the-stack
train
0458e27387052e2fd46d5623
train
function
def test_piecewise_integrate_independent_conditions(): p = Piecewise((0, Eq(y, 0)), (x*y, True)) assert integrate(p, (x, 1, 3)) == \ Piecewise((0, Eq(y, 0)), (4*y, True))
def test_piecewise_integrate_independent_conditions():
p = Piecewise((0, Eq(y, 0)), (x*y, True)) assert integrate(p, (x, 1, 3)) == \ Piecewise((0, Eq(y, 0)), (4*y, True))
5*Min(b, y) - Min(a, b, y) assert integrate(p5, (x, -oo, y)) == 0.5*y + 0.5*Min(b, y) - Min(a, b, y) def test_piecewise_integrate_independent_conditions():
64
64
64
10
54
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_integrate_independent_conditions
test_piecewise_integrate_independent_conditions
244
247
244
244
05406d0b72d8fbc8af6b2b742aa30325b08dabf2
bigcode/the-stack
train
44239b4d191f48a29341840b
train
function
@XFAIL def test_piecewise_solve2(): f = Piecewise(((x - 2)**2, x >= 0), (0, True)) assert solve(f, x) == [2, Interval(0, oo, True, True)]
@XFAIL def test_piecewise_solve2():
f = Piecewise(((x - 2)**2, x >= 0), (0, True)) assert solve(f, x) == [2, Interval(0, oo, True, True)]
+ 2, x - 2 <= 0), (x - 2, x - 2 > 0)) assert solve(g, x) == [5] # See issue 1253 (enhance the solver to handle inequalities). @XFAIL def test_piecewise_solve2():
64
64
56
12
52
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_solve2
test_piecewise_solve2
281
284
281
282
fe632d0110e59158cd3286eb5e17ed7249d06872
bigcode/the-stack
train
9d990f26393c2ad151c754d6
train
function
def test_piecewise_fold(): p = Piecewise((x, x < 1), (1, 1 <= x)) assert piecewise_fold(x*p) == Piecewise((x**2, x < 1), (x, 1 <= x)) assert piecewise_fold(p + p) == Piecewise((2*x, x < 1), (2, 1 <= x)) assert piecewise_fold(Piecewise((1, x < 0), (2, True)) + Piecewise((10, x...
def test_piecewise_fold():
p = Piecewise((x, x < 1), (1, 1 <= x)) assert piecewise_fold(x*p) == Piecewise((x**2, x < 1), (x, 1 <= x)) assert piecewise_fold(p + p) == Piecewise((2*x, x < 1), (2, 1 <= x)) assert piecewise_fold(Piecewise((1, x < 0), (2, True)) + Piecewise((10, x < 0), (-10, True))) == \ ...
3 (enhance the solver to handle inequalities). @XFAIL def test_piecewise_solve2(): f = Piecewise(((x - 2)**2, x >= 0), (0, True)) assert solve(f, x) == [2, Interval(0, oo, True, True)] def test_piecewise_fold():
72
73
246
6
66
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_fold
test_piecewise_fold
287
302
287
288
6fd62b648d1e523a3963e43c0ab2cc8ce6515dbd
bigcode/the-stack
train
f3605920f1bd1ef9cb3f60a6
train
function
def test_piecewise_as_leading_term(): p1 = Piecewise((1/x, x > 1), (0, True)) p2 = Piecewise((x, x > 1), (0, True)) p3 = Piecewise((1/x, x > 1), (x, True)) p4 = Piecewise((x, x > 1), (1/x, True)) p5 = Piecewise((1/x, x > 1), (x, True)) p6 = Piecewise((1/x, x < 1), (x, True)) p7 = Piecewise((...
def test_piecewise_as_leading_term():
p1 = Piecewise((1/x, x > 1), (0, True)) p2 = Piecewise((x, x > 1), (0, True)) p3 = Piecewise((1/x, x > 1), (x, True)) p4 = Piecewise((x, x > 1), (1/x, True)) p5 = Piecewise((1/x, x > 1), (x, True)) p6 = Piecewise((1/x, x < 1), (x, True)) p7 = Piecewise((x, x < 1), (1/x, True)) p8 = Piece...
, O p1 = Piecewise((sin(x), x < 0), (cos(x), x > 0)) p2 = Piecewise((x + O(x**2), x < 0), (1 + O(x**2), x > 0)) assert p1.nseries(x, n=2) == p2 def test_piecewise_as_leading_term():
84
84
280
9
74
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_as_leading_term
test_piecewise_as_leading_term
398
414
398
398
ccd7e4b3ba14e9907c7eb98b81f48fc75f2c8284
bigcode/the-stack
train
7950907e8fe2bf62ac9dcfe1
train
function
def test_doit(): p1 = Piecewise((x, x < 1), (x**2, -1 <= x), (x, 3 < x)) p2 = Piecewise((x, x < 1), (Integral(2 * x), -1 <= x), (x, 3 < x)) assert p2.doit() == p1 assert p2.doit(deep=False) == p2
def test_doit():
p1 = Piecewise((x, x < 1), (x**2, -1 <= x), (x, 3 < x)) p2 = Piecewise((x, x < 1), (Integral(2 * x), -1 <= x), (x, 3 < x)) assert p2.doit() == p1 assert p2.doit(deep=False) == p2
False, True).contains(x)), (0, True)) def test_piecewise_duplicate(): p = Piecewise((x, x < -10), (x**2, x <= -1), (x, 1 < x)) assert p == Piecewise(*p.args) def test_doit():
64
64
96
5
59
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_doit
test_doit
351
355
351
351
10c31e176c6704c979233992123b6dbdae33c2e1
bigcode/the-stack
train
23398b151ae4787247f6ad93
train
function
def test_conjugate_transpose(): A, B = symbols("A B", commutative=False) p = Piecewise((A*B**2, x > 0), (A**2*B, True)) assert p.adjoint() == \ Piecewise((adjoint(A*B**2), x > 0), (adjoint(A**2*B), True)) assert p.conjugate() == \ Piecewise((conjugate(A*B**2), x > 0), (conjugate(A**2*B),...
def test_conjugate_transpose():
A, B = symbols("A B", commutative=False) p = Piecewise((A*B**2, x > 0), (A**2*B, True)) assert p.adjoint() == \ Piecewise((adjoint(A*B**2), x > 0), (adjoint(A**2*B), True)) assert p.conjugate() == \ Piecewise((conjugate(A*B**2), x > 0), (conjugate(A**2*B), True)) assert p.transpose()...
assert p3.is_imaginary is None assert p3.is_real is None assert p1.as_real_imag() == (p1, 0) assert p2.as_real_imag() == (0, -I*p2) def test_conjugate_transpose():
64
64
157
8
56
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_conjugate_transpose
test_conjugate_transpose
438
446
438
438
173f1a4d7dd5b365b1d7de74d6c9ece4f3729f24
bigcode/the-stack
train
e7ac1ea18bc4ebcb59b15be0
train
function
def test_piecewise_integrate_symbolic_conditions(): from sympy.abc import a, b, x, y p0 = Piecewise((0, Or(x < a, x > b)), (1, True)) p1 = Piecewise((0, x < a), (0, x > b), (1, True)) p2 = Piecewise((0, x > b), (0, x < a), (1, True)) p3 = Piecewise((0, x < a), (1, x < b), (0, True)) p4 = Piecewi...
def test_piecewise_integrate_symbolic_conditions():
from sympy.abc import a, b, x, y p0 = Piecewise((0, Or(x < a, x > b)), (1, True)) p1 = Piecewise((0, x < a), (0, x > b), (1, True)) p2 = Piecewise((0, x > b), (0, x < a), (1, True)) p3 = Piecewise((0, x < a), (1, x < b), (0, True)) p4 = Piecewise((0, x > b), (1, x > a), (0, True)) p5 = Piece...
assert integrate(g, (x, -5, y)).subs(y, 1) == 1 assert integrate(g, (x, y, 1)).subs(y, -5) == 1 assert integrate(g, (x, 1, -5)) == -1 assert integrate(g, (x, 1, y)).subs(y, -5) == -1 assert integrate(g, (x, y, -5)).subs(y, 1) == -1 assert integrate(g, (x, -5, y)) == Piecewise((0, y <= -1), (1, y...
256
256
920
10
246
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_integrate_symbolic_conditions
test_piecewise_integrate_symbolic_conditions
207
241
207
207
8050af2901077f66af1ee90026b17cdc56323ede
bigcode/the-stack
train
00ead485b0124a378db0af1e
train
function
@XFAIL def test_piecewise_fold_piecewise_in_cond_2(): p1 = Piecewise((cos(x), x < 0), (0, True)) p2 = Piecewise((0, Eq(p1, 0)), (1 / p1, True)) p3 = Piecewise((0, Or(And(Eq(cos(x), 0), x < 0), Not(x < 0))), (1 / cos(x), True)) assert(piecewise_fold(p2) == p3)
@XFAIL def test_piecewise_fold_piecewise_in_cond_2():
p1 = Piecewise((cos(x), x < 0), (0, True)) p2 = Piecewise((0, Eq(p1, 0)), (1 / p1, True)) p3 = Piecewise((0, Or(And(Eq(cos(x), 0), x < 0), Not(x < 0))), (1 / cos(x), True)) assert(piecewise_fold(p2) == p3)
7 = piecewise_fold(Piecewise((1, p5 < p6), (0, True))) assert(Piecewise((1, And(Not(x < 1), x < 0)), (0, True))) @XFAIL def test_piecewise_fold_piecewise_in_cond_2():
63
64
113
16
47
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_fold_piecewise_in_cond_2
test_piecewise_fold_piecewise_in_cond_2
325
331
325
326
878cb4b631f32b38e3ace2e6985f13011b16920f
bigcode/the-stack
train
e5dd6839e1fb960018d0b463
train
function
def test_piecewise_solve(): abs2 = Piecewise((-x, x <= 0), (x, x > 0)) f = abs2.subs(x, x - 2) assert solve(f, x) == [2] assert solve(f - 1, x) == [1, 3] f = Piecewise(((x - 2)**2, x >= 0), (1, True)) assert solve(f, x) == [2] g = Piecewise(((x - 5)**5, x >= 4), (f, True)) assert solve...
def test_piecewise_solve():
abs2 = Piecewise((-x, x <= 0), (x, x > 0)) f = abs2.subs(x, x - 2) assert solve(f, x) == [2] assert solve(f - 1, x) == [1, 3] f = Piecewise(((x - 2)**2, x >= 0), (1, True)) assert solve(f, x) == [2] g = Piecewise(((x - 5)**5, x >= 4), (f, True)) assert solve(g, x) == [2, 5] g = Pi...
, (x, -oo, y)) == 0.5*y + 0.5*Min(b, y) - Min(a, b, y) def test_piecewise_integrate_independent_conditions(): p = Piecewise((0, Eq(y, 0)), (x*y, True)) assert integrate(p, (x, 1, 3)) == \ Piecewise((0, Eq(y, 0)), (4*y, True)) def test_piecewise_solve():
105
105
350
7
98
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_solve
test_piecewise_solve
250
276
250
250
04f1e311a7cba622a400e3d4fb47a2e273bf389f
bigcode/the-stack
train
a9e396b4c200e994bda48b47
train
function
def test_piecewise_series(): from sympy import sin, cos, O p1 = Piecewise((sin(x), x < 0), (cos(x), x > 0)) p2 = Piecewise((x + O(x**2), x < 0), (1 + O(x**2), x > 0)) assert p1.nseries(x, n=2) == p2
def test_piecewise_series():
from sympy import sin, cos, O p1 = Piecewise((sin(x), x < 0), (cos(x), x > 0)) p2 = Piecewise((x + O(x**2), x < 0), (1 + O(x**2), x > 0)) assert p1.nseries(x, n=2) == p2
p) assert f(-2.0) == 4.0 assert f(0.0) == 0.0 assert f(0.5) == 0.5 assert f(2.0) == 0.0 def test_piecewise_series():
64
64
89
6
57
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_series
test_piecewise_series
391
395
391
391
45826afd20f77e9cb4aa605e2089a56e274fb8b5
bigcode/the-stack
train
c1c615236690248d8a5a60a7
train
function
def test_piecewise_fold_piecewise_in_cond(): p1 = Piecewise((cos(x), x < 0), (0, True)) p2 = Piecewise((0, Eq(p1, 0)), (p1 / Abs(p1), True)) p3 = piecewise_fold(p2) assert(p2.subs(x, -pi/2) == 0.0) assert(p2.subs(x, 1) == 0.0) assert(p2.subs(x, -pi/4) == 1.0) p4 = Piecewise((0, Eq(p1, 0)), (...
def test_piecewise_fold_piecewise_in_cond():
p1 = Piecewise((cos(x), x < 0), (0, True)) p2 = Piecewise((0, Eq(p1, 0)), (p1 / Abs(p1), True)) p3 = piecewise_fold(p2) assert(p2.subs(x, -pi/2) == 0.0) assert(p2.subs(x, 1) == 0.0) assert(p2.subs(x, -pi/4) == 1.0) p4 = Piecewise((0, Eq(p1, 0)), (1,True)) assert(piecewise_fold(p4) == Pie...
(0, True)) p2 = Piecewise((0, x < 0), (1 - x, x <= 1), (0, True)) p = 4*p1 + 2*p2 assert integrate( piecewise_fold(p), (x, -oo, oo)) == integrate(2*x + 2, (x, 0, 1)) def test_piecewise_fold_piecewise_in_cond():
93
93
310
10
83
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_fold_piecewise_in_cond
test_piecewise_fold_piecewise_in_cond
305
322
305
305
945111a999484c794ccfd66599be34adaa68b976
bigcode/the-stack
train
401e7fa615a5a838d856bb93
train
function
def test_piecewise_lambdify(): p = Piecewise( (x**2, x < 0), (x, Interval(0, 1, False, True).contains(x)), (2 - x, x >= 1), (0, True) ) f = lambdify(x, p) assert f(-2.0) == 4.0 assert f(0.0) == 0.0 assert f(0.5) == 0.5 assert f(2.0) == 0.0
def test_piecewise_lambdify():
p = Piecewise( (x**2, x < 0), (x, Interval(0, 1, False, True).contains(x)), (2 - x, x >= 1), (0, True) ) f = lambdify(x, p) assert f(-2.0) == 4.0 assert f(0.0) == 0.0 assert f(0.5) == 0.5 assert f(2.0) == 0.0
, 1 < x)) p1 = Piecewise((Piecewise((x, x < 0), (1, True)), True)) assert p1 == Piecewise((Piecewise((x, x < 0), (1, True)), True)) def test_piecewise_lambdify():
64
64
129
9
55
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_lambdify
test_piecewise_lambdify
376
388
376
376
ca798192b1af98da128c40ee1f269c35c9ef0bd1
bigcode/the-stack
train
081a881700f629a7fe913b96
train
function
def test_piecewise_evaluate(): assert Piecewise((x, True)) == x assert Piecewise((x, True), evaluate=True) == x p = Piecewise((x, True), evaluate=False) assert p != x assert p.is_Piecewise assert all(isinstance(i, Basic) for i in p.args)
def test_piecewise_evaluate():
assert Piecewise((x, True)) == x assert Piecewise((x, True), evaluate=True) == x p = Piecewise((x, True), evaluate=False) assert p != x assert p.is_Piecewise assert all(isinstance(i, Basic) for i in p.args)
ate(A*B**2), x > 0), (conjugate(A**2*B), True)) assert p.transpose() == \ Piecewise((transpose(A*B**2), x > 0), (transpose(A**2*B), True)) def test_piecewise_evaluate():
64
64
76
7
57
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_evaluate
test_piecewise_evaluate
449
455
449
449
5e4d0d4c2d98365bdc09946a7dc2d64dbf998d04
bigcode/the-stack
train
25084a8a988bb4ca44e20a12
train
function
def test_piecewise_collapse(): p1 = Piecewise((x, x < 0), (x**2, x > 1)) p2 = Piecewise((p1, x < 0), (p1, x > 1)) assert p2 == Piecewise((x, x < 0), (x**2, 1 < x)) p1 = Piecewise((Piecewise((x, x < 0), (1, True)), True)) assert p1 == Piecewise((Piecewise((x, x < 0), (1, True)), True))
def test_piecewise_collapse():
p1 = Piecewise((x, x < 0), (x**2, x > 1)) p2 = Piecewise((p1, x < 0), (p1, x > 1)) assert p2 == Piecewise((x, x < 0), (x**2, 1 < x)) p1 = Piecewise((Piecewise((x, x < 0), (1, True)), True)) assert p1 == Piecewise((Piecewise((x, x < 0), (1, True)), True))
) == Piecewise((1, Interval(0, 1).contains(x)), (0, True)) assert integrate( p1, x) == Piecewise((x**2/2, Interval(0, 1).contains(x)), (0, True)) def test_piecewise_collapse():
64
64
129
7
57
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_collapse
test_piecewise_collapse
367
373
367
367
db23dc2826522590bbf8d22aa724d442746ff5d9
bigcode/the-stack
train
3de1645974f22760280758ff
train
function
def test_piecewise_integrate(): # XXX Use '<=' here! '>=' is not yet implemented .. f = Piecewise(((x - 2)**2, 0 <= x), (1, True)) assert integrate(f, (x, -2, 2)) == Rational(14, 3) g = Piecewise(((x - 5)**5, 4 <= x), (f, True)) assert integrate(g, (x, -2, 2)) == Rational(14, 3) assert integrat...
def test_piecewise_integrate(): # XXX Use '<=' here! '>=' is not yet implemented ..
f = Piecewise(((x - 2)**2, 0 <= x), (1, True)) assert integrate(f, (x, -2, 2)) == Rational(14, 3) g = Piecewise(((x - 5)**5, 4 <= x), (f, True)) assert integrate(g, (x, -2, 2)) == Rational(14, 3) assert integrate(g, (x, -2, 5)) == Rational(43, 6) g = Piecewise(((x - 5)**5, 4 <= x), (f, x < 4))...
, -1 <= x), (x, 3 < x)) assert integrate(p, (x, -2, 2)) == 5.0/6.0 assert integrate(p, (x, 2, -2)) == -5.0/6.0 p = Piecewise((0, x < 0), (1, x < 1), (0, x < 2), (1, x < 3), (0, True)) assert integrate(p, (x, -oo, oo)) == 2 p = Piecewise((x, x < -10), (x**2, x <= -1), (x, 1 < x)) raises(ValueErro...
256
256
1,415
22
234
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_integrate
test_piecewise_integrate
134
204
134
135
dd61c297d86251f917e3b1e9b14e1cef5688b874
bigcode/the-stack
train
d6449c96182f514a312a7029
train
function
def test_piecewise(): # Test canonization assert Piecewise((x, x < 1), (0, True)) == Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, True), (1, True)) == \ Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, False), (-1, 1 > 2)) == \ Piecewise((x, x < 1))...
def test_piecewise(): # Test canonization
assert Piecewise((x, x < 1), (0, True)) == Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, True), (1, True)) == \ Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, False), (-1, 1 > 2)) == \ Piecewise((x, x < 1)) assert Piecewise((x, x < 1), (0, x < 1), (...
from sympy import ( adjoint, And, Basic, conjugate, diff, expand, Eq, Function, I, im, Integral, integrate, Interval, lambdify, log, Max, Min, oo, Or, pi, Piecewise, piecewise_fold, Rational, re, solve, symbols, transpose, cos, exp, Abs, Not ) from sympy.utilities.pytest import XFAIL, raises x, y = sym...
121
256
1,874
11
110
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise
test_piecewise
13
125
13
15
ccabcbf2a6c714194e679677c3d42097b7eda9f4
bigcode/the-stack
train
080a484ea968f6ef811c9af6
train
function
def test_piecewise_fold_expand(): p1 = Piecewise((1, Interval(0, 1, False, True).contains(x)), (0, True)) p2 = piecewise_fold(expand((1 - x)*p1)) assert p2 == Piecewise((1 - x, Interval(0, 1, False, True).contains(x)), (Piecewise((-x, Interval(0, 1, False, True).contains(x)), (0, True)), True)) ...
def test_piecewise_fold_expand():
p1 = Piecewise((1, Interval(0, 1, False, True).contains(x)), (0, True)) p2 = piecewise_fold(expand((1 - x)*p1)) assert p2 == Piecewise((1 - x, Interval(0, 1, False, True).contains(x)), (Piecewise((-x, Interval(0, 1, False, True).contains(x)), (0, True)), True)) p2 = expand(piecewise_fold((1 - ...
1, True)) p3 = Piecewise((0, Or(And(Eq(cos(x), 0), x < 0), Not(x < 0))), (1 / cos(x), True)) assert(piecewise_fold(p2) == p3) def test_piecewise_fold_expand():
64
64
155
7
57
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_fold_expand
test_piecewise_fold_expand
334
343
334
334
9cbecc2180ce618756c435f97534886d301c5abd
bigcode/the-stack
train
3547e1b8b689795109e1bbef
train
function
def test_piecewise_free_symbols(): a = symbols('a') f = Piecewise((x, a < 0), (y, True)) assert f.free_symbols == set([x, y, a])
def test_piecewise_free_symbols():
a = symbols('a') f = Piecewise((x, a < 0), (y, True)) assert f.free_symbols == set([x, y, a])
-10), (x**2, x <= -1), (x, 1 < x)) raises(ValueError, lambda: integrate(p, (x, -2, 2))) # Test commutativity assert p.is_commutative is True def test_piecewise_free_symbols():
64
64
46
7
56
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_free_symbols
test_piecewise_free_symbols
128
131
128
128
cd9f0409c8fbeac4f1202453ce836af1122fd478
bigcode/the-stack
train
d8714835b0af4b9e22d979b6
train
function
def test_piecewise_complex(): p1 = Piecewise((2, x < 0), (1, 0 <= x)) p2 = Piecewise((2*I, x < 0), (I, 0 <= x)) p3 = Piecewise((I*x, x > 1), (1 + I, True)) p4 = Piecewise((-I*conjugate(x), x > 1), (1 - I, True)) assert conjugate(p1) == p1 assert conjugate(p2) == piecewise_fold(-p2) assert c...
def test_piecewise_complex():
p1 = Piecewise((2, x < 0), (1, 0 <= x)) p2 = Piecewise((2*I, x < 0), (I, 0 <= x)) p3 = Piecewise((I*x, x > 1), (1 + I, True)) p4 = Piecewise((-I*conjugate(x), x > 1), (1 - I, True)) assert conjugate(p1) == p1 assert conjugate(p2) == piecewise_fold(-p2) assert conjugate(p3) == p4 assert...
(x) == 1/x assert p5.as_leading_term(x) == x assert p6.as_leading_term(x) == 1/x assert p7.as_leading_term(x) == x assert p8.as_leading_term(x) == 1/x def test_piecewise_complex():
69
69
232
6
62
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_complex
test_piecewise_complex
417
435
417
417
46fe693a151f4b42a5b9533efb47fa1deff38578
bigcode/the-stack
train
c716030558010a98cd45b75e
train
function
def test_piecewise_duplicate(): p = Piecewise((x, x < -10), (x**2, x <= -1), (x, 1 < x)) assert p == Piecewise(*p.args)
def test_piecewise_duplicate():
p = Piecewise((x, x < -10), (x**2, x <= -1), (x, 1 < x)) assert p == Piecewise(*p.args)
(x)), (0, True)), True)) p2 = expand(piecewise_fold((1 - x)*p1)) assert p2 == Piecewise( (1 - x, Interval(0, 1, False, True).contains(x)), (0, True)) def test_piecewise_duplicate():
64
64
47
6
58
lidavidm/sympy
sympy/functions/elementary/tests/test_piecewise.py
Python
test_piecewise_duplicate
test_piecewise_duplicate
346
348
346
346
71eb6dab0ddbf3b2f49e63699ecab21f017ae0f8
bigcode/the-stack
train
6b1980d697d2051cb31665d4
train
function
@login_required def simulator_main(request): """ 模拟股市的主页面 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') result = simulator_main_func(request.user) context = {'result': result} return render(request, 'market/simu...
@login_required def simulator_main(request):
""" 模拟股市的主页面 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') result = simulator_main_func(request.user) context = {'result': result} return render(request, 'market/simulator/simulator_main.html', context)
context = {'stock': this_stock, 'info': tick_info, 'level5_ask': ask_info, 'level5_bid': bid_info, 'time': str(cur_datetime)} return render(request, 'market/simulator/v_stock_tick.html', context) @login_required def simulator_main(request):
64
64
88
8
56
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_main
simulator_main
357
367
357
358
c025732b8dfc27c872040669482d5fe2a6bfaff7
bigcode/the-stack
train
b741fb23e0d662483fecc2f1
train
function
@login_required def simulator_stock_detail(request, stock_id): """ 具体显示股票市场中某支股票的详细信息 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) ask_info, bid_info = this...
@login_required def simulator_stock_detail(request, stock_id):
""" 具体显示股票市场中某支股票的详细信息 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) ask_info, bid_info = this_stock.get_order_book_data(level=5) market = sim_market.Si...
_welcome.html', context) @login_required def simulator_v_stocks(request): """ 在模拟股票市场中显示全部虚拟股票 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') all_the_v_stocks = sim_stocks.SimStock.objects.order_by('symbol') contex...
126
126
421
12
114
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_stock_detail
simulator_stock_detail
211
251
211
212
d765e3c49d58133e03109e745481a3752c265efe
bigcode/the-stack
train
3d727d97942bf465986f9b53
train
function
@login_required def simulator_stock_tick(request, stock_id): """ 显示股票市场中某支股票的tick截面信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market, created = sim_market.SimMarket.objects...
@login_required def simulator_stock_tick(request, stock_id):
""" 显示股票市场中某支股票的tick截面信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market, created = sim_market.SimMarket.objects.get_or_create(id=2) # 用于浏览截面 if created: origin...
float(info.high), float(info.low), float(info.close)]) volume.append([str(info.date), info.volume]) context = {'stock': this_stock, 'time': str(cur_datetime), 'candles': json.dumps(candles), 'volume': json.dumps(volume)} return render(request, 'market/simulator/v_stock_daily.html', cont...
85
85
285
12
73
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_stock_tick
simulator_stock_tick
278
302
278
279
cf2f11073398fedd2ea92c5e2c35db5f9b878d4c
bigcode/the-stack
train
8d8216cf42c6ac80976cc87e
train
function
def simulator_reset_handler(request, superuser_client): time0 = time.time() assert isinstance(superuser_client, clients.BaseClient) market = sim_market.SimMarket.objects.get(id=1) sim_market.SimMarket.objects.filter(id=2).delete() clients.BaseClient.objects.filter(driver=None).delete() sim_clien...
def simulator_reset_handler(request, superuser_client):
time0 = time.time() assert isinstance(superuser_client, clients.BaseClient) market = sim_market.SimMarket.objects.get(id=1) sim_market.SimMarket.objects.filter(id=2).delete() clients.BaseClient.objects.filter(driver=None).delete() sim_clients.SimTransactionElem.objects.all().delete() sim_cli...
.is_superuser: return render(request, 'market/invalid/no_permission.html') superuser_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user) simulator_reset_handler(request, superuser_client) return HttpResponseRedirect(reverse('market:sim_welcome')) def simulator_reset_handler(req...
68
69
230
10
58
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_reset_handler
simulator_reset_handler
444
467
444
444
a58d76f4f60b58ec33f6cbb6b7d56ed7ba94b7dd
bigcode/the-stack
train
df7eeccb568c51a869bbf448
train
function
@login_required def simulator_stock_daily(request, stock_id): """ 显示股票市场中某支股票的历史信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market = sim_market.SimMarket.objects.get(id=1) ...
@login_required def simulator_stock_daily(request, stock_id):
""" 显示股票市场中某支股票的历史信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market = sim_market.SimMarket.objects.get(id=1) cur_datetime = market.datetime cur_date = cur_datetime....
json.dumps(time_log), 'price_log': json.dumps(price_log), 'volume_log': json.dumps(volume_log), 'tick': json.dumps(tick), 'price_generated': json.dumps(price_generated)} return render(request, 'market/simulator/v_stock.html', context) @login_required def simulator_stock_daily(request, stock_id):
68
68
227
12
56
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_stock_daily
simulator_stock_daily
254
275
254
255
c9f341280263b365c0e73010194023e7d1d576f9
bigcode/the-stack
train
4a3dd2652b1f3f9db96a0a17
train
function
@login_required def simulator_reset(request): """ 重置模拟的股市(还原到切入的点) """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') superuser_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user) simulator_reset_handler(request, superu...
@login_required def simulator_reset(request):
""" 重置模拟的股市(还原到切入的点) """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') superuser_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user) simulator_reset_handler(request, superuser_client) return HttpResponseRedirect(re...
hold.refresh() this_client.profit += hold.profit this_client.save() context = {'client': this_client, 'holding': holding, 'commission': commission, 'transaction': transaction} return render(request, 'market/simulator/client.html', context) @login_required def simulator_reset(request):
64
64
91
8
56
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_reset
simulator_reset
432
441
432
433
131ca83d323e7c29830d2c78fc9d40c68213d373
bigcode/the-stack
train
a4888e6e71e196f43e27ad8d
train
function
@login_required def simulator_v_stocks(request): """ 在模拟股票市场中显示全部虚拟股票 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') all_the_v_stocks = sim_stocks.SimStock.objects.order_by('symbol') context = {'stocks': all_the_v_st...
@login_required def simulator_v_stocks(request):
""" 在模拟股票市场中显示全部虚拟股票 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') all_the_v_stocks = sim_stocks.SimStock.objects.order_by('symbol') context = {'stocks': all_the_v_stocks} return render(request, 'market/simulato...
{'num_clients': num_clients, 'num_stocks': num_stocks, 'num_v_clients': num_v_clients, 'datetime': cur_datetime, 'tick': tick} return render(request, 'market/simulator/simulator_welcome.html', context) @login_required def simulator_v_stocks(request):
64
64
108
10
54
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_v_stocks
simulator_v_stocks
198
208
198
199
78843230d8c99133e7b532ca4521d111f99dd048
bigcode/the-stack
train
c6a5fb5cbbbb83881c9abb9d
train
function
@login_required def simulator_stock_next_tick(request, stock_id): """ 显示股票市场中某支股票的tick截面信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market = sim_market.SimMarket.objects.get...
@login_required def simulator_stock_next_tick(request, stock_id):
""" 显示股票市场中某支股票的tick截面信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market = sim_market.SimMarket.objects.get(id=2) cur_datetime = market.datetime stock_tick_info = si...
market.save() cur_datetime = market.datetime context = {'stock': this_stock, 'info': tick_info, 'level5_ask': ask_info, 'level5_bid': bid_info, 'time': str(cur_datetime)} return render(request, 'market/simulator/v_stock_tick.html', context) @login_required def simulator_stock_next_tick(request...
80
80
268
13
67
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_stock_next_tick
simulator_stock_next_tick
331
354
331
332
e6f8940c6de81d13614b3011fdf8970f794e552a
bigcode/the-stack
train
f96a98b80f258f386a72049b
train
function
def index(request): """ Main page """ return render(request, 'market/index.html')
def index(request):
""" Main page """ return render(request, 'market/index.html')
sim_clients, sim_stocks from .models import config, utils from .models.trades import CommissionMsg, commission_handler from .simulator_main import simulator_main_func, anchor_one_stock from .baselines.baselines.gail.dataset.generate_expert_data import generate_expert_data def index(request):
64
64
22
4
59
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
index
index
20
24
20
20
8e792c4dfb71a661a031b465bfecb9a19b2c6d71
bigcode/the-stack
train
66fb686866ddde079fe08338
train
function
@login_required def gail_generate_expert_data(request): """ 生成专家数据 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') market, _ = sim_market.SimMarket.objects.get_or_create(id=1) cur_datetime = str(market.datetime) if request.method == '...
@login_required def gail_generate_expert_data(request):
""" 生成专家数据 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') market, _ = sim_market.SimMarket.objects.get_or_create(id=1) cur_datetime = str(market.datetime) if request.method == 'POST': generate_data_form = forms.GenerateDataFo...
@login_required def gail_main(request): market, _ = sim_market.SimMarket.objects.get_or_create(id=1) cur_datetime = str(market.datetime) context = {'datetime': cur_datetime} return render(request, 'market/gail/gail_main.html', context) @login_required def gail_generate_expert_data(request):
73
73
246
12
61
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
gail_generate_expert_data
gail_generate_expert_data
644
669
644
645
3d261f164ee7a4805f9fe01d923de8b8b01aca8f
bigcode/the-stack
train
792ab746b1dd8d2e4359242b
train
function
def stock_detail(request, stock_id): """ 具体显示股票市场中某支股票的详细信息 """ this_stock = stocks.Stock.objects.get(id=stock_id) ask_info, bid_info = this_stock.get_level5_data() context = {'stock': this_stock, 'level5_ask': ask_info, 'level5_bid': bid_info} return render(request, 'market/stock.html', con...
def stock_detail(request, stock_id):
""" 具体显示股票市场中某支股票的详细信息 """ this_stock = stocks.Stock.objects.get(id=stock_id) ask_info, bid_info = this_stock.get_level5_data() context = {'stock': this_stock, 'level5_ask': ask_info, 'level5_bid': bid_info} return render(request, 'market/stock.html', context)
_stocks(request): """ 在股票市场中显示全部股票 """ all_the_stocks = stocks.Stock.objects.order_by('symbol') context = {'stocks': all_the_stocks} return render(request, 'market/all_stocks.html', context) def stock_detail(request, stock_id):
64
64
92
8
56
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
stock_detail
stock_detail
36
43
36
36
51cbfe3f403e4ce258904301304f20632f408dd6
bigcode/the-stack
train
7453ab6942ff4f3bc2e086f9
train
function
def import_stock_data(symbol, start_date, end_date, interval): import os abs_path = os.path.abspath('utils.py') abs_path = abs_path[:-9] path = os.path.join(abs_path, 'market', 'data', symbol) tb = utils.TickTable(path) data = tb.select(symbol, 10180101093000000, 30191231153000000) num_recor...
def import_stock_data(symbol, start_date, end_date, interval):
import os abs_path = os.path.abspath('utils.py') abs_path = abs_path[:-9] path = os.path.join(abs_path, 'market', 'data', symbol) tb = utils.TickTable(path) data = tb.select(symbol, 10180101093000000, 30191231153000000) num_record = len(data) start_datetime = utils.get_int_from_timestamp...
, superuser_client) sim_stocks.SimStockSlice.objects.all().delete() sim_stocks.SimTradeHistory.objects.all().delete() return HttpResponseRedirect(reverse('market:sim_welcome')) @login_required def simulator_import_stock_data(request): """ 模拟股市导入股票数据 """ if not request.user.is_superuser: ...
256
256
904
14
242
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
import_stock_data
import_stock_data
509
589
509
509
d62deb6e3a012dab04735fd4882be928050cc38f
bigcode/the-stack
train
b494795807d0f7b66ac3f25b
train
function
@login_required def simulator_reset_all(request): """ 重置模拟股市的全部数据(包括导入的) """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') superuser_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user) simulator_reset_handler(request, ...
@login_required def simulator_reset_all(request):
""" 重置模拟股市的全部数据(包括导入的) """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') superuser_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user) simulator_reset_handler(request, superuser_client) sim_stocks.SimStockSlice.obj...
_client.flexible_cash = 100000000 superuser_client.frozen_cash = 0 superuser_client.save() time1 = time.time() print('Simulator Reset, Cost {}s'.format(time1 - time0)) return True @login_required def simulator_reset_all(request):
64
64
117
9
54
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_reset_all
simulator_reset_all
470
481
470
471
81ab2b1eb2cc9771ac410cccbd6466b32efe3b93
bigcode/the-stack
train
4f2ab85912c2016adfedc773
train
function
@login_required def gail_main(request): market, _ = sim_market.SimMarket.objects.get_or_create(id=1) cur_datetime = str(market.datetime) context = {'datetime': cur_datetime} return render(request, 'market/gail/gail_main.html', context)
@login_required def gail_main(request):
market, _ = sim_market.SimMarket.objects.get_or_create(id=1) cur_datetime = str(market.datetime) context = {'datetime': cur_datetime} return render(request, 'market/gail/gail_main.html', context)
elcome')) else: return render(request, 'market/invalid/import_data_failed.html') else: form = forms.AnchorForm() context = {'form': form} return render(request, 'market/simulator/anchor_in_time_point.html', context) @login_required def gail_main(request):
64
64
61
9
55
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
gail_main
gail_main
636
641
636
637
e37088e026c7dc227fb9800f65b8d6ac81aafc33
bigcode/the-stack
train
6a719e8d38bce3d9f269960d
train
function
@login_required def commit_view(request): user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user, name=request.user.username) err_msg = None if request.method == 'POST': form = forms.BidForm(request.POST) if form.is_valid(): bid_stock = form.cleaned_data['...
@login_required def commit_view(request):
user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user, name=request.user.username) err_msg = None if request.method == 'POST': form = forms.BidForm(request.POST) if form.is_valid(): bid_stock = form.cleaned_data['stock_corr'] bid_price = form....
fit = 0 hold.refresh() user_client.profit += hold.profit user_client.save() context = {'client': user_client, 'holding': holding, 'commission': commission, 'transaction': transaction, 'focusing': focusing} return render(request, 'market/my_account.html', context) @login_requir...
76
76
256
8
68
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
commit_view
commit_view
115
143
115
116
306d278f3acf04cabb7443dee6029b0d49ed03aa
bigcode/the-stack
train
180cbcde988a6e17b093ed03
train
function
@login_required def simulator_stock_prev_tick(request, stock_id): """ 显示股票市场中某支股票上一个的tick截面信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market = sim_market.SimMarket.objects....
@login_required def simulator_stock_prev_tick(request, stock_id):
""" 显示股票市场中某支股票上一个的tick截面信息 """ if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_stock = sim_stocks.SimStock.objects.get(id=stock_id) market = sim_market.SimMarket.objects.get(id=2) cur_datetime = market.datetime stock_tick_info =...
5_data() tick_info = stock_tick_info[0] context = {'stock': this_stock, 'info': tick_info, 'level5_ask': ask_info, 'level5_bid': bid_info, 'time': str(cur_datetime)} return render(request, 'market/simulator/v_stock_tick.html', context) @login_required def simulator_stock_prev_tick(request, stock_id):
81
81
270
13
68
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_stock_prev_tick
simulator_stock_prev_tick
305
328
305
306
e19166078a2b2bf588b6e950e3ae4fe998f5c968
bigcode/the-stack
train
685eefbf49e38e517c44f3d1
train
function
def anchor_in_time_point(request): if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') if request.method == 'POST': form = forms.AnchorForm(request.POST) if form.is_valid(): user_client, _ = clients.BaseClient.objects.get_or_create(dr...
def anchor_in_time_point(request):
if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') if request.method == 'POST': form = forms.AnchorForm(request.POST) if form.is_valid(): user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user) simu...
4, b4_v=data_slice.b4_v, a5=data_slice.a5, a5_v=data_slice.a5_v, b5=data_slice.b5, b5_v=data_slice.b5_v, amount=data_slice.amount, volume=data_slice.volume) stick.save() prev_imported_time = cur_datetime # 每导入10条记...
120
120
403
7
112
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
anchor_in_time_point
anchor_in_time_point
592
633
592
592
e9793d886d1c6224e9c4470d91fdeafdb773d767
bigcode/the-stack
train
bc83b94d7d49b56e735271ef
train
function
def all_stocks(request): """ 在股票市场中显示全部股票 """ all_the_stocks = stocks.Stock.objects.order_by('symbol') context = {'stocks': all_the_stocks} return render(request, 'market/all_stocks.html', context)
def all_stocks(request):
""" 在股票市场中显示全部股票 """ all_the_stocks = stocks.Stock.objects.order_by('symbol') context = {'stocks': all_the_stocks} return render(request, 'market/all_stocks.html', context)
commission_handler from .simulator_main import simulator_main_func, anchor_one_stock from .baselines.baselines.gail.dataset.generate_expert_data import generate_expert_data def index(request): """ Main page """ return render(request, 'market/index.html') def all_stocks(request):
64
64
58
6
58
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
all_stocks
all_stocks
27
33
27
27
a84c078c6af3b3edf27e30319afbd92544273ff5
bigcode/the-stack
train
a81cf4f513ef6eea3cadacfe
train
function
@login_required def cancel_view(request): user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user, name=request.user.username) if request.method == 'POST': form = forms.CancelForm(request.POST) if form.is_valid(): cancel = form.cleaned_data['cancel_cms'] ...
@login_required def cancel_view(request):
user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user, name=request.user.username) if request.method == 'POST': form = forms.CancelForm(request.POST) if form.is_valid(): cancel = form.cleaned_data['cancel_cms'] new_commission = CommissionMsg(commi...
, 'market/invalid/invalid_form.html') else: form = forms.BidForm() holding = user_client.holdingelem_set.all() context = {'client': user_client,'form': form, 'holding': holding} return render(request, 'market/user_commit.html', context) @login_required def cancel_view(request):
71
71
239
8
63
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
cancel_view
cancel_view
146
171
146
147
d98a01c67f81cc18cf90562a839bb65cbfe71c90
bigcode/the-stack
train
26227324608381a260394a6e
train
function
@login_required def simulator_welcome(request): """ 模拟股市的欢迎页面,需要超级用户权限 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') num_clients = clients.BaseClient.objects.count() num_v_clients = clients.BaseClient.objects.filte...
@login_required def simulator_welcome(request):
""" 模拟股市的欢迎页面,需要超级用户权限 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') num_clients = clients.BaseClient.objects.count() num_v_clients = clients.BaseClient.objects.filter(driver=None).count() num_stocks = sim_stoc...
_client,'form': form, 'commission': commission} return render(request, 'market/user_cancel.html', context) # 下面的视图用于股市模拟,需要超级用户权限 # 使用虚拟的client,基于真实的股票数据进行模拟 @login_required def simulator_welcome(request):
64
64
189
9
54
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_welcome
simulator_welcome
178
195
178
179
4173f38c2c886448915200d7d878af1b2e700993
bigcode/the-stack
train
0f6b36eab7d4df119097f27a
train
function
@login_required def simulator_client_detail(request, client_id): """ 模拟股市的client信息界面 """ # 只有超级用户才有权限进行查看 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_client = clients.BaseClient.objects.get(id=client_id) holding = sim_clients.Si...
@login_required def simulator_client_detail(request, client_id):
""" 模拟股市的client信息界面 """ # 只有超级用户才有权限进行查看 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') this_client = clients.BaseClient.objects.get(id=client_id) holding = sim_clients.SimHoldingElem.objects.filter(owner=client_id).order_by('stock_symb...
/invalid/invalid_form.html') else: client_form = forms.VClientForm() context = {'v_clients': v_clients, 'client_form': client_form} return render(request, 'market/simulator/all_v_clients.html', context) @login_required def simulator_client_detail(request, client_id):
64
64
214
12
52
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_client_detail
simulator_client_detail
409
429
409
410
7cb885796ada4ca220cc693bd40ba9f57f97735c
bigcode/the-stack
train
55c79169dacd5cc583f2c3a0
train
function
@login_required def account_view(request): user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user, name=request.user.username) holding = clients.HoldingElem.objects.filter(owner=user_client).order_by('stock_symbol') commission = clients.CommissionElem.objects.filter(owner=user_client)...
@login_required def account_view(request):
user_client, _ = clients.BaseClient.objects.get_or_create(driver=request.user, name=request.user.username) holding = clients.HoldingElem.objects.filter(owner=user_client).order_by('stock_symbol') commission = clients.CommissionElem.objects.filter(owner=user_client).order_by('stock_symbol') transaction =...
import timezone time = timezone.now() context = {'user': user, 'user_agent': user_agent, 'num_client': num_client, 'num_stock': num_stock, 'time': time} return render(request, 'market/welcome.html', context) @login_required def account_view(request):
64
64
182
8
56
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
account_view
account_view
97
112
97
98
19a58303d32771d92aefb217675607df5923791e
bigcode/the-stack
train
9074ca2014180a87aee83167
train
function
@login_required def simulator_v_clients(request): """ 模拟股市的主页面 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') v_clients = clients.BaseClient.objects.filter(driver=None) if request.method == 'POST': client_for...
@login_required def simulator_v_clients(request):
""" 模拟股市的主页面 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') v_clients = clients.BaseClient.objects.filter(driver=None) if request.method == 'POST': client_form = forms.VClientForm(request.POST) if cli...
/v_stock_tick.html', context) @login_required def simulator_main(request): """ 模拟股市的主页面 """ # 只有超级用户才有权限进行模拟 if not request.user.is_superuser: return render(request, 'market/invalid/no_permission.html') result = simulator_main_func(request.user) context = {'result': result} ret...
104
104
347
9
95
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
simulator_v_clients
simulator_v_clients
370
406
370
371
3b621d7158c06b81b47a57396786229c14d31429
bigcode/the-stack
train
673820b72c14381902eb8dc1
train
function
def welcome(request): """ 注册或登陆成功的欢迎页面 """ user = request.user user_agent = request.META.get('HTTP_USER_AGENT', 'unknown') num_client = clients.BaseClient.objects.count() num_stock = stocks.Stock.objects.count() from django.utils import timezone time = timezone.now() context = {'...
def welcome(request):
""" 注册或登陆成功的欢迎页面 """ user = request.user user_agent = request.META.get('HTTP_USER_AGENT', 'unknown') num_client = clients.BaseClient.objects.count() num_stock = stocks.Stock.objects.count() from django.utils import timezone time = timezone.now() context = {'user': user, 'user_age...
定向至主页 authenticated_user = authenticate(username=new_user.username, password=request.POST['password1']) login(request, authenticated_user) return HttpResponseRedirect(reverse('market:welcome')) context = {'form': form} return render(request, 'market/register.html', context) ...
64
64
118
4
60
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
welcome
welcome
82
94
82
82
f0d36ac2481fed6c4d97431af56b44e9adddfe52
bigcode/the-stack
train
5ed0042e99ccd6d2e5cf788f
train
function
@login_required def gail_train(request): if request.method == 'POST': gail_train_form = forms.GailTrainForm(request.POST) if gail_train_form.is_valid(): stock_symbol = gail_train_form.cleaned_data['stock_symbol'] seed = gail_train_form.cleaned_data['seed'] task = ...
@login_required def gail_train(request):
if request.method == 'POST': gail_train_form = forms.GailTrainForm(request.POST) if gail_train_form.is_valid(): stock_symbol = gail_train_form.cleaned_data['stock_symbol'] seed = gail_train_form.cleaned_data['seed'] task = gail_train_form.cleaned_data['task'] ...
else: return render(request, 'market/invalid/invalid_form.html') else: generate_data_form = forms.GenerateDataForm() context = {'datetime': cur_datetime, 'generate_data_form': generate_data_form} return render(request, 'market/gail/generate_expert_data.html', context) @login_required ...
74
74
247
9
65
LuoMaimingS/django_virtual_stock_market
market/views.py
Python
gail_train
gail_train
672
695
672
673
3fb7a929003184a953d8ce4e26e648e926e3cbdd
bigcode/the-stack
train