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 |
|---|---|---|---|---|---|---|
Fine the point of intersetion of a line and a point Line is given as (x1,y1, x2,y2), point (x,y) | def _line_intersection(self, line, point):
den = euclidean_distance((line[0],line[1]), (line[2],line[3]))
x1, y1, x2, y2 = line[0], line[1], line[2], line[3]
x3, y3 = point[0], point[1]
u = ( ((x3-x1) * (x2-x1)) + ((y3-y1) * (y2-y1)) ) / den
x, y = (x1 + u * (x2-x1)), (y1 + u *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_intercept(p1,p2,p3,p4):\n # Note if vertical line m = None and b holds x-val\n (m1,b1) = line_param(p1,p2)\n (m2,b2) = line_param(p3,p4)\n if (m1 != None) and (m2 != None):\n if (m1-m2) != 0.:\n x = (b2-b1)/(m1-m2)\n y = m1*x + b1\n else:\n return... | [
"0.7547847",
"0.7472181",
"0.7185416",
"0.71675444",
"0.710887",
"0.7107195",
"0.71035105",
"0.7093404",
"0.70183545",
"0.7017182",
"0.70014757",
"0.6994758",
"0.6993493",
"0.6973039",
"0.6964101",
"0.69465834",
"0.69333804",
"0.69283307",
"0.6924636",
"0.69116575",
"0.688791... | 0.75218457 | 1 |
Returns True if 'list1' and 'list2' have at least 1 element in common, False otherwise | def __listsCommon(list1, list2) :
for i in range(len(list1)) :
for j in range(len(list2)) :
if (list1[i]==list2[j]) :
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonempty_intersection(list1, list2):\n return len(list(set(list1) & set(list2))) > 0",
"def common_member(lst1, lst2):\n for i in lst1:\n for j in lst2:\n if i == j:\n return True\n return False",
"def all_in_list (list1, list2):\n return all(map(lambda c: c in li... | [
"0.7992433",
"0.7926499",
"0.7657093",
"0.7554909",
"0.7383712",
"0.7340888",
"0.7207706",
"0.71978486",
"0.7155412",
"0.7120226",
"0.7117233",
"0.71061814",
"0.7007421",
"0.6948971",
"0.6937587",
"0.69196266",
"0.69033265",
"0.6890824",
"0.6881718",
"0.6868015",
"0.6854923",... | 0.85858804 | 0 |
combine different DM actuator commands into single map to send to prop_dm prop_dm needs an input map of n_actuators x n_actuators in units of actuator command height. quick_ao will handle the conversion to actuator command height, and the CDI probe must be scaled in cdip.probe_amp in params in units of m. Each subrouti... | def deformable_mirror(wf, WFS_map, iter, plane_name=None):
# AO Actuator Count from DM Type
if plane_name == 'tweeter' and hasattr('tp','act_tweeter'):
nact = tp.act_tweeter
elif plane_name == 'woofer' and hasattr('tp','act_woofer'):
nact = tp.act_woofer
else:
nact = tp.ao_act
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quick_ao(wf, nact, WFS_map):\n\n nact_across_pupil = nact-2 # number of full DM actuators across pupil (oversizing DM extent)\n # Note: oversample by 2 actuators hardcoded here, check if this is appropriate \n \n ############################\n # Creat... | [
"0.5388792",
"0.5254645",
"0.5087103",
"0.50331646",
"0.4826417",
"0.4798796",
"0.47714773",
"0.47641993",
"0.4763139",
"0.47544935",
"0.47447577",
"0.46802023",
"0.46774086",
"0.46708953",
"0.46417853",
"0.45745838",
"0.4561269",
"0.45490715",
"0.45465413",
"0.45448145",
"0.... | 0.56155765 | 0 |
calculate the offset map to send to the DM from the WFS map The main idea is to apply the DM only to the region of the wavefront that contains the beam. The phase map from the wfs saved the whole wavefront, so that must be cropped. During the wavefront initialization in wavefront.initialize_proper, the beam ratio set i... | def quick_ao(wf, nact, WFS_map):
nact_across_pupil = nact-2 # number of full DM actuators across pupil (oversizing DM extent)
# Note: oversample by 2 actuators hardcoded here, check if this is appropriate
############################
# Creating AO Surf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deformable_mirror(wf, WFS_map, iter, plane_name=None):\n # AO Actuator Count from DM Type\n if plane_name == 'tweeter' and hasattr('tp','act_tweeter'):\n nact = tp.act_tweeter\n elif plane_name == 'woofer' and hasattr('tp','act_woofer'):\n nact = tp.act_woofer\n else:\n nact = ... | [
"0.6485061",
"0.559169",
"0.5315689",
"0.5282786",
"0.52768815",
"0.519825",
"0.5160003",
"0.5143875",
"0.5136089",
"0.511695",
"0.506369",
"0.5052633",
"0.5016512",
"0.50060576",
"0.4977645",
"0.4942742",
"0.49417567",
"0.49369612",
"0.49286658",
"0.49209467",
"0.49072888",
... | 0.65041155 | 0 |
saves the unwrapped phase [arctan2(imag/real)] of the wfo.wf_collection at each wavelength It is an idealized image (exact copy) of the wavefront phase per wavelength. Only the map for the first object (the star) is saved TODO the way this is saved for naming the WFS_map is going to break if you want to do closed loop ... | def open_loop_wfs(wfo):
star_wf = wfo.wf_collection[:, 0]
WFS_map = np.zeros((len(star_wf), sp.grid_size, sp.grid_size))
for iw in range(len(star_wf)):
WFS_map[iw] = unwrap_phase(proper.prop_get_phase(star_wf[iw]))
if 'open_loop_wfs' in sp.save_list or sp.closed_loop:
wfo.save_plane(lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saver(self, index, int_fwm, sim_wind, u, U, P0_p, P0_s, f_p, f_s\n , ro, mode_names, pump_wave='', filename=None, title=None,\n im=0, plots=True):\n\n if filename[:4] != 'port':\n layer = filename[-1]+'/'+filename[:-1]\n else:\n layer = filename\n... | [
"0.56787395",
"0.56739455",
"0.56457245",
"0.56010795",
"0.5593426",
"0.55816233",
"0.55145013",
"0.55001384",
"0.5345378",
"0.533937",
"0.53072387",
"0.5304182",
"0.52795106",
"0.5271391",
"0.5231856",
"0.5229632",
"0.52293843",
"0.5181394",
"0.5172749",
"0.5158705",
"0.5153... | 0.69103086 | 0 |
Unit tests for the coding_strand_to_AA function | def coding_strand_to_AA_unit_tests():
print "input: GTTGACAGTACGTACAGGGAA, "+"output: "+coding_strand_to_AA("GTTGACAGTACGTACAGGGAA")+", actual output: VDSTYRE"
print "input: TTATTGCTTATTATCATG, "+"output: "+coding_strand_to_AA("TTATTGCTTATTATCATG")+", actual output: LLLIIM"
print "input: TTTTTAATTATGGTTTCTC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coding_strand_to_AA_unit_tests():\n input_a='ATTATTATT'\n expected_output='III'\n actual_output=coding_strand_to_AA(input_a)\n print 'Expected Output is ' + expected_output\n print 'Actual Output is ' +actual_output\n \n input_a='ATGATGATT'\n expected_output='MMI'\n actual_output=cod... | [
"0.8719991",
"0.83976084",
"0.8258785",
"0.8033961",
"0.711596",
"0.7098858",
"0.70144624",
"0.6977299",
"0.68907475",
"0.68672943",
"0.68555397",
"0.68044215",
"0.67995477",
"0.66153115",
"0.6552953",
"0.65054137",
"0.64102983",
"0.6404805",
"0.6328699",
"0.61388296",
"0.612... | 0.8747725 | 0 |
Unit tests for the rest_of_ORF function | def rest_of_ORF_unit_tests():
print "input: CTA, "+"output: "+rest_of_ORF("CTA")+", actual output: CTA"
print "input: GTCACTTAGGGTTTT, "+"output: "+rest_of_ORF("GTCACTTAGGGTTTT")+", actual output: GTCACT"
print "input: AAATTTTATAATGGGTGAAGTTAG, "+"output: "+rest_of_ORF("AAATTTTATAATGGGTGAAGTTAG")+", actual ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rest_of_ORF_unit_tests():\n input_a='ATTCATTAG'\n expected_output='ATTCAT'\n actual_output=rest_of_ORF(input_a)\n print 'Expected Output is ' + expected_output\n print 'Actual Output is ' +actual_output\n \n input_a='ATTCATCATCATCATTAG'\n expected_output='ATTCATCATCATCAT'\n actual_ou... | [
"0.7737007",
"0.7421629",
"0.6843093",
"0.66474515",
"0.65701455",
"0.6512438",
"0.6403422",
"0.62002724",
"0.6115223",
"0.60935855",
"0.6043698",
"0.6043698",
"0.5992064",
"0.5988105",
"0.597611",
"0.5960472",
"0.5960472",
"0.5960472",
"0.5960472",
"0.5960472",
"0.5915767",
... | 0.77167684 | 1 |
Unit tests for the find_all_ORFs_oneframe function | def find_all_ORFs_oneframe_unit_tests():
# YOUR IMPLEMENTATION HERE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_ORFs_oneframe_unit_tests():\n data_list = [\n [\"ATGCATGAATGTAGATAGATGTGCCC\", [\"ATGCATGAATGTAGA\", \"ATGTGCCC\"]],\n [\"ATGTAGATGTAG\", [\"ATG\", \"ATG\"]],\n [\"ATGATGATG\", [\"ATGATGATG\"]],\n [\"ATGGGGGATTAGATGATG\", [\"ATGGGGGAT\", \"ATGATG\"]],\n [\"ATGTGAA... | [
"0.76647025",
"0.7348566",
"0.73415834",
"0.7203369",
"0.7158465",
"0.6796761",
"0.6632994",
"0.6604659",
"0.6478488",
"0.6478216",
"0.62701315",
"0.62148196",
"0.6200575",
"0.61729914",
"0.61653095",
"0.61079854",
"0.607584",
"0.60689676",
"0.6063073",
"0.59820056",
"0.59409... | 0.8545172 | 0 |
Unit tests for the longest_ORF function | def longest_ORF_unit_tests():
# YOUR IMPLEMENTATION HERE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_ORF_unit_tests():\n\n input_a=\"ATGCGAATGTAGCATCAAA\"\n expected_output=''\n actual_output=longest_ORF(input_a)\n print 'Expected Output is ' + expected_output\n print \"actual output: \", actual_output",
"def longest_ORF_unit_tests():\n data_list = [\n [\"ATGCGAATGTAGCATCAAA... | [
"0.8736765",
"0.851448",
"0.81515014",
"0.80334777",
"0.7929165",
"0.78935254",
"0.78055173",
"0.77413636",
"0.7728444",
"0.76983595",
"0.7673481",
"0.76274866",
"0.7623019",
"0.754806",
"0.7460199",
"0.7436398",
"0.7400007",
"0.73346215",
"0.73211986",
"0.7308984",
"0.726143... | 0.8759363 | 1 |
Returns the amino acid sequences coded by all genes that have an ORF larger than the specified threshold. | def gene_finder(dna, threshold):
orfs = find_all_ORFs_both_strands(dna)
orfs = [i for i in orfs if len(i)>threshold]
orfs = [coding_strand_to_AA(i) for i in orfs]
return orfs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gene_finder(dna, threshold):\n l = find_all_ORFs_both_strands(dna)\n r = []\n if len(l) > 0:\n for item in l:\n if len(item) > threshold:\n r.append(item)\n for i in range(len(r)):\n r[i] = coding_strand_to_AA(r[i])\n return r",
"def gene_finder(dna):\n ... | [
"0.7182217",
"0.71519053",
"0.6997211",
"0.68669146",
"0.6792017",
"0.67671883",
"0.5973524",
"0.582018",
"0.5698906",
"0.55772597",
"0.55629754",
"0.5524424",
"0.5455393",
"0.5453216",
"0.54217774",
"0.5412803",
"0.5353909",
"0.51573676",
"0.5149576",
"0.511574",
"0.5061432"... | 0.7431712 | 0 |
Finds quantizer nodes that should be removed in addition to `quantizer_node` to get the correct model for inference. Returns the list of quantizer nodes (`quantizer_node` + nodes which were found) and the list of nodes that will be reverted to original precision if quantizer nodes are removed. | def find_quantizer_nodes_to_cut(
graph: NNCFGraph,
quantizer_node: NNCFNode,
quantizer_metatypes: List[OperatorMetatype],
const_metatypes: List[OperatorMetatype],
quantizable_metatypes: List[OperatorMetatype],
quantize_agnostic_metatypes: List[OperatorMetatype],
) -> Tuple[List[NNCFNode], List[N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_not_quantize_node_name(model):\n node_name_not_quantize = []\n qconfig_map = model._qconfig_map # pylint: disable=protected-access\n\n modules = dict(model.named_modules(remove_duplicate=False))\n\n for node in model.graph.nodes:\n if node.op == \"call_module\" and isinstance(modules[no... | [
"0.575151",
"0.52028507",
"0.5141197",
"0.5115581",
"0.50211483",
"0.5013961",
"0.49952653",
"0.49348733",
"0.49217913",
"0.4896299",
"0.48793873",
"0.48720056",
"0.4833633",
"0.48002222",
"0.47985065",
"0.47756767",
"0.47678775",
"0.47618622",
"0.47392565",
"0.47291318",
"0.... | 0.68069404 | 0 |
Reverts provided operations to floatingpoint precision by removing quantizers. Restores original bias for operations with bias. Restores original weights for operations with weights. | def revert_operations_to_floating_point_precision(
operations: List[NNCFNode], quantizers: List[NNCFNode], quantized_model: TModel, quantized_model_graph: NNCFGraph
) -> TModel:
transformation_layout = TransformationLayout()
command_creator = CommandCreatorFactory.create(quantized_model)
for node in q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_reshard_and_mixed_precision(self):\n self.run_subtests(\n {\"use_full_prec_in_eval\": [False, True]},\n self._test_no_reshard_and_mixed_precision,\n )",
"def tuning_cfg_to_fw(self, tuning_cfg):\n self.quantize_config['calib_iteration'] = tuning_cfg['calib_it... | [
"0.53059363",
"0.5125579",
"0.5081503",
"0.5062275",
"0.5053571",
"0.50528663",
"0.5043214",
"0.5035497",
"0.49977216",
"0.49977216",
"0.49823198",
"0.49478883",
"0.4939857",
"0.4934106",
"0.49179563",
"0.49149007",
"0.49022868",
"0.48986846",
"0.48962328",
"0.48934612",
"0.4... | 0.7833125 | 0 |
Tests homepage properly renders | def test_homepage_render(self):
result = self.client.get("/")
self.assertIn("<h1 class=\"title\">Bark Park!</h1>", result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_homepage_view(self):\n response = self.client.get(url_for('home'))\n self.assertEqual(response.status_code, 200)",
"def test_homepage_view(self):\n response = self.client.get(url_for('home'))\n self.assertEqual(response.status_code, 200)",
"def test_home(self):\n\t\trespons... | [
"0.8286543",
"0.8286543",
"0.80288696",
"0.80261856",
"0.8022295",
"0.79548097",
"0.79130465",
"0.7811535",
"0.77317524",
"0.7719305",
"0.771608",
"0.77036077",
"0.76768106",
"0.7669529",
"0.76621985",
"0.76119643",
"0.7584721",
"0.75810295",
"0.75592273",
"0.7525854",
"0.752... | 0.8676804 | 0 |
Tests signup form render | def test_signup_form_render(self):
result = self.client.get("/signup_form")
self.assertIn("<p>Please enter a user name and password</p>", result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_signin_form_render(self):\n\n result = self.client.get(\"/sign_in_form\")\n self.assertIn(\"<p>Please sign in</p>\", result.data)",
"def testSignupRenders(self):\r\n res = self.app.get('/signup')\r\n\r\n self.assertIn('Sign up for Bookie', res.body)\r\n self.assertNotI... | [
"0.75560784",
"0.7529701",
"0.74113053",
"0.73706675",
"0.7333195",
"0.7307019",
"0.7301895",
"0.7297944",
"0.72906446",
"0.7290278",
"0.72764075",
"0.7196684",
"0.7153199",
"0.71511257",
"0.71451944",
"0.71435046",
"0.7141847",
"0.71231854",
"0.7089075",
"0.70689857",
"0.706... | 0.83772904 | 0 |
Tests sign in form render | def test_signin_form_render(self):
result = self.client.get("/sign_in_form")
self.assertIn("<p>Please sign in</p>", result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_signup_form_render(self):\n\n result = self.client.get(\"/signup_form\")\n self.assertIn(\"<p>Please enter a user name and password</p>\", result.data)",
"def test_display_form(self):\n\n result = self.client.get(\"/registration\")\n self.assertIn(b\"password\", result.data)"... | [
"0.70470554",
"0.703775",
"0.69333017",
"0.65567654",
"0.6539801",
"0.65219086",
"0.6514679",
"0.64855236",
"0.64382976",
"0.64300466",
"0.6425008",
"0.6305364",
"0.62502295",
"0.62502295",
"0.62329024",
"0.6221079",
"0.6221079",
"0.621464",
"0.62094843",
"0.61999875",
"0.617... | 0.7947892 | 0 |
Tests enter info form render | def test_enter_info_render(self):
result = self.client.get("/enter_info")
self.assertIn("Park id:", result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_form():",
"def test_signup_form_render(self):\n\n result = self.client.get(\"/signup_form\")\n self.assertIn(\"<p>Please enter a user name and password</p>\", result.data)",
"def test_signin_form_render(self):\n\n result = self.client.get(\"/sign_in_form\")\n self.assertI... | [
"0.71324396",
"0.6978247",
"0.6787008",
"0.67160803",
"0.6651425",
"0.6486152",
"0.63744015",
"0.60756445",
"0.6074533",
"0.6066615",
"0.6032576",
"0.59839845",
"0.59480363",
"0.594559",
"0.58923167",
"0.58735377",
"0.58678764",
"0.5866702",
"0.57843953",
"0.5784116",
"0.5783... | 0.7254948 | 0 |
Test park_info render correctly | def test_park_info(self):
# Checks that park info is rendering correctly
result = self.client.get("/park_info/2", follow_redirects=True)
self.assertIn("JAPANTOWN PEACE PLAZA", result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_enter_info_render(self):\n result = self.client.get(\"/enter_info\")\n self.assertIn(\"Park id:\", result.data)",
"def test_format_park_output(self):\n # Setup params and mock result for successfully parking a car\n park_cmd = \"park\"\n success_result, fail_result = 3... | [
"0.6660706",
"0.6355036",
"0.5856119",
"0.5811545",
"0.5612354",
"0.5612354",
"0.54689485",
"0.5456563",
"0.54361403",
"0.5403662",
"0.53866446",
"0.53521395",
"0.5338805",
"0.53045446",
"0.53045446",
"0.5285303",
"0.525638",
"0.52529645",
"0.5249967",
"0.52291465",
"0.520732... | 0.70226526 | 0 |
Test adding new photo | def test_add_new_photo(self):
result = self.client.post("/add_new_photo/2",
data={"park_id": "2", "user_id": 25, "description": "Taurus having a great time!", "photo": "http://s3-media3.fl.yelpcdn.com/bphoto/ZUhteyc0UWdWbgM-4VbZhw/o.jpg"},
fol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_images_add(self):\n response = self.client.get('/images/photos/add')\n self.assertEqual(response.status_code, 200)",
"def test_create(self):\n data = {\n 'image': images.load_image()\n }\n photo = Photo.objects.create(**data)\n self.assertTrue(photo.p... | [
"0.8101235",
"0.8026537",
"0.7981487",
"0.7825003",
"0.7615926",
"0.75143087",
"0.74651533",
"0.7336449",
"0.7290538",
"0.7287154",
"0.72751683",
"0.7270891",
"0.7228573",
"0.7217122",
"0.7203814",
"0.717076",
"0.7156646",
"0.7147599",
"0.7129838",
"0.7117978",
"0.70968175",
... | 0.8562085 | 0 |
Fontfamily is listed in Google Font Directory | def test_family_is_listed_in_gwf(self):
url = 'http://fonts.googleapis.com/css?family=%s' % self.metadata['name'].replace(' ', '+')
fp = requests.get(url)
self.assertTrue(fp.status_code == 200, 'No family found in GWF in %s' % url)
self.assertEqual(self.metadata.get('visibility'), 'Exter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fonts():\r\n return pygame.font.get_fonts()",
"def test_font_name_matches_family(self):\n\n for font_metadata in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if font_metadata.name != font.familyname:\n msg ... | [
"0.68306017",
"0.6814408",
"0.67356247",
"0.67104864",
"0.66717947",
"0.6631511",
"0.6630835",
"0.6582492",
"0.6549525",
"0.65490985",
"0.64849263",
"0.64471143",
"0.641377",
"0.6402516",
"0.63938975",
"0.6391513",
"0.63592094",
"0.63592094",
"0.63592094",
"0.6353017",
"0.632... | 0.68352264 | 0 |
Designer exists in GWF profiles.csv | def test_metadata_designer_exists_in_profiles_csv(self):
designer = self.metadata.get('designer', u'')
self.assertTrue(designer, 'Field "designer" MUST NOT be empty')
import urllib
import csv
fp = urllib.urlopen('https://raw.githubusercontent.com/google/fonts/master/designers/pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_components_profile(self):\r\n\t\tprofile = Profile.objects.get(bio=\"I'm a female profile with inserted components\")\r\n\t\tself.assertEqual(self.u1.profile, profile)",
"def allow_designer(self):\n return self.properties.get(\"AllowDesigner\", None)",
"def _validate_num_profiles(self):\n ... | [
"0.5214195",
"0.5157362",
"0.5069574",
"0.49687594",
"0.4952878",
"0.49470884",
"0.49187973",
"0.49164245",
"0.4895499",
"0.48455888",
"0.4845009",
"0.48043796",
"0.47693458",
"0.47666386",
"0.47616172",
"0.4752277",
"0.4751595",
"0.47400478",
"0.4719153",
"0.46977338",
"0.46... | 0.8076158 | 0 |
METADATA.json fonts propery only should have uniq values | def test_metadata_fonts_no_dupes(self):
fonts = {}
for x in self.metadata.get('fonts', None):
self.assertFalse(x.get('fullName', '') in fonts)
fonts[x.get('fullName', '')] = x
self.assertEqual(len(set(fonts.keys())),
len(self.metadata.get('fonts'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fonts_items_dicts(self):\n for x in self.metadata.get('fonts', None):\n self.assertEqual(type(x), type({}), msg=\"type(%s) is not dict\" % x)",
"def test_metadata_fonts_key_list(self):\n self.assertEqual(type(self.metadata.get('fonts', '')), type([]))",
"def test_meta... | [
"0.7148735",
"0.7148274",
"0.68586934",
"0.68324167",
"0.6508626",
"0.6315923",
"0.6147427",
"0.61141056",
"0.59751123",
"0.5967416",
"0.587476",
"0.58441174",
"0.5834785",
"0.5795578",
"0.5712134",
"0.5657229",
"0.5657099",
"0.56292534",
"0.5613162",
"0.56095904",
"0.5574174... | 0.7460132 | 0 |
METADATA.json font key should be list | def test_metadata_fonts_key_list(self):
self.assertEqual(type(self.metadata.get('fonts', '')), type([])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fonts_items_dicts(self):\n for x in self.metadata.get('fonts', None):\n self.assertEqual(type(x), type({}), msg=\"type(%s) is not dict\" % x)",
"def test_metadata_fonts_fields_have_fontname(self):\n for x in self.metadata.fonts:\n font = Font.get_ttfont_from_... | [
"0.7041857",
"0.63672256",
"0.6113491",
"0.5998007",
"0.59016675",
"0.59016675",
"0.59016675",
"0.5668828",
"0.5668607",
"0.56112456",
"0.5580641",
"0.55714065",
"0.5561082",
"0.55486125",
"0.550653",
"0.5462129",
"0.5424566",
"0.54121506",
"0.54065496",
"0.53918576",
"0.5384... | 0.7776431 | 0 |
METADATA.json subsets key should be list | def test_metadata_subsets_key_list(self):
self.assertEqual(type(self.metadata.get('subsets', '')), type([])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metadata(self) -> dict:\n\n meta = {}\n meta['name'] = self.name\n meta['potential_key'] = self.potential_key\n meta['potential_id'] = self.potential_id\n meta['potential_LAMMPS_key'] = self.potential_LAMMPS_key\n meta['potential_LAMMPS_id'] = self.potential_LAMMPS_id\... | [
"0.6463854",
"0.5797937",
"0.5768708",
"0.5734376",
"0.5554672",
"0.5540957",
"0.55364376",
"0.54748344",
"0.5444627",
"0.53987503",
"0.5345431",
"0.5329478",
"0.5325029",
"0.5311895",
"0.529772",
"0.5285566",
"0.52753043",
"0.5238191",
"0.5214531",
"0.51937",
"0.5191789",
... | 0.7590414 | 0 |
METADATA.json fonts key items are dicts | def test_metadata_fonts_items_dicts(self):
for x in self.metadata.get('fonts', None):
self.assertEqual(type(x), type({}), msg="type(%s) is not dict" % x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fonts_key_list(self):\n self.assertEqual(type(self.metadata.get('fonts', '')), type([]))",
"def test_check_metadata_fields(self):\n contents = self.read_metadata_contents()\n family = Metadata.get_family_metadata(contents)\n\n keys = [(\"name\", str), (\"postScriptNa... | [
"0.7258909",
"0.63500243",
"0.6211992",
"0.61855096",
"0.59469616",
"0.5928215",
"0.5841445",
"0.5759975",
"0.57415646",
"0.5734197",
"0.5717449",
"0.5711371",
"0.5707974",
"0.5705567",
"0.5705021",
"0.570084",
"0.57002795",
"0.5696081",
"0.56929094",
"0.56903833",
"0.5683566... | 0.7718863 | 0 |
METADATA.json should have proper top keys types | def test_metadata_top_keys_types(self):
self.assertEqual(type(self.metadata.get("name", None)),
type(u""), msg="'name' is {0}, but must be {1}".format(type(self.metadata.get("name", None)), type(u"")))
self.assertEqual(type(self.metadata.get("designer", None)),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_metadata_type(self):\n self.assertTrue(type(self.meta) is dict)",
"def test_metadata(list_json_output):\n\n listing = list_json_output('valid-json', metadata=True)\n for c in listing:\n if 'meta' in c:\n assert c['meta'] == True\n assert c['title'] == 'NPC... | [
"0.70076925",
"0.66270345",
"0.6557464",
"0.6520598",
"0.609462",
"0.6061046",
"0.60600847",
"0.60529405",
"0.6003036",
"0.60022056",
"0.599129",
"0.59896505",
"0.5980709",
"0.59704125",
"0.59642357",
"0.5956953",
"0.5952112",
"0.5948878",
"0.5946932",
"0.5943469",
"0.5943268... | 0.73434883 | 0 |
METADATA.json don't have unknown top keys | def test_metadata_no_unknown_top_keys(self):
top_keys = ["name", "designer", "license", "visibility", "category",
"size", "dateAdded", "fonts", "subsets"]
for x in self.metadata.keys():
self.assertIn(x, top_keys, msg="%s found unknown top key" % x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_top_keys_types(self):\n self.assertEqual(type(self.metadata.get(\"name\", None)),\n type(u\"\"), msg=\"'name' is {0}, but must be {1}\".format(type(self.metadata.get(\"name\", None)), type(u\"\")))\n\n self.assertEqual(type(self.metadata.get(\"designer\", Non... | [
"0.67051446",
"0.6685521",
"0.6376735",
"0.63745517",
"0.6282386",
"0.62259007",
"0.6222068",
"0.6165991",
"0.6092794",
"0.60686874",
"0.59721017",
"0.5962008",
"0.58598506",
"0.58506167",
"0.58215386",
"0.5807291",
"0.57750154",
"0.5770649",
"0.5756042",
"0.5756042",
"0.5731... | 0.75930357 | 0 |
METADATA.json subsets should have at least 'menu' and 'latin' | def test_metadata_atleast_latin_menu_subsets_exist(self):
self.assertIn('menu', self.metadata.get('subsets', []),
msg="Subsets missing menu")
self.assertIn('latin', self.metadata.get('subsets', []),
msg="Subsets missing latin") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_subsets_key_list(self):\n self.assertEqual(type(self.metadata.get('subsets', '')), type([]))",
"def test_metadata_fonts_items_dicts(self):\n for x in self.metadata.get('fonts', None):\n self.assertEqual(type(x), type({}), msg=\"type(%s) is not dict\" % x)",
"def test_... | [
"0.6309181",
"0.58442897",
"0.57330245",
"0.5654883",
"0.56103677",
"0.5445936",
"0.5444328",
"0.5162038",
"0.51150095",
"0.50701636",
"0.5030377",
"0.5029047",
"0.49769622",
"0.49525937",
"0.4951524",
"0.4943614",
"0.4925639",
"0.49054593",
"0.4902613",
"0.48843136",
"0.4879... | 0.7498523 | 0 |
METADATA.json license is 'Apache2', 'UFL' or 'OFL' | def test_metadata_license(self):
licenses = ['Apache2', 'OFL', 'UFL']
self.assertIn(self.metadata.get('license', ''), licenses) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_license():\n repo_fs()\n return LICENSE",
"def license(p):\n # Input file\n f = '/'.join([p, 'collector.stats'])\n check_path(f)\n\n # Open file with universal newline support\n with open(f, 'rU') as fh:\n for line in fh.readlines():\n if 'License key' in line:\n ... | [
"0.64497304",
"0.61799014",
"0.6101011",
"0.60896206",
"0.5992022",
"0.5979991",
"0.59319353",
"0.590923",
"0.5900866",
"0.58510584",
"0.5789927",
"0.5766529",
"0.57537115",
"0.56614906",
"0.5658792",
"0.56326425",
"0.5619584",
"0.5602811",
"0.5576566",
"0.55648667",
"0.55459... | 0.76547855 | 0 |
Font on disk and in METADATA.json have the same family name | def test_font_on_disk_family_equal_in_metadata_json(self):
contents = self.read_metadata_contents()
metadata = Metadata.get_family_metadata(contents)
unmatched_fonts = []
for font_metadata in metadata.fonts:
try:
font = Font.get_ttfont_from_metadata(self.oper... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_familyname_matches_fontnames(self):\n contents = self.read_metadata_contents()\n fm = Metadata.get_family_metadata(contents)\n for font_metadata in fm.fonts:\n _ = '%s: Family name \"%s\" does not match font name: \"%s\"'\n _ = _ % (font_metadata.filename, ... | [
"0.7125211",
"0.7099576",
"0.70956355",
"0.70024824",
"0.6986877",
"0.66815084",
"0.6639087",
"0.66352236",
"0.6576001",
"0.65312165",
"0.6496095",
"0.6491387",
"0.64128804",
"0.6405642",
"0.6396673",
"0.63644433",
"0.6357654",
"0.6351355",
"0.63068163",
"0.6294116",
"0.62660... | 0.7654194 | 0 |
Checks METADATA.json 'postScriptName' matches TTF 'postScriptName' | def test_postscriptname_in_metadata_equal_to_font_on_disk(self):
contents = self.read_metadata_contents()
metadata = Metadata.get_family_metadata(contents)
for font_metadata in metadata.fonts:
try:
font = Font.get_ttfont_from_metadata(self.operator.path, font_metadat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_filename_matches_postscriptname(self):\n import re\n regex = re.compile(r'\\W')\n\n fonts = [font for font in self.metadata.fonts\n if not font.post_script_name.endswith('-Regular')]\n\n for x in fonts:\n post_script_name = regex.sub('', x.po... | [
"0.7662234",
"0.7293032",
"0.6253602",
"0.56192815",
"0.5284768",
"0.5213924",
"0.51423526",
"0.5078195",
"0.5049576",
"0.5043858",
"0.50200784",
"0.49979708",
"0.49957865",
"0.49311423",
"0.49309516",
"0.49226233",
"0.48839355",
"0.48819166",
"0.48501968",
"0.47958294",
"0.4... | 0.75473976 | 1 |
Check that METADATA family values are all the same | def test_metadata_family_values_are_all_the_same(self):
name = ''
for font_metadata in self.metadata.fonts:
if name and font_metadata.name != name:
self.fail('Family name in metadata fonts items not the same')
name = font_metadata.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _metadata_is_consistent(metadata):\n checks = []\n required = ('version', 'fields', 'size', 'width', 'height', 'points',\n 'viewpoint', 'data')\n for f in required:\n if f not in metadata:\n print('%s required' % f)\n checks.append((lambd... | [
"0.6967222",
"0.6812418",
"0.67487496",
"0.65187705",
"0.64226615",
"0.640453",
"0.63531834",
"0.63395494",
"0.6309929",
"0.6252961",
"0.60991293",
"0.60742",
"0.6031558",
"0.5956039",
"0.5952839",
"0.58738923",
"0.58640724",
"0.5860876",
"0.58581144",
"0.5818176",
"0.5808373... | 0.7658507 | 0 |
METADATA.json `filename` matches `postScriptName` | def test_metadata_filename_matches_postscriptname(self):
import re
regex = re.compile(r'\W')
fonts = [font for font in self.metadata.fonts
if not font.post_script_name.endswith('-Regular')]
for x in fonts:
post_script_name = regex.sub('', x.post_script_name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fullname_matches_postScriptName(self):\n import re\n regex = re.compile(r'\\W')\n\n for x in self.metadata.fonts:\n post_script_name = regex.sub('', x.post_script_name)\n fullname = regex.sub('', x.full_name)\n if fullname != post_script_name:... | [
"0.6242659",
"0.5877668",
"0.56742036",
"0.5594717",
"0.5592306",
"0.5586732",
"0.5506245",
"0.5490767",
"0.54795843",
"0.5467642",
"0.54207855",
"0.54048926",
"0.5371814",
"0.5298902",
"0.5286938",
"0.527544",
"0.5272672",
"0.5185626",
"0.51506484",
"0.51411945",
"0.5137981"... | 0.6979829 | 0 |
METADATA.json `fullName` matches `postScriptName` | def test_metadata_fullname_matches_postScriptName(self):
import re
regex = re.compile(r'\W')
for x in self.metadata.fonts:
post_script_name = regex.sub('', x.post_script_name)
fullname = regex.sub('', x.full_name)
if fullname != post_script_name:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_filename_matches_postscriptname(self):\n import re\n regex = re.compile(r'\\W')\n\n fonts = [font for font in self.metadata.fonts\n if not font.post_script_name.endswith('-Regular')]\n\n for x in fonts:\n post_script_name = regex.sub('', x.po... | [
"0.6453028",
"0.52925247",
"0.51974595",
"0.5087876",
"0.50789285",
"0.49901122",
"0.4918052",
"0.49001634",
"0.48393753",
"0.4821171",
"0.4798194",
"0.47925773",
"0.47608513",
"0.47402513",
"0.46420488",
"0.4638828",
"0.46370846",
"0.46337023",
"0.45863876",
"0.4535629",
"0.... | 0.702138 | 0 |
METADATA.json 'fullname' value matches internal 'fullname' | def test_metadata_fullname_is_equal_to_internal_font_fullname(self):
for font_metadata in self.metadata.fonts:
font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)
self.assertEqual(font.fullname, font_metadata.full_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name_attribute_in_base_metadata(self):\n name = 'idsvc.basemeta'\n meta = { 'name': name }\n base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, meta=meta)\n self.assertEqual(base_meta.name, meta['name'])",
"def test_metadata_fullname_matches_postScriptName(self):\n ... | [
"0.6274889",
"0.60657954",
"0.58614814",
"0.58135635",
"0.57366437",
"0.5687102",
"0.5592129",
"0.55794483",
"0.5576561",
"0.5575539",
"0.5557946",
"0.5514591",
"0.54918945",
"0.5491303",
"0.54634714",
"0.5454241",
"0.5432782",
"0.5419309",
"0.5406995",
"0.5359503",
"0.531884... | 0.6357181 | 0 |
METADATA.json fonts 'name' property should be same as font familyname | def test_font_name_matches_family(self):
for font_metadata in self.metadata.fonts:
font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)
if font_metadata.name != font.familyname:
msg = '"fonts.name" property is not the same as TTF familyname'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fonts_fields_have_fontname(self):\n for x in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, x)\n\n self.assertIn(font.familyname, x.name)\n self.assertIn(font.familyname, x.full_name)\n self.assertIn(\"\".join(str... | [
"0.7828246",
"0.74797285",
"0.71023893",
"0.70273054",
"0.7002404",
"0.6919298",
"0.68906325",
"0.6564974",
"0.64813936",
"0.6423085",
"0.6377916",
"0.63429266",
"0.630458",
"0.62524605",
"0.6246653",
"0.6246344",
"0.6241811",
"0.61815023",
"0.61470807",
"0.6146112",
"0.60912... | 0.74861383 | 1 |
METADATA.json fonts items fields "name", "postScriptName", "fullName", "filename" contains font name right format | def test_metadata_fonts_fields_have_fontname(self):
for x in self.metadata.fonts:
font = Font.get_ttfont_from_metadata(self.operator.path, x)
self.assertIn(font.familyname, x.name)
self.assertIn(font.familyname, x.full_name)
self.assertIn("".join(str(font.familyn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fullname_is_equal_to_internal_font_fullname(self):\n for font_metadata in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n self.assertEqual(font.fullname, font_metadata.full_name)",
"def test_postscriptname_in_metadata... | [
"0.6552034",
"0.63708365",
"0.623146",
"0.6161567",
"0.6149218",
"0.6124916",
"0.60486174",
"0.5990743",
"0.5990743",
"0.5990743",
"0.5970162",
"0.5969141",
"0.59545547",
"0.5906889",
"0.58947253",
"0.5889975",
"0.58711123",
"0.58702487",
"0.58620065",
"0.5811285",
"0.5784792... | 0.71831113 | 0 |
Copyright notice does not contain Reserved File Name | def test_copyright_contains_correct_rfn(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
if 'Reserved Font Name' in font_metadata.copyright:
msg = '"%s" contains "Reserved File Name"'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fsleyes_copyright():\n with open(op.join(basedir, 'COPYRIGHT')) as f:\n return f.read().strip()",
"def test_ensure_copyright():\n issues = []\n regex = re.compile(r\"# Copyright \\d{4}(-\\d{4})? Canonical Ltd.$\")\n for filepath in get_python_filepaths():\n if os.stat(filepath).... | [
"0.72586244",
"0.7034991",
"0.6630011",
"0.660838",
"0.65749997",
"0.64993834",
"0.63159007",
"0.6292956",
"0.62436783",
"0.62436783",
"0.61998",
"0.61239433",
"0.611826",
"0.60296196",
"0.6002487",
"0.58504516",
"0.58137524",
"0.5801681",
"0.57514966",
"0.57509303",
"0.56985... | 0.7221478 | 1 |
Copyright notice matches canonical pattern | def test_copyright_matches_pattern(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
self.assertRegexpMatches(font_metadata.copyright,
r'Copyright\s+\(c\)\s+20\d{2}.*\(.*@.*... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refine_copyright(c):\n c = strip_some_punct(c)\n c = fix_trailing_space_dot(c)\n c = strip_all_unbalanced_parens(c)\n # FIXME: this should be in the grammar, but is hard to get there right\n # these are often artifacts of markup\n c = c.replace('Copyright Copyright', 'Copyright')\n c = c.r... | [
"0.6847598",
"0.62608576",
"0.5977816",
"0.59695137",
"0.59593976",
"0.5942248",
"0.59142286",
"0.5765672",
"0.5686327",
"0.56831664",
"0.5680724",
"0.5680724",
"0.55736166",
"0.5522666",
"0.55056196",
"0.54760164",
"0.546581",
"0.5431113",
"0.5392795",
"0.5311113",
"0.530788... | 0.7153262 | 0 |
Copyright notice is the same in all fonts? | def test_copyright_is_consistent_across_family(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
copyright = ''
for font_metadata in fm.fonts:
if copyright and font_metadata.copyright != copyright:
self.fail('Copyrigh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_copyright():\n pass",
"def test_copyright_contains_correct_rfn(self):\n contents = self.read_metadata_contents()\n fm = Metadata.get_family_metadata(contents)\n\n for font_metadata in fm.fonts:\n if 'Reserved Font Name' in font_metadata.copyright:\n msg = ... | [
"0.6734123",
"0.6631291",
"0.6494119",
"0.6292609",
"0.615486",
"0.61474884",
"0.60760784",
"0.57513845",
"0.57513845",
"0.5747906",
"0.57336783",
"0.57298076",
"0.5693686",
"0.56205964",
"0.56205964",
"0.55895346",
"0.5527469",
"0.54552966",
"0.54549944",
"0.5444323",
"0.543... | 0.70671237 | 0 |
Check that corresponding subset files exist for fonts | def test_check_subsets_exists(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
for subset in fm.subsets:
subset_filename = self.get_subset_filename(font_metadata.filename, subset)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_font_on_disk_family_equal_in_metadata_json(self):\n contents = self.read_metadata_contents()\n metadata = Metadata.get_family_metadata(contents)\n\n unmatched_fonts = []\n for font_metadata in metadata.fonts:\n try:\n font = Font.get_ttfont_from_metada... | [
"0.6975063",
"0.69722265",
"0.68899983",
"0.6838571",
"0.6817696",
"0.6758472",
"0.6758472",
"0.6715067",
"0.6623259",
"0.64125764",
"0.6395913",
"0.6299291",
"0.6293904",
"0.6289034",
"0.6259021",
"0.6255832",
"0.6192996",
"0.6152074",
"0.61413413",
"0.6101614",
"0.60798186"... | 0.82299614 | 0 |
Monospace font has hhea.advanceWidthMax equal to each glyph advanceWidth | def test_check_monospace_agreement(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
if fm.category != 'Monospace':
return
for font_metadata in fm.fonts:
font = Font.get_ttfont_from_metadata(self.operator.path,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def harfbuzz_width(lines, hb_font):\n\tout = []\n\tbuf = hb.buffer_create ()\n\tfor text in lines:\n\t\thb.buffer_clear_contents (buf)\n\t\thb.buffer_add_utf8 (buf, tobytes(text), 0, -1)\n\t\thb.buffer_guess_segment_properties (buf)\n\n\t\thb.shape (hb_font, buf, [])\n\n\t\tpositions = hb.buffer_get_glyph_position... | [
"0.60602677",
"0.6029948",
"0.58235323",
"0.5727132",
"0.5661234",
"0.5581287",
"0.5469084",
"0.5468837",
"0.546774",
"0.5459221",
"0.5459221",
"0.53927684",
"0.53909093",
"0.53868973",
"0.5386202",
"0.534403",
"0.5328514",
"0.53068435",
"0.5273504",
"0.52599335",
"0.5259414"... | 0.685062 | 0 |
Check metadata.json font.style `italic` matches font internal | def test_check_italic_style_matches_names(self):
contents = self.read_metadata_contents()
family = Metadata.get_family_metadata(contents)
for font_metadata in family.fonts:
if font_metadata.style != 'italic':
continue
font = Font.get_ttfont_from_metadata... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_canonical_styles(self):\n contents = self.read_metadata_contents()\n fm = Metadata.get_family_metadata(contents)\n for font_metadata in fm.fonts:\n self.assertIn(font_metadata.style, self.CANONICAL_STYLE_VALUES)\n if self.is_italic(font_metadata):\n ... | [
"0.7558341",
"0.73380977",
"0.6939594",
"0.67242837",
"0.67035174",
"0.6615761",
"0.64679974",
"0.63273317",
"0.6287998",
"0.61372036",
"0.6129144",
"0.6017762",
"0.5974976",
"0.5882355",
"0.58799505",
"0.5876883",
"0.58353376",
"0.57994324",
"0.57427514",
"0.564695",
"0.5559... | 0.8031599 | 0 |
Check METADATA.json "fonts" property items have required field | def test_check_metadata_fields(self):
contents = self.read_metadata_contents()
family = Metadata.get_family_metadata(contents)
keys = [("name", str), ("postScriptName", str),
("fullName", str), ("style", str),
("weight", int), ("filename", str),
(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_fonts_items_dicts(self):\n for x in self.metadata.get('fonts', None):\n self.assertEqual(type(x), type({}), msg=\"type(%s) is not dict\" % x)",
"def test_metadata_fonts_fields_have_fontname(self):\n for x in self.metadata.fonts:\n font = Font.get_ttfont_from_... | [
"0.77730477",
"0.7456836",
"0.7332151",
"0.72616744",
"0.6973677",
"0.69446564",
"0.681128",
"0.6778316",
"0.6740089",
"0.64284027",
"0.6259921",
"0.6204493",
"0.6152625",
"0.60604924",
"0.5909761",
"0.5879806",
"0.5874075",
"0.58633304",
"0.58570975",
"0.5833173",
"0.5814633... | 0.7913161 | 0 |
Check menu file contains proper glyphs | def test_check_menu_contains_proper_glyphs(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
tf = Font.get_ttfont_from_metadata(self.operator.path, font_metadata, is_menu=True)
self.check_retrieve_gl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_menu_file_agreement(self):\n contents = self.read_metadata_contents()\n fm = Metadata.get_family_metadata(contents)\n for font_metadata in fm.fonts:\n menufile = self.menufile(font_metadata)\n path = op.join(op.dirname(self.operator.path), menufile)\n\n ... | [
"0.7236188",
"0.5776545",
"0.57665694",
"0.571857",
"0.56248385",
"0.5600218",
"0.55575675",
"0.5531383",
"0.5522599",
"0.54640484",
"0.5445867",
"0.54449725",
"0.5442131",
"0.54373264",
"0.5411489",
"0.5328205",
"0.530127",
"0.52945983",
"0.52666074",
"0.52666074",
"0.526098... | 0.8218143 | 0 |
The same number of glyphs across family? | def test_the_same_number_of_glyphs_across_family(self):
glyphs_count = 0
for font_metadata in self.familymetadata.fonts:
ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)
if not glyphs_count:
glyphs_count = len(ttfont.glyphs)
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_the_same_names_of_glyphs_across_family(self):\n glyphs = None\n for font_metadata in self.familymetadata.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if not glyphs:\n glyphs = len(ttfont.glyphs)\n\n if gl... | [
"0.7337582",
"0.6741604",
"0.640238",
"0.62625974",
"0.61017925",
"0.5953575",
"0.59203243",
"0.57973087",
"0.5796659",
"0.5788215",
"0.5758734",
"0.572801",
"0.5611642",
"0.5596291",
"0.55564994",
"0.5553652",
"0.55515736",
"0.55480313",
"0.5528035",
"0.5528035",
"0.5509093"... | 0.7578371 | 0 |
The same names of glyphs across family? | def test_the_same_names_of_glyphs_across_family(self):
glyphs = None
for font_metadata in self.familymetadata.fonts:
ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)
if not glyphs:
glyphs = len(ttfont.glyphs)
if glyphs != len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_the_same_encodings_of_glyphs_across_family(self):\n encoding = None\n for font_metadata in self.familymetadata.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n cmap = ttfont.retrieve_cmap_format_4()\n\n if not encoding:\n ... | [
"0.7080407",
"0.6850735",
"0.6627418",
"0.6614728",
"0.6207078",
"0.61908984",
"0.6187246",
"0.6174458",
"0.6166088",
"0.6136338",
"0.6128186",
"0.6100021",
"0.6098216",
"0.5975284",
"0.5962659",
"0.5912008",
"0.5906176",
"0.5880083",
"0.58718705",
"0.5860597",
"0.5814837",
... | 0.7704335 | 0 |
The same unicode encodings of glyphs across family? | def test_the_same_encodings_of_glyphs_across_family(self):
encoding = None
for font_metadata in self.familymetadata.fonts:
ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)
cmap = ttfont.retrieve_cmap_format_4()
if not encoding:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_the_same_names_of_glyphs_across_family(self):\n glyphs = None\n for font_metadata in self.familymetadata.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if not glyphs:\n glyphs = len(ttfont.glyphs)\n\n if gl... | [
"0.62726206",
"0.62070125",
"0.6142102",
"0.611168",
"0.6000407",
"0.5976361",
"0.5885889",
"0.58385843",
"0.5827247",
"0.58153534",
"0.58130074",
"0.5786559",
"0.577748",
"0.57382566",
"0.57320553",
"0.57217056",
"0.5685212",
"0.56843835",
"0.5682137",
"0.5678385",
"0.567698... | 0.78110653 | 0 |
Check if fontname is not camel cased | def test_fontname_not_in_camel_case(self):
contents = self.read_metadata_contents()
familymetadata = Metadata.get_family_metadata(contents)
camelcased_fontnames = []
for font_metadata in familymetadata.fonts:
if bool(re.match(r'([A-Z][a-z]+){2,}', font_metadata.name)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_capitalized(): # noqa: D416",
"def checkCapitalizeName(self, stringToCheck):\n #https://stackoverflow.com/questions/15947614/regex-to-match-capitalized-words-with-a-single-space-between-them\n pattern = \"^[A-Z]\\w{1,16}( [A-Z]\\w{1,16})*$\"\n return True if re.search(pattern, strin... | [
"0.7299418",
"0.6814531",
"0.64580864",
"0.6442552",
"0.634324",
"0.630866",
"0.6298321",
"0.62423754",
"0.6214539",
"0.61962366",
"0.6176714",
"0.617265",
"0.6144388",
"0.614162",
"0.6020115",
"0.59657913",
"0.5906275",
"0.5898908",
"0.588127",
"0.5877115",
"0.5836694",
"0... | 0.8788829 | 0 |
Check fonts have corresponding menu files | def test_menu_file_agreement(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
menufile = self.menufile(font_metadata)
path = op.join(op.dirname(self.operator.path), menufile)
if not op.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_menu_contains_proper_glyphs(self):\n contents = self.read_metadata_contents()\n fm = Metadata.get_family_metadata(contents)\n for font_metadata in fm.fonts:\n tf = Font.get_ttfont_from_metadata(self.operator.path, font_metadata, is_menu=True)\n self.check_r... | [
"0.8131917",
"0.6556118",
"0.62684363",
"0.61026263",
"0.6068627",
"0.6057434",
"0.60499495",
"0.5996451",
"0.59863824",
"0.59755224",
"0.59727985",
"0.5960549",
"0.5960549",
"0.59213585",
"0.5885702",
"0.58109355",
"0.58028036",
"0.57836825",
"0.5743406",
"0.57267773",
"0.57... | 0.7843477 | 1 |
Check font name is the same as family name | def test_check_familyname_matches_fontnames(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
_ = '%s: Family name "%s" does not match font name: "%s"'
_ = _ % (font_metadata.filename, fm.name, font_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_font_name_matches_family(self):\n\n for font_metadata in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if font_metadata.name != font.familyname:\n msg = '\"fonts.name\" property is not the same as TTF familyname... | [
"0.8535346",
"0.7771687",
"0.75874037",
"0.74644387",
"0.7452007",
"0.73833656",
"0.7344782",
"0.70914936",
"0.6906705",
"0.6884841",
"0.6822116",
"0.667163",
"0.6665045",
"0.66505325",
"0.6634465",
"0.6609229",
"0.65947413",
"0.6589833",
"0.65627986",
"0.64888775",
"0.646372... | 0.81513685 | 1 |
Check that weights have canonical value | def test_check_canonical_weights(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
weight = font_metadata.weight
first_digit = weight / 100
is_invalid = (weight % 100) != 0 or (first_digi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_null_weight_with_nonzeros() -> None:\n sample_weight = np.ones_like(y_toy)\n sw_out, X_out, y_out = check_null_weight(sample_weight, X_toy, y_toy)\n np.testing.assert_almost_equal(sw_out, sample_weight)\n np.testing.assert_almost_equal(X_out, X_toy)\n np.testing.assert_almost_equal(y_... | [
"0.6634336",
"0.6289582",
"0.6261584",
"0.6249548",
"0.6249548",
"0.620331",
"0.61956155",
"0.6062227",
"0.60326266",
"0.59921074",
"0.5959513",
"0.5892867",
"0.5891711",
"0.58291775",
"0.5820584",
"0.58049935",
"0.5772395",
"0.5739897",
"0.57198334",
"0.5694808",
"0.56930083... | 0.6512201 | 1 |
Metadata weight matches postScriptName | def test_postscriptname_contains_correct_weight(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
pair = []
for k, weight in weights.items():
if weight == font_metadata.weight:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadata_filename_matches_postscriptname(self):\n import re\n regex = re.compile(r'\\W')\n\n fonts = [font for font in self.metadata.fonts\n if not font.post_script_name.endswith('-Regular')]\n\n for x in fonts:\n post_script_name = regex.sub('', x.po... | [
"0.53987545",
"0.52983224",
"0.51746094",
"0.5139424",
"0.5117865",
"0.50890535",
"0.50777584",
"0.49101636",
"0.49021816",
"0.49017617",
"0.48994467",
"0.4898874",
"0.48922902",
"0.4855456",
"0.48394388",
"0.48172387",
"0.4758968",
"0.4758968",
"0.4758968",
"0.4758968",
"0.4... | 0.7113027 | 0 |
Font weight matches metadata.json value of key "weight" | def test_font_weight_same_as_in_metadata(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)
if font.OS2_usWeightClass != font_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_canonical_weights(self):\n contents = self.read_metadata_contents()\n fm = Metadata.get_family_metadata(contents)\n for font_metadata in fm.fonts:\n weight = font_metadata.weight\n first_digit = weight / 100\n is_invalid = (weight % 100) != 0 or ... | [
"0.7211928",
"0.7113503",
"0.69582194",
"0.6877166",
"0.66003686",
"0.6414719",
"0.6322323",
"0.6315574",
"0.5943667",
"0.5813832",
"0.5649811",
"0.5623015",
"0.5515056",
"0.5443374",
"0.5428625",
"0.5400887",
"0.5388671",
"0.5374472",
"0.5363614",
"0.5322757",
"0.5291531",
... | 0.79129016 | 0 |
Test If font styles are canonical | def test_check_canonical_styles(self):
contents = self.read_metadata_contents()
fm = Metadata.get_family_metadata(contents)
for font_metadata in fm.fonts:
self.assertIn(font_metadata.style, self.CANONICAL_STYLE_VALUES)
if self.is_italic(font_metadata):
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_normal_style_matches_names(self):\n contents = self.read_metadata_contents()\n family = Metadata.get_family_metadata(contents)\n\n for font_metadata in family.fonts:\n if font_metadata.style != 'normal':\n continue\n\n font = Font.get_ttfont_... | [
"0.7248282",
"0.6935411",
"0.6680462",
"0.6253085",
"0.62378496",
"0.62230104",
"0.606966",
"0.6040576",
"0.60307646",
"0.59415674",
"0.59023315",
"0.5703632",
"0.5693834",
"0.56794",
"0.5653981",
"0.55639493",
"0.5533116",
"0.5526273",
"0.5525132",
"0.5478395",
"0.54339075",... | 0.7875416 | 0 |
Test If filename is canonical | def test_check_canonical_filenames(self):
contents = self.read_metadata_contents()
family_metadata = Metadata.get_family_metadata(contents)
for font_metadata in family_metadata.fonts:
canonical_filename = self.create_canonical_filename(font_metadata)
if canonical_filename... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canonic(filename):\r\n if filename is None:\r\n return ''\r\n\r\n if filename == (\"<\" + filename[1:-1] + \">\"):\r\n return filename\r\n canonic_ = os.path.realpath(filename)\r\n canonic_ = os.path.normcase(canonic_)\r\n return canonic_",
"def canonical_filename(filename):\n i... | [
"0.66859955",
"0.6648033",
"0.64460415",
"0.64346355",
"0.6421668",
"0.6241108",
"0.60469574",
"0.6042017",
"0.6038499",
"0.6029806",
"0.60270005",
"0.6008632",
"0.6005622",
"0.59906447",
"0.5974498",
"0.5968066",
"0.59679115",
"0.5967139",
"0.59447575",
"0.5929974",
"0.59103... | 0.70434004 | 0 |
Postprocess output tensors from Fast RCNN. Box encoding predictions are decoded w.r.t. the proposal boxes predicted from RPN, and then go through the multiclass version of NMS. | def postprocess_frcnn(model,
frcnn_prediction_dict,
rpn_detection_dict):
box_encoding_predictions = frcnn_prediction_dict['box_encoding_predictions']
class_predictions = frcnn_prediction_dict['class_predictions']
proposal_boxlist_list = rpn_detection_dict['proposal_boxl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_processing(conf_thresh, nms_thresh, output):\n # anchors = [12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401]\n # num_anchors = 9\n # anchor_masks = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]\n # strides = [8, 16, 32]\n # anchor_step = len(anchors) // num_anchors\n\n ... | [
"0.6748592",
"0.66923344",
"0.64830357",
"0.63359743",
"0.63317955",
"0.6318814",
"0.6311672",
"0.63046706",
"0.6252147",
"0.62499297",
"0.6247293",
"0.62330717",
"0.6223152",
"0.6181827",
"0.6180195",
"0.6175555",
"0.6158713",
"0.61516434",
"0.61302596",
"0.61204636",
"0.611... | 0.7043132 | 0 |
Remove anchors that are not completely bounded within the image window, as well as the predictions associated with these outlying anchors. | def prune_outlying_anchors_and_predictions(box_encoding_predictions,
objectness_predictions,
anchor_boxlist,
clip_window):
pruned_anchor_boxlist, indices = box_list_ops.prune_outside_wind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_anchors(anchors, classification_targets, regression_targets, img_width=640, img_height=640):\n anchor_centers = tf.transpose(tf.stack([(anchors[:, 0] + anchors[:, 2]) / 2, (anchors[:, 1] + anchors[:, 3]) / 2]))\n \n outside_wdith_indices = tf.math.logical_or(tf.math.greater_equal(anchor_centers... | [
"0.5959764",
"0.5836451",
"0.5813163",
"0.58057064",
"0.5663937",
"0.5638801",
"0.56053454",
"0.5533746",
"0.53872126",
"0.53857964",
"0.53481275",
"0.53219485",
"0.52918553",
"0.52322155",
"0.52241045",
"0.52168787",
"0.52100444",
"0.52092826",
"0.5199738",
"0.5170391",
"0.5... | 0.7134823 | 0 |
Sample a minibatch of proposal boxes to send to Fast RCNN at training time. The decoded, nms'ed, and clipped proposal boxes from RPN are further sampled to an even smaller set to be used for extracting ROI feature maps for Fast | def sample_frcnn_minibatch(model,
batch_proposal_boxes,
batch_num_proposals,
gt_boxlist_list):
proposal_boxlist_list = []
num_proposals_list = []
for proposal_boxes, num_proposals, gt_boxlist in zip(
tf.unstack(batch_proposal_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fast_rcnn_proposals(self, rpn_proposal_bbox, encode_boxes, categories, scores, image_window):\n\n def batch_slice_rcnn_proposals(rpn_proposal_bbox,\n encode_boxes,\n categories,\n scores,\n ... | [
"0.6559674",
"0.64411736",
"0.63796157",
"0.610468",
"0.6082845",
"0.60051656",
"0.5952239",
"0.5932984",
"0.58271086",
"0.58226293",
"0.5805831",
"0.57984835",
"0.57609177",
"0.5755549",
"0.57436234",
"0.57082653",
"0.5685502",
"0.5670065",
"0.564898",
"0.5645712",
"0.561750... | 0.6868036 | 0 |
Sample a minibatch of proposal boxes for a single image. A total of `model._frcnn_minibatch_size` boxes are sampled according to a desired positive percentage rate. If there are not enough positive boxes to achieve this rate, negative boxes are padded to the sampled set of boxes. | def _sample_frcnn_minibatch_per_image(model,
proposal_boxlist,
gt_boxlist):
(loc_targets, loc_weights, cls_targets, cls_weights, msk_targets, _
) = model._frcnn_target_assigner.assign(proposal_boxlist, gt_boxlist)
# `cls_weights` is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_frcnn_minibatch(model,\n batch_proposal_boxes,\n batch_num_proposals,\n gt_boxlist_list):\n proposal_boxlist_list = []\n num_proposals_list = []\n\n for proposal_boxes, num_proposals, gt_boxlist in zip(\n tf.unstack(ba... | [
"0.7632359",
"0.6020198",
"0.5875332",
"0.56892735",
"0.5618419",
"0.55486417",
"0.54287046",
"0.54169184",
"0.540089",
"0.5356255",
"0.5341498",
"0.5265375",
"0.5232999",
"0.52147204",
"0.5199616",
"0.5144513",
"0.51442325",
"0.51193076",
"0.5117595",
"0.50971895",
"0.509620... | 0.76515996 | 0 |
Compute mask loss. Each proposal (out of `max_num_proposals`) predictes `num_classes` masks of shape [mask_height, mask_width]. However, only the one corresponding to the groundtruth class label `k` will be "selected" and contribute to the loss. | def _compute_mask_loss(model,
mask_predictions,
batch_cls_targets,
batch_msk_targets,
batch_msk_weights,
padding_indicator,
proposal_boxlist_list):
(batch_num_proposals, num_classe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postprocess_masks(mask_predictions, frcnn_detection_dict):\n # [batch_size, max_num_proposals] e.g. 1, 300\n detection_classes = frcnn_detection_dict['classes']\n # e.g 300, 90, 33, 33 \n _, num_classes, mask_height, mask_width = mask_predictions.shape.as_list()\n batch_size, max_detection = detection_cla... | [
"0.67618287",
"0.6542938",
"0.6495758",
"0.63780904",
"0.63696027",
"0.6329117",
"0.6237516",
"0.61294407",
"0.5989295",
"0.59697896",
"0.59415644",
"0.5940343",
"0.59046674",
"0.5888546",
"0.58790874",
"0.5876182",
"0.5835143",
"0.583081",
"0.58214194",
"0.58172345",
"0.5802... | 0.7792567 | 0 |
Postprocess_masks to generate mask predictions. Each proposal (out of `max_num_proposals`) predictes `num_classes` masks of shape [mask_height, mask_width]. However, only the one corresponding to the predicted class label `k` will be "selected" and generate a mask detection. | def postprocess_masks(mask_predictions, frcnn_detection_dict):
# [batch_size, max_num_proposals] e.g. 1, 300
detection_classes = frcnn_detection_dict['classes']
# e.g 300, 90, 33, 33
_, num_classes, mask_height, mask_width = mask_predictions.shape.as_list()
batch_size, max_detection = detection_classes.get_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_mask_loss(model,\n mask_predictions,\n batch_cls_targets,\n batch_msk_targets,\n batch_msk_weights,\n padding_indicator,\n proposal_boxlist_list):\n (batch_num_proposals... | [
"0.6861565",
"0.6561429",
"0.6560561",
"0.63544565",
"0.63211066",
"0.6238282",
"0.6176481",
"0.6168751",
"0.6168098",
"0.6156714",
"0.61305714",
"0.6115925",
"0.610042",
"0.6066866",
"0.60392797",
"0.6015793",
"0.6012942",
"0.60003036",
"0.5985489",
"0.5981014",
"0.587412",
... | 0.79600555 | 0 |
Set up a TestPushkin for the test. | def config_setup(self, config):
super(PushGatewayApiV1TestCase, self).config_setup(config)
config["apps"]["com.example.spqr"] = {
"type": "tests.test_pushgateway_api_v1.TestPushkin"
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.pump = Pump('127.0.0.1', 8000)",
"def setUpClass(cls):\n WxPusher.default_token = config.TOKEN",
"def setUp(self):\n logging.debug('setting up')",
"def setUp(self):\n logging.debug('setting up')",
"def setup_method(self):\n self.hass = get_test_hom... | [
"0.7122624",
"0.69579494",
"0.67404014",
"0.67404014",
"0.6676195",
"0.6670377",
"0.6603108",
"0.6574682",
"0.6574682",
"0.6528346",
"0.6492175",
"0.6444044",
"0.6430749",
"0.6417126",
"0.6409189",
"0.63952833",
"0.63625073",
"0.6357726",
"0.6357726",
"0.6353507",
"0.6350375"... | 0.69813585 | 1 |
Test that good requests give a 200 response code. | def test_good_requests_give_200(self):
# 200 codes cause the result to be parsed instead of returning the code
self.assertNot(
isinstance(
self._request(
self._make_dummy_notification([DEVICE_ACCEPTED, DEVICE_REJECTED])
),
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_response_200_on_get(self):\n pass",
"def test_status_code(self):\n self.assertEquals(self.response.status_code, 200)",
"def test_site_get_status_200_code(api_client):\n r = api_client.get(path=\"/\")\n assert r.status_code == 200",
"def test_1():\n\tassert api_call().status_code ... | [
"0.8366052",
"0.8109574",
"0.80699474",
"0.8015894",
"0.8006835",
"0.7980883",
"0.7931863",
"0.7882258",
"0.7840906",
"0.78161216",
"0.7730852",
"0.77084374",
"0.77072483",
"0.77072483",
"0.77072483",
"0.77072483",
"0.77072483",
"0.77072483",
"0.77072483",
"0.77072483",
"0.77... | 0.81243604 | 1 |
Test that devices which are accepted by the Pushkin do not lead to a rejection being returned to the homeserver. | def test_accepted_devices_are_not_rejected(self):
self.assertEqual(
self._request(self._make_dummy_notification([DEVICE_ACCEPTED])),
{"rejected": []},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_only_rejected_devices_are_rejected(self):\n self.assertEqual(\n self._request(\n self._make_dummy_notification([DEVICE_REJECTED, DEVICE_ACCEPTED])\n ),\n {\"rejected\": [DEVICE_REJECTED[\"pushkey\"]]},\n )",
"def test_rejected_devices_are_rej... | [
"0.7589871",
"0.752034",
"0.6467261",
"0.63251835",
"0.6310379",
"0.6295371",
"0.6278096",
"0.62775946",
"0.6209423",
"0.61690414",
"0.61639637",
"0.615318",
"0.60253876",
"0.59828544",
"0.59717953",
"0.5945808",
"0.5937678",
"0.593201",
"0.59185964",
"0.59135383",
"0.5907165... | 0.77541375 | 0 |
Test that devices which are rejected by the Pushkin DO lead to a rejection being returned to the homeserver. | def test_rejected_devices_are_rejected(self):
self.assertEqual(
self._request(self._make_dummy_notification([DEVICE_REJECTED])),
{"rejected": [DEVICE_REJECTED["pushkey"]]},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_only_rejected_devices_are_rejected(self):\n self.assertEqual(\n self._request(\n self._make_dummy_notification([DEVICE_REJECTED, DEVICE_ACCEPTED])\n ),\n {\"rejected\": [DEVICE_REJECTED[\"pushkey\"]]},\n )",
"def test_accepted_devices_are_not... | [
"0.7739414",
"0.7292945",
"0.64102954",
"0.6372204",
"0.624335",
"0.6214547",
"0.61519873",
"0.6139364",
"0.6114347",
"0.60957825",
"0.6039541",
"0.60349476",
"0.5992696",
"0.59193885",
"0.5903018",
"0.5886335",
"0.5839631",
"0.58294874",
"0.58286476",
"0.5812369",
"0.5812353... | 0.78516287 | 0 |
Test that devices which are rejected by the Pushkin are the only ones to have a rejection returned to the homeserver, even if other devices feature in the request. | def test_only_rejected_devices_are_rejected(self):
self.assertEqual(
self._request(
self._make_dummy_notification([DEVICE_REJECTED, DEVICE_ACCEPTED])
),
{"rejected": [DEVICE_REJECTED["pushkey"]]},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rejected_devices_are_rejected(self):\n self.assertEqual(\n self._request(self._make_dummy_notification([DEVICE_REJECTED])),\n {\"rejected\": [DEVICE_REJECTED[\"pushkey\"]]},\n )",
"def test_accepted_devices_are_not_rejected(self):\n self.assertEqual(\n ... | [
"0.7852091",
"0.77019984",
"0.62974644",
"0.60812265",
"0.603366",
"0.594662",
"0.5900683",
"0.586145",
"0.5822811",
"0.5805447",
"0.5768422",
"0.5755719",
"0.5749999",
"0.5743728",
"0.5700017",
"0.5692686",
"0.56890213",
"0.56496006",
"0.56390953",
"0.56291646",
"0.5624644",... | 0.8052974 | 0 |
Test that bad requests lead to a 400 Bad Request response. | def test_bad_requests_give_400(self):
self.assertEqual(self._request({}), 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_request(self):\n self._error_test(fitbit_exceptions.HTTPBadRequest)",
"def bad_request():\n return HttpError(400)",
"def assertHttpBadRequest(self, response):\r\n self.assertEqual(response.status_code, 400)",
"def test_400_bad_request(app, client):\n\n @app.route(\"/400\")\n ... | [
"0.83668786",
"0.82290065",
"0.80439466",
"0.8022105",
"0.79909754",
"0.7924414",
"0.77513343",
"0.771216",
"0.7640599",
"0.7608521",
"0.7534371",
"0.7532017",
"0.75092214",
"0.7439776",
"0.7426386",
"0.73832756",
"0.7283752",
"0.7283068",
"0.72757006",
"0.7246199",
"0.724292... | 0.89622575 | 0 |
Test that errors caused by remote services such as GCM or APNS lead to a 502 Bad Gateway response. | def test_remote_errors_give_502(self):
self.assertEqual(
self._request(self._make_dummy_notification([DEVICE_REMOTE_ERROR])), 502
)
# we also check that a successful device doesn't hide the exception
self.assertEqual(
self._request(
self._make_du... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_bad_gateway(self):\n self._error(502, \"Bad Gateway\")",
"def test_internal_server_error_beomces_remote_initiated_server_error(self):\n msg = \"The server has encountered an error\"\n error = ErrorParser().process_all(msg)\n assert isinstance(error, RemoteInitiatedServerErro... | [
"0.72009605",
"0.68032765",
"0.6392767",
"0.6313582",
"0.6272545",
"0.6221544",
"0.6218704",
"0.6199463",
"0.6025479",
"0.5992929",
"0.59796154",
"0.5951715",
"0.59206307",
"0.5914606",
"0.5865999",
"0.5836617",
"0.5834235",
"0.58115697",
"0.58040667",
"0.57583904",
"0.570471... | 0.79343057 | 0 |
Wrap data in a pktline. | def pkt_line(data):
if data is None:
return b"0000"
return ("%04x" % (len(data) + 4)).encode("ascii") + data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _split_line( self, data_list, line_num, text ):\n\t\t# if blank line or context separator, just add it to the output list\n\t\tif not line_num:\n\t\t\tdata_list.append( ( line_num, text ) )\n\t\t\treturn\n\n\t\t# if line text doesn't need wrapping, just add it to the output list\n\t\tsize = len( text )\n\t\tma... | [
"0.637851",
"0.61395586",
"0.5798506",
"0.5757137",
"0.5583528",
"0.5544903",
"0.55227596",
"0.546691",
"0.5461219",
"0.54565406",
"0.53980154",
"0.5386462",
"0.53805095",
"0.53432435",
"0.5322355",
"0.5282483",
"0.52766263",
"0.52751166",
"0.5254884",
"0.5183273",
"0.5179044... | 0.6977658 | 0 |
Reads a pktline from the remote git process. This method may read from the readahead buffer; see unread_pkt_line. | def read_pkt_line(self):
if self._readahead is None:
read = self.read
else:
read = self._readahead.read
self._readahead = None
try:
sizestr = read(4)
if not sizestr:
raise HangupException()
size = int(sizest... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unread_pkt_line(self, data):\n if self._readahead is not None:\n raise ValueError(\"Attempted to unread multiple pkt-lines.\")\n self._readahead = BytesIO(pkt_line(data))",
"def readline( self ):\n self.readbuf += self.read( 1024 )\n if '\\n' not in self.readbuf:\n ... | [
"0.60654914",
"0.58343184",
"0.5746313",
"0.5713916",
"0.5604577",
"0.56039476",
"0.55823517",
"0.55635846",
"0.5504266",
"0.5451499",
"0.5451499",
"0.53195196",
"0.53101134",
"0.525865",
"0.5254707",
"0.523701",
"0.52064",
"0.5197758",
"0.5174041",
"0.51538587",
"0.51481694"... | 0.7623639 | 0 |
Test whether the protocol stream has reached EOF. Note that this refers to the actual stream EOF and not just a flushpkt. | def eof(self):
try:
next_line = self.read_pkt_line()
except HangupException:
return True
self.unread_pkt_line(next_line)
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eof_received(self):\n self.connection_lost('EOF')\n return False",
"def isEOF(self):\n return _libsbml.XMLInputStream_isEOF(self)",
"def at_eof(self):\n return self._eof and not self._buffer",
"def EndOfPacket(self) -> bool:",
"def isEOF(self):\n return _libsbml.XMLTo... | [
"0.8005917",
"0.75207925",
"0.7487831",
"0.7406883",
"0.73358893",
"0.73277694",
"0.7299223",
"0.7143877",
"0.70836014",
"0.70545065",
"0.6996729",
"0.6926387",
"0.6915888",
"0.67768115",
"0.67768115",
"0.67768115",
"0.67768115",
"0.666015",
"0.6657719",
"0.6638315",
"0.64917... | 0.7601946 | 1 |
Unread a single line of data into the readahead buffer. This method can be used to unread a single pktline into a fixed readahead buffer. | def unread_pkt_line(self, data):
if self._readahead is not None:
raise ValueError("Attempted to unread multiple pkt-lines.")
self._readahead = BytesIO(pkt_line(data)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_pkt_line(self):\n if self._readahead is None:\n read = self.read\n else:\n read = self._readahead.read\n self._readahead = None\n\n try:\n sizestr = read(4)\n if not sizestr:\n raise HangupException()\n s... | [
"0.6237095",
"0.6038473",
"0.57843417",
"0.57250655",
"0.57105124",
"0.5643139",
"0.5566772",
"0.54605937",
"0.54454356",
"0.53100026",
"0.52821004",
"0.5278632",
"0.5278632",
"0.5258794",
"0.5233717",
"0.5220417",
"0.5196931",
"0.5183471",
"0.51438427",
"0.51422936",
"0.5128... | 0.78933 | 0 |
Sends a pktline to the remote git process. | def write_pkt_line(self, line):
try:
line = pkt_line(line)
self.write(line)
if self.report_activity:
self.report_activity(len(line), "write")
except socket.error as e:
raise GitProtocolError(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_line(self, line):\n self.send({\"content\": f\"{line}\\r\\n\"})",
"def send_line(self, line):\n self.ser.write(line + \"\\r\")",
"def do_log(self, line):\n subprocess.call([\n 'git', '-C', self.repo.path,\n 'log', '--graph', '--oneline',\n \"{}...p... | [
"0.5976438",
"0.58296734",
"0.57387185",
"0.5690254",
"0.563885",
"0.562356",
"0.5614085",
"0.55545294",
"0.5538175",
"0.55308515",
"0.5519796",
"0.5406222",
"0.5391091",
"0.53573895",
"0.53275293",
"0.5312595",
"0.529618",
"0.5274024",
"0.5250301",
"0.5240664",
"0.52271235",... | 0.6983859 | 0 |
Return a writable filelike object for this protocol. | def write_file(self):
class ProtocolFile(object):
def __init__(self, proto):
self._proto = proto
self._offset = 0
def write(self, data):
self._proto.write(data)
self._offset += len(data)
def tell(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap(self):\n return open(str(self), mode=\"a\")",
"def fs_write(obj, file_path):\n try:\n with open(str(file_path), 'w') as f:\n f.write(obj)\n return obj\n except TypeError as e:\n raise e",
"def write(self, object, content_type, to_file):\n return to_f... | [
"0.6533838",
"0.6336955",
"0.627701",
"0.61485547",
"0.6129662",
"0.61164707",
"0.6109132",
"0.60906744",
"0.60825753",
"0.6040922",
"0.6003314",
"0.5918463",
"0.58536315",
"0.57450175",
"0.57251894",
"0.5713926",
"0.56929713",
"0.5691276",
"0.5690234",
"0.5655157",
"0.565389... | 0.7767989 | 0 |
Write multiplexed data to the sideband. | def write_sideband(self, channel, blob):
# a pktline can be a max of 65520. a sideband line can therefore be
# 65520-5 = 65515
# WTF: Why have the len in ASCII, but the channel in binary.
while blob:
self.write_pkt_line(bytes(bytearray([channel])) + blob[:65515])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, data):\n\t\tself.outputbuffer.write(data)",
"def write( data ):",
"def write(data):",
"def write(self, data):\n self.buffer.append(data)\n while self.push():\n pass",
"def write(self, data):\n raise NotImplementedError()",
"def write(self, out):",
"def wr... | [
"0.6140103",
"0.5822756",
"0.5804623",
"0.5804449",
"0.5775977",
"0.56251913",
"0.56141996",
"0.55667806",
"0.556184",
"0.5559571",
"0.5555202",
"0.554515",
"0.5520507",
"0.5475498",
"0.5446895",
"0.54404384",
"0.543529",
"0.54348016",
"0.5430016",
"0.54056835",
"0.537824",
... | 0.61415505 | 0 |
Extract a capabilities list from a string, if present. | def extract_capabilities(text):
if b"\0" not in text:
return text, []
text, capabilities = text.rstrip().split(b"\0")
return (text, capabilities.strip().split(b" ")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_list_str(setting_str):\n return re.split('\\s*,\\s*', setting_str)",
"def fromChannelCapability(capability):\n assert isChannelCapability(capability), 'got %s' % capability\n return capability.split(',', 1)",
"def capabilities(self) -> Optional[Sequence[str]]:\n return pulumi.get(self... | [
"0.5712559",
"0.56877166",
"0.5544859",
"0.53554165",
"0.534204",
"0.5323479",
"0.5251328",
"0.52212495",
"0.5207596",
"0.5070931",
"0.5065005",
"0.5023225",
"0.4999685",
"0.49822563",
"0.49566996",
"0.49424976",
"0.49424976",
"0.4942203",
"0.4931715",
"0.49199003",
"0.491044... | 0.68393815 | 0 |
Extract a capabilities list from a want line, if present. Note that want lines have capabilities separated from the rest of the line | def extract_want_line_capabilities(text):
split_text = text.rstrip().split(b" ")
if len(split_text) < 3:
return text, []
return (b" ".join(split_text[:2]), split_text[2:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_capabilities(text):\n if b\"\\0\" not in text:\n return text, []\n text, capabilities = text.rstrip().split(b\"\\0\")\n return (text, capabilities.strip().split(b\" \"))",
"def test_get_capabilities():\n capabilties = (\n \"Capability Identity : Capa1\\r\\n State : Installed... | [
"0.61705464",
"0.5742173",
"0.5668369",
"0.5617442",
"0.55993676",
"0.5542799",
"0.54709315",
"0.5421424",
"0.5367552",
"0.53381246",
"0.5315918",
"0.53121763",
"0.5257215",
"0.52202064",
"0.5194016",
"0.5193577",
"0.51772237",
"0.51483595",
"0.51483595",
"0.500061",
"0.49958... | 0.6504761 | 0 |
Extract the ack type from a capabilities list. | def ack_type(capabilities):
if b"multi_ack_detailed" in capabilities:
return MULTI_ACK_DETAILED
elif b"multi_ack" in capabilities:
return MULTI_ACK
return SINGLE_ACK | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_supported_caps():\n result = []\n # generate list of supported capabilities\n\n # Intel RDT L3 CAT\n if common.PQOS_API.is_l3_cat_supported():\n result.append(common.CAT_L3_CAP)\n\n # Intel RDT L2 CAT\n if common.PQOS_API.is_l2_cat_supported():\n result.append(common.CAT_... | [
"0.5060372",
"0.50528365",
"0.5024367",
"0.49090785",
"0.4712331",
"0.46624753",
"0.4622932",
"0.45944288",
"0.4546804",
"0.45112157",
"0.4510836",
"0.45106286",
"0.44893143",
"0.44808757",
"0.44399983",
"0.4421436",
"0.44178936",
"0.44013375",
"0.43996078",
"0.43832308",
"0.... | 0.7684149 | 0 |
Write data, wrapping it in a pktline. | def write(self, data):
line = pkt_line(data)
line_len = len(line)
over = self._buflen + line_len - self._bufsize
if over >= 0:
start = line_len - over
self._wbuf.write(line[:start])
self.flush()
else:
start = 0
saved = line[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeLine(self, data):\n raise NotImplementedError()",
"def write( data ):",
"def write(data):",
"def write_pkt_line(self, line):\n try:\n line = pkt_line(line)\n self.write(line)\n if self.report_activity:\n self.report_activity(len(line), \"... | [
"0.77363765",
"0.68403333",
"0.6740575",
"0.6729256",
"0.67281187",
"0.6720931",
"0.6714167",
"0.66081816",
"0.6605214",
"0.6592525",
"0.652679",
"0.6495463",
"0.6491304",
"0.64801604",
"0.6474141",
"0.6385463",
"0.63730884",
"0.6344737",
"0.6332594",
"0.6249804",
"0.62128353... | 0.8075877 | 0 |
Parse a fragment of data and call back for any completed packets. | def parse(self, data):
self._readahead.write(data)
buf = self._readahead.getvalue()
if len(buf) < 4:
return
while len(buf) >= 4:
size = int(buf[:4], 16)
if size == 0:
self.handle_pkt(None)
buf = buf[4:]
elif ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self, data):\r\n\r\n parser.Parser.parse(self, data)\r\n\r\n # in case the current state of the parser is finished, must\r\n # reset the state to the start position as the parser is\r\n # re-starting (probably a new data sequence)\r\n if self.state == FINISH_STATE: self... | [
"0.6417268",
"0.6352155",
"0.62725854",
"0.62084985",
"0.62001276",
"0.61109674",
"0.60636824",
"0.6017022",
"0.58834016",
"0.5834325",
"0.5831261",
"0.58221",
"0.5819908",
"0.58088964",
"0.57752466",
"0.57290775",
"0.5716695",
"0.56845474",
"0.5662079",
"0.5643322",
"0.56317... | 0.65082204 | 0 |
Generate a unique name for the object in question Returns a name of the form "{calling_class_name}_{count}" | def generate_name(obj):
global NAME_COUNTERS
calling_name = obj.__name__
NAME_COUNTERS[calling_name] += 1
return '{0}_{1}'.format(calling_name, NAME_COUNTERS[calling_name]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_unique_class_name(self):\n if Project.__next_type_id > 2_000_000_000:\n raise Exception(\"Too many classes\")\n\n Project.__next_type_id += 1\n return f'Class_{Project.__next_type_id}'",
"def name(self) -> str:\n return f\"{self._obj_name} count\"",
"def gene... | [
"0.769304",
"0.74042475",
"0.7346067",
"0.70908105",
"0.701504",
"0.6995797",
"0.6857081",
"0.6848706",
"0.6825209",
"0.6811608",
"0.6808437",
"0.67691547",
"0.67593205",
"0.67588013",
"0.67393875",
"0.67349625",
"0.6731565",
"0.6670789",
"0.6658555",
"0.6658555",
"0.66528136... | 0.8733586 | 0 |
Set `logp` to negative infinity when `X` is outside the allowed bounds. Arguments | def set_logp_to_neg_inf(X, logp, bounds):
conditions = []
for l, u in bounds:
lower_is_neg_inf = not isinstance(l, tf.Tensor) and np.isneginf(l)
upper_is_pos_inf = not isinstance(u, tf.Tensor) and np.isposinf(u)
if not lower_is_neg_inf and upper_is_pos_inf:
conditions.append... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logp(self, x):\n pass",
"def safelog(x):\n #return np.log(x)\n return np.log(np.clip(x,floor,np.inf))",
"def neg_log_p(p):\n return np.nan_to_num(-np.log10(p))",
"def logp(self, F, Y):\n raise NotImplementedError(\"implement the logp function\\\n for th... | [
"0.71406347",
"0.69890064",
"0.6920529",
"0.687885",
"0.6704204",
"0.6619069",
"0.6469033",
"0.6457033",
"0.6414548",
"0.6395825",
"0.6280646",
"0.6270109",
"0.6269846",
"0.62419087",
"0.6233688",
"0.622782",
"0.62175864",
"0.62174034",
"0.6208965",
"0.61985666",
"0.60952914"... | 0.7539016 | 0 |
Find a new set of boundaries combining `bounds_1` and `bounds_2` Arguments | def find_common_bounds(bounds_1, bounds_2):
new_bounds = []
for (lower_1, upper_1), (lower_2, upper_2) in itertools.product(bounds_1, bounds_2):
# Ignore this region if it's outside the current limits
if upper_1 <= lower_2 or upper_2 <= lower_1:
continue
new_bounds.append(Reg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _combine_bounds(bounds1, bounds2):\n \n bounds_comb = np.zeros((2, 2), dtype=int)\n bounds_comb[0, 0] = bounds1[0, 0] if (bounds1[0, 0] < bounds2[0, 0]) else bounds2[0, 0]\n bounds_comb[1, 0] = bounds1[1, 0] if (bounds1[1, 0] < bounds2[1, 0]) else bounds2[1, 0]\n bounds_comb[0, 1] = bounds1[0, 1... | [
"0.7715347",
"0.6710567",
"0.66856617",
"0.6493881",
"0.6461956",
"0.63912714",
"0.6300225",
"0.626203",
"0.62357503",
"0.6207035",
"0.62008715",
"0.61290604",
"0.6109712",
"0.610042",
"0.6091096",
"0.60840344",
"0.6002763",
"0.5936327",
"0.5935136",
"0.5929456",
"0.5898049",... | 0.77315205 | 0 |
Make tasks with setting from paper. | def make_task(task_name, override_kwargs=None, max_code_length=100,
require_correct_syntax=False,
do_code_simplification=False,
correct_bonus=2.0, code_length_bonus=1.0):
logging.info('Making paper-config task.')
n = 16 # Number of test cases.
task_mapping = {
'pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_tasks(self, task):",
"def create_task():",
"def tasks():",
"def task():",
"def assign_task(x):\n Board.style = x\n if x == 1:\n b = Board(files[board], Engine.DIJKSTRA)\n active_boards.append(b)\n active_engines.append(Engine(b, Engine.DIJKSTRA))\n elif x == 2:\n ... | [
"0.69294506",
"0.6665678",
"0.65250504",
"0.62063086",
"0.6084005",
"0.5981199",
"0.59461004",
"0.59461004",
"0.5912851",
"0.5910416",
"0.5861224",
"0.58334297",
"0.5816955",
"0.5795692",
"0.5720717",
"0.56974655",
"0.5662473",
"0.5655708",
"0.5655708",
"0.56520903",
"0.56520... | 0.67749566 | 1 |
Run test cases on code and compute reward. | def _score_code(self, code):
# Get list of 2-tuples, each containing an input sequence and an output
# sequence.
io_seqs = self.task.make_io_set()
terminal_reward = 0.0
results = []
reason = 'correct'
for input_seq, output_seq in io_seqs:
eval_result = bf.evaluate(
code, inpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(args):\n brain_name = env.brain_names[0]\n brain = env.brains[brain_name]\n env_info = env.reset(train_mode=True)[brain_name]\n\n num_agents = len(env_info.agents)\n print('Number of agents:', num_agents)\n\n # dim of each action\n action_size = brain.vector_action_space_size\n pri... | [
"0.6732342",
"0.6615527",
"0.65945077",
"0.64790094",
"0.6476169",
"0.6445508",
"0.6440616",
"0.63859",
"0.6308646",
"0.6293128",
"0.62635726",
"0.6253372",
"0.6220339",
"0.6219079",
"0.62004536",
"0.61721396",
"0.6112167",
"0.6110509",
"0.60910785",
"0.6080738",
"0.60736054"... | 0.68491966 | 0 |
Return a strategy that holds if and only if pending >= x or player reaches goal. | def hold_at(x):
def strategy(state):
(p, me, you, pending) = state
return 'hold' if (pending >= x or me + pending >= goal) else 'roll'
strategy.__name__ = 'hold_at(%d)' % x
return strategy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hold_at(x):\n\n def strategy(state):\n # your code here\n p, me, you, pending = state\n return \"hold\" if (pending >= x or me + pending >= goal) else \"roll\"\n strategy.__name__ = 'hold_at(%d)' % x\n return strategy",
"def Pwin(state):\n # Assumes opponent also plays with optim... | [
"0.7068438",
"0.6023212",
"0.6022653",
"0.5952269",
"0.593654",
"0.5723054",
"0.56627566",
"0.56205976",
"0.56155175",
"0.56149507",
"0.5596191",
"0.557648",
"0.5567466",
"0.5565691",
"0.5486716",
"0.5442923",
"0.5435431",
"0.54241216",
"0.54045504",
"0.5403766",
"0.53954136"... | 0.7355243 | 0 |
Initial mw_plot images and plot | def initialize_mwplot(self):
if self.fig is None:
self.fig, self.ax = plt.subplots(1, figsize=self.figsize, dpi=self.dpi)
if self.title is not None:
self.fig.suptitle(self.title, fontsize=self.fontsize)
self.ax.set_xlabel(f'{self._coord_english} ({self._unit_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_mwplot(self):\n if self.fig is None:\n self.fig, self.ax = plt.subplots(1, figsize=self.figsize, dpi=self.dpi)\n if self.title is not None:\n self.fig.suptitle(self.title, fontsize=self.fontsize)\n if self.__grid == 'galactic':\n ... | [
"0.7306115",
"0.6932989",
"0.6838127",
"0.6741711",
"0.66630477",
"0.6657935",
"0.6635585",
"0.6603174",
"0.6579284",
"0.65176815",
"0.6514958",
"0.6514958",
"0.6514958",
"0.65110385",
"0.651041",
"0.65056896",
"0.6500299",
"0.64988",
"0.6454421",
"0.6423132",
"0.642233",
"... | 0.74907994 | 0 |
Plot scatter points with colorbar | def mw_scatter(self, x, y, c, **kwargs):
x, y = self.xy_unit_check(x, y)
self.initialize_mwplot()
# decide whether we need colorbar or not
if isinstance(c, list):
color = c[0]
cbar_label = c[1]
self.cbar_flag = True
if type(color) == u.qua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scatterPlot2():\n N = 100\n x = np.random.rand(N)\n y = np.random.rand(N)\n colors = np.random.rand(N)\n\n plt.scatter(x, y, c=colors, alpha=0.5)\n plt.show()",
"def plot_scatter(dataframe, colx, coly, xlabel='', \n ylabel='', \n xlim=[0,15], ylim=[0,15], den... | [
"0.6957231",
"0.68189776",
"0.6781912",
"0.6725077",
"0.667742",
"0.64773524",
"0.64616114",
"0.64443624",
"0.64385337",
"0.63356435",
"0.6334097",
"0.6324725",
"0.62319404",
"0.6228918",
"0.62105215",
"0.61905533",
"0.6189272",
"0.6186147",
"0.61778843",
"0.6163995",
"0.6151... | 0.6978989 | 0 |
Initial mw_plot images and plot | def initialize_mwplot(self):
if self.fig is None:
self.fig, self.ax = plt.subplots(1, figsize=self.figsize, dpi=self.dpi)
if self.title is not None:
self.fig.suptitle(self.title, fontsize=self.fontsize)
if self.__grid == 'galactic':
self.ax.set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_mwplot(self):\n if self.fig is None:\n self.fig, self.ax = plt.subplots(1, figsize=self.figsize, dpi=self.dpi)\n if self.title is not None:\n self.fig.suptitle(self.title, fontsize=self.fontsize)\n self.ax.set_xlabel(f'{self._coord_english} ({se... | [
"0.7490845",
"0.69329554",
"0.6838161",
"0.67417103",
"0.66630715",
"0.6657996",
"0.66355616",
"0.66032076",
"0.657932",
"0.6517709",
"0.6514982",
"0.6514982",
"0.6514982",
"0.65110624",
"0.65104574",
"0.65057063",
"0.6500342",
"0.6498811",
"0.6454433",
"0.6423086",
"0.642230... | 0.7306133 | 1 |
Deploys a proxy inside the cluster which allows to access the centralized solr without authentication | def deploy():
labels = {'app': 'ckan-cloud-solrcloud-proxy'}
solr_url = parse_url(solr_manager.get_internal_http_endpoint())
scheme = solr_url.scheme
hostname = solr_url.hostname
port = solr_url.port
solr_user, solr_password = '', ''
if solr_url.auth:
solr_user, solr_password = solr_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repository_create_proxy():\n pass",
"def proxy(c, path=local.proxy_path):\r\n c = conn(c)\r\n c.run('rm {conf} -rf'.format(conf=local.proxy_conf))\r\n\r\n \"\"\" 这里需要分开安装:先安装 epel-release 之后,才能安装 其他server\r\n \"\"\"\r\n system.install(c, 'source')\r\n system.install(c, 'apt-cacher-ng')\r... | [
"0.63305604",
"0.6177893",
"0.6136548",
"0.58640164",
"0.58560234",
"0.5816085",
"0.58004284",
"0.57565767",
"0.57198006",
"0.5637831",
"0.55530673",
"0.5459441",
"0.5410911",
"0.5401137",
"0.5377645",
"0.5369848",
"0.5292949",
"0.5289257",
"0.5239129",
"0.52300036",
"0.52293... | 0.7754981 | 0 |
create a new enumerationType definition (named for typeName) enum is NOT populated with values at this time | def getEnumerationTypeXmlStub (typeName):
simpleType = createSchemaElement("simpleType")
simpleType.setAttribute ("name",typeName)
restriction = createSchemaElement("restriction")
restriction.setAttribute ("base", qp("token"))
simpleType.appendChild (restriction)
return simpleType | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_enum(dct, name):\n return type(name, (Enum,), dct)",
"def from_string(cls, name: str) -> Enum:",
"def create_enum(name, fields, values=None):\n Enum = namedtuple(name, fields)\n if values is None:\n return Enum(*fields)\n return Enum(*values)",
"def test_type_builder_handles_en... | [
"0.7119985",
"0.65749115",
"0.6546982",
"0.6424037",
"0.6306205",
"0.6202732",
"0.6139445",
"0.6138822",
"0.61073095",
"0.6082157",
"0.6068417",
"0.5979457",
"0.59693533",
"0.5925831",
"0.5917477",
"0.5833892",
"0.5812985",
"0.5800444",
"0.5754362",
"0.5688803",
"0.56700826",... | 0.70210654 | 1 |
create an EnuerationType for "countriesType" populate it with info from the countryCodeMap | def makeCountriesEnumerationType (self):
# stub = getEnumerationTypeXmlStub ("countriesType")
# countriesVocab = AnnotatedEnumerationType (stub)
countriesVocab = self.createEnumerationType ("countriesType");
country_codes = self.countryCodeMap.keys()
country_codes.sort()
dataList = map (lambda key: (key, se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeCountriesEnumerationType (self):\n\t\t# stub = getEnumerationTypeXmlStub (\"countriesType\")\n\t\t# countriesVocab = AnnotatedEnumerationType (stub)\n\t\tcountriesType = self.createEnumerationType (\"countriesType\");\n\t\t\n\t\tself.setDataHubValues (countriesType)\n\t\t\n\t\tself.setPubsValues (countries... | [
"0.6894949",
"0.58707315",
"0.57558376",
"0.57416195",
"0.56944567",
"0.56487584",
"0.5470839",
"0.53961104",
"0.5338221",
"0.5250554",
"0.5219144",
"0.5158898",
"0.51312083",
"0.5085716",
"0.5079407",
"0.5078878",
"0.50527793",
"0.5045781",
"0.5040648",
"0.502151",
"0.496529... | 0.70057565 | 0 |
derive a type name from provided country_name e.g., "United States" > "unitedStatesType" | def makeTypeName (self, country_name):
#capitalize the segments (but leave first segment lowercase)
segments = map (lambda x: x.capitalize(), country_name.split(" "))
segments[0] = segments[0].lower()
name = "".join(segments) + "Type"
return unicode(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country_identifier(name):\n if name.lower() in _country_dict.keys():\n return _country_dict[name.lower()]\n else:\n return name",
"def typeToName(type: int) -> unicode:\n ...",
"def name_to_type(self, name):\n return self.CUSTOM_PREFIX + name",
"def city_country(city_name, c... | [
"0.62854075",
"0.6070885",
"0.60006964",
"0.5901309",
"0.5823116",
"0.57179815",
"0.5641593",
"0.5614854",
"0.560646",
"0.5581799",
"0.5578232",
"0.55536073",
"0.55463034",
"0.5535245",
"0.55272824",
"0.54868925",
"0.54133743",
"0.540993",
"0.5371416",
"0.5341667",
"0.5337637... | 0.8455244 | 0 |
Add transition probabilities to the grid world. p_good_transition is the probability that the agent successfully executes the intended action. The action is then incorrectly executed with probability 1 p_good_transition and in tis case the agent transitions to the left of the intended transition with probability (1 p_g... | def add_transition_probability(self, p_good_transition, bias):
self.p_good_trans = p_good_transition
self.bias = bias | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transition(self, row, col, action, tot_row, tot_col):\n\n '''\n Expand the grid of the environment to handle when the \n agent decides to move in the direction of a wall \n '''\n state_probabilities = np.zeros((int(np.sqrt(self.env.observation_space.n)) + 2, int(np.sqrt(s... | [
"0.6520693",
"0.6520693",
"0.61554277",
"0.598048",
"0.5729623",
"0.5647532",
"0.55879456",
"0.55477995",
"0.5507891",
"0.5477519",
"0.5388233",
"0.53746235",
"0.5356306",
"0.5354252",
"0.5335465",
"0.5335321",
"0.5297136",
"0.52890503",
"0.5276229",
"0.52486646",
"0.5232936"... | 0.6897156 | 0 |
Takes is a direction and an action and returns a new direction. | def _get_direction(self, action, direction):
left = [2,3,1,0]
right = [3,2,0,1]
if direction == 0:
new_direction = action
elif direction == -1:
new_direction = left[action]
elif direction == 1:
new_direction = right[action]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_action(self, game, node, action, moves):\n pass",
"def _direction_action(self, delta):\n all_directions = [\n 3, # football_action_set.action_top,\n 2, #football_action_set.action_top_left,\n 1, #football_action_set.action_left,\n 8, #football_ac... | [
"0.6134578",
"0.6078408",
"0.58893335",
"0.5874434",
"0.58678085",
"0.5851045",
"0.57970715",
"0.5740984",
"0.5732394",
"0.56936777",
"0.56890917",
"0.5607301",
"0.5594053",
"0.5572057",
"0.55654794",
"0.5555926",
"0.5540061",
"0.5529433",
"0.5515547",
"0.5486383",
"0.5483447... | 0.7031928 | 0 |
Get the next_state from the current state and a direction. | def _get_state(self, state, direction):
row_change = [-1,1,0,0]
col_change = [0,0,-1,1]
row_col = seq_to_col_row(state, self.num_cols)
row_col[0,0] += row_change[direction]
row_col[0,1] += col_change[direction]
# check for invalid states
if self.obs_states is not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next(self):\n\t\tassert(len(self.past_values) < 256**3)\n\t\twhile self.advance_state() in self.past_values:\n\t\t\tpass\n\t\tself.past_values.add(self.state)\n\t\treturn self.state",
"def go_one_step(old_state, direction):\n assert direction in ['R', 'L', 'U', 'D']\n\n x, y = old_state\n if dir... | [
"0.6917042",
"0.6894652",
"0.67598915",
"0.66928583",
"0.65743846",
"0.6443867",
"0.6439758",
"0.6363758",
"0.6331778",
"0.63023716",
"0.6271548",
"0.62355876",
"0.61482376",
"0.61159456",
"0.60470897",
"0.5994004",
"0.597474",
"0.5970635",
"0.5968833",
"0.59663206",
"0.59559... | 0.80074984 | 0 |
Test omitting default values on a perclass basis, but with individual overrides. | def test_individual_overrides(cl_and_vals):
converter = Converter()
cl, vals = cl_and_vals
for attr, val in zip(adapted_fields(cl), vals):
if attr.default is not NOTHING:
break
else:
assume(False)
chosen_name = attr.name
converter.register_unstructure_hook(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_default(Class, default_in, default_out):\n attribute = Class(\"test\", default=default_in)\n assert attribute.default == default_out",
"def without_defaults(self):\n ...",
"def test_overridable_parameter() -> None:\n param_dict = ParamClass.get_overridable_parameters()\n assert \"na... | [
"0.699537",
"0.65441453",
"0.6484113",
"0.6345803",
"0.6239284",
"0.6138489",
"0.6135049",
"0.6132409",
"0.6085254",
"0.6066474",
"0.60519874",
"0.6042269",
"0.6035791",
"0.60046893",
"0.5952607",
"0.5940098",
"0.5899657",
"0.5876268",
"0.58490825",
"0.58335704",
"0.58148766"... | 0.6660965 | 1 |
Omitting fields works with generated structuring functions. | def test_omitting_structure():
converter = Converter()
@define
class A:
a: int
b: int = field(init=False)
c: int = 1
converter.register_structure_hook(
A,
make_dict_structure_fn(
A, converter, b=override(omit=True), c=override(omit=True)
),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_all_fields(self):\n self.fields = None",
"def data_without(self, fields):\n without = {}\n data = json.loads(self.data())\n for field, value in data.items():\n if field not in fields:\n without[field] = value\n return json.dumps(without)",
... | [
"0.6457364",
"0.5907062",
"0.5795436",
"0.575384",
"0.56539893",
"0.5629004",
"0.562024",
"0.5604411",
"0.5603603",
"0.5601388",
"0.5590831",
"0.55850697",
"0.5574677",
"0.5568494",
"0.5561513",
"0.5549544",
"0.55447376",
"0.552427",
"0.5506951",
"0.54943097",
"0.5484334",
... | 0.6580121 | 0 |
generate a set of samples from the density matrix to be used for RBM training | def generate_samples(self, n_samples): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_runlist(self):\n\n if self.seed is not None:\n np.random.seed(self.seed)\n\n for i in moves.range(self.num_samples):\n sample = []\n for key, meta in iteritems(self.get_desvar_metadata()):\n nval = meta['size']\n values = []\n ... | [
"0.6543012",
"0.651311",
"0.62632036",
"0.61768943",
"0.61431444",
"0.6136097",
"0.6059645",
"0.60587394",
"0.6024747",
"0.6004419",
"0.59970945",
"0.59964937",
"0.5990772",
"0.5960781",
"0.5919938",
"0.5911328",
"0.58683705",
"0.5825365",
"0.5823669",
"0.5821116",
"0.5771471... | 0.6594295 | 0 |
generate a set of samples from the density matrix to be used for RBM training | def generate_samples(self, n_samples): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_runlist(self):\n\n if self.seed is not None:\n np.random.seed(self.seed)\n\n for i in moves.range(self.num_samples):\n sample = []\n for key, meta in iteritems(self.get_desvar_metadata()):\n nval = meta['size']\n values = []\n ... | [
"0.65419656",
"0.65123874",
"0.6263096",
"0.6175779",
"0.61411715",
"0.61350965",
"0.6059837",
"0.60576314",
"0.6024742",
"0.60027915",
"0.5996073",
"0.5995513",
"0.59895533",
"0.59602714",
"0.5918633",
"0.5909669",
"0.58669597",
"0.58248115",
"0.5821336",
"0.58195853",
"0.57... | 0.65922266 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.