query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Validate that the EC2 instance(s) holding the production web server are running | def test_instance_running(self) -> None:
if self.prod_env:
ec2_name = 'saints-xctf-server-prod-asg'
else:
ec2_name = 'saints-xctf-server-dev-asg'
instances = self.get_ec2(ec2_name)
self.assertTrue(len(instances) > 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instance_not_overscaled(self) -> None:\n if self.prod_env:\n ec2_name = 'saints-xctf-server-prod-asg'\n else:\n ec2_name = 'saints-xctf-server-dev-asg'\n\n instances = self.get_ec2(ec2_name)\n self.assertTrue(len(instances) < 3)",
"def verify_instance_ru... | [
"0.70084226",
"0.6691112",
"0.6481514",
"0.6261631",
"0.62523884",
"0.6162713",
"0.6081752",
"0.6047556",
"0.59907573",
"0.59864587",
"0.5976284",
"0.5945998",
"0.59435093",
"0.5914454",
"0.5893794",
"0.58857274",
"0.5884217",
"0.58677155",
"0.5846041",
"0.5827965",
"0.579056... | 0.7410676 | 0 |
Ensure that there aren't too many EC2 instances running for the production web server | def test_instance_not_overscaled(self) -> None:
if self.prod_env:
ec2_name = 'saints-xctf-server-prod-asg'
else:
ec2_name = 'saints-xctf-server-dev-asg'
instances = self.get_ec2(ec2_name)
self.assertTrue(len(instances) < 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_too_many_cores(self):\n compute1 = self.start_service('compute', host='host1')\n compute2 = self.start_service('compute', host='host2')\n instance_ids1 = []\n instance_ids2 = []\n for index in xrange(FLAGS.max_cores):\n instance_id = self._create_instance()\n ... | [
"0.6280161",
"0.59391683",
"0.59027857",
"0.5894725",
"0.58843917",
"0.5871358",
"0.5835645",
"0.5823603",
"0.5733274",
"0.57295024",
"0.5727804",
"0.5715997",
"0.566455",
"0.55512476",
"0.5452848",
"0.5450341",
"0.54045576",
"0.53864896",
"0.53748494",
"0.5352179",
"0.533273... | 0.7298936 | 0 |
Prove that the instance profile exists for the prod EC2 web server | def test_instance_profile_exists(self) -> None:
self.assertTrue(self.validate_instance_profile('s3-access-role', is_prod=self.prod_env)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_instance_profile(self, role_name: str, is_prod: bool = True):\n if is_prod:\n env = \"prod\"\n else:\n env = \"dev\"\n\n # First get the instance profile resource name from the ec2 instance\n instances = self.get_ec2(f'saints-xctf-server-{env}-asg')\n ... | [
"0.6894565",
"0.67180425",
"0.6643288",
"0.64320534",
"0.6359056",
"0.62219054",
"0.600066",
"0.591194",
"0.58480656",
"0.57825094",
"0.5750481",
"0.57268167",
"0.57260436",
"0.56870514",
"0.56327266",
"0.5623819",
"0.56226015",
"0.56042284",
"0.55913603",
"0.55913264",
"0.55... | 0.81340647 | 0 |
Ensure that the Launch Configuration for a SaintsXCTF web server in production is valid | def test_launch_config_valid(self) -> None:
if self.prod_env:
ec2_name = 'saints-xctf-server-prod-asg'
launch_config_name = 'saints-xctf-server-prod-lc'
instance_profile = 'saints-xctf-prod-instance-profile'
else:
ec2_name = 'saints-xctf-server-dev-asg'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_app_is_production(self):\n self.assertFalse(app.config['DEBUG'])\n self.assertFalse(app.config['TESTING'])",
"def test_launch_config_sg_valid(self):\n if self.prod_env:\n launch_config_name = 'saints-xctf-server-prod-lc'\n launch_config_sg = 'saints-xctf-prod-s... | [
"0.6838075",
"0.62086934",
"0.6170953",
"0.6130534",
"0.60267466",
"0.6022237",
"0.59383035",
"0.589912",
"0.58990014",
"0.5879315",
"0.58528084",
"0.5849046",
"0.58339006",
"0.5783783",
"0.5752801",
"0.5749761",
"0.57421064",
"0.57368237",
"0.5735979",
"0.5708809",
"0.568639... | 0.67045176 | 1 |
Ensure that the security group attached to the launch configuration is as expected | def test_launch_config_sg_valid(self):
if self.prod_env:
launch_config_name = 'saints-xctf-server-prod-lc'
launch_config_sg = 'saints-xctf-prod-server-lc-security-group'
else:
launch_config_name = 'saints-xctf-server-dev-lc'
launch_config_sg = 'saints-xctf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_security_group(self):\n return True",
"def test_break_security_group_failed():",
"def test_break_security_group_usual_case_specify_sg():",
"def prod_load_balancer_sg_valid(self) -> None:\n if self.prod_env:\n sg_name = 'saints-xctf-prod-server-elb-security-group'\n e... | [
"0.7335682",
"0.72298133",
"0.681288",
"0.66234654",
"0.6571226",
"0.6466389",
"0.64513963",
"0.64436626",
"0.63290036",
"0.6233709",
"0.61910903",
"0.61886334",
"0.6080912",
"0.5979866",
"0.5958562",
"0.5905669",
"0.5870705",
"0.57115376",
"0.57027006",
"0.5624756",
"0.56215... | 0.7423223 | 0 |
Ensure that the AutoScaling Group for a SaintsXCTF web server in production is valid | def test_autoscaling_group_valid(self) -> None:
self.assertTrue(self.validate_autoscaling_group(is_prod=self.prod_env)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_autoscaling_group(self, is_prod: bool = True) -> bool:\n if is_prod:\n env = \"prod\"\n else:\n env = \"dev\"\n\n asgs = self.autoscaling.describe_auto_scaling_groups(\n AutoScalingGroupNames=[f'saints-xctf-server-{env}-asg'],\n MaxRecor... | [
"0.74461466",
"0.709041",
"0.66462946",
"0.6620595",
"0.602017",
"0.59300655",
"0.5854016",
"0.57385385",
"0.5700055",
"0.5674477",
"0.56280303",
"0.56230265",
"0.56020445",
"0.55620414",
"0.55301094",
"0.55271995",
"0.55190575",
"0.55176234",
"0.5466169",
"0.5460073",
"0.544... | 0.7404869 | 1 |
Make sure there are no autoscaling schedules in production (the ASG should always be up) | def test_autoscaling_schedules_unset(self) -> None:
if self.prod_env:
schedules = self.autoscaling.describe_scheduled_actions(AutoScalingGroupName='saints-xctf-server-prod-asg')
self.assertTrue(len(schedules.get('ScheduledUpdateGroupActions')) == 0)
else:
self.assertT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instance_not_overscaled(self) -> None:\n if self.prod_env:\n ec2_name = 'saints-xctf-server-prod-asg'\n else:\n ec2_name = 'saints-xctf-server-dev-asg'\n\n instances = self.get_ec2(ec2_name)\n self.assertTrue(len(instances) < 3)",
"def handle_single_asg(... | [
"0.64611644",
"0.6077463",
"0.60593003",
"0.5942397",
"0.57933694",
"0.57816595",
"0.5734097",
"0.56559396",
"0.5655242",
"0.5650104",
"0.56340003",
"0.5622716",
"0.5595818",
"0.5579917",
"0.5562857",
"0.5544261",
"0.550569",
"0.5493324",
"0.54650974",
"0.54541117",
"0.541851... | 0.7037721 | 0 |
Prove that the application load balancer in production is running | def prod_load_balancer_running(self) -> None:
self.assertTrue(self.validate_load_balancer(is_prod=self.prod_env)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def issuer_liveness_check():\n global app_config\n\n if app_config[\"running\"]:\n # return True until we get a shutdown request\n return True\n\n # return True until the work queue is cleared\n return tob_connection_active()",
"def validate_load_balancer(self, is_prod: bool = True) -> ... | [
"0.6503178",
"0.63543564",
"0.63539064",
"0.6274522",
"0.6267101",
"0.60391116",
"0.5958274",
"0.58971715",
"0.58865076",
"0.58741146",
"0.5834471",
"0.58119434",
"0.5810649",
"0.57983667",
"0.57345355",
"0.5695448",
"0.56924754",
"0.56790626",
"0.5663028",
"0.56615275",
"0.5... | 0.7870406 | 0 |
Ensure that the security group attached to the load balancer is as expected | def prod_load_balancer_sg_valid(self) -> None:
if self.prod_env:
sg_name = 'saints-xctf-prod-server-elb-security-group'
else:
sg_name = 'saints-xctf-dev-server-elb-security-group'
response = self.ec2.describe_security_groups(Filters=[
{
'Name'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_security_group(self):\n return True",
"def test_break_security_group_failed():",
"def ensure_security_groups_created(vpc, environment):\n conglomerate_name = environment + '-conglomerate'\n load_balancer_name = environment + '-load-balancer'\n\n existing = vpc.security_groups.filter(F... | [
"0.75372666",
"0.7454231",
"0.732608",
"0.6906471",
"0.68293524",
"0.66852295",
"0.6641212",
"0.6561113",
"0.6488808",
"0.6435735",
"0.6346929",
"0.62816423",
"0.6275387",
"0.6206017",
"0.6194121",
"0.61715746",
"0.6126973",
"0.6077169",
"0.60336405",
"0.60298276",
"0.5930388... | 0.77932215 | 0 |
Get a list of running EC2 instances with a given name | def get_ec2(self, name: str) -> list:
filters = [
{
'Name': 'tag:Name',
'Values': [name]
},
{
'Name': 'instance-state-name',
'Values': ['running']
}
]
return list(self.ec2.instances.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_instances(self):\n print '# AWS EC2 instances'\n self.compute.list_instances()",
"def list_running_instances(self):\n print '# Running AWS EC2 instances'\n self.compute.list_running_instances()",
"def list_instances():\n print(str_sep)\n print(\"Listing EC2 instances ... | [
"0.7886278",
"0.7740352",
"0.75273013",
"0.72322005",
"0.72264236",
"0.7080459",
"0.70581025",
"0.6999213",
"0.69858617",
"0.6945677",
"0.6934355",
"0.6848675",
"0.6840899",
"0.6828031",
"0.6719885",
"0.67122644",
"0.67038614",
"0.66958",
"0.6629787",
"0.6616417",
"0.66151404... | 0.8374668 | 0 |
Validate that the instance profile for an EC2 instance contains the expected role | def validate_instance_profile(self, role_name: str, is_prod: bool = True):
if is_prod:
env = "prod"
else:
env = "dev"
# First get the instance profile resource name from the ec2 instance
instances = self.get_ec2(f'saints-xctf-server-{env}-asg')
instance_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instance_profile_exists(self) -> None:\n self.assertTrue(self.validate_instance_profile('s3-access-role', is_prod=self.prod_env))",
"def test_ec2_iaminstanceprofiles(mock_get_instances, neo4j_session):\n # Arrange\n boto3_session = MagicMock()\n create_test_account(neo4j_session, TEST_AC... | [
"0.748473",
"0.64953846",
"0.6094468",
"0.60904104",
"0.57561445",
"0.57361716",
"0.57139206",
"0.567742",
"0.55771035",
"0.54478556",
"0.54373324",
"0.54003024",
"0.5366104",
"0.53387",
"0.52978635",
"0.5296545",
"0.5281051",
"0.5274092",
"0.5261785",
"0.524521",
"0.52082",
... | 0.7753122 | 0 |
Ensure that the AutoScaling Group for a SaintsXCTF web server in a given environment is valid | def validate_autoscaling_group(self, is_prod: bool = True) -> bool:
if is_prod:
env = "prod"
else:
env = "dev"
asgs = self.autoscaling.describe_auto_scaling_groups(
AutoScalingGroupNames=[f'saints-xctf-server-{env}-asg'],
MaxRecords=1
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_autoscaling_group_valid(self) -> None:\n self.assertTrue(self.validate_autoscaling_group(is_prod=self.prod_env))",
"def prod_load_balancer_sg_valid(self) -> None:\n if self.prod_env:\n sg_name = 'saints-xctf-prod-server-elb-security-group'\n else:\n sg_name = '... | [
"0.72042537",
"0.66541445",
"0.6537455",
"0.6269853",
"0.6075279",
"0.5770872",
"0.5762108",
"0.5724649",
"0.57223004",
"0.5566689",
"0.5534292",
"0.55320007",
"0.54698837",
"0.54166985",
"0.5406743",
"0.54009223",
"0.5394937",
"0.5384789",
"0.53772426",
"0.53679657",
"0.5359... | 0.7165349 | 1 |
Prove that an application load balancer is running by checking its target groups | def validate_load_balancer(self, is_prod: bool = True) -> bool:
if is_prod:
env = "prod"
else:
env = "dev"
response = self.autoscaling.describe_load_balancer_target_groups(
AutoScalingGroupName=f'saints-xctf-server-{env}-asg'
)
load_balancers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gh_226_elasticloadbalancing_v1_and_v2(self):\n results = get_actions_for_service(\"elasticloadbalancing\")\n # print(json.dumps(results, indent=4))\n lb_v1_only_action = \"elasticloadbalancing:CreateTargetGroup\"\n lb_v2_only_action = \"elasticloadbalancing:SetSecurityGroups\"\... | [
"0.6301458",
"0.62787396",
"0.6035134",
"0.5966148",
"0.5916811",
"0.59001195",
"0.5634059",
"0.5576155",
"0.5551739",
"0.5543311",
"0.54996705",
"0.54623556",
"0.54260904",
"0.54065996",
"0.5371752",
"0.53500694",
"0.5331804",
"0.5282278",
"0.5256664",
"0.5218892",
"0.517340... | 0.6517437 | 0 |
Determine if a security group rule which opens connections from a different source security group exists as expected. | def validate_sg_rule_source(self, rule: dict, protocol: str, from_port: int, to_port: int, source_sg: str) -> bool:
return all([
rule.get('IpProtocol') == protocol,
rule.get('FromPort') == from_port,
rule.get('ToPort') == to_port,
rule.get('UserIdGroupPairs')[0].g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def does_grp_rule_exist ( tgt_secgrp, new_secgrp, from_port, to_port = None, protocol = 'tcp' ) :\n from_port = str( from_port ) # Boto stores ports as strings!\n if not to_port :\n to_port = from_port\n else :\n to_port = str( to_port ) # Boto stores ports as strings!\n\n ## Verify that this ... | [
"0.77986133",
"0.6409556",
"0.6406358",
"0.61482143",
"0.6114916",
"0.5786046",
"0.5682224",
"0.56801486",
"0.5655128",
"0.5604419",
"0.5601227",
"0.5566865",
"0.5547236",
"0.5499543",
"0.54568267",
"0.5353741",
"0.53537256",
"0.5330669",
"0.52972037",
"0.5270842",
"0.5233972... | 0.68314135 | 1 |
Will list runs that exist in swestore | def list_runs_in_swestore(path, pattern=RUN_RE, no_ext=False):
try:
status = check_call(['icd', path])
proc = Popen(['ils'], stdout=PIPE)
contents = [c.strip() for c in proc.stdout.readlines()]
runs = [r for r in contents if re.match(pattern, r)]
if no_ext:
runs =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_runs(self):\n pass",
"def runs_list(years, runs):\n\thr_runs = []\n\tfor run in runs:\n\t\tif run[0:4] in years and \"Run\" in run:\n\t\t\tcheck = pc.read_file(\"/Users/mchronert/Desktop/activities/\"+run)\n\t\t\tif \"hr\" in check:\n\t\t\t\thr_runs.append(run)\n\treturn hr_runs",
"def lis... | [
"0.6560191",
"0.64781743",
"0.6364133",
"0.63554263",
"0.62660134",
"0.6144883",
"0.5942393",
"0.5917219",
"0.5896872",
"0.58313376",
"0.58009607",
"0.57942986",
"0.57804334",
"0.5743569",
"0.5728",
"0.57103944",
"0.5673403",
"0.56532174",
"0.56004",
"0.55935156",
"0.55514157... | 0.6682568 | 0 |
Looks for text appearing in a file. | def is_in_file(file_path, text):
with open(file_path, 'r') as f:
content = f.read()
return text in content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_text_in_log_file(self, text) :\n try:\n with open(self.file_path_name, 'r') as searchfile:\n for line in searchfile:\n if text in line:\n return True \n return False \n except: \n print 'Th... | [
"0.7547322",
"0.71939677",
"0.6937726",
"0.6933058",
"0.6851892",
"0.6787831",
"0.65733516",
"0.65669507",
"0.6561423",
"0.6432966",
"0.6376921",
"0.62095785",
"0.6201378",
"0.6136911",
"0.60632163",
"0.60529274",
"0.604333",
"0.60123014",
"0.6006087",
"0.59752154",
"0.596956... | 0.7429515 | 1 |
Looks for fastq files with a hyphen in the sample nsame and turns it in an underscore. | def control_fastq_filename(demux_folder):
pattern=re.compile("^(P[0-9]+)-([0-9]{3,4}).+fastq.*$")
for root, dirs, files in os.walk(demux_folder):
for f in files:
matches=pattern.search(f)
if matches:
new_name=f.replace("{}-{}".format(matches.group(1), matches.grou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fastq_filename(fastq_base):\n return fastq_base+\"_1.fastq\", fastq_base+\"_2.fastq\"",
"def genSamName(fastq):\n return os.path.join(samFolder, os.path.splitext(fastq)[0] + \".sam\")\n # return os.path.join(samFolder, ntpath.split(fastq)[1].replace(\".fastq\", \".sam\"))",
"def scrub_underscore_s... | [
"0.6361795",
"0.6072957",
"0.6065767",
"0.60343707",
"0.59811246",
"0.5887324",
"0.58244926",
"0.58124954",
"0.5791629",
"0.5765793",
"0.5742408",
"0.5726349",
"0.572312",
"0.56187475",
"0.55863035",
"0.55802757",
"0.5579444",
"0.5569306",
"0.55674577",
"0.5560077",
"0.553386... | 0.68632597 | 0 |
Take a network and output a mean IP/ IP thats in the middle of the Network | def ipMinMaxMean(network):
Network=network
# print('Network=' ,Network)
NetAddr=Network.split('/')[0].split('.')
# print('NetAddr= ',NetAddr)
NetMask=int(Network.split('/')[1])
# print('NetMask= ',NetMask, type(NetMask))
binAddr=''
saLen=len(NetAddr)
for j in range(saLen):
te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipMinMaxMean(network):\n Network=network\n print('Network=' ,Network)\n NetAddr=Network.split('/')[0].split('.')\n print('NetAddr= ',NetAddr)\n NetMask=int(Network.split('/')[1])\n print('NetMask= ',NetMask, type(NetMask))\n binAddr=''\n saLen=len(NetAddr)\n for j in range(saLen):\n ... | [
"0.7164685",
"0.6396373",
"0.62586206",
"0.62586206",
"0.62586206",
"0.62586206",
"0.61935306",
"0.60563844",
"0.59797406",
"0.59328294",
"0.58153355",
"0.58084685",
"0.5789701",
"0.5766283",
"0.558018",
"0.55426216",
"0.55159074",
"0.54907185",
"0.546692",
"0.5438191",
"0.54... | 0.7058392 | 1 |
Split a list into parts based on a set of indexes | def partition(alist, indices):
return [alist[i:j] for i, j in zip([0]+indices, indices+[None])] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(array, indexes):\n if isinstance(indexes, int):\n return list(array[0:indexes], array[indexes:])\n\n newarray = []\n offset = 0\n for idx in indexes:\n newarray.append(array[offset:idx])\n offset += idx\n if indexes[-1] < len(array):\n newarray.append(array[inde... | [
"0.69890213",
"0.6807072",
"0.677275",
"0.677275",
"0.6755652",
"0.6721113",
"0.6678109",
"0.66106856",
"0.6585786",
"0.64385384",
"0.6438394",
"0.643007",
"0.63700277",
"0.6337263",
"0.63080686",
"0.6291404",
"0.62714213",
"0.6254273",
"0.62111574",
"0.6197336",
"0.61953783"... | 0.72672635 | 0 |
Execute a function repetedly with a short sleep until it does not raise the error specified in the function. Used to handle async events on site. | def patiently(function, exception_to_catch, exception_to_raise=None, msg="", seconds=15):
if not exception_to_raise:
exception_to_raise = exception_to_catch
attempts = 15
i = 0
print "Execute function %s patiently" % function.__name__
while i < attempts:
try:
return funct... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_fn(*args, **kwargs):\n for delay in delays():\n try:\n return fn(*args, **kwargs)\n except Exception as e: # pylint: disable=broad-except)\n if is_retriable is None:\n continue\n\n ... | [
"0.68716073",
"0.6855326",
"0.68329716",
"0.68206763",
"0.680055",
"0.6724734",
"0.6683692",
"0.6582535",
"0.6556579",
"0.6525358",
"0.6464299",
"0.6447867",
"0.6439185",
"0.64337677",
"0.6431883",
"0.6429444",
"0.640152",
"0.6382389",
"0.63793135",
"0.6301594",
"0.6301094",
... | 0.716191 | 0 |
Pass a list of csv files and merge to DictList | def merge_csv_files(filelist):
data = tables.DictList()
for file_name in filelist:
reader = csv.DictReader(open(file_name))
data += list(reader)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_csv(csv_files):\n results = dict()\n data_all = list()\n keys = set()\n for filename in csv_files:\n data, row_len = load_csv_to_dict(filename)\n keys |= set(data.keys())\n data_all.append((data, row_len))\n for key in keys:\n values = list()\n for value,... | [
"0.67085326",
"0.65995055",
"0.65114456",
"0.6479601",
"0.6382606",
"0.6355147",
"0.6347731",
"0.5945818",
"0.5901265",
"0.5890714",
"0.5845077",
"0.5801467",
"0.5764622",
"0.5742922",
"0.5741666",
"0.5729558",
"0.57209665",
"0.57048273",
"0.5692741",
"0.5691743",
"0.56681573... | 0.8202666 | 0 |
test whether clock increment works correctly | def test__API_increment_clock(self):
self.mock_connection.state = MockConnection.CORRECT_NUM_OF_CONFIRMATIONS
# simulate request
other_time = 10
self.mock_connection.simulate_request_from_other_process(other_time) # time bigger than ours
# add 1 after receiving
# add on... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clock_realtime():\n clock = Clock()\n assert clock.realtime\n old_time = clock.time\n time.sleep(0.1)\n assert clock.time - old_time >= 0.1\n assert clock.time - old_time < 0.2\n clock.update()\n assert clock.time - old_time >= 0.1\n assert clock.time - old_time < 0.2\n time.... | [
"0.72485536",
"0.7177985",
"0.67815006",
"0.6731686",
"0.67307115",
"0.6711901",
"0.6616105",
"0.661602",
"0.6607438",
"0.6426756",
"0.639809",
"0.63282144",
"0.63000846",
"0.6206308",
"0.62060666",
"0.6196815",
"0.6189482",
"0.617125",
"0.613628",
"0.61075693",
"0.6102656",
... | 0.7301365 | 0 |
Tests for ``set_user_ns`` decorator. The functionality of the decorator | def test_set_user_ns_1(tmp_path):
pc_path = copy_default_profile_collection(tmp_path)
create_local_imports_files(pc_path)
patch_first_startup_file(pc_path, patch_code)
nspace = load_profile_collection(pc_path)
assert len(nspace) > 0, "Failed to load the profile collection"
assert "f1" in nspac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_global_user_namespace():\n ns = {\"ab\": 1, \"cd\": 2}\n global_user_namespace.set_user_namespace(user_ns=ns)\n assert global_user_namespace.user_ns == ns\n assert global_user_namespace.use_ipython is False\n\n global_user_namespace.set_user_namespace(user_ns={}, use_ipython=True)\n asse... | [
"0.674577",
"0.5991528",
"0.5780788",
"0.5772976",
"0.5735392",
"0.55862904",
"0.55317456",
"0.54831475",
"0.54707116",
"0.54483175",
"0.5432013",
"0.5426181",
"0.5418364",
"0.538991",
"0.53591555",
"0.5351918",
"0.528349",
"0.52808684",
"0.52754754",
"0.52736235",
"0.526339"... | 0.75073653 | 0 |
Basic test for ``global_user_namespace``. | def test_global_user_namespace():
ns = {"ab": 1, "cd": 2}
global_user_namespace.set_user_namespace(user_ns=ns)
assert global_user_namespace.user_ns == ns
assert global_user_namespace.use_ipython is False
global_user_namespace.set_user_namespace(user_ns={}, use_ipython=True)
assert global_user_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_user_ns_1(tmp_path):\n pc_path = copy_default_profile_collection(tmp_path)\n\n create_local_imports_files(pc_path)\n patch_first_startup_file(pc_path, patch_code)\n\n nspace = load_profile_collection(pc_path)\n assert len(nspace) > 0, \"Failed to load the profile collection\"\n asser... | [
"0.63320553",
"0.623831",
"0.6137258",
"0.61309534",
"0.6048084",
"0.58833367",
"0.576932",
"0.5731475",
"0.57300997",
"0.5600555",
"0.55362535",
"0.54620886",
"0.54299086",
"0.54185516",
"0.5416357",
"0.5410243",
"0.54023975",
"0.53992623",
"0.53955173",
"0.5394267",
"0.5375... | 0.7391939 | 0 |
Creates a new badge and adds it to the db. | def add_badge(name, description, tier, image):
badge = Badge.objects.get_or_create(name=name)[0]
badge.description = description
badge.tier = tier
badge.icon = image
badge.save()
return badge | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_badge(self, *,\n id: str,\n badge_name: str,\n category: str = '',\n resource_type: ResourceType = ResourceType.Table) -> None:\n LOGGER.info(f'New badge {badge_name} for id {id} with category {category} '\n f'and... | [
"0.7376787",
"0.69089484",
"0.61126024",
"0.5885596",
"0.58592856",
"0.5850361",
"0.57408774",
"0.5736687",
"0.567645",
"0.5641444",
"0.5635096",
"0.556025",
"0.5518536",
"0.5501843",
"0.54783165",
"0.5471185",
"0.5471185",
"0.5447197",
"0.54265785",
"0.54152805",
"0.54003876... | 0.77809614 | 0 |
add new subscription and return a substream, ready to be used as an async iterator | async def subscribe(self, subscription: Subscription, reqid: int) -> SubStreamPrivate:
# a simple request response API, unblocking.
# Because subscribe is callable multiple times with the same subdata,
# but this would trigger "already subscribed" error on kraken side
chanpriv = priva... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def substream(self):\n raise NotImplementedError()",
"def subscribe(self):\n pubsub = self.redis_client.pubsub()\n pubsub.subscribe(self.message_channel)\n for item in pubsub.listen():\n if item.get(\"data\") not in (1, None):\n yield item",
"def subscribe(... | [
"0.58740497",
"0.5820188",
"0.5607406",
"0.55882293",
"0.55451345",
"0.5480385",
"0.54753625",
"0.5415702",
"0.5399826",
"0.5337744",
"0.5300106",
"0.5286691",
"0.52813315",
"0.5279592",
"0.5275993",
"0.5257531",
"0.52179664",
"0.52001977",
"0.5179999",
"0.51442945",
"0.51216... | 0.662625 | 0 |
Runs a unique background task to receive messages, even if not explicitly requested by the user | def msgpull():
async def unknown():
async for msg in _privateapi: # required to consume messages...
print(f"Unknown message: {msg}") # TODO : probaby onto some error log somehow...
if msgpull_task is None:
asyncio.get_running_loop().create_task(unknown()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n listen_active_email_channel()",
"def start_background_task(target, *args, **kwargs):\n context.application.socket_io.start_background_task(target, *args, **kwargs)",
"def handle_chat(self):\n while True:\n if self.chat_breakout:\n return\n\n time.s... | [
"0.70231164",
"0.6547362",
"0.64191985",
"0.6376946",
"0.62835056",
"0.6116333",
"0.60420763",
"0.59997994",
"0.5989868",
"0.59836614",
"0.5951939",
"0.5930505",
"0.5930505",
"0.5906824",
"0.59059584",
"0.5892485",
"0.58645743",
"0.58553857",
"0.5849823",
"0.582382",
"0.58082... | 0.65908283 | 1 |
False if self.audit or self.audit_id is set, True otherwise. | def allow_map_to_audit(self):
return self.audit_id is None and self.audit is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audit_only(self) -> bool:\n result = True\n for effect in self.allowed_effects:\n if effect not in [\"disabled\", \"audit\", \"auditifnotexists\"]:\n result = False\n return result",
"def controlled(self):\n if self.crypt_private is not None and self.sign... | [
"0.683113",
"0.6191331",
"0.6014149",
"0.5957627",
"0.59350103",
"0.5918815",
"0.5918815",
"0.5884331",
"0.58457464",
"0.57644427",
"0.5666733",
"0.5666299",
"0.5661693",
"0.56545955",
"0.5641392",
"0.5625657",
"0.5624119",
"0.5619391",
"0.56157696",
"0.56139696",
"0.5597099"... | 0.71672326 | 0 |
Return whether an IAM 'notaction' clause in the given statement applies to the item | def evaluate_notaction_for_permission(statement: Dict, permission: str) -> bool:
if 'notaction' not in statement:
return False
for clause in statement['notaction']:
if evaluate_clause(clause, permission):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_notresource_for_permission(statement: Dict, resource_arn: str) -> bool:\n if 'notresource' not in statement:\n return False\n for clause in statement['notresource']:\n if evaluate_clause(clause, resource_arn):\n return True\n return False",
"def not_met(predicate, r... | [
"0.71349144",
"0.62823075",
"0.58156395",
"0.57648265",
"0.5646848",
"0.5638718",
"0.5627532",
"0.5571176",
"0.5522091",
"0.5504519",
"0.54485404",
"0.537713",
"0.5354285",
"0.53503114",
"0.5340631",
"0.5324317",
"0.532345",
"0.53234124",
"0.5303016",
"0.5289241",
"0.5277319"... | 0.7567711 | 0 |
Return whether an IAM 'action' clause in the given statement applies to the permission | def evaluate_action_for_permission(statement: Dict, permission: str) -> bool:
if 'action' not in statement:
return True
for clause in statement['action']:
if evaluate_clause(clause, permission):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_statements_for_permission(statements: List[Dict], permission: str, resource_arn: str) -> bool:\n allowed = False\n for statement in statements:\n if not evaluate_notaction_for_permission(statement, permission):\n if evaluate_action_for_permission(statement, permission):\n ... | [
"0.7387174",
"0.726337",
"0.67236775",
"0.66013336",
"0.64764035",
"0.6145591",
"0.6142327",
"0.60476136",
"0.6037787",
"0.60010713",
"0.5931356",
"0.592689",
"0.5895413",
"0.58885",
"0.58800983",
"0.58322155",
"0.5760876",
"0.5751259",
"0.57262695",
"0.5684612",
"0.5671168",... | 0.8122944 | 0 |
Return whether the given IAM 'resource' statement applies to the resource_arn | def evaluate_resource_for_permission(statement: Dict, resource_arn: str) -> bool:
if 'resource' not in statement:
return False
for clause in statement['resource']:
if evaluate_clause(clause, resource_arn):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_notresource_for_permission(statement: Dict, resource_arn: str) -> bool:\n if 'notresource' not in statement:\n return False\n for clause in statement['notresource']:\n if evaluate_clause(clause, resource_arn):\n return True\n return False",
"def is_resource_enabled(... | [
"0.7056804",
"0.6716987",
"0.65085953",
"0.6442605",
"0.6422475",
"0.63460433",
"0.6289926",
"0.6214411",
"0.6165086",
"0.60205245",
"0.59933305",
"0.5989941",
"0.59271866",
"0.591511",
"0.58911467",
"0.58162504",
"0.5785422",
"0.5768864",
"0.5767793",
"0.57417554",
"0.572454... | 0.82477206 | 0 |
Return whether an IAM 'notresource' clause in the given statement applies to the resource_arn | def evaluate_notresource_for_permission(statement: Dict, resource_arn: str) -> bool:
if 'notresource' not in statement:
return False
for clause in statement['notresource']:
if evaluate_clause(clause, resource_arn):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_resource_for_permission(statement: Dict, resource_arn: str) -> bool:\n if 'resource' not in statement:\n return False\n for clause in statement['resource']:\n if evaluate_clause(clause, resource_arn):\n return True\n return False",
"def evaluate_notaction_for_permis... | [
"0.6598029",
"0.6349655",
"0.603533",
"0.5746438",
"0.57433146",
"0.55868155",
"0.5301468",
"0.5301468",
"0.52687454",
"0.5237731",
"0.5198726",
"0.51573354",
"0.51499605",
"0.5138109",
"0.5118903",
"0.5093517",
"0.5045479",
"0.5012309",
"0.4994386",
"0.49926805",
"0.49651393... | 0.8767449 | 0 |
Evaluate an entire statement for a specific permission against a resource | def evaluate_statements_for_permission(statements: List[Dict], permission: str, resource_arn: str) -> bool:
allowed = False
for statement in statements:
if not evaluate_notaction_for_permission(statement, permission):
if evaluate_action_for_permission(statement, permission):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_resource_for_permission(statement: Dict, resource_arn: str) -> bool:\n if 'resource' not in statement:\n return False\n for clause in statement['resource']:\n if evaluate_clause(clause, resource_arn):\n return True\n return False",
"def evaluate_action_for_permissio... | [
"0.7527101",
"0.6988031",
"0.6357526",
"0.6073271",
"0.5821523",
"0.5734088",
"0.5682788",
"0.54415005",
"0.5331309",
"0.52812827",
"0.5265164",
"0.51425403",
"0.51074207",
"0.50988454",
"0.50795054",
"0.5056322",
"0.5056015",
"0.5046082",
"0.50343955",
"0.5022899",
"0.501803... | 0.70676386 | 1 |
Evaluates an entire policy for specific permissions to a resource. AWS Policy evaluation reference | def evaluate_policy_for_permissions(
statements: List[Dict], permissions: List[str], resource_arn: str,
) -> Tuple[bool, bool]:
allow_statements = [s for s in statements if s["effect"] == "Allow"]
deny_statements = [s for s in statements if s["effect"] == "Deny"]
for permission in permissions:
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_resource_for_permission(statement: Dict, resource_arn: str) -> bool:\n if 'resource' not in statement:\n return False\n for clause in statement['resource']:\n if evaluate_clause(clause, resource_arn):\n return True\n return False",
"def principal_allowed_on_resource... | [
"0.68860245",
"0.6792301",
"0.63797516",
"0.62786245",
"0.62081486",
"0.6014454",
"0.5869392",
"0.5645835",
"0.5623886",
"0.56131667",
"0.55435914",
"0.5525851",
"0.55254596",
"0.55254596",
"0.5521915",
"0.55133724",
"0.55113566",
"0.5480533",
"0.5442626",
"0.5359772",
"0.534... | 0.7221172 | 0 |
Evaluates an enture set of policies for a specific resource for a specific permission. | def principal_allowed_on_resource(policies: Dict, resource_arn: str, permissions: List[str]) -> bool:
if not isinstance(permissions, list):
raise ValueError("permissions is not a list")
granted = False
for _, statements in policies.items():
allowed, explicit_deny = evaluate_policy_for_permis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_policy_for_permissions(\n statements: List[Dict], permissions: List[str], resource_arn: str,\n) -> Tuple[bool, bool]:\n allow_statements = [s for s in statements if s[\"effect\"] == \"Allow\"]\n deny_statements = [s for s in statements if s[\"effect\"] == \"Deny\"]\n for permission in perm... | [
"0.6582711",
"0.6217248",
"0.60956913",
"0.6047665",
"0.5957934",
"0.5920563",
"0.5823205",
"0.57583994",
"0.56579655",
"0.56495506",
"0.5622994",
"0.56135774",
"0.5584308",
"0.55549896",
"0.555429",
"0.55107427",
"0.5504304",
"0.5488254",
"0.5473531",
"0.544209",
"0.54064786... | 0.63673544 | 1 |
Convert a fits image to .pl file for IRAF Useful for feeding a object mask image to ELLIPSE | def fits_to_pl( in_image, out_image=None ):
try:
if out_image is None:
input_ext = os.path.splitext( in_image )[1]
out_image = in_image.replace( input_ext, '.pl' )
"""
Delete the old file, if existed
"""
if os.path.exists( out_image ):
os.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n print(\"Program version: 1.5\")\n StartTime = datetime.now()\n args = parseArguments()\n\n verbose = args.verbose\n images = args.images\n ignore_warnings = args.ignore_warnings\n if(args.silent):\n verbose = False\n images = False\n ignore_warnings = True\n\... | [
"0.6186718",
"0.61574835",
"0.6052742",
"0.5750088",
"0.56398576",
"0.5576728",
"0.5511031",
"0.5500834",
"0.54728204",
"0.54726917",
"0.54721683",
"0.5470239",
"0.54677904",
"0.5458218",
"0.54469746",
"0.5443921",
"0.54384667",
"0.54336995",
"0.54290426",
"0.5419338",
"0.541... | 0.672992 | 0 |
Convert the IRAF binary table to ASCII table Using IRAF.TABLES.TTOOLS.TDUMP | def bin_to_asc( in_table, out_table=None, cdfile=None, pfile=None ):
try:
if out_table is None:
input_ext = os.path.splitext( in_table )[1]
out_table = in_table.replace( input_ext, '.asc' )
"""
Delete the old table, if existed
"""
if os.path.exists( ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truthtable(self):\n table = []\n for i in xrange(self.length):\n inputs = []\n binary = bin(i).lstrip('0b')\n for i in xrange(len(binary)):\n inputs.append(int(binary[i]))\n inputs.append(1)\n table.append(self.compute(inputs))... | [
"0.58981043",
"0.58801335",
"0.568338",
"0.5664132",
"0.5549975",
"0.55225205",
"0.54848814",
"0.5451924",
"0.5414104",
"0.5389989",
"0.5312993",
"0.528425",
"0.52157587",
"0.5207305",
"0.5186406",
"0.51778567",
"0.51277167",
"0.511725",
"0.51071787",
"0.50962913",
"0.5090786... | 0.59254134 | 0 |
Parse the output binary table from IRAF.ELLIPSE NaN The string to replace INDEF in the output table scale Pixel scale in unit of arcsec/pixel to convert the value of radius from pixel to arcse magzpt Magnitude zeropoint to convert intensity into magnitude | def parse_ellipse_out( bin_table, NaN='NaN', scale=None, magzpt=None ):
if os.path.exists( bin_table ):
asc_tab = bin_to_asc( bin_table)
""" Replace the INDEF with NaN """
NaN = str( NaN )
os.system( 'sed -i "s/INDEF/' + NaN + '/g" ' + asc_tab )
""" Read in the table using As... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseSpineXout(ofname):\n# 0 1 2 3 4 5 6 7 8 9 10 11 12\n# # index AA SS phi1 psi1 P_E P_C P_H phi0 psi0 ASA S_pk S_SS pk_phi pk_psi pkc_phi pkc_... | [
"0.5213926",
"0.52069825",
"0.51487404",
"0.5116344",
"0.5060955",
"0.5001436",
"0.49973103",
"0.49785048",
"0.49725154",
"0.49473506",
"0.48894623",
"0.48808664",
"0.48765177",
"0.48653308",
"0.48118803",
"0.47740927",
"0.47670555",
"0.47439584",
"0.47203106",
"0.4691416",
"... | 0.6968367 | 0 |
Test case for deleteorganizations_item | def test_deleteorganizations_item(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_organization(self):\n pass",
"def test_delete_item_using_delete(self):\n pass",
"def test_putorganizations_item(self):\n pass",
"def test_delete_admin_from_org(self):\n pass",
"def test_vault_delete_vault_item(self):\n pass",
"def test_getorganizations_i... | [
"0.8198734",
"0.7724268",
"0.7436424",
"0.7395154",
"0.71516806",
"0.71390104",
"0.7136497",
"0.71017224",
"0.7040363",
"0.7020919",
"0.695006",
"0.6927405",
"0.6834146",
"0.68265617",
"0.6823365",
"0.6783197",
"0.6753148",
"0.673214",
"0.6704223",
"0.6701983",
"0.670061",
... | 0.9542995 | 0 |
Test case for getorganizations_item | def test_getorganizations_item(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_l_organizations(self):\n pass",
"def test_get_organization(self):\n pass",
"def test_organizations_list(self):\n pass",
"def test_putorganizations_item(self):\n pass",
"def test_retrieve_l_organization(self):\n pass",
"def test_organizations_read(self)... | [
"0.7989642",
"0.7752838",
"0.7693435",
"0.76342416",
"0.7624298",
"0.7621926",
"0.75099355",
"0.7125035",
"0.70932245",
"0.67811453",
"0.67526287",
"0.673138",
"0.6653035",
"0.6647264",
"0.6601137",
"0.65505487",
"0.6501515",
"0.6433913",
"0.6422868",
"0.6244029",
"0.6225316"... | 0.94699186 | 0 |
Test case for getorgs | def test_getorgs(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_l_organizations(self):\n pass",
"def test_get_organization(self):\n pass",
"def test_retrieve_l_organization(self):\n pass",
"def test_organizations_list(self):\n pass",
"def test_getorganizations_item(self):\n pass",
"def test_retrieve_l_organization_... | [
"0.8415889",
"0.8026167",
"0.7976462",
"0.7798647",
"0.7568265",
"0.7532433",
"0.75208676",
"0.74948263",
"0.7408879",
"0.74088603",
"0.7338776",
"0.7147756",
"0.70154226",
"0.693396",
"0.6816699",
"0.6758112",
"0.6734042",
"0.6708021",
"0.6650987",
"0.66461354",
"0.66395265"... | 0.9382936 | 0 |
Test case for patchorganizations_item | def test_patchorganizations_item(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_putorganizations_item(self):\n pass",
"def test_deleteorganizations_item(self):\n pass",
"def test_getorganizations_item(self):\n pass",
"def test_patchhardwares_item(self):\n pass",
"def test_resuableitem_submit_changerequest_private(self):\n # add a second refe... | [
"0.78514796",
"0.72950554",
"0.7125334",
"0.6937784",
"0.67738825",
"0.67511046",
"0.6672842",
"0.66220677",
"0.65709776",
"0.65671235",
"0.6552505",
"0.65069586",
"0.6506685",
"0.64660966",
"0.6426618",
"0.64080006",
"0.6404411",
"0.6369542",
"0.63634783",
"0.6363367",
"0.63... | 0.94896746 | 0 |
Test case for postorgs | def test_postorgs(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_organizations_post(self):\n pass",
"def test_getorgs(self):\n pass",
"def test_add_organization(self):\n pass",
"def test_organizations_list(self):\n pass",
"def test_retrieve_l_organizations(self):\n pass",
"def test_get_organization(self):\n pas... | [
"0.7542364",
"0.73203605",
"0.6910247",
"0.68333644",
"0.66764855",
"0.6631782",
"0.66268706",
"0.65373695",
"0.65234315",
"0.6479839",
"0.64526355",
"0.6352376",
"0.63260144",
"0.6195135",
"0.6194825",
"0.61926144",
"0.6189838",
"0.6161529",
"0.6156081",
"0.6116248",
"0.6088... | 0.93601644 | 0 |
Test case for putorganizations_item | def test_putorganizations_item(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_patchorganizations_item(self):\n pass",
"def test_deleteorganizations_item(self):\n pass",
"def test_getorganizations_item(self):\n pass",
"def test_add_organization(self):\n pass",
"def test_put_list_new(self):\n for org in Organization.objects.all():\n ... | [
"0.8115033",
"0.7666503",
"0.76288176",
"0.7346229",
"0.71280277",
"0.7100913",
"0.7081201",
"0.70357925",
"0.6991379",
"0.6901047",
"0.67626506",
"0.6728538",
"0.6708153",
"0.66687196",
"0.6633642",
"0.65567356",
"0.6548972",
"0.6486448",
"0.6437029",
"0.6432886",
"0.6418944... | 0.9489743 | 0 |
Get all the joints state | def get_all_joint_states(self) -> Tuple[List[float], List[float], List[str]]:
rospy.wait_for_service('/' + self.model_name + '/get_all_joint_states', timeout=2.0)
try:
resp = self.__get_all_joint_states()
except rospy.ServiceException as e:
print('Service did not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_joint_states(self, joints: List[str]) -> Tuple[List[float], List[float], List[str]]:\n assert all([j in self.joints.names for j in joints]), 'All joints requested must be in self.joints'\n \n rospy.wait_for_service('/' + self.model_name + '/get_joint_states', timeout=2.0)\n try:... | [
"0.67613924",
"0.66031986",
"0.64427465",
"0.6278781",
"0.6242687",
"0.6240864",
"0.62150246",
"0.61394346",
"0.6100671",
"0.600261",
"0.5992329",
"0.5973555",
"0.5953255",
"0.5936754",
"0.591872",
"0.5896578",
"0.58771694",
"0.58568627",
"0.58568627",
"0.58389115",
"0.582998... | 0.74538213 | 0 |
Get the state of the specified joints | def get_joint_states(self, joints: List[str]) -> Tuple[List[float], List[float], List[str]]:
assert all([j in self.joints.names for j in joints]), 'All joints requested must be in self.joints'
rospy.wait_for_service('/' + self.model_name + '/get_joint_states', timeout=2.0)
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_joint_state_msg(self):\n \n js_msg = JointState()\n js_msg.header.stamp = rospy.Time.now()\n \n if self.joint_names == []:\n self.joint_names = [\"{}.{}\".format('hand', attr) \n for attr in ORI_ATTRIBUTES] + \\\n [\"{}.{}.{}\".f... | [
"0.65744746",
"0.6563551",
"0.6209341",
"0.59463084",
"0.58364886",
"0.577522",
"0.5764159",
"0.57618934",
"0.5717721",
"0.5680723",
"0.5617732",
"0.5592609",
"0.5579538",
"0.55668944",
"0.5549132",
"0.5486777",
"0.5462116",
"0.54555523",
"0.5442965",
"0.54414564",
"0.5437693... | 0.7277138 | 0 |
Get collision for every model link | def get_collisions(self) -> Tuple[bool, int]:
colliding_links = 0
collision = False
for link in self.links:
rospy.wait_for_service('/' + self.model_name + '/' + link + '/collision', timeout=2.0)
try:
resp = self._get_collision[link]()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _collide(self):\n\n collisions = self._get_collisions()\n for collision in collisions:\n self._update_excitation(collision)\n atom1 = self.atoms[collision[0]]\n atom2 = self.atoms[collision[1]]\n\n r = atom1.pos-atom2.pos\n r_mag = np.linalg.... | [
"0.6548894",
"0.64435226",
"0.6398198",
"0.6390239",
"0.6088465",
"0.59198517",
"0.5787814",
"0.57877916",
"0.5758066",
"0.57349205",
"0.5711774",
"0.56984097",
"0.5685866",
"0.56565905",
"0.565161",
"0.564505",
"0.5627261",
"0.56111765",
"0.55933595",
"0.5578683",
"0.5563146... | 0.6535112 | 1 |
Service to set brakes on all joints | def brake_all_joints(self, brake: bool) -> NoReturn:
assert type(brake) is bool, 'Brake command must be a bool'
assert self.joints.dof > 0, 'self.dof must be > 0'
rospy.wait_for_service('/' + self.model_name + '/brake_all', timeout=2.0)
try:
self.__brake_all_joints(brake)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setBrake(self, brake):\r\n if brake < 0.0:\r\n brake = 0.0\r\n elif brake > 1.0:\r\n brake = 1.0\r\n brake *= self.maxBrake\r\n for tire in self.tires:\r\n if tire.brake:\r\n tire.shape.setBrakeTorque( brake )",
"def brake_joints(sel... | [
"0.7022132",
"0.6534931",
"0.5609246",
"0.54615265",
"0.54114217",
"0.5407457",
"0.53842396",
"0.537649",
"0.5359809",
"0.53323627",
"0.53127414",
"0.53074205",
"0.527879",
"0.52752197",
"0.52724713",
"0.5263314",
"0.5258129",
"0.5243225",
"0.52258545",
"0.52097386",
"0.52078... | 0.71012634 | 0 |
Set brakes for a set of joints | def brake_joints(self, brake: bool, joints: List[str]) -> NoReturn:
assert type(brake) is bool, 'Brake command must be a bool'
assert type(joints) is list, 'joints must be a list of string'
for j in joints:
assert j in self.joints.names, '%r is not a joint of %r' % (j, self.model_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setBrake(self, brake):\r\n if brake < 0.0:\r\n brake = 0.0\r\n elif brake > 1.0:\r\n brake = 1.0\r\n brake *= self.maxBrake\r\n for tire in self.tires:\r\n if tire.brake:\r\n tire.shape.setBrakeTorque( brake )",
"def brake_all_joints... | [
"0.69019246",
"0.6591254",
"0.6264404",
"0.590139",
"0.5870957",
"0.55239546",
"0.54758734",
"0.54699343",
"0.5390965",
"0.537638",
"0.53234",
"0.5273478",
"0.51561725",
"0.5142489",
"0.51422495",
"0.51308835",
"0.50983626",
"0.5052775",
"0.5050359",
"0.5049509",
"0.5037017",... | 0.68095434 | 1 |
Set the collision mode for the link specified, it should be used only to set non standard collision mode i.e. all modes except from 'all' | def set_links_collision_mode(self, links: List[str], mode: List[str]) -> NoReturn:
assert type(links) is list, 'links must be a list'
assert type(mode) is list, 'mode must be a list'
assert len(links) == len(mode), 'links and mode must have the same length'
for l in links:
as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_links_collision_mode_to_init(self) -> NoReturn:\n self.set_links_collision_mode(links=self.non_default_collision_link,\n mode=self.collision_links_mode)",
"def _setmode(self, mode=None):\n if mode is None:\n return self._mode\n if mode ... | [
"0.715904",
"0.5662587",
"0.53435427",
"0.5267811",
"0.5257017",
"0.52147937",
"0.5198394",
"0.51309717",
"0.50457925",
"0.5041766",
"0.5030394",
"0.50094277",
"0.50066227",
"0.49788517",
"0.496495",
"0.49621385",
"0.49336493",
"0.49218684",
"0.49004185",
"0.48573214",
"0.485... | 0.7344594 | 0 |
Set to all non default collision link to mode specified in in init | def set_links_collision_mode_to_init(self) -> NoReturn:
self.set_links_collision_mode(links=self.non_default_collision_link,
mode=self.collision_links_mode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_links_collision_mode(self, links: List[str], mode: List[str]) -> NoReturn:\n assert type(links) is list, 'links must be a list'\n assert type(mode) is list, 'mode must be a list'\n assert len(links) == len(mode), 'links and mode must have the same length'\n for l in links:\n ... | [
"0.6881462",
"0.6481515",
"0.5870258",
"0.58672875",
"0.5819545",
"0.5640785",
"0.5476465",
"0.54644924",
"0.5390656",
"0.53839153",
"0.53818333",
"0.53769135",
"0.53614146",
"0.5344152",
"0.5281354",
"0.52516484",
"0.52478814",
"0.5209679",
"0.51991206",
"0.51926774",
"0.517... | 0.79844815 | 0 |
Updates the zoomed plot to match the region set in the primary graph | def update_zoom_plot(self):
self.plot_zoom.setXRange(*self.linear_region.getRegion(), padding=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_zoom_region(self):\n self.linear_region.setRegion(self.plot_zoom.getViewBox().viewRange()[0])",
"def update_plots_using_region(self):\n self.frequency_plot_graph.setXRange(\n *self.linear_region.getRegion(), padding=0)\n self.resistance_graph.setXRange(\n *se... | [
"0.790381",
"0.7520724",
"0.7488714",
"0.6844032",
"0.67129993",
"0.67029494",
"0.6649298",
"0.6641762",
"0.6503898",
"0.6481953",
"0.63945895",
"0.63889146",
"0.6358034",
"0.6314915",
"0.6295211",
"0.6102786",
"0.6099367",
"0.6096052",
"0.6068913",
"0.6041583",
"0.6040947",
... | 0.80907273 | 0 |
Updates the zoom region in the primary graph to match the area of the zoomed graph | def update_zoom_region(self):
self.linear_region.setRegion(self.plot_zoom.getViewBox().viewRange()[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_zoom_plot(self):\n self.plot_zoom.setXRange(*self.linear_region.getRegion(), padding=0)",
"def apply_zoom(self):\n self.maparea.setTransform(self.zoom_levels[self.cur_zoom][1])\n self.scene.draw_visible_area()",
"def update_simulate_plot(self):\n a = self.plot_zoom.getVie... | [
"0.8165253",
"0.7731067",
"0.6901438",
"0.6818132",
"0.6765265",
"0.67287916",
"0.6694868",
"0.660221",
"0.65830684",
"0.65610045",
"0.6557693",
"0.6546722",
"0.6535164",
"0.6516308",
"0.64867926",
"0.64297104",
"0.6377508",
"0.6339373",
"0.6334652",
"0.629731",
"0.6259234",
... | 0.83144236 | 0 |
Updates the simulation plot view to match that of the zoomed signal | def update_simulate_plot(self):
a = self.plot_zoom.getViewBox().viewRange()
self.plot_simulate.setXRange(a[0][0], a[0][1])
self.plot_simulate.setYRange(a[1][0], a[1][1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_zoom_plot(self):\n self.plot_zoom.setXRange(*self.linear_region.getRegion(), padding=0)",
"def update_plot():\n pass",
"def updatePlot(self,*args):\n # set x limits\n timeDisplayOptions = {'10 minutes':10,'1 hour':60,'6 hours':6*60,'24 hours':24*60,'All':0}\n try:\... | [
"0.7215096",
"0.68219435",
"0.67608243",
"0.6681393",
"0.6674071",
"0.64707494",
"0.6335788",
"0.6268798",
"0.6241539",
"0.622368",
"0.6218841",
"0.6218841",
"0.6218841",
"0.6218841",
"0.6218841",
"0.62077135",
"0.6174366",
"0.6149355",
"0.6145008",
"0.61393875",
"0.6130115",... | 0.8424346 | 0 |
Read the measurements of a folder to Measurement objects in a list. | def read_to_list(folder, start, stop):
measurements = []
for i in range(start, stop+1):
measurements.append(Measurement(folder + str(i) + ".tdms"))
return measurements | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_measurements_to_list(ms, filename='n'):\n m_list = []\n for el in ms:\n # print(\"def all_measurements_to_list 010: \", el)\n for k, v in el.items():\n # print(\"def all_measurements_to_list 020: \", k, v)\n for meas in v:\n m_list.append(k + ',' + m... | [
"0.62958294",
"0.61532193",
"0.6081782",
"0.6004441",
"0.5923364",
"0.5817305",
"0.5675707",
"0.5599779",
"0.5522035",
"0.5497301",
"0.54119706",
"0.53974813",
"0.53969455",
"0.53845155",
"0.5375002",
"0.5367514",
"0.53584516",
"0.534456",
"0.53390217",
"0.5338606",
"0.533405... | 0.80649495 | 0 |
Return a projection of the given record dict | def project(record, selected, pkey_name) -> StateDictInterface:
if selected:
keys = set(selected.keys()) | {pkey_name}
return record.projection(keys)
else:
return record | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_data_from_record(self, record):\n x, y = {}, {}\n for name, tensor in record.items():\n if name in ('start_positions', 'end_positions'):\n y[name] = tensor\n elif name == 'input_ids':\n x['input_word_ids'] = tensor\n elif name == 'segment_ids':\n x['input_type_i... | [
"0.59873754",
"0.5807321",
"0.5787224",
"0.575497",
"0.5635301",
"0.56174535",
"0.55989796",
"0.55033374",
"0.5488253",
"0.54809505",
"0.542868",
"0.5410599",
"0.5405011",
"0.5373182",
"0.5341477",
"0.53229254",
"0.5322777",
"0.53085613",
"0.52830803",
"0.5263654",
"0.5245384... | 0.7254392 | 0 |
Execute callbacks assigned to the query | def execute_callbacks(query, result):
for func in self.callbacks:
func(query, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(self):\n\t\tfor callback in self:\n\t\t\tcallback()",
"def _run_query(self):",
"def execute_query(self, *args, **kwargs):",
"def execute(self):\n return self.callback(*self.args)",
"def _during_execute(self, db):\n pass",
"def _execute(self, db):\n raise NotImplementedErr... | [
"0.75254256",
"0.7316349",
"0.7171953",
"0.66583735",
"0.66164935",
"0.6608934",
"0.65410846",
"0.6448968",
"0.642871",
"0.6410169",
"0.63957924",
"0.63758475",
"0.63555706",
"0.63536066",
"0.6288101",
"0.62644464",
"0.62448263",
"0.6234544",
"0.6205267",
"0.62049365",
"0.619... | 0.84618187 | 0 |
Create a copy of this Query, optionally with a different store instance than this query's self.store. | def copy(self, store: Optional[StoreInterface] = None) -> 'Query':
query = Query(store=store or self.store)
query.selected = {k: v.copy() for k, v in self.selected.items()}
query.predicate = self.predicate.copy()
query.orderings = deepcopy(self.orderings)
query.limit_index = self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n return type(self)(*self.__queries, op=self.__op)",
"def _clone(self):\n c = self.__class__(\n model=self.model,\n query=self.query.chain(),\n using=self._db,\n hints=self._hints,\n )\n c._sticky_filter = self._sticky_filter... | [
"0.7348373",
"0.6757588",
"0.67500645",
"0.6685531",
"0.6333551",
"0.6175301",
"0.61612636",
"0.61032754",
"0.59796643",
"0.5944079",
"0.5938738",
"0.59329224",
"0.5882597",
"0.5845459",
"0.5837441",
"0.5806018",
"0.5794587",
"0.57779443",
"0.57744503",
"0.57643527",
"0.57435... | 0.8707415 | 0 |
Add "where" predicates, like `query.where(user.name == 'John')`. If multiple predicates are supplied, they are composed with a logical conjunction (AND'ed together). | def where(
self,
*predicates: Predicate,
append: bool = True
) -> 'Query':
if not append:
self.predicate = None
if len(predicates) > 1:
predicate = reduce(lambda x, y: x & y, predicates)
else:
predicate = predicates[0]
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def where(self, *wheres, **kw):\n if wheres: # arbitrary expressions\n self._whereskw.update(kw)\n for where in wheres:\n self._wheres.append(where)\n else:\n # plain x=<val> expressions\n self._kw.update(kw)\n return self",
"def fi... | [
"0.69395673",
"0.6290434",
"0.6219483",
"0.61638737",
"0.61431456",
"0.6140414",
"0.6139042",
"0.59944123",
"0.5967697",
"0.59060615",
"0.59006083",
"0.5891042",
"0.58863187",
"0.58809537",
"0.5848669",
"0.5847512",
"0.5832649",
"0.5822333",
"0.5820142",
"0.5784679",
"0.57777... | 0.76379657 | 0 |
Set the initial "page" offset. For example, if the query matches 100 records with an offset of 10, then, `query.execute()` would return | def offset(self, offset: int) -> 'Query':
self.offset_index = max(0, offset)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offset(self, offset: int) -> MongoDBQuerySet:\n\n self.cursor = self.cursor.skip(offset)\n return self",
"def set_limit_offset(query_params, query):\n if query_params.get('limit') is not None:\n query = query.limit(int(request.args.get('limit')))\n else:\n query = query.limi... | [
"0.7237057",
"0.70979255",
"0.6524283",
"0.6250543",
"0.61400276",
"0.61400276",
"0.60654086",
"0.5980085",
"0.5961196",
"0.5885089",
"0.5824514",
"0.5815752",
"0.58137625",
"0.5767151",
"0.5738606",
"0.5725718",
"0.56924313",
"0.56924313",
"0.56924313",
"0.5654263",
"0.56542... | 0.7509971 | 0 |
In this function have given the particles the attribute to collide and and escape a hole within a interval L/4 <xy < 3L/4 when z < 0 | def box_collision_info(self):
position = np.zeros((self.Npart,3)) # antall part, dim, iterasjoner
position[:,:] = np.random.uniform(0,1e-6, size = (self.Npart,3))
velocity = np.zeros((self.Npart,3))
velocity[:,:] = np.random.normal(0,self.sigma,size = (self.Npart,3))
part_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collide(self, pos):\n\t\tpass",
"def _collide(self):\n\n collisions = self._get_collisions()\n for collision in collisions:\n self._update_excitation(collision)\n atom1 = self.atoms[collision[0]]\n atom2 = self.atoms[collision[1]]\n\n r = atom1.pos-at... | [
"0.5934385",
"0.5839628",
"0.5828278",
"0.5701312",
"0.5642691",
"0.5569635",
"0.55619997",
"0.55020034",
"0.54779595",
"0.54418427",
"0.53766894",
"0.53383213",
"0.53170025",
"0.5309063",
"0.5303263",
"0.5301518",
"0.52941495",
"0.5290843",
"0.5287839",
"0.527074",
"0.526694... | 0.62075186 | 0 |
calculates the invidual kinetic energy (by that i mean kinetic energy per particle), and it also calculate the total kinetic energy. | def kinetic_energy(self):
position, velocity, escaped_particles,impact, wall_collision,mom = self.box_collision_info()
for j in xrange(1,self.n):
abs_velocity = np.sqrt(velocity[:,0]**2+velocity[:,1]**2
+ velocity[:,2]**2)
KE = 0.5*self.m*abs_velocity**2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kinetic_energy(self):\r\n return self.mass * np.dot(self.vel, self.vel) / 2",
"def total_KE(particles):\r\n return sum([particle.kinetic_energy() for particle in particles])",
"def compute_energy(self):\n energy = 0.5 * self.masses * np.sum(self.velocities * self.velocities, axis=1)\n ... | [
"0.7840165",
"0.78392464",
"0.7697966",
"0.7653788",
"0.7453591",
"0.7450311",
"0.7371138",
"0.7361925",
"0.7240785",
"0.7234466",
"0.7121707",
"0.70868444",
"0.7017018",
"0.6983611",
"0.69577116",
"0.67083013",
"0.6600157",
"0.65698344",
"0.6559075",
"0.6524509",
"0.6521091"... | 0.84230727 | 0 |
This function calculates the force and acceleration per engine, by using the escaped momentum. | def engine_boost(self):
gamma = 6.67e-11
esc_velocity = np.sqrt((2*gamma*self.home_m*2.0e30)/(self.home_r*10**3))
print esc_velocity
esc_mom, per_force = self.escaped_momentum()
pos, vel,part_esc, impact, part_coll, mom = self.box_collision_info()
rock_vel = []; r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_acceleration(self) -> np.array:\n F = self.calculate_net_force()\n m = self.mass\n a = F / m\n\n return a",
"def updateForces(self):\n for atom1 in range(0, self.numAtoms-1):\n for atom2 in range(atom1+1, self.numAtoms):\n self.calculateF... | [
"0.69132036",
"0.64734775",
"0.6463232",
"0.64139247",
"0.6388521",
"0.63243735",
"0.6289296",
"0.6212004",
"0.61978346",
"0.6171319",
"0.61275834",
"0.6097714",
"0.6066543",
"0.6050113",
"0.60445106",
"0.6041577",
"0.6027513",
"0.6017432",
"0.6007763",
"0.59953505",
"0.59754... | 0.65756285 | 1 |
This function demonstrates how to get the statevector of a register in Forest. | def test_statevector(self):
qubits = QubitPlaceholder.register(3)
program = Program()
program += H(qubits[0])
program += X(qubits[2])
program += CNOT(qubits[0], qubits[1])
measurement = program.declare("ro", "BIT", 3)
for i in range(0, 3):
pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stateVector(self):\n simulator=Aer.get_backend('statevector_simulator')\n result=execute(self.circuit,backend=simulator).result()\n statevector=result.get_statevector(decimals=4) #\"decimals=4\" doesn't work in version 0.20.0 \n return statevector.tolist()",
"def get_vector(self):... | [
"0.70373994",
"0.61248416",
"0.6056065",
"0.60210156",
"0.56724524",
"0.5527871",
"0.5384323",
"0.53625154",
"0.5333524",
"0.5324026",
"0.52926874",
"0.52909285",
"0.5288498",
"0.5288498",
"0.5268385",
"0.5260755",
"0.5257031",
"0.5251272",
"0.5241958",
"0.5236818",
"0.523422... | 0.6247046 | 1 |
Test the situation when scenario is not found. | def test_scenario_not_found(testdir, pytest_params):
testdir.makefile(
".feature",
not_found=textwrap.dedent(
"""\
Feature: Scenario is not found
"""
),
)
testdir.makepyfile(
textwrap.dedent(
"""\
import re
impo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_such_step(self):\n with self.assertRaises(Exception):\n self.run_step('FAKE-STEP.no-exists')",
"def test_find_unit_notfound(self):\r\n url = \"i4x://MITx/999/chapter/notfound\"\r\n with self.assertRaises(tools.DashboardError):\r\n tools.find_unit(self.course... | [
"0.7552852",
"0.724558",
"0.71064776",
"0.69101816",
"0.6812769",
"0.67679614",
"0.67449826",
"0.6726229",
"0.658368",
"0.6548276",
"0.6542335",
"0.65245664",
"0.65075564",
"0.65014774",
"0.64789724",
"0.6474327",
"0.64591765",
"0.6428042",
"0.6419193",
"0.6389983",
"0.636883... | 0.7472041 | 1 |
Test comments inside scenario. | def test_scenario_comments(testdir):
testdir.makefile(
".feature",
comments=textwrap.dedent(
"""\
Feature: Comments
Scenario: Comments
# Comment
Given I have a bar
Scenario: Strings that are not comments... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_like_a_comment(self):\n self.base_test()",
"def test_add_comment(self):\n self.tc_id = \"Ts_018\"\n self.tc_desc = \"Verify the admin is able to add the comment\"\n self.tc_step = \"TC Start\"\n\n comment = commentFeatures(self.driver)\n\n self.tc_step = \"Launc... | [
"0.76344156",
"0.7460493",
"0.7378377",
"0.71012145",
"0.70999604",
"0.69933504",
"0.6973299",
"0.6861677",
"0.68463475",
"0.6838469",
"0.6825161",
"0.6812742",
"0.67890483",
"0.6667358",
"0.6616405",
"0.65218836",
"0.6492777",
"0.6450239",
"0.6384795",
"0.63724214",
"0.63643... | 0.7930772 | 0 |
Return True if `word` can be made from the blocks in `block_collection`. >>> can_make_word("") False >>> can_make_word("a") True >>> can_make_word("bark") True >>> can_make_word("book") False >>> can_make_word("treat") True >>> can_make_word("common") False >>> can_make_word("squad") True >>> can_make_word("coNFused") ... | def can_make_word(word, block_collection=blocks):
if not word:
return False
blocks_remaining = block_collection[:]
for char in word.upper():
for block in blocks_remaining:
if char in block:
blocks_remaining.remove(block)
break
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_make_word(word, letters):\n grouped_chars = group_input(word)\n for char in letters:\n\n if is_empty(grouped_chars):\n return True\n\n if char in grouped_chars and grouped_chars[char] > 0:\n grouped_chars[char] -= 1\n\n return is_empty(grouped_chars)",
"def ch... | [
"0.504671",
"0.4949184",
"0.48825812",
"0.48546275",
"0.48039597",
"0.48035523",
"0.47882596",
"0.4777344",
"0.4777256",
"0.47587782",
"0.47452393",
"0.4731335",
"0.46975198",
"0.46858197",
"0.46858197",
"0.46590525",
"0.46442837",
"0.46177778",
"0.46151608",
"0.46040964",
"0... | 0.7470639 | 0 |
Generate a new folder with folder name fldrname in output_directory. Will create output_directory if it does not exist. If fldrname exists, will generate a folder with a time tag next to it instead. Will always create a folder this way. | def create_folder(output_directory: str, fldrname: str):
os.makedirs(output_directory, exist_ok=True)
tstmp = datetime.now().strftime('%Y%m%d_%H%M%S')
try:
fldr_path = os.path.join(output_directory, fldrname)
os.mkdir(fldr_path)
except FileExistsError:
fldr_path = os.path.join(o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_experiment_folder(path_out, dir_name, name='', stamp_unique=True):\n assert os.path.exists(path_out), 'missing base folder \"%s\"' % path_out\n date = time.gmtime()\n if isinstance(name, str) and name:\n dir_name = '{}_{}'.format(dir_name, name)\n path_exp = os.path.join(path_out, dir... | [
"0.73228276",
"0.73005563",
"0.711051",
"0.7073591",
"0.7072488",
"0.7065514",
"0.69746727",
"0.69063383",
"0.6903372",
"0.68697834",
"0.68643916",
"0.67850506",
"0.6755355",
"0.6753724",
"0.67517734",
"0.6688293",
"0.6669752",
"0.66653377",
"0.6664259",
"0.6658352",
"0.65963... | 0.8578428 | 0 |
node_data is the structured array that will hold the node values. Size will be equal to the number of size=resolution grid cells fit in the quadtree extents. | def _build_node_data_matrix(self, mins: list, maxs: list):
self.mins = mins
self.maxs = maxs
if self.is_vr:
self.node_data = []
else: # calculate MxN shape
size = int((self.maxs[0] - self.mins[0]) / self.min_grid_size)
# cast to float64 to allow us ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data):\n if type(data) != np.ndarray:\n raise TypeError(\"Node input not a numpy array!!!\")\n self.value = data\n self.left = None\n self.right = None\n self.pivot = None",
"def node_data(self):\n return self.node_data_",
"def node_data(s... | [
"0.5916422",
"0.5890055",
"0.5873762",
"0.5739794",
"0.5529232",
"0.5499518",
"0.549892",
"0.54614586",
"0.54296964",
"0.5383283",
"0.531575",
"0.53077525",
"0.53036857",
"0.5270007",
"0.5263625",
"0.5221447",
"0.5205035",
"0.5184451",
"0.5173618",
"0.51377785",
"0.51275915",... | 0.60242605 | 0 |
Return True if QuadTree is variable resolution, i.e. the min grid size/max grid size is a range Returns bool True if VR | def is_vr(self):
if self.max_grid_size:
return self.max_grid_size != self.min_grid_size
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidForSimulation(self):\n for position, myQuad in self.myDesign.quads.iteritems():\n if myQuad.components != {}:\n return 1\n return 0",
"def isVariantOfArea(self, relaxed=False):\n return _libsbml.UnitDefinition_isVariantOfArea(self, relaxed)",
"def isVar... | [
"0.59212124",
"0.58864397",
"0.56516105",
"0.56149465",
"0.56136996",
"0.5612954",
"0.558724",
"0.5586059",
"0.5561641",
"0.5508675",
"0.54817593",
"0.54705447",
"0.5470125",
"0.54664147",
"0.5457126",
"0.54332393",
"0.53966707",
"0.5394665",
"0.53884137",
"0.5378812",
"0.537... | 0.72572124 | 0 |
If parent is None (i.e. this is the entry point to the quad and the data is just now being examined) we ensure that it is a valid xarray/numpy structured array/dask array | def _validate_input_data(self):
if type(self.data) in [np.ndarray, da.Array]:
if not self.data.dtype.names:
raise ValueError('QuadTree: numpy array provided for data, but no names were found, array must be a structured array')
if 'x' not in self.data.dtype.names or 'y' n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_array(self):\n return self._parent_array",
"def _syncDataWithParent(self):\n parent = self.parent()\n if parent is None:\n self._data = None\n else:\n self._data = parent.getData(\n mode=parent.getComplexMode(), copy=False)\n\n if... | [
"0.5891859",
"0.58102167",
"0.56270295",
"0.5524131",
"0.5469869",
"0.54657114",
"0.53787845",
"0.53687394",
"0.5240895",
"0.5237193",
"0.5204248",
"0.52007306",
"0.5146444",
"0.50865686",
"0.5083033",
"0.50438666",
"0.5041268",
"0.50402087",
"0.50232863",
"0.50164866",
"0.50... | 0.61606157 | 0 |
node_data starts out as list of lists, for fast appending when each quad is generated. We finalize to dask for saving, to use the dask save methods and chunking. data is either a dask Array already or a numpy structured array. Convert to dask for the same reasons, if that is needed. | def _finalize_data(self):
if isinstance(self.node_data, np.ndarray): # SR workflow
self.node_data = da.from_array(self.node_data)
elif isinstance(self.node_data, list): # vr workflow
struct_data = np.empty(len(self.node_data), dtype=self.data.dtype)
datavals = np.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _serialize(self, data):\n data = [np.array(j) for j in data]\n self._data_shape_list = [j.shape for j in data]\n serialized_data = [j.ravel() for j in data]\n serialized_data = np.hstack(serialized_data)\n return serialized_data",
"def data_nodes(self):\n data_nodes ... | [
"0.5595843",
"0.5581717",
"0.52978855",
"0.52886397",
"0.52616173",
"0.52559346",
"0.52409625",
"0.5232878",
"0.5228284",
"0.5228284",
"0.5228284",
"0.5228284",
"0.5214635",
"0.52117544",
"0.5202034",
"0.5194422",
"0.519187",
"0.51864123",
"0.51787126",
"0.51784015",
"0.51784... | 0.6608562 | 0 |
Save the QuadTree to one of the tree_method formats and the point data to the data_method format. | def save(self, folderpath, data_method='numpy', tree_method='pickle'):
if self.node_data is not []:
folderpath = create_folder(folderpath, 'grid')
self._finalize_data()
if tree_method == 'pickle':
self._save_tree_pickle(folderpath)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, outputfolder, data_method='numpy', tree_method='pickle'):\n\n if tree_method == 'pickle':\n self._load_tree_pickle(outputfolder)\n else:\n raise ValueError('QuadManager: tree loading method not supported: {}'.format(tree_method))\n\n if data_method == 'nump... | [
"0.58569956",
"0.562188",
"0.5460082",
"0.543926",
"0.54237026",
"0.54020613",
"0.5375346",
"0.5299962",
"0.5277079",
"0.5262705",
"0.52610433",
"0.51803416",
"0.5142071",
"0.5095069",
"0.50614315",
"0.50353676",
"0.50294906",
"0.5027525",
"0.5005638",
"0.4997867",
"0.4987538... | 0.6935446 | 0 |
Load the QuadTree from one of the tree_method formats and the point data/quad data from the data_method format. | def load(self, outputfolder, data_method='numpy', tree_method='pickle'):
if tree_method == 'pickle':
self._load_tree_pickle(outputfolder)
else:
raise ValueError('QuadManager: tree loading method not supported: {}'.format(tree_method))
if data_method == 'numpy':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_input_data(self):\n\n if type(self.data) in [np.ndarray, da.Array]:\n if not self.data.dtype.names:\n raise ValueError('QuadTree: numpy array provided for data, but no names were found, array must be a structured array')\n if 'x' not in self.data.dtype.name... | [
"0.5574936",
"0.53508407",
"0.52323043",
"0.51975876",
"0.51658076",
"0.51397437",
"0.5052742",
"0.5041948",
"0.5028134",
"0.5011028",
"0.4966048",
"0.4956062",
"0.49504423",
"0.49239188",
"0.49036542",
"0.48838806",
"0.4882971",
"0.4867069",
"0.4848743",
"0.48283508",
"0.481... | 0.72040266 | 0 |
Get the layer indicated by the provided layername and trim to the minimum bounding box of real values in the layer. Since the quadtree is going to be built with size = multiple of 128, we might have a great deal of NaNs in the layer (where there is no data) | def get_layer_trimmed(self, layername: str):
lyr = self.get_layer_by_name(layername)
notnan = ~np.isnan(lyr)
rows = np.any(notnan, axis=1)
cols = np.any(notnan, axis=0)
rmin, rmax = np.where(rows)[0][[0, -1]]
cmin, cmax = np.where(cols)[0][[0, -1]]
rmax += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_layer_by_name(self, layername: str):\n\n if self.node_data is not []:\n if layername in list(self.layer_lookup.keys()):\n return np.array(self.node_data[self.layer_lookup[layername]].compute())\n else:\n print('get_layer_by_name: Unable to find {} ... | [
"0.69076043",
"0.579399",
"0.5675716",
"0.5548726",
"0.51090515",
"0.5107964",
"0.50879496",
"0.5054237",
"0.5053175",
"0.50398904",
"0.50355",
"0.49593922",
"0.49539396",
"0.4938403",
"0.49069732",
"0.49069732",
"0.48975444",
"0.48830745",
"0.48658708",
"0.48417482",
"0.4841... | 0.69408715 | 0 |
Return the extents of the whole tree, which is equivalent to the extents of the root quad Returns list [[minx, miny], [maxx, maxy]] | def return_extents(self):
return [qm.tree.mins, qm.tree.maxs] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extents(self):\n x0, y0, width, height = self._rect_bbox\n xmin, xmax = sorted([x0, x0 + width])\n ymin, ymax = sorted([y0, y0 + height])\n return xmin, xmax, ymin, ymax",
"def extents(nodes):\n from numpy import min, max\n return ( min(nodes[:,0]), max(nodes[:,0]),\n ... | [
"0.76802033",
"0.7560967",
"0.7162069",
"0.70367646",
"0.67377853",
"0.6729868",
"0.67229515",
"0.6704645",
"0.66783667",
"0.6619445",
"0.66109544",
"0.6576464",
"0.65682846",
"0.6506094",
"0.648989",
"0.6471995",
"0.64522636",
"0.64171946",
"0.6361858",
"0.63600785",
"0.6341... | 0.8118436 | 0 |
Plotting helper function to distinguish between vr and sr surface plotting | def plot_surface(self, varname):
if self.is_vr:
self._plot_vr_surface(varname)
else:
self._plot_sr_surface(varname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot_sr_surface(self, varname):\n\n fig = plt.figure()\n varname = self.layer_lookup[varname]\n data = self.node_data[varname]\n x_node_loc = np.arange(self.mins[0], self.maxs[0], self.min_grid_size) + self.min_grid_size/2\n y_node_loc = np.arange(self.mins[1], self.maxs[1],... | [
"0.6400208",
"0.6115266",
"0.61043274",
"0.608517",
"0.60793257",
"0.5997312",
"0.5878719",
"0.5871539",
"0.5870153",
"0.58492863",
"0.5842076",
"0.5833267",
"0.58283377",
"0.5820798",
"0.57993525",
"0.5798616",
"0.573833",
"0.5722779",
"0.5715269",
"0.57150674",
"0.570306",
... | 0.73653585 | 0 |
Return the xyz grid values as well as an index for the valid nodes in the surface. z is the gridded result that matches the provided layername | def return_surf_xyz(self, layername: str = 'depth', pcolormesh: bool = True):
if self.is_vr:
raise NotImplementedError("VR surfacing doesn't currently return gridded data arrays yet, have to figure this out")
surf, new_mins, new_maxs = self.get_layer_trimmed(layername)
valid_nodes ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid(self, z, x, y, fields, layer):\n logger.debug(_(\"Render grid %s\") % ((z, x, y),))\n mercator = GlobalMercator(False,self.tilesize,[z])\n return self.render_grid(mercator.tile_bbox((z, x, y)), fields, layer)",
"def NN_z(x, y, con_ver, nbr_ver, cellsize):\n gx, gy, elevNNGrid = interpolate_to_grid... | [
"0.6224236",
"0.6214942",
"0.5944417",
"0.5868027",
"0.57968295",
"0.5749872",
"0.569653",
"0.5693694",
"0.5612211",
"0.55734736",
"0.55710834",
"0.55551183",
"0.55294687",
"0.5494839",
"0.54757816",
"0.5471903",
"0.54555684",
"0.54124737",
"0.53923595",
"0.53918964",
"0.5333... | 0.68853587 | 0 |
Build the regular grid of depth and vertical uncertainty that raster outputs require. Additionally, return the origin/pixel size (geotransform) and the bandnames to display in the raster. If vertical uncertainty is not found, will only return a list of [depth grid] Set all NaN in the dataset given to the provided nodat... | def _gdal_preprocessing(self, nodatavalue: float = 1000000.0, z_positive_up: bool = True,
layer_names: tuple = ('depth', 'vertical_uncertainty')):
if self.is_vr:
raise NotImplementedError("VR surfacing doesn't currently return gridded data arrays yet, have to figure this... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _featgrid(center, value, grid, npts):\n\n # shortcut for th center\n x0, y0, z0 = center\n\n sigma = np.sqrt(1. / 2)\n beta = 0.5 / (sigma**2)\n cutoff = 5. * beta\n\n dd = np.sqrt((grid[0] - x0)**2 +\n (grid[1] - y0)**2 + (grid[2] - z0)**2)\n\n ... | [
"0.59682536",
"0.57182604",
"0.5620845",
"0.56066597",
"0.5515674",
"0.5469108",
"0.542388",
"0.53600496",
"0.5321338",
"0.53026706",
"0.5287692",
"0.52612054",
"0.52317023",
"0.5218054",
"0.5214613",
"0.51503557",
"0.5139683",
"0.5138258",
"0.5136155",
"0.5089323",
"0.508338... | 0.63026583 | 0 |
Export a GDAL generated geotiff to the provided filepath | def _export_geotiff(self, filepath: str, z_positive_up: bool = True):
nodatavalue = 1000000.0
data, geo_transform, bandnames = self._gdal_preprocessing(nodatavalue=nodatavalue, z_positive_up=z_positive_up)
gdal_raster_create(filepath, data, geo_transform, self.crs, nodatavalue=nodatavalue, band... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveAsGeotiff(self, geotiff_fname, overwrite=True, verbose=False):\n if not overwrite and os.path.exists(geotiff_fname):\n raise ValueError('output geotiff already exists:\\n {}'.format(\n geotiff_fname))\n\n if overwrite and os.path.exists(geotiff_fname):\n ... | [
"0.74925894",
"0.6950661",
"0.6592693",
"0.65717083",
"0.64989924",
"0.6466895",
"0.6454929",
"0.6439599",
"0.64197713",
"0.6326096",
"0.6300495",
"0.62182754",
"0.6196158",
"0.6169682",
"0.6152776",
"0.6034093",
"0.59844244",
"0.5969992",
"0.59629756",
"0.59627116",
"0.59511... | 0.76966554 | 0 |
Pickle the QuadManager and QuadTree objects. Leave out the point data and the node_data, as those are going to be saved separately, in a chunked format We clear out the manager reference (refers to self) as we don't need to pickle that, repopulate it on load instead | def _save_tree_pickle(self, folderpath):
if not os.path.exists(folderpath):
raise EnvironmentError('Unable to save pickle file to {}, does not exist'.format(folderpath))
self.tree.manager = None
picklefile = open(os.path.join(folderpath, "grid.pickle"), "wb")
data = {}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, outputfolder, data_method='numpy', tree_method='pickle'):\n\n if tree_method == 'pickle':\n self._load_tree_pickle(outputfolder)\n else:\n raise ValueError('QuadManager: tree loading method not supported: {}'.format(tree_method))\n\n if data_method == 'nump... | [
"0.593135",
"0.5870134",
"0.5693586",
"0.56090236",
"0.5584475",
"0.5477792",
"0.5439398",
"0.54271513",
"0.53973025",
"0.53966904",
"0.53598136",
"0.5351007",
"0.53122836",
"0.5245017",
"0.52391154",
"0.517744",
"0.517256",
"0.51412576",
"0.5140822",
"0.513395",
"0.5128007",... | 0.59448385 | 0 |
So that our grids will line up nicely with each other, we set the origin to the nearest multiple of 128 and adjust the width/height of the quadtree to the nearest power of two. This way when we use powers of two resolution, everything will work out nicely. | def _align_toplevel_grid(self):
# align origin with nearest multple of 128
self.mins[0] -= self.mins[0] % 128
self.mins[1] -= self.mins[1] % 128
width = self.maxs[0] - self.mins[0]
height = self.maxs[1] - self.mins[1]
greatest_dim = max(width, height)
nearest_po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_grid(self):\n\n # option 1: no shared axes. Trees are scaled(?)\n\n\n # option 2: shared axes. Spacing of tree",
"def __init__(self, origin_x=0., origin_y=0., resolution=myRes,\n width=30, height=30):\n self.origin_x = origin_x\n self.origin_y = origin_y\n ... | [
"0.62411135",
"0.6192554",
"0.6177181",
"0.6019692",
"0.60196006",
"0.59201187",
"0.5865663",
"0.57721955",
"0.57071567",
"0.5651169",
"0.56337094",
"0.54712576",
"0.5451549",
"0.541833",
"0.54053915",
"0.5378918",
"0.53617275",
"0.5351873",
"0.5325571",
"0.52978396",
"0.5292... | 0.67340505 | 0 |
Determine the data indices that split the data into four quadrants | def _build_quadrant_indices(self, xval: Union[np.ndarray, da.Array], yval: Union[np.ndarray, da.Array]):
xmin, ymin = self.mins
xmax, ymax = self.maxs
xmid = (0.5 * (xmin + xmax)).astype(xmin.dtype)
ymid = (0.5 * (ymin + ymax)).astype(ymin.dtype)
# split the data into four quad... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def footprint_corner_indices():",
"def get_indices(waves):\n prob_ = np.abs(waves)**2\n # batch\n prob = [np.sum(prob_[i:i+4,:], axis=0) for i in range(0, len(waves[:,0]), 4)]\n prob = np.asarray(prob)\n prob_tot = np.sum(prob, axis=0)\n \n # cutoff\n length = np.size(prob[:,0])\n len1... | [
"0.6446108",
"0.6049301",
"0.60274434",
"0.594658",
"0.5929567",
"0.5884179",
"0.58666277",
"0.5859402",
"0.58380526",
"0.5836715",
"0.58307034",
"0.5795692",
"0.5757703",
"0.57434726",
"0.57388824",
"0.572234",
"0.5705574",
"0.568453",
"0.56451243",
"0.5637832",
"0.5633666",... | 0.6930008 | 0 |
Get the attribute corresponding to attr from all leaves | def get_leaves_attr(self, attr: str):
return [getattr(q, attr) for q in self.leaves] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_attr(self, attr, root=None):\n with self._h5file('r') as h5file:\n if root is None:\n obj = h5file\n else:\n obj = h5file[root]\n return get_decoded(obj.attrs, attr)[attr]",
"def _get_node_attr(self, node, attr):\n return self.... | [
"0.69037783",
"0.68113965",
"0.68011683",
"0.6742704",
"0.66509706",
"0.62171644",
"0.6213443",
"0.6208558",
"0.6163948",
"0.6148756",
"0.60806924",
"0.6068117",
"0.6030441",
"0.5967563",
"0.59623355",
"0.59315515",
"0.59315515",
"0.58916986",
"0.58902794",
"0.58779556",
"0.5... | 0.7731435 | 0 |
Recursively plot an x/y box drawing of the qtree. | def draw_tree(self, ax: plt.Axes = None, tree_depth: int = None, exclude_empty: bool = False,
line_width: int = 1, edge_color='red', plot_nodes: bool = False, plot_points: bool = False):
manager = self.root.manager
manager._finalize_data()
root_quad = self.root
norm =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotTree(self):\n t = self.make(self.tree)\n t.draw()",
"def plot_tree(tree, min_x, max_x, min_y, max_y, prev_node, branch, depth=0):\r\n \r\n cur_node = tree.location # current tree's node\r\n left_branch = tree.left_child # its left branch\r\n right_branch = tree.right_chi... | [
"0.6663919",
"0.62323534",
"0.60558575",
"0.6011418",
"0.58963066",
"0.589021",
"0.573874",
"0.5661747",
"0.5578204",
"0.55717385",
"0.55031794",
"0.54844064",
"0.5436077",
"0.5430804",
"0.54296625",
"0.540878",
"0.538508",
"0.53829783",
"0.53759027",
"0.53748596",
"0.5369170... | 0.6427593 | 1 |
Return a list of siblings for this QuadTree, returns None if this QuadTree has no parent (top level) Returns list list of QuadTree instances for the siblings of this QuadTree | def siblings(self):
if self.parent is None:
return None
siblings = self.parent.children.copy()
siblings.remove(self)
return siblings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def siblings(self, u):\n if u == self.virtual_root:\n return tuple()\n parent = self.parent(u)\n if self.is_root(u):\n parent = self.virtual_root\n if parent != tskit.NULL:\n return tuple(v for v in self.children(parent) if u != v)\n return tuple(... | [
"0.66554505",
"0.64604574",
"0.63861185",
"0.63241917",
"0.631914",
"0.63083327",
"0.63016236",
"0.62375206",
"0.62217236",
"0.62182117",
"0.61727023",
"0.6079254",
"0.60279185",
"0.6015629",
"0.59855485",
"0.5939708",
"0.5919162",
"0.5882864",
"0.5879468",
"0.58642554",
"0.5... | 0.77024865 | 0 |
Return a list of all neighbors for this QuadTree (orthogonal) Returns list list of QuadTrees that are orthogonally adjacent to this QuadTree | def neighbours(self):
neighbours = []
root = self.root
if self == root:
return neighbours
########################
# IMMEDIATELY ADJACENT #
sizes = [self.maxs[0] - self.mins[0], self.maxs[1] - self.mins[1]]
coords = [(self.mins[0] + sizes[0] / 2, sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbours(self):\n seen = set()\n return [l.other(self) for l in self.dovetails \\\n if id(l) not in seen and not seen.add(id(l))]",
"def neighbours_L(self):\n seen = set()\n return [l.other(self) for l in self.dovetails_L \\\n if id(l) not in seen and not seen.add(id(l)... | [
"0.69070774",
"0.6672059",
"0.6541326",
"0.6539021",
"0.6521663",
"0.6521663",
"0.6507441",
"0.64733523",
"0.6458688",
"0.6458688",
"0.64416724",
"0.6341816",
"0.6302468",
"0.62991655",
"0.62931883",
"0.6275906",
"0.62652934",
"0.62225336",
"0.6208394",
"0.6181248",
"0.618098... | 0.70649123 | 0 |
Return the max depth of this QuadTree tree Returns int max depth of tree (a 7 means there are 7 levels to the tree) | def max_tree_depth(self):
depths = np.array([leaf.tree_depth for leaf in self.leaves])
return depths.max() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_depth(self) -> int:\n return pulumi.get(self, \"max_depth\")",
"def get_max_depth(self):\n return self.MAX_DEPTH",
"def max_depth(self) -> int:\n return 0",
"def depth(self):\n return self._max_depth",
"def _max_depth(self):\n max_depth = 0\n for node, data... | [
"0.82715815",
"0.8194223",
"0.80802417",
"0.79431325",
"0.7928423",
"0.76819795",
"0.76308984",
"0.75978315",
"0.7539991",
"0.74760693",
"0.73841053",
"0.7329702",
"0.7324974",
"0.730623",
"0.7282659",
"0.7199515",
"0.7191711",
"0.71864516",
"0.71802247",
"0.71774167",
"0.714... | 0.819653 | 1 |
Return a list of all leaves for the tree that have data Returns list list of QuadTrees | def leaves_with_data(self):
return [lv for lv in self.get_leaves() if lv.index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leaves(self) -> List[RTreeNode[T]]:\n leaves = []\n fn = partial(_append_if_leaf, leaves)\n # noinspection PyTypeChecker\n self.traverse_level_order(fn)\n return leaves",
"def get_leafs(self) -> list:\n return self._leafs[:]",
"def get_leaves(self):\n re... | [
"0.69837725",
"0.69674194",
"0.6954507",
"0.6895389",
"0.68443096",
"0.67743796",
"0.6730984",
"0.66840476",
"0.6643745",
"0.6557427",
"0.65453345",
"0.6485738",
"0.64778954",
"0.6430082",
"0.6429386",
"0.64155",
"0.64146966",
"0.63958883",
"0.63879585",
"0.63872164",
"0.6380... | 0.71947634 | 0 |
Compute song's chromagram and BPM | def compute_chroma_bpm(filepath):
y, sr = librosa.load(filepath)
# Compute chroma features from the harmonic signal
chromagram = librosa.feature.chroma_stft(y=y,sr=sr)
chromaDF = pd.DataFrame(chromagram)
# Filter intensity values less than 1
chromaDF[chromaDF < 1] = 0
chroma_f = chromaDF.sum(axis = 1)
# Cal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_bigram_probability(self, bigram):\n if bigram == (\"START\", \"START\"):\n return 1/2\n num = self.bigramcounts[bigram]\n den = self.unigramcounts[bigram[:1]]\n if den == 0:\n return 1/len(self.unigramcounts)\n\n return num/den",
"def chromagram(si... | [
"0.5780765",
"0.5530341",
"0.55135757",
"0.5506445",
"0.54764473",
"0.5378549",
"0.5318955",
"0.52492714",
"0.52421904",
"0.5220965",
"0.5218749",
"0.5149569",
"0.5139561",
"0.50733656",
"0.5061079",
"0.50502557",
"0.5048618",
"0.50298584",
"0.50246704",
"0.50212073",
"0.5014... | 0.55791336 | 1 |
Calculate chroma bpm distances for every permutation pair; filter pairs with bpm distances that exceeds threshold | def calculate_distances(results_df):
# Perform cartesian join (compare each song to every other song)
results_df['join'] = 1
results_ct = results_df.merge(results_df, on = 'join', how = 'outer')
s1_col = ['C_x', 'Db_x', 'D_x', 'Eb_x', 'E_x', 'F_x', 'Gb_x', 'G_x', 'Ab_x','A_x', 'Bb_x', 'B_x']
s2_col = ['C_y', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findUncertainPairs(field_distances, data_model, bias=0.5):\n\n probability = core.scorePairs(field_distances, data_model)\n\n p_max = (1.0 - bias)\n logger.info(p_max)\n\n informativity = numpy.copy(probability)\n informativity[probability < p_max] /= p_max\n informativity[probability >= p_ma... | [
"0.5514179",
"0.5419576",
"0.53640294",
"0.5352374",
"0.53468573",
"0.513882",
"0.5101431",
"0.5087955",
"0.5046073",
"0.49758437",
"0.49737212",
"0.4948948",
"0.49451643",
"0.49429443",
"0.49386644",
"0.49215853",
"0.4907688",
"0.4906235",
"0.49040017",
"0.48971444",
"0.4894... | 0.5943316 | 0 |
Create a language model based on the Crepe model in Zhang et. al. Creates a model that uses only Convolutional Layers (max pooling in between), and dense layers for prediction tasks. For this model, the final output layer will predict the next character in the sequence. | def build_character_cnn(model_hyperparameters=None, verbose=None):
if model_hyperparameters is None:
model_hyperparameters = _dutils.load_dictionary('model_hyperparameters.json')
'''
Load hyperparameter-specific values from JSON file.
'''
#The size of the characater vocabulary
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_model():\n model = Sequential()\n\n model.add(Lambda(lambda x: x/127.5-1.0, input_shape=INPUT_SHAPE))\n\n # Now we are going to add some Convulation Layers identical to paper\n\n model.add(Conv2D(24, (5, 5), activation='elu', strides=(2, 2)))\n model.add(BatchNormalization()) \n mo... | [
"0.67907363",
"0.67853427",
"0.66978896",
"0.6664061",
"0.6596703",
"0.6590391",
"0.65843797",
"0.6537042",
"0.6521642",
"0.65098804",
"0.6504644",
"0.64829683",
"0.64660394",
"0.64641047",
"0.6429148",
"0.64270455",
"0.6405421",
"0.6403719",
"0.6393534",
"0.6377966",
"0.6366... | 0.6983286 | 0 |
Sets the cytoscape graph elements. | def _set_cyto_graph(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes(self, nodes):\n\n self._nodes = nodes",
"def _set_elements(self, elements):\n self._elements = elements",
"def set_nodes(self, nodes):\n self._drv_nodes = nodes",
"def set_node_positions(self):",
"def _set_element(self,data):\n self._element._labels = [list(data[0]), l... | [
"0.6212544",
"0.62092626",
"0.61086464",
"0.609503",
"0.60833675",
"0.604455",
"0.60164315",
"0.59944093",
"0.5914976",
"0.578059",
"0.5708692",
"0.56698656",
"0.5619934",
"0.56113076",
"0.55065787",
"0.5498848",
"0.54500395",
"0.53961277",
"0.5372013",
"0.53555405",
"0.53082... | 0.7041395 | 0 |
Returns the node size for given node index if the node sizes have been set. | def _get_node_size(self, index):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size_node(node):\n if node is None:\n return 0\n return node.size",
"def get_node_size(self):\n return self._node_size",
"def get_device_size(self, device_index):\n return self.drt_manager.get_size_from_index(device_index)",
"def __get_index_size(self, index, index_id):\n in... | [
"0.69880474",
"0.6498795",
"0.64675134",
"0.63853014",
"0.63140357",
"0.6240018",
"0.6229265",
"0.61306804",
"0.6127098",
"0.60878235",
"0.60878235",
"0.60874915",
"0.6023811",
"0.6014595",
"0.6002804",
"0.5977377",
"0.5965165",
"0.5901819",
"0.5879005",
"0.58528423",
"0.5832... | 0.81598926 | 0 |
Generates the layout for cytoscape. | def _generate_layout(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_cytoscape_layout(layout):\n\n pass",
"def create_layout( self ):",
"def layout(self):\n\n # Initialise all plots and widgets\n widgets = self.widgets(width=200)\n\n plot_width = 500\n sizing_mode = 'stretch_height'\n self.init_grid_plot()\n self.init... | [
"0.73818094",
"0.65796286",
"0.64137465",
"0.6356779",
"0.63012385",
"0.62721467",
"0.6212926",
"0.6168664",
"0.61325115",
"0.5996014",
"0.5995691",
"0.58597904",
"0.57518446",
"0.5746693",
"0.5720134",
"0.57163674",
"0.57051486",
"0.56892204",
"0.56694317",
"0.5612603",
"0.5... | 0.71489936 | 1 |
Assigns the colours to industry or sector groups by creating a dictionary of group name to colour. | def _assign_colours_to_groups(self, groups):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_entity_colors(pairs):\n groups = []\n for a, b in pairs:\n for grp in groups:\n if a in grp or b in grp:\n grp.add(a)\n grp.add(b)\n else:\n groups.append(set([a, b]))\n\n colors = {}\n for grp in groups:\n color = rand... | [
"0.6431674",
"0.6383385",
"0.62992877",
"0.59508806",
"0.5806845",
"0.5766477",
"0.57653433",
"0.5759812",
"0.5688718",
"0.55279016",
"0.54877424",
"0.5471405",
"0.54324853",
"0.5427096",
"0.54066956",
"0.53494245",
"0.5334228",
"0.5330882",
"0.5303143",
"0.5297329",
"0.52928... | 0.7731807 | 0 |
Appends the colour styling to stylesheet for the different groups. | def _style_colours(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assign_colours_to_groups(self, groups):\n\n pass",
"def process_css_group(name, group, output_dir):\n files = group['files']\n\n css = concat(files)\n css_min = cssmin(css)\n\n if not group.has_key(\"plain\") or (group.has_key(\"plain\") and group[\"plain\"]):\n file_data = { 'name... | [
"0.71419656",
"0.5694847",
"0.5677255",
"0.56552434",
"0.5534603",
"0.54808676",
"0.5452689",
"0.53435236",
"0.53394014",
"0.5311847",
"0.5305697",
"0.5270053",
"0.52513975",
"0.52129114",
"0.5205994",
"0.5151232",
"0.5132168",
"0.512927",
"0.51259553",
"0.511462",
"0.5102731... | 0.6724177 | 1 |
Callback function for updating the cytoscape layout. The useful layouts for MST have been included as options (cola, cosebilkent, spread). | def _update_cytoscape_layout(layout):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_layout(self, change=None):\n layout_method = self.layout_method_mapper[self.layout_method]\n if self.layout_method in \"fruchterman_reingold_layout\":\n self.layout = layout_method(\n self.graph,\n k=self.k,\n iterations=self.iteratio... | [
"0.67759144",
"0.642061",
"0.6097314",
"0.60736483",
"0.5882686",
"0.5805108",
"0.563689",
"0.5622119",
"0.5585224",
"0.54286253",
"0.5366763",
"0.5324959",
"0.5324556",
"0.52502626",
"0.52406806",
"0.52406496",
"0.5179321",
"0.51535285",
"0.51522785",
"0.51420105",
"0.512864... | 0.81304747 | 0 |
Returns the Graph Summary statistics. The following statistics are included the number of nodes and edges, smallest and largest edge, average node connectivity, normalised tree length and the average shortest path. | def get_graph_summary(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node_statistics(self):\n return self._network.manager.getNodeStatistics(\n self._network.home_id, self.node_id\n )",
"def RefreshStats(self):\n with self.ctx.Profile(\n 2,\n lambda t: (\n \"Computed stats over \"\n f\"{humanize.BinaryPrefix(stats.graph_... | [
"0.6694576",
"0.6694329",
"0.6672756",
"0.6541843",
"0.646226",
"0.63518786",
"0.6312896",
"0.6294344",
"0.6294277",
"0.62090683",
"0.6191274",
"0.6165328",
"0.6152487",
"0.6073234",
"0.6063577",
"0.6057687",
"0.604776",
"0.6044825",
"0.5997507",
"0.5994373",
"0.59856313",
... | 0.7315786 | 0 |
Callback function for updating decimal places. Updates the elements to modify the rounding of edge values. | def _round_decimals(self, dps):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision_changed(self, new_precision):\n super(PyDMSpinbox, self).precision_changed(new_precision)\n self.setDecimals(self.precision)",
"def rounder(lst, decimals=4):\n\n idx = 0\n for item in lst:\n lst[idx] = round(item, decimals)\n idx += 1",
"def round_series_values(e... | [
"0.58360463",
"0.5709506",
"0.5702389",
"0.5675197",
"0.56292665",
"0.56256354",
"0.55849504",
"0.5360667",
"0.5244893",
"0.52243614",
"0.52222675",
"0.522005",
"0.5184703",
"0.515375",
"0.514757",
"0.51419777",
"0.51419777",
"0.511397",
"0.510382",
"0.50938797",
"0.50911576"... | 0.60911185 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.