query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Creates a temporary folder and removes it later. | def create_temp_dir(self, *args, **kwargs):
temp_dir = tempfile.mkdtemp(*args, **kwargs)
try:
yield decode_path(temp_dir)
finally:
remove_directory(temp_dir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def temporary_folder():\r\n tempdir = mkdtemp()\r\n try:\r\n yield tempdir\r\n finally:\r\n rmtree(tempdir)",
"def emptyTmpFolder(tmpFolderName:str = 'tmp'):\n removeTmpFolder(tmpFolderName)\n createTmpFolder(tmpFolderName)",
"def tmp_dir():\n tmpdir = tempfile.mkdtemp()\n yi... | [
"0.7982165",
"0.77585584",
"0.75517905",
"0.7493324",
"0.74830693",
"0.74282265",
"0.7409031",
"0.7332812",
"0.73097944",
"0.728743",
"0.727821",
"0.7251626",
"0.7243327",
"0.7178301",
"0.71573216",
"0.7146841",
"0.71295214",
"0.711919",
"0.7117585",
"0.7074823",
"0.7048555",... | 0.6873946 | 27 |
Insert new federal accounts records based on the TreasuryAppropriationAccount (TAS) table. Each TAS maps to a higherlevel federal account, defined by a unique combination of TAS agency_id (AID) and TAS main account code (MAC). | def insert_federal_accounts():
# look for treasury_appropriation_accounts with no federal_account FK
tas_no_federal_account = TreasuryAppropriationAccount.objects.filter(federal_account__isnull=True)
if tas_no_federal_account.count() > 0:
# there are tas records with no corresponding federal_accou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_federal_accounts(tas_tuple=None):\n\n # add federal_account_code\n queryset = FederalAccount.objects.all()\n queryset = queryset.filter(federal_account_code=None)\n for fa in queryset:\n # fa.save() is overwritten to add federal_account_code\n fa.save()\n\n # Because orm doe... | [
"0.61618704",
"0.51957715",
"0.49648538",
"0.48510122",
"0.47886592",
"0.47871605",
"0.47850755",
"0.47509208",
"0.4711211",
"0.45977607",
"0.45610386",
"0.45494926",
"0.4538106",
"0.44958264",
"0.4492509",
"0.44799647",
"0.44683558",
"0.44590577",
"0.44490206",
"0.44440094",
... | 0.73805857 | 0 |
Return number of rows this ContainerType has. | def row_count(self):
return self.well_count // self.col_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_count(self) -> int:\n return len(self.rows)",
"def row_count(self) -> int:\n return len(self.rows)",
"def getNumRows(self) -> int:\n ...",
"def rows_count(self):\n return len(self.value)",
"def num_rows(self):\n return (len(self.rows))",
"def num_rows(self):\n ... | [
"0.80426466",
"0.80426466",
"0.80323654",
"0.8031512",
"0.80151767",
"0.79809934",
"0.7922251",
"0.7906773",
"0.77700424",
"0.77311575",
"0.7730535",
"0.77244866",
"0.76997614",
"0.7625388",
"0.76250887",
"0.7621514",
"0.7619856",
"0.760746",
"0.7551008",
"0.75378376",
"0.750... | 0.6862185 | 72 |
Auto complete the brackets. | def auto_complete(self, event):
text = self.get_current()
# print(event)
if event.char == '(':
text.insert('insert', ')')
text.mark_set('insert', 'insert-1c')
elif event.char == '{':
text.insert('insert', '}')
text.mark_set('insert', 'inser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MenuWithBrackets(p_question: str):\n choices = [];\n\n for c in range(0,len(p_question)):\n if (p_question[c] == '[' and p_question[c+2] == ']'):\n choices.append((p_question[c+1]).lower())\n\n while True:\n character = (val.Char(ERASE_LINE + p_question)).lower()\n \n ... | [
"0.5576758",
"0.55426383",
"0.55359864",
"0.5484081",
"0.5471465",
"0.52958596",
"0.52753514",
"0.5273248",
"0.52221465",
"0.5217561",
"0.5208465",
"0.51820385",
"0.51627684",
"0.5140483",
"0.51224494",
"0.5096743",
"0.5096016",
"0.5088715",
"0.50718933",
"0.50451547",
"0.503... | 0.7019731 | 0 |
Change the modified flag of text widget | def modified_flag(self, event):
text = self.get_current()
text.modified = 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_text(self, text):\n # to set text you must first set it so it is editable,\n # then delete all the old text, insert the new text\n # and then disable editing again.\n self.configure(state=tk.NORMAL)\n self.delete(1.0, tk.END)\n self.insert(tk.END, text)\n se... | [
"0.7462077",
"0.7402745",
"0.7314721",
"0.71978104",
"0.7078623",
"0.7055851",
"0.698846",
"0.695777",
"0.6842217",
"0.68391055",
"0.6810094",
"0.67547995",
"0.67416924",
"0.6687369",
"0.6686604",
"0.6644247",
"0.66298395",
"0.66217494",
"0.6598999",
"0.65901685",
"0.6562261"... | 0.8028869 | 0 |
Utility method to reset data in DB between tests | def _data_reset(self):
conn = self.get_connection()
elements = {
**self.domain.registry.aggregates,
**self.domain.registry.entities,
**self.domain.registry.views,
}
for _, element_record in elements.items():
provider = current_domain.provi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_the_db(_step):\r\n reset_data(None)",
"def reset():\n teardown_db()\n build()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n... | [
"0.80278593",
"0.7747111",
"0.77452326",
"0.77452326",
"0.77452326",
"0.77452326",
"0.77452326",
"0.77452326",
"0.75154006",
"0.75154006",
"0.75154006",
"0.75154006",
"0.75154006",
"0.75154006",
"0.75154006",
"0.75154006",
"0.75154006",
"0.7397721",
"0.7377602",
"0.73607486",
... | 0.0 | -1 |
Saving the JSON output in file to reduce api calls | def save_server_list_json(server_list):
with open(output_file,"w+") as f:
json.dump(server_list, f)
return server_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self):\n self.json_o.write()",
"def write(self):\r\n\r\n with open(self.filename + \".json\", mode='w') as json_file:\r\n json.dump(self.data, json_file, separators=(',', ':'))",
"def export_file(self):\n if self.args.keyfilter:\n self.filter_keys()\n ... | [
"0.7092212",
"0.69925094",
"0.69505084",
"0.6925383",
"0.6915385",
"0.69101727",
"0.69021356",
"0.68666285",
"0.68464744",
"0.677794",
"0.67426777",
"0.6699499",
"0.66921324",
"0.6672704",
"0.6668035",
"0.66490513",
"0.6630014",
"0.6628091",
"0.6607886",
"0.65845263",
"0.6572... | 0.0 | -1 |
Saving the JSON output in file to reduce api calls | def export_server_list_json(server_list, filename):
with open(filename,"w+") as f:
json.dump(server_list, f)
return server_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self):\n self.json_o.write()",
"def write(self):\r\n\r\n with open(self.filename + \".json\", mode='w') as json_file:\r\n json.dump(self.data, json_file, separators=(',', ':'))",
"def export_file(self):\n if self.args.keyfilter:\n self.filter_keys()\n ... | [
"0.7092212",
"0.69925094",
"0.69505084",
"0.6925383",
"0.6915385",
"0.69101727",
"0.69021356",
"0.68666285",
"0.68464744",
"0.677794",
"0.67426777",
"0.6699499",
"0.66921324",
"0.6672704",
"0.6668035",
"0.66490513",
"0.6630014",
"0.6628091",
"0.6607886",
"0.65845263",
"0.6572... | 0.0 | -1 |
Construct heap from array A | def buildHeap(A):
n = len(A)
for i in range(n/2-1, -1, -1):
heapify(A, i, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_heap(self, A: list):\n self.size = len(A)\n med = (self.size // 2) - 1 #Mid point of array\n for i in range(0, med + 1): #Reverse iteration\n self.heapify(A, med - i) #Reverse iteration",
"def build_heap(arr):\n for i in range((len(arr)//2), -1, -1):\n heapify(... | [
"0.8162481",
"0.78898317",
"0.7745901",
"0.7577263",
"0.74283427",
"0.7355965",
"0.7286814",
"0.7275115",
"0.72547346",
"0.72501206",
"0.72134125",
"0.71794015",
"0.71004933",
"0.7092042",
"0.70334303",
"0.70334303",
"0.69489515",
"0.6915527",
"0.68802613",
"0.68802613",
"0.6... | 0.816595 | 0 |
Output the stored log values to screen and TensorBoard summaries. | def write(self, *, global_step: int, new_line: bool = True):
for w in self.__writers:
w.write(global_step=global_step,
queues=self.queues,
histograms=self.histograms,
pairs=self.pairs,
scalars=self.scalars,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_to_tensorboard(self, log_path: str) -> None:\n LOGGER.info(f'Log evaluations in tensorboard.')\n writer = SummaryWriter(log_dir=log_path)\n for key, value in self.eval_dict:\n writer.add_scalar(key, value)",
"def log_tensorboard(self, callback, names, logs, batch_no):\n\n... | [
"0.75942254",
"0.7423476",
"0.70048016",
"0.69833153",
"0.6807202",
"0.6780844",
"0.6757505",
"0.65567327",
"0.65542346",
"0.6551927",
"0.63893414",
"0.63514525",
"0.633815",
"0.62885255",
"0.622969",
"0.62240374",
"0.6221519",
"0.62039906",
"0.6199607",
"0.6192494",
"0.61262... | 0.0 | -1 |
This function Resize the image in width and height using original aspect ratio. It use desire width for calculate the new height Besides, resizing returns the same image twice because the extraction module needs it for later image processing purposes. | def resizing(image, image_2, desire_width):
height, width = image.shape[0:2]
aspect_ratio = (width / height)
new_width = desire_width
new_height = int(round(new_width / aspect_ratio))
standard_src = cv2.resize(image, (new_width, new_height))
image_tocut = cv2.resize(image_2,(new_width, new... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize_image(self, width=200):\n self.new_width = width\n aspect_ratio = self.original_height/float(self.original_width)\n self.new_height = int(aspect_ratio * self.new_width)\n\n resized_image = self.image.resize((self.new_width, self.new_height), Image.BILINEAR)\n return re... | [
"0.80984867",
"0.77260554",
"0.7397049",
"0.7348135",
"0.73390317",
"0.73308736",
"0.72597474",
"0.7241674",
"0.72203267",
"0.7173186",
"0.71115285",
"0.71115285",
"0.71012324",
"0.70892286",
"0.700555",
"0.69926536",
"0.6988651",
"0.6984629",
"0.6974211",
"0.6966637",
"0.695... | 0.69387376 | 21 |
Converting to gray scale the image to make an adaptative thresholding for find the outlines | def threshold_image(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh_image_inv = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 15, 7)
thresh_image = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 15, 7)
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_edges(original_image: Image, threshold: int) -> Image :\r\n \r\n new_image = copy(original_image)\r\n final_image = copy(new_image)\r\n \r\n # Only two colours to be used\r\n black = create_color(0, 0, 0)\r\n white = create_color(255, 255, 255)\r\n \r\n # determine the width a... | [
"0.73270786",
"0.7269959",
"0.7061801",
"0.6804693",
"0.6742535",
"0.6742535",
"0.66835123",
"0.66359097",
"0.66250736",
"0.6592301",
"0.6585989",
"0.6567829",
"0.6567764",
"0.6540281",
"0.6529292",
"0.64922976",
"0.64846987",
"0.6472695",
"0.6461164",
"0.6453322",
"0.6444026... | 0.63226867 | 31 |
First Hidden layer with zeroes initiated | def initHidden(self, batch_size):
zero_hidden = torch.zeros(self.n_layers, batch_size, self.hidden_size)
return zero_hidden | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_hidden(self):\n # TODO ========================\n # initialize the hidden states to zero\n\n initial_hidden = torch.zeros(self.num_layers, self.batch_size, self.hidden_size)\n return initial_hidden # a parameter tensor of shape (self.num_layers, self.batch_size, self.hidden_si... | [
"0.73804605",
"0.7294904",
"0.7086532",
"0.6950707",
"0.6923773",
"0.6908031",
"0.6717069",
"0.6704652",
"0.65038264",
"0.648665",
"0.64673334",
"0.6445984",
"0.6431873",
"0.642712",
"0.642712",
"0.6418645",
"0.6398223",
"0.6398223",
"0.639458",
"0.63436013",
"0.63057464",
... | 0.7544034 | 0 |
A view to return the index.html page | def index(request):
return render(request, 'home/index.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\r\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index():\r\n return render_template('index... | [
"0.9035053",
"0.9015076",
"0.89756584",
"0.89756584",
"0.89409",
"0.89409",
"0.8913624",
"0.891081",
"0.8902496",
"0.8902496",
"0.8902496",
"0.8899004",
"0.88629603",
"0.88518476",
"0.8844311",
"0.8838597",
"0.8838597",
"0.8838597",
"0.8838597",
"0.8838597",
"0.8838597",
"0... | 0.8537187 | 88 |
Return the smallest distance between two angles | def deltaAngle(x, y):
return math.atan2(math.sin(x-y), math.cos(x-y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_abs_dist(self, pos1, pos2):\n\t\treturn min(abs(pos1 - pos2), abs(pos1 - pos2 + 360))",
"def angle_diff(a1, a2):\n a = a1 - a2\n if abs(a) > 180:\n return np.sign(a)*360 - a\n else:\n return a",
"def direction_diff(direction_a, direction_b):\n diff = abs(direction_a - directio... | [
"0.7197325",
"0.6954031",
"0.69272804",
"0.690755",
"0.6895958",
"0.6876547",
"0.6864704",
"0.68607736",
"0.68280244",
"0.68101037",
"0.68101037",
"0.67851186",
"0.67505914",
"0.67505914",
"0.6708877",
"0.6701813",
"0.66306984",
"0.6618783",
"0.6612154",
"0.66080064",
"0.6605... | 0.0 | -1 |
Add an AR tag to the state of the EKF ARTAG_landmark object np.eye(4) scale for how sure we are of the state of the tag | def add_AR_tag(self, ar_obj, certainty):
transform = np.zeros([3,1])
transform[0] = ar_obj.x
transform[1] = ar_obj.y
transform[2] = ar_obj.theta_z
self.current_state_estimate = np.vstack((self.current_state_estimate, transform))
self.A = np.zeros([self.current_state_estim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag(self):\n \n tag = super(self.__class__, self).tag();\n tag = als.tag_join(tag, als.stra(self.strain));\n tag = als.tag_join(tag, als.stra(self.dtype));\n tag = als.tag_join(tag, 'w=%s' % als.stra(self.wid)); \n tag = als.tag_join(tag, 's=%s' % als.stra(self.stage));\n #tag = analysis... | [
"0.5461921",
"0.5215728",
"0.5138931",
"0.50896007",
"0.50329",
"0.49514237",
"0.49459115",
"0.4853579",
"0.47939852",
"0.4791932",
"0.4775525",
"0.47719073",
"0.47440112",
"0.47043395",
"0.46742916",
"0.46696565",
"0.4649841",
"0.46304098",
"0.462776",
"0.46046305",
"0.46013... | 0.65895873 | 0 |
Tests the vehicle profile list after a vehicle profile is added to it. | def test_populate_vehicle_profile_list():
tester = TestClass()
vehicle_profiles = tester.populate_vehicle_profile_list()
assert vehicle_profiles
first_added_vehicle_profile = vehicle_profiles[1]
assert first_added_vehicle_profile.get_width() == 3
assert first_added_vehicle_profile.get_vehicl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_vehicle_profile_in_list():\n tester = TestClass()\n vehicle_profiles = tester.populate_vehicle_profile_list()\n\n assert len(vehicle_profiles) == 2\n assert vehicle_profiles[1].get_vehicle_profile_name() == 'testVehicleName'\n\n tester.delete_vehicle_profile()\n\n assert len(vehic... | [
"0.718763",
"0.68488395",
"0.67087024",
"0.6404893",
"0.6326258",
"0.6148604",
"0.61108804",
"0.6095637",
"0.60929763",
"0.6061309",
"0.60300124",
"0.60100776",
"0.6004973",
"0.59762514",
"0.597048",
"0.5937971",
"0.5926148",
"0.5868671",
"0.58614784",
"0.57900685",
"0.577236... | 0.7678037 | 0 |
Tests to see if a spawning profile can be successfully stored in our system | def test_populate_spawning_profile_list():
tester = TestClass()
spawning_profiles = tester.populate_spawning_profile_list()
assert spawning_profiles
assert len(spawning_profiles) == 2
assert spawning_profiles[1].get_spawning_profile_name() == 'testSpawnName'
assert spawning_profiles[0].get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instance_profile_exists(self) -> None:\n self.assertTrue(self.validate_instance_profile('s3-access-role', is_prod=self.prod_env))",
"def test_pm_profile_create(profile_manager, name):\n profile = profile_manager.create(name)\n assert os.path.isdir(profile.path)\n if name:\n assert... | [
"0.7228491",
"0.66597277",
"0.64975727",
"0.6375943",
"0.6338634",
"0.63361514",
"0.633036",
"0.633036",
"0.6301697",
"0.6201813",
"0.61988425",
"0.6187414",
"0.61797315",
"0.6151097",
"0.61367357",
"0.6131471",
"0.6105704",
"0.6085598",
"0.6056102",
"0.6039661",
"0.5993303",... | 0.60384196 | 20 |
path path to repository rev revision number txn name of transaction (usually the one about to be committed) cmd if set, specifies cmd_ method to execute txn takes precedence over rev; if both are None, inspect the head revision | def __init__(self, path, rev=None, txn=None, cmd=None):
path = core.svn_path_canonicalize(path)
repos_ptr = repos.open(path)
self.fs_ptr = repos.fs(repos_ptr)
# if set, txn takes precendence
if txn:
self.txn_ptr = fs.open_txn(self.fs_ptr, txn)
else:
self.txn_ptr = None
if rev ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_file_with_git_and_revision(self):\n self._test_get_file(\n tool_name='Git',\n revision='123',\n base_commit_id=None,\n expected_revision='123')",
"def gitCheckoutRevision(self, path, rev):\r\n\r\n with workInDirectory(path):\r\n ch... | [
"0.57857186",
"0.5722634",
"0.5697884",
"0.5653439",
"0.5606309",
"0.55645615",
"0.55223006",
"0.54924905",
"0.54772943",
"0.5460706",
"0.54566604",
"0.5407407",
"0.5383838",
"0.5346866",
"0.5288115",
"0.52690524",
"0.52495795",
"0.52473986",
"0.5221635",
"0.519963",
"0.51726... | 0.6113968 | 0 |
Test to verify work query do not parse keywords. | def test_get_work_list_with_query_no_keywords(self):
# Login as simple user
self.authenticate(self.user)
# Get works list with query = "title:work1"
# Should not return anything since it searched for the whole string
self.work_query_test("title:work1", [], ["title:work1"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_queryUnkeywordFlag(self):\n self._keywordFilteringTest(\"unkeyword\")",
"def test_queryUnkeywordFlagWithQuotes(self):\n query = imap4.Query(unkeyword='twisted')\n self.assertEqual('(UNKEYWORD twisted)', query)",
"def test_queryKeywordFlag(self):\n self._keywordFilteringTest... | [
"0.73988044",
"0.7265009",
"0.72597957",
"0.70393866",
"0.68593264",
"0.68445873",
"0.6685981",
"0.666446",
"0.66434795",
"0.659445",
"0.6592471",
"0.6524252",
"0.64953554",
"0.6388702",
"0.63317233",
"0.63111246",
"0.6275587",
"0.62409294",
"0.6237351",
"0.6230623",
"0.62260... | 0.71568143 | 3 |
Construct a matrix of `m`length segments of `x`. | def pattern_mat(x, m):
x = np.asarray(x).ravel()
if m == 1:
return x
else:
N = len(x)
patterns = np.zeros((m, N-m+1))
for i in range(m):
patterns[i, :] = x[i:N-m+i+1]
return patterns | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_matrix(line):\n\tlst = line.split()\n\tn = int(len(lst)**.5)\n\treturn [lst[i*n:i*n+n] for i in range(n)]",
"def m(x):\n return np.zeros_like(x)",
"def make_segments(x, y):\n\n points = np.array([x, y]).T.reshape(-1, 1, 2)\n segments = np.concatenate([points[:-1], points[1:]], axis=1)\n ... | [
"0.5824136",
"0.5707972",
"0.56305367",
"0.56305367",
"0.56305367",
"0.56305367",
"0.55669636",
"0.5514384",
"0.54425585",
"0.5436296",
"0.5429317",
"0.537968",
"0.536118",
"0.5300167",
"0.5258182",
"0.5242477",
"0.52260864",
"0.52066207",
"0.51996213",
"0.5191134",
"0.518432... | 0.6353382 | 0 |
Scales data by removing the mean and scaling to unit variance. | def _scale(x, axis=None):
x = _remove_baseline(x, axis=axis)
x /= np.std(x, ddof=1, axis=axis, keepdims=True)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_data(self, data):\n return (data - self.mean)/self.std",
"def unscale_data(self, data):\n return (data + self.mean)*self.std",
"def test_set_scale():\n data = io.create_sample_Dataset()\n tmp = data.piv.set_scale(1.0)\n assert np.allclose(tmp[\"x\"], data[\"x\"])\n\n tmp = d... | [
"0.7732943",
"0.7665981",
"0.70470524",
"0.7030516",
"0.7001338",
"0.69789255",
"0.69376016",
"0.6899201",
"0.68767464",
"0.6819132",
"0.6810007",
"0.6810007",
"0.6774628",
"0.6760385",
"0.6672394",
"0.66458255",
"0.66227555",
"0.65962374",
"0.6594068",
"0.65895617",
"0.65580... | 0.69965976 | 5 |
Initialize object. uid Unique ID for module. mass Mass of module. | def __init__(self, uid: int, mass: int):
self._uid = uid
self._mass = mass
self._calculate_fuel_simple()
self._calculate_fuel() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _createModuleObj(self):\n ModuleInitialCondition.__init__(self)",
"def __init__(self, uid=None):\n self.uid = str(uuid.uuid4()) if uid is None else uid",
"def __init__(self, module):\n\n # Keep a reference to the parent module.\n self._module = module\n \n # Keep a... | [
"0.6528462",
"0.6514825",
"0.6468349",
"0.637046",
"0.637046",
"0.62697965",
"0.6233595",
"0.62297195",
"0.61880106",
"0.617958",
"0.61473995",
"0.6139841",
"0.6139409",
"0.61389446",
"0.6128191",
"0.6116017",
"0.6038332",
"0.60239315",
"0.5952211",
"0.5951318",
"0.5950523",
... | 0.6509532 | 2 |
Create an OutgoingMessage with an empty buffer. | def __init__(self):
self.buffer = bytearray() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emptyBuffer(self):\n msg = True\n while msg:\n msg = self.receive()",
"def empty(cls) -> EnvelopeStructure:\n return _EmptyEnvelopeStructure()",
"def message_no_reply(cmd, name, data, version = NATIVE_HEADER_VERSION, order=\"<\"):\n return message(0, cmd, name, data, version = version, order=... | [
"0.6294702",
"0.61100113",
"0.5928298",
"0.57633835",
"0.5661715",
"0.55898327",
"0.55886686",
"0.5532811",
"0.5508461",
"0.550784",
"0.5505501",
"0.54805475",
"0.54556775",
"0.54479676",
"0.5381595",
"0.5379453",
"0.5356602",
"0.5346281",
"0.5323993",
"0.53064936",
"0.530276... | 0.5089288 | 41 |
Return the default config for the handler | def get_default_config(self):
config = super(SignalfxHandler, self).get_default_config()
config.update({
'url': 'https://ingest.signalfx.com/v2/datapoint',
'batch': 300,
# Don't wait more than 10 sec between pushes
'batch_max_interval': 10,
'a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_handler():\n global config_handler\n # This is to ensure that incase the initial setup\n # of config handler failed,\n return config_handler",
"def default(cls) -> 'Config':\n parser: configparser.ConfigParser = configparser.ConfigParser()\n parser.read_dict(dict(wpwatche... | [
"0.7320949",
"0.719965",
"0.7193589",
"0.7067962",
"0.70598876",
"0.6786117",
"0.6774274",
"0.670064",
"0.6655828",
"0.66535",
"0.66517246",
"0.6642275",
"0.6625678",
"0.6607969",
"0.66036606",
"0.6579853",
"0.65493035",
"0.6546264",
"0.6546264",
"0.65222245",
"0.6520133",
... | 0.69304216 | 5 |
A predicate to get all classes that are subclasses of MafColumnRecord | def predicate(obj):
return inspect.isclass(obj) and issubclass(obj, MafColumnRecord) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_column_types():\n\n def predicate(obj):\n \"\"\"A predicate to get all classes that are subclasses of\n MafColumnRecord\"\"\"\n return inspect.isclass(obj) and issubclass(obj, MafColumnRecord)\n\n # Get all available column types\n return inspect.getmembers(sys.modules[\"mafli... | [
"0.67658865",
"0.66078866",
"0.62281007",
"0.6002186",
"0.5943207",
"0.5915661",
"0.5915661",
"0.59094304",
"0.5871976",
"0.5851241",
"0.58263004",
"0.5813109",
"0.58118564",
"0.58012754",
"0.5741989",
"0.57248706",
"0.57007277",
"0.5696095",
"0.5686536",
"0.56787866",
"0.567... | 0.58999443 | 8 |
initialize a payment object, you can only define a payment id | def __init__(self, payment_id, camper_id = '', camp_id = '', payment_date = '', paid_amount = ''):
self.__payment_id__ = payment_id
self.__camper_id__ = camper_id
self.__camp_id__ = camp_id
self.__payment_date__ = payment_date
self.__paid_amount__ = paid_amount | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, id, amount, merchant_account_id, plan_id, recurring, refund, status, transaction_source,\n created_at):\n self.id = id\n self.amount = amount\n self.merchant_account_id = merchant_account_id\n self.plan_id = plan_id\n self.recurring = recurring\... | [
"0.7376024",
"0.71611816",
"0.6936008",
"0.666104",
"0.66385376",
"0.6594571",
"0.65905505",
"0.65854573",
"0.65385014",
"0.6498965",
"0.6451217",
"0.6439445",
"0.6400159",
"0.6352219",
"0.6334732",
"0.6302899",
"0.6296105",
"0.6296105",
"0.6285136",
"0.6285136",
"0.62522763"... | 0.8087496 | 0 |
Generates alphanumeric random string of given length. | def random_string(length=8):
return "".join([random.choice(string.letters + string.digits) for x in range(length)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_random_alphanumeric(length):\n return ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) \\\n for _ in range(length))",
"def generate_random_alphanumeric(length):\n return ''.join(random.SystemRandom().choice(\n string.ascii_uppercase + string.d... | [
"0.8868332",
"0.88649416",
"0.8814338",
"0.8730813",
"0.85786265",
"0.8566345",
"0.85511535",
"0.85278106",
"0.85069555",
"0.84942204",
"0.8487719",
"0.84780765",
"0.8466707",
"0.84661055",
"0.8449418",
"0.8448173",
"0.8414974",
"0.83719057",
"0.83500975",
"0.83473396",
"0.83... | 0.8457419 | 14 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(imu_all, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.Timestamp_sec is None:
self.Timestamp_sec = 0
if self.Timestamp_nsec is None:
self.Timestamp_nsec ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.77937967",
"0.77195275",
"0.77195275",
"0.7685702",
"0.762502",
"0.7562939",
"0.74384665",
"0.7416083",
"0.73515767",
"0.73078126",
"0.7280228",
"0.723719",
"0.72265446",
"0.72230625",
"0.72230625",
"0.7218876",
"0.721051",
"0.721051",
"0.721051",
"0.721051",
"0.721051",
... | 0.0 | -1 |
Reset metric variable values to their initial values. | def reset_metric_variables(self) -> None:
with self._lock:
self._reset_metric_variables() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()",
"def reset(self):\n self.num_inst = 0\n self.sum_metric = 0.0",
"def reset_metrics(self):\n self.metrics['loss'] = 0.0\n self.metrics['num_tokens'] = 0\n self.metr... | [
"0.78972256",
"0.7691141",
"0.75545144",
"0.75235677",
"0.7439711",
"0.7389852",
"0.73263395",
"0.73037887",
"0.7263015",
"0.7254951",
"0.72460955",
"0.7235719",
"0.72259295",
"0.71836036",
"0.7162598",
"0.71619034",
"0.71539193",
"0.71441376",
"0.7123724",
"0.7123724",
"0.71... | 0.8379023 | 0 |
Replace local tearDown function to the original TestCase's instance | def _tear_down():
repl._tearDown = self.tearDown | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n print('Calling \\'tearDown\\'')",
"def tearDown(self) -> None:\n pass",
"def tearDown(self) -> None:\n pass",
"def tearDown(self) -> None:\n pass",
"def tearDown(self):\r\n testing.tearDown()",
"def tearDown(self):\n pass\n # teardown... | [
"0.8067944",
"0.7973621",
"0.7973621",
"0.7973621",
"0.79566354",
"0.78895557",
"0.7863067",
"0.7863067",
"0.7863067",
"0.7863067",
"0.7863067",
"0.7853834",
"0.7852342",
"0.78446835",
"0.7830322",
"0.7807578",
"0.7807578",
"0.7807578",
"0.7807578",
"0.7807578",
"0.7807578",
... | 0.7957392 | 4 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, CreateTestCaseRequestBody):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, largest=True, sorted=True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].contiguous().view(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Get the queryset for the page | def get_queryset(self):
queryset = self.request.user.messages_to_moderate
# Filter by group if group is in kwargs
group = self.kwargs.get('group')
if group:
queryset = queryset.filter(thread__group_id=group)
queryset = queryset.select_related(
'thread', '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return Page.objects.active()",
"def get_queryset(self):\n request = self.request\n # Allow pages to be filtered to a specific type\n page_type = request.GET.get('type', 'wagtailcore.Page')\n try:\n models = page_models_from_string(page_type)... | [
"0.81897706",
"0.7722157",
"0.77110183",
"0.7521296",
"0.75098884",
"0.74274886",
"0.7424863",
"0.7414163",
"0.7279587",
"0.7262228",
"0.72478694",
"0.72390467",
"0.71888286",
"0.71738374",
"0.71643925",
"0.71643925",
"0.712479",
"0.7102882",
"0.7069147",
"0.70637673",
"0.704... | 0.0 | -1 |
The url a user should be returned to if post was a success. | def get_success_url(self, request):
return request.POST.get('next', reverse('mod_admin')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_success_url(self):\n url = force_text(reverse_lazy('post_detail', kwargs=self.kwargs))\n return url",
"def get_success_url(self):\n return self.request.path",
"def get_success_url(self):\n return \"/\"",
"def get_success_url(self):\n if self.success_url:\n ... | [
"0.72835857",
"0.7231031",
"0.71956545",
"0.7129277",
"0.7129277",
"0.71143043",
"0.7096541",
"0.70632714",
"0.70438784",
"0.70205754",
"0.70082545",
"0.6998029",
"0.69658834",
"0.69283295",
"0.6918382",
"0.6891263",
"0.6849653",
"0.6845414",
"0.6845414",
"0.6819956",
"0.6735... | 0.66367674 | 23 |
Get the queryset for the Flag log | def get_queryset(self):
queryset = super(FlagLogView, self).get_queryset()
if not self.request.user.global_moderator:
queryset = queryset.filter(
message__thread__group__in=self.request.user.groups_moderating
).distinct()
return queryset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n qs = Log.objects.filter(user=self.request.user)\n return qs",
"def get_queryset(self):\n return Flag.objects.order_by('name').annotate(num_votes=Count('vote'))",
"def get_queryset(self):\n filter = {self.kwargs.get('field'): self.kwargs.get('constraint')}\n... | [
"0.68462884",
"0.64936316",
"0.64275235",
"0.62937176",
"0.6101246",
"0.6056232",
"0.6050867",
"0.60311896",
"0.5996306",
"0.59744763",
"0.59640235",
"0.58716077",
"0.58716077",
"0.5868608",
"0.58569753",
"0.5842924",
"0.5809004",
"0.57816565",
"0.5780306",
"0.5778964",
"0.57... | 0.6609231 | 1 |
Return the value of the derivative for values in x. | def calculate_derivative_value(self, x: np.array) -> np.array:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative(self, x):\n z = np.asarray(x)\n return (self._der(z.flatten())).reshape(z.shape)",
"def _derivative_(self, x, diff_param=None):\n return 2*exp(-x**2)/sqrt(pi)",
"def derivative(self,x,dx=None):\n if dx is None:\n x = np.array(x,copy=False)\n if l... | [
"0.80886644",
"0.79423946",
"0.7885961",
"0.77690023",
"0.77270985",
"0.7698927",
"0.7698927",
"0.74725795",
"0.7406448",
"0.73738706",
"0.7294115",
"0.7294115",
"0.7291438",
"0.7283187",
"0.72766566",
"0.7254961",
"0.7243343",
"0.71918327",
"0.71918327",
"0.71416926",
"0.713... | 0.86170524 | 0 |
Update the weights of the network given a training sample. | def update(self, state, y):
y_pred = self.model(torch.Tensor(state))
loss = self.criterion(y_pred, Variable(torch.Tensor(y)))
self.optimizer.zero_grad()
loss.backward()
self.optimizer.step() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value",
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weights(self, example):\n p... | [
"0.74392164",
"0.7397062",
"0.73945713",
"0.7214572",
"0.7116506",
"0.69962287",
"0.69691974",
"0.6905256",
"0.68491787",
"0.6808423",
"0.68082225",
"0.6798149",
"0.67136854",
"0.66977626",
"0.6691002",
"0.6690842",
"0.6674953",
"0.6602656",
"0.65764797",
"0.6574915",
"0.6561... | 0.0 | -1 |
Weight function for the numerator of the quadratic estimator for phi. l1, l2 are 2d vectors. Quantity is symmetric in l1,l2, as expected. Enforces the lmin, lmax boundaries. | def F_TT_cart(self, l1, l2):
l1norm = np.sqrt(np.sum(l1**2))
l2norm = np.sqrt(np.sum(l2**2))
if (l1norm<self.CMB.lMin) or (l1norm>self.CMB.lMaxT) or (l2norm<self.CMB.lMin) or (l2norm>self.CMB.lMaxT):
result = 0.
else:
L = l1 + l2
result = self.CMB.funlensedTT(l1norm) *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phi2_coefficient(L):\r\n\r\n if 0 < L < 120:\r\n return L / 120\r\n if L >= 120:\r\n return 1",
"def l2(weights):\n\treturn np.sqrt(np.sum(weights * weights))",
"def hellinger_weighted(mu1, sigma1, pi1, mu2, sigma2, pi2):\n sigma1norm = np.linalg.norm(sigma1)\n sigma2norm = np.lin... | [
"0.6477538",
"0.6320163",
"0.61660314",
"0.59584725",
"0.5928981",
"0.5910112",
"0.5910112",
"0.5854881",
"0.5760559",
"0.56808275",
"0.5646496",
"0.5642044",
"0.5625087",
"0.56199163",
"0.5593041",
"0.55804443",
"0.55701786",
"0.5565686",
"0.5565686",
"0.55245215",
"0.549196... | 0.0 | -1 |
Returns a string representation of this schedule. | def __str__(self):
strRepr = ''
for i, person in enumerate(self.people):
assignmentsString = ','.join((self.assignments[i,:].astype(int)).astype(str))
strRepr += '{0},{1}\n'.format(person.uid, assignmentsString)
return strRepr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n schedule = \"\"\n\n schedule_list = self.in_order_traversal()\n for node in schedule_list:\n schedule += str(node)\n if node is not schedule_list[-1]:\n schedule += \" \"\n return schedule",
"def get_schedule_string(self):\n ... | [
"0.8422793",
"0.8302511",
"0.8041377",
"0.7660001",
"0.75926244",
"0.71500957",
"0.7132892",
"0.7122861",
"0.7086516",
"0.70688224",
"0.70443",
"0.6982647",
"0.69814885",
"0.69744986",
"0.69733095",
"0.69733095",
"0.690881",
"0.6878765",
"0.6838925",
"0.6775981",
"0.67379564"... | 0.0 | -1 |
Return the default value for this field. | def get_default(self) -> T | None:
return (
self.default # TODO: deepcopy mutable defaults?
if self.default_factory is None
else self.default_factory()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default(self):\n\n return self._get_field(\"value\")",
"def default_value(self):\n return self._default_value",
"def default_value(self):\n return self._default_value",
"def default_value(self):\n return self.get_property('defaultValue', DefaultColumnValue())",
"def get_defa... | [
"0.87749404",
"0.8658228",
"0.8658228",
"0.83940864",
"0.8384012",
"0.8374654",
"0.8277071",
"0.8180633",
"0.8063534",
"0.8063534",
"0.8036896",
"0.79988635",
"0.79968137",
"0.7996488",
"0.7994531",
"0.79223996",
"0.79202306",
"0.7910881",
"0.7910881",
"0.7896661",
"0.7862259... | 0.6309649 | 73 |
Whether the field is an Annotated type. | def is_annotated_type(self) -> bool:
return get_origin(self.type) is Annotated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_annotated_type(self):\n raise exceptions.NotImplementedError()",
"def is_typing_annotation(node: ast.AST, ctx: 'model.Documentable') -> bool:\n return is_using_annotations(node, TYPING_ALIAS, ctx) or \\\n is_using_annotations(node, SUBSCRIPTABLE_CLASSES_PEP585, ctx)",
"def is_type_v... | [
"0.75782245",
"0.72593373",
"0.63551474",
"0.62401044",
"0.61864305",
"0.6166038",
"0.59737253",
"0.5945107",
"0.5927166",
"0.5890218",
"0.58503854",
"0.58233047",
"0.5756524",
"0.5745798",
"0.5692763",
"0.5688102",
"0.5684063",
"0.56711286",
"0.56372124",
"0.5622147",
"0.562... | 0.84769 | 0 |
Convert an Annotated type to a dict of UiField kwargs. | def _uikwargs_from_annotated_type(hint: Any) -> dict[str, Any]:
# hint must be an Annotated[...] type
annotated_types = sys.modules.get("annotated_types")
base_metas: list[BaseMetadata] = []
origin, *metadata = get_args(hint)
kwargs = {}
for item in metadata:
if isinstance(item, UiFiel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_fields(\n annotations: Dict[str, Union[Annotation, Input, Output]]\n ) -> Dict[str, Union[Annotation, Input, Output]]:\n annotation_fields = OrderedDict()\n for name, annotation in annotations.items():\n # Skip return type\n if name == \"return\":\n ... | [
"0.58383906",
"0.5739805",
"0.56492794",
"0.5544963",
"0.54956424",
"0.5452071",
"0.54474074",
"0.53722835",
"0.5363384",
"0.53607804",
"0.5351316",
"0.52974176",
"0.52816004",
"0.52746767",
"0.5268901",
"0.52436167",
"0.52200377",
"0.5195209",
"0.5194914",
"0.5189173",
"0.51... | 0.7691228 | 0 |
Return a dict of the default values for a function's parameters. | def _get_function_defaults(func: FunctionType) -> dict[str, Any]:
# extracted bit from inspect.signature... ~20x faster
pos_count = func.__code__.co_argcount
arg_names = func.__code__.co_varnames
defaults = func.__defaults__ or ()
non_default_count = pos_count - len(defaults)
positional_args =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_args(func):\n signature = inspect.signature(func)\n return {\n k: v.default\n for k, v in signature.parameters.items()\n if v.default is not inspect.Parameter.empty\n }",
"def get_defaults(self):\n default_dict = {}\n args, varargs, keyword, defaults = ... | [
"0.7896796",
"0.7391901",
"0.7269788",
"0.7104777",
"0.70296514",
"0.689667",
"0.68850267",
"0.68401015",
"0.67926264",
"0.6737243",
"0.6679678",
"0.66788954",
"0.66239333",
"0.6611359",
"0.65396273",
"0.64461285",
"0.6393608",
"0.63929874",
"0.63697684",
"0.63090074",
"0.630... | 0.8185932 | 0 |
Hash a password for storing. | def hash_password(password):
salt = hashlib.sha256(os.urandom(60)).hexdigest().encode('ascii')
pwdhash = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'),
salt, 100000)
pwdhash = binascii.hexlify(pwdhash)
return (salt + pwdhash).decode('ascii') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_password(self):\n self.__password = self.str_to_hash(self.__password)",
"def hash_password(self, password):\n self.password = pwd_context.encrypt(password)",
"def hash_password(self, password):\n self.password_hash = generate_password_hash(password)",
"def hash_passwd(password, ... | [
"0.847967",
"0.8346137",
"0.82644516",
"0.80417943",
"0.7999399",
"0.7979167",
"0.7971465",
"0.7947968",
"0.7919728",
"0.78821445",
"0.78162515",
"0.77545875",
"0.77411246",
"0.766462",
"0.76507545",
"0.76267356",
"0.75862885",
"0.75638247",
"0.755944",
"0.7549114",
"0.754458... | 0.7510138 | 23 |
Function normalizes the given vector | def unit(vector: np.array) -> np.array:
return np.array([*vector]) / np.sqrt((vector * vector).sum(axis=0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(vector):\n return vector / np.linalg.norm(vector)",
"def normalize(v):\n return v / np.linalg.norm(v)",
"def normalize(v):\n return np.array(v) / np.linalg.norm(v)",
"def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n normalized = [i * normalizer for i in v]\n return ... | [
"0.8512117",
"0.838958",
"0.83851063",
"0.8329684",
"0.8245313",
"0.8162584",
"0.81239873",
"0.8084479",
"0.807215",
"0.8025776",
"0.8017441",
"0.7992565",
"0.7980572",
"0.7947778",
"0.7886378",
"0.78817695",
"0.78787136",
"0.7863949",
"0.7849553",
"0.7777708",
"0.77422446",
... | 0.0 | -1 |
Creates numpy matrix for rotation around custom axis | def Raxis(axis: Tuple[float, float, float], a: float, origin=np.array([0, 0, 0])):
oneminuscos = 1 - np.cos(a)
x, y, z = axis
return np.array([
[np.cos(a) + (x ** 2) * oneminuscos, x * y * oneminuscos - z * np.sin(a), x * z * oneminuscos + y * np.sin(a),
origin[0]],
[y * x * onemin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rot(axis, angle):\n if axis == 1:\n return Matrix([[1, 0, 0],\n [0, cos(angle), -sin(angle)],\n [0, sin(angle), cos(angle)]])\n elif axis == 2:\n return Matrix([[cos(angle), 0, sin(angle)],\n [0, 1, 0]... | [
"0.768256",
"0.7494091",
"0.7481602",
"0.74472725",
"0.74234873",
"0.7379216",
"0.7295815",
"0.7261676",
"0.7190785",
"0.7143728",
"0.70918393",
"0.70727193",
"0.7071786",
"0.7055689",
"0.7053288",
"0.7051761",
"0.70381755",
"0.70285016",
"0.70265985",
"0.70265985",
"0.702659... | 0.0 | -1 |
Return the computed path, that has been successfully verified. Use the corresponding playback index for that. | def get_verified_computed_path(self) -> Path:
assert self.computed, f"Expected to be computed: {self.computed}"
assert self.playback_index is not None, f"Playback index was {self.playback_index}"
return self.computed_paths[self.playback_index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_path(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"check_path\")",
"def test_get_path_valid(self, audio_collection, key_idx, file_idx):\n # TODO: the hard-coded parametrization is gross.\n keys = list(audio_collection.audio_stores.keys())\n keys.sort()\n st... | [
"0.62818867",
"0.5982109",
"0.5945011",
"0.59229857",
"0.59229857",
"0.59168226",
"0.5908526",
"0.59033424",
"0.5894667",
"0.582035",
"0.57172406",
"0.5695205",
"0.56879175",
"0.5657824",
"0.5636198",
"0.5630176",
"0.5621685",
"0.5620931",
"0.5609619",
"0.5558602",
"0.5543060... | 0.7950548 | 0 |
Returns the lastname of the person | def getLastname(self):
return self.lastname | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_name(self) -> str:\n return self.last_name",
"def get_last_name(people, individual):\n surname = people[individual]['NAME'].split()\n return surname[1]",
"def get_last_name(self):\n return self._last_name",
"def lastname(self):\n return self._lastname",
"def getLastN... | [
"0.8672903",
"0.8553794",
"0.8540746",
"0.8417888",
"0.83623105",
"0.83623105",
"0.83623105",
"0.83623105",
"0.83623105",
"0.8352938",
"0.83309484",
"0.832836",
"0.83054394",
"0.83054394",
"0.83054394",
"0.83054394",
"0.819429",
"0.819429",
"0.81784624",
"0.81249005",
"0.7968... | 0.84698415 | 3 |
Returns the email of the person | def getEmail(self):
return self.email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_email(obj):\r\n return obj.user.email",
"def get_user_email(self):\n member = self.get_user()\n if member:\n return member.getProperty('email')",
"def get_email(self):\n return self.email",
"def get_email(self):\n return self.reference[REF_EMAIL_ADDRESS][REF_... | [
"0.8109802",
"0.8089216",
"0.80577403",
"0.8035239",
"0.78824055",
"0.7861409",
"0.7805442",
"0.7794515",
"0.7794515",
"0.7794515",
"0.77488726",
"0.77230865",
"0.7714919",
"0.77126455",
"0.76318806",
"0.7606639",
"0.7606639",
"0.7606639",
"0.7606639",
"0.75341606",
"0.753416... | 0.7764104 | 10 |
Sets the name of the person | def setName(self, name):
self.name = name
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, PersonName):\r\n self.name = PersonName",
"def person_name(self, person_name):\n\n self._person_name = person_name",
"def person_name(self, person_name):\n\n self._person_name = person_name",
"def set_name(self, name):\n self.name = name # overwrite the existin... | [
"0.89367473",
"0.8364097",
"0.8364097",
"0.8148444",
"0.8148444",
"0.81440526",
"0.80807924",
"0.80807924",
"0.80807924",
"0.80807924",
"0.80807924",
"0.7954997",
"0.7937365",
"0.7903114",
"0.7859471",
"0.7859374",
"0.7847464",
"0.7808179",
"0.7808179",
"0.7808179",
"0.780817... | 0.7379051 | 45 |
Sets the lastname of the person | def setLastname(self, lastname):
self.lastname = lastname
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_last_name(self, last_name):\n self.last_name = last_name",
"def lastname(self, lastname):\n\n self._lastname = lastname",
"def last_name(self, last_name):\n\n self._last_name = last_name",
"def last_name(self, last_name):\n\n self._last_name = last_name",
"def last_name(... | [
"0.8810476",
"0.85731727",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.8337195",
"0.81621855",
"0.757863",
"0.75438565",
"0.75093293",
"0.74130565",
"0.7278209",
"0.7278209",
"0.7278018",
"0.71376264"... | 0.8780561 | 1 |
Sets the email of the person | def setEmail(self, email):
self.email = email
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
"def email(self, email):\n\n self._email = email",
"def email(self,... | [
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.78245515",
"0.7693071",
"0.734507",
"0.72977525",
"0.72977525",
"0.7228297",
"0.717312",
"0.71004075",
"0.71004075",
"0.71004075",
"0.70587945",
"0... | 0.78610027 | 0 |
`log_superuser_login` should not create a `LogEntry` when users login. | def test_user_does_not_create_log(self):
user = UserFactory.create()
self.request.user = user
user_logged_in.send(
sender=user.__class__,
request=self.request,
user=user,
)
self.assertFalse(LogEntry.objects.count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_supeuser_create_log(self):\n user = SuperUserFactory.create()\n self.request.user = user\n user_logged_in.send(\n sender=user.__class__,\n request=self.request,\n user=user,\n )\n\n self.assertTrue(LogEntry.objects.get())",
"def create_... | [
"0.69145954",
"0.6652177",
"0.6397216",
"0.6054432",
"0.6043255",
"0.59846526",
"0.5879487",
"0.5810956",
"0.5804774",
"0.5795369",
"0.5669419",
"0.5560893",
"0.54870486",
"0.5483733",
"0.5470098",
"0.54606014",
"0.54606014",
"0.54606014",
"0.54606014",
"0.54490995",
"0.54144... | 0.68114555 | 1 |
computes the distance between two coordinates in (meters) | def get_distance(lat1, lon1, lat2, lon2):
phi1 = math.radians(lat1)
phi2 = math.radians(lat2)
d_phi = math.radians(lat2 - lat1)
d_lam = math.radians(lon2 - lon1)
a = math.sin(d_phi/2) ** 2 + math.cos(phi1) * math.cos(phi2) * math.sin(d_lam/2)**2
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_in_meters(coord1, coord2):\n return vincenty(coord1, coord2).meters",
"def get_distance_meters(aLocation1, aLocation2):\n dlat = aLocation2.lat - aLocation1.lat\n dlong = aLocation2.lon - aLocation1.lon\n return math.sqrt((dlat*dlat) + (dlong*dlong)) * 1.113195e5",
"def get_distance_me... | [
"0.85390085",
"0.8324335",
"0.8210539",
"0.7974289",
"0.7928913",
"0.79059905",
"0.79059905",
"0.79059905",
"0.79059905",
"0.79059905",
"0.78956753",
"0.78795666",
"0.78655416",
"0.7826311",
"0.7764629",
"0.7758175",
"0.77523357",
"0.77286386",
"0.76996815",
"0.76987535",
"0.... | 0.74809027 | 41 |
Convert a string into a number, preferable a float! | def get_number(text):
if text is None:
return None
text = text.strip()
if text == "":
retval = None
elif text == "MM":
retval = None
elif text == "T":
retval = TRACE_VALUE
else:
number = re.findall(r"[\-\+]?\d*\.\d+|[\-\+]?\d+", text)
if len(number... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_str_float(x):\n\ttry:\n\t\treturn float(x)\n\texcept ValueError:\n\t\tprint(\"must be a number\")",
"def _convert_to_float(s):\n try:\n return float(s)\n except:\n return s",
"def float_from_string(data):\n return float(maybe_number(data))",
"def num(s: str):\n try: retu... | [
"0.8421807",
"0.8352667",
"0.8266572",
"0.81538904",
"0.8147368",
"0.81237274",
"0.8092496",
"0.80081326",
"0.7977722",
"0.7969988",
"0.79679155",
"0.79551727",
"0.7867926",
"0.7859843",
"0.7783678",
"0.7778355",
"0.77775246",
"0.7747573",
"0.7746885",
"0.7742719",
"0.7733286... | 0.0 | -1 |
Test whether the hex_bytes correctly handles invalid truncate parameter values. | def test_hex_bytes_negative_truncate():
with pytest.raises(ValueError):
hex_bytes(bytes([0x00, 0x01, 0x02]), truncate=-1)
with pytest.raises(ValueError):
hex_bytes(bytes([]), truncate=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hex_bytes_truncated():\n buffer = bytes(range(5))\n assert hex_bytes(buffer, truncate=4) == '0x00 0x01 0x02 0x03 ...(1 more byte)'\n assert hex_bytes(buffer, truncate=3) == '0x00 0x01 0x02 ...(2 more bytes)'\n assert hex_bytes(buffer, truncate=2) == '0x00 0x01 ...(3 more bytes)'\n assert he... | [
"0.764324",
"0.73163056",
"0.7314565",
"0.65783226",
"0.6427658",
"0.6049937",
"0.5993117",
"0.5940839",
"0.5939125",
"0.5871367",
"0.5810782",
"0.56990683",
"0.5624304",
"0.56146836",
"0.5587249",
"0.5576987",
"0.55603087",
"0.55537117",
"0.5531334",
"0.5530085",
"0.55202496... | 0.7925882 | 0 |
Test whether the hex_bytes correctly renders buffers with truncation. | def test_hex_bytes_truncated():
buffer = bytes(range(5))
assert hex_bytes(buffer, truncate=4) == '0x00 0x01 0x02 0x03 ...(1 more byte)'
assert hex_bytes(buffer, truncate=3) == '0x00 0x01 0x02 ...(2 more bytes)'
assert hex_bytes(buffer, truncate=2) == '0x00 0x01 ...(3 more bytes)'
assert hex_bytes(bu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hex_bytes_untruncated():\n short = bytes([0x00, 0x01, 0x02])\n assert(hex_bytes(short, truncate=None)) == '0x00 0x01 0x02'\n buffer = bytes(range(5))\n assert hex_bytes(buffer, truncate=6) == '0x00 0x01 0x02 0x03 0x04'\n assert hex_bytes(buffer, truncate=5) == '0x00 0x01 0x02 0x03 0x04'",
... | [
"0.73365605",
"0.7271818",
"0.7007826",
"0.64052725",
"0.6109263",
"0.60032976",
"0.58752733",
"0.5841673",
"0.56805193",
"0.56721413",
"0.563298",
"0.56188416",
"0.5538575",
"0.5515574",
"0.54838765",
"0.5472313",
"0.5459594",
"0.5410429",
"0.5399236",
"0.53844917",
"0.53629... | 0.7643745 | 0 |
Computes the hidden state that the RNN decoder should start with. | def get_rnn_init_state(
combiner_outputs: Dict[str, torch.Tensor], sequence_reducer: SequenceReducer, num_layers: int
) -> torch.Tensor:
if ENCODER_OUTPUT_STATE not in combiner_outputs:
# Use the combiner's hidden state.
encoder_output_state = combiner_outputs[HIDDEN]
else:
# Use the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_hidden_state(self):\n initializer = tf.keras.initializers.Zeros()\n rnnten = initializer(shape=(self.batch, self.units))\n return rnnten",
"def init_hidden(self):\n # TODO ========================\n # initialize the hidden states to zero\n\n initial_hidden... | [
"0.7366186",
"0.7284721",
"0.7270641",
"0.71044475",
"0.7074667",
"0.7074667",
"0.7074667",
"0.7069737",
"0.7069737",
"0.7068249",
"0.7068249",
"0.7061608",
"0.6928207",
"0.68620354",
"0.68073297",
"0.6766438",
"0.67017627",
"0.66404116",
"0.66340375",
"0.6564002",
"0.6543768... | 0.0 | -1 |
Fetches the height of the last block in our blockchain. | def fetch_last_height(self, cb):
self.send_command('blockchain.fetch_last_height', cb=cb) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def last_block_height(self, api_params: dict) -> Optional[int]:\n\n transform_id: str = api_params['transform_id']\n\n db = self.transform_storage_dbs[transform_id]\n value = db.get(Storage.LAST_BLOCK_HEIGHT_KEY)\n\n try:\n height = int(value)\n except Exception:... | [
"0.7775353",
"0.7675757",
"0.76076645",
"0.7416985",
"0.7348307",
"0.734598",
"0.729765",
"0.72908956",
"0.7175804",
"0.7122879",
"0.7021965",
"0.70152396",
"0.700399",
"0.6986451",
"0.69669706",
"0.69660443",
"0.6961061",
"0.6863547",
"0.6780519",
"0.6779728",
"0.6779728",
... | 0.83182615 | 0 |
Fetches list of transaction hashes in a block by block hash. | def fetch_block_transaction_hashes(self, index, cb):
data = pack_block_index(index)
self.send_command('blockchain.fetch_block_transaction_hashes',
data, cb) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_blockhashes_at_height(self, height):\n return self.chain[height]",
"def get_chain_ending_with(self, block_hash):\n\n # Solution for (1a)\n if not block_hash in self.blocks:\n return []\n block_hashes = []\n curr_block = self.blocks[block_hash]\n while ... | [
"0.67851377",
"0.66551054",
"0.663235",
"0.6583825",
"0.6488358",
"0.63822484",
"0.6362354",
"0.6358083",
"0.6341867",
"0.6287345",
"0.6262416",
"0.6253629",
"0.6223859",
"0.62065995",
"0.6193733",
"0.61814743",
"0.6171997",
"0.6142143",
"0.61076826",
"0.61076826",
"0.6038941... | 0.73497295 | 0 |
Find the path to the application data directory; add an electrum folder and return path. | def appdata_dir():
if platform.system() == "Windows":
return os.path.join(os.environ["APPDATA"], "Electrum")
elif platform.system() == "Linux":
return os.path.join(sys.prefix, "share", "electrum")
elif (platform.system() == "Darwin" or
platform.system() == "DragonFly" or
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_dir():\n return Path(current_app.config[\"USER_DIR\"]) / \"data\"",
"def datadir():\n return '../data/'",
"def user_data_dir():\n # TODO: hardcoded\n app_name = 'etheroll'\n data_dir = os.path.join('/sdcard', app_name)\n data_dir = os.path.expanduser(data_dir)\n ... | [
"0.70930374",
"0.7016596",
"0.6797815",
"0.6729415",
"0.6661458",
"0.6587978",
"0.6586738",
"0.65581644",
"0.6554598",
"0.65477204",
"0.65374905",
"0.6507131",
"0.64769936",
"0.6471382",
"0.6456394",
"0.64542717",
"0.6439899",
"0.6399632",
"0.6381517",
"0.63642436",
"0.629770... | 0.7735564 | 0 |
Return path to the data folder. | def local_data_dir():
assert sys.argv
prefix_path = os.path.dirname(sys.argv[0])
local_data = os.path.join(prefix_path, "data")
return local_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def data_dir(self) -> Path:\n return self._data_dir",
"def get_data_path():\n\treturn _paths[_DATA_DIRECTORY_KEY]",
"def data_dir():\n return os.path.join(os.path.dirna... | [
"0.8864518",
"0.88255817",
"0.8743293",
"0.8708211",
"0.8697515",
"0.86047864",
"0.85863674",
"0.8527289",
"0.8439614",
"0.8439614",
"0.8422302",
"0.834199",
"0.8341687",
"0.8281089",
"0.8280809",
"0.8226193",
"0.82233226",
"0.8211304",
"0.82088023",
"0.8194767",
"0.81439215"... | 0.78951806 | 30 |
Normalize the reference vectors to a unit hypersphere. | def normalize(self):
self.number_of_vectors = self.values.shape[0]
norm_2 = np.linalg.norm(self.values, axis=1)
norm_1 = np.sum(self.values_planar, axis=1)
norm_2 = np.repeat(norm_2, self.number_of_objectives).reshape(
self.number_of_vectors, self.number_of_objectives
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(self):\n self.vector /= np.linalg.norm(self.vector)",
"def normalize(self):\n self._vectors = [vector.normalized() for vector in self._vectors]",
"def normalize(self):\n return Vector(self.args + []) / self.magnitude()",
"def normalize_all(self):\n #for i, vector in ... | [
"0.7187248",
"0.71419746",
"0.6901959",
"0.68915397",
"0.685873",
"0.6846318",
"0.6832045",
"0.66749114",
"0.66629124",
"0.66199875",
"0.6606452",
"0.6602143",
"0.65857255",
"0.65843713",
"0.6555013",
"0.65057826",
"0.6457185",
"0.64542913",
"0.64161927",
"0.64124215",
"0.638... | 0.7002514 | 2 |
Given a list of labels (data) and the indices among the list (idxList) to consider, returns the Shannon Entropy of the concerned items. S = sum(p_i log(p_i)) | def entropy(data, idxList):
df = data.loc[idxList]
counts = df.value_counts().to_numpy()
counts = counts.reshape(1, -1).astype(np.float32)
counts /= np.sum(counts)
log_sum = counts @ np.log2(counts.T)
return -log_sum[0, 0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shannon_entropy(counts):\n freq = np.array(counts) * 1.0 / np.sum(counts)\n return -np.sum([f * np.log2(f) for f in freq if f != 0])",
"def ShannonEntropy(self,s):\n e = s[np.nonzero(s)]**2 * np.log(s[np.nonzero(s)]**2)\n return np.sum(e)",
"def entropy(data):\n\n freqs = {}\n sum... | [
"0.671045",
"0.67049396",
"0.661212",
"0.64909816",
"0.6341671",
"0.630872",
"0.6287976",
"0.62800974",
"0.6243621",
"0.6212742",
"0.6014015",
"0.59715426",
"0.5920455",
"0.5880619",
"0.5857907",
"0.5841575",
"0.5813167",
"0.5790847",
"0.5788927",
"0.57685566",
"0.5756327",
... | 0.7724833 | 0 |
id3 Algorithm for classification of categorical labels. | def id3Categorical(X, y, attrs, idxList, idGen, height, maxHeight):
unique_value_counts = y.loc[idxList].nunique()
print(unique_value_counts, end="\r")
if unique_value_counts == 1:
# Homogenous node
node = DecisionTreeNode(idx=next(idGen), discriminator=None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_category(self):\n pass",
"def classify_k_cluster(labels, datas):\n classify_k_cluster_to_redis(labels=labels, texts=datas)",
"def classify(self, data):\n abstract",
"def _classification(text_path_list, id_list, label_list):\n textnum = len(text_path_list)\n batched_... | [
"0.691057",
"0.65469813",
"0.64070857",
"0.62861943",
"0.62849945",
"0.6256598",
"0.6222719",
"0.6169037",
"0.61451817",
"0.6109081",
"0.60404277",
"0.60374826",
"0.6037319",
"0.5999518",
"0.5997279",
"0.59665865",
"0.5965316",
"0.5965289",
"0.5956717",
"0.59362143",
"0.59360... | 0.62557566 | 6 |
If block_id is None, return the last block in the chain, This doesn't use any locks | def get_block(block_id: Optional[bytes] = None) -> Optional[Block]:
if block_id is not None and not isinstance(block_id, bytes):
raise TypeError
if block_id is None:
logging.debug("Last block requested")
else:
logging.debug("Block %s requested", util.bintos(block_id))
r = util.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_block():\n if namoto_length < 1:\n return None\n\n return namoto_blockchain[-1]",
"def last_block(self):\n return self.chain[len(self.chain) - 1]",
"def last_block(self):\n return self.chain[-1]",
"def last_block(self):\n return self.chain[-1]",
"def getLastBl... | [
"0.7747664",
"0.7695054",
"0.7671081",
"0.7671081",
"0.7605627",
"0.74756557",
"0.743086",
"0.7425592",
"0.71747893",
"0.7006987",
"0.6937943",
"0.6911598",
"0.6910124",
"0.6821859",
"0.67948246",
"0.6794383",
"0.6710376",
"0.668066",
"0.65580076",
"0.64753854",
"0.6455892",
... | 0.6683533 | 17 |
If node_id is None, return current node's balance | def get_balance(node_id: Optional[int] = None) -> float:
logging.debug("Balance requested for node %s", "local" if node_id is None else str(node_id))
keyb = wallet.get_public_key(node_id).dumpb()
r = util.get_db()
with r.lock("blockchain:utxo-tx:lock"):
utxo_tx = r.hvals("blockchain:utxo-tx")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance(self, node=None):\n if node is None:\n node = self.root\n if self.root is None:\n return 0\n if not node.left and not node.right:\n return 0\n elif not node.left:\n return node.right.balance_number\n elif not node.ri... | [
"0.75804275",
"0.75586444",
"0.68440676",
"0.6771975",
"0.6710295",
"0.6692545",
"0.66197735",
"0.6548301",
"0.6548301",
"0.65102345",
"0.6426156",
"0.64195025",
"0.64111465",
"0.63978624",
"0.63850087",
"0.6358756",
"0.6348083",
"0.6282218",
"0.6254154",
"0.6172685",
"0.6170... | 0.8253148 | 0 |
Return now() in Apache Common Log Format (no timezone). | def time_hack(self):
now = datetime.datetime.now()
monthnames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
month = monthnames[now.month - 1].capitalize()
return ('[%02d/%s/%04d:%02d:%02d:%02d.%06d]' %
(now.day, month, now.year, now.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def now():\n now = datetime.datetime.now()\n return \"%04d-%02d-%02d %02d:%02d:%02d.%03d\" % ( now.year, now.month,now.day,\n now.hour,now.minute,now.second,int(now.microsecond/1e3))",
"def timestamp_now():\n return datetime.now().strftime(\"%A, %B %d, %Y, %I:%M %p\")",
"def now(self):... | [
"0.7856626",
"0.7855255",
"0.77789456",
"0.7706137",
"0.7693792",
"0.7643583",
"0.7637152",
"0.76358235",
"0.7572497",
"0.7528446",
"0.748852",
"0.7474767",
"0.7472154",
"0.7391723",
"0.73707664",
"0.734145",
"0.7291855",
"0.7291855",
"0.7284689",
"0.7257214",
"0.7248414",
... | 0.0 | -1 |
Return whether a number is prime. >>> is_prime(2) True >>> is_prime(14) False >>> is_prime(23) True | def is_prime(num):
# 2 is prime; exclude
if num == 2:
return True
# exclude all other even numbers and numbers less than 2
if num % 2 == 0 or num < 2:
return False
# Only need to count up to the the square root of num
sqrt = int(num ** 0.5 +1) # int rounds down; corre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(num: int) -> bool:\n return factorial(num - 1) % num != 0",
"def is_prime(number):\n\t\n\tif number < 2: return False\n\telif number == 2: return True\n\telif number % 2 == 0: return False\n\telse:\n\t\tfor x in range(2, number):\n\t\t\tif number % x == 0:\n\t\t\t\treturn False\n\t\telse:\n\t\t\t... | [
"0.83203024",
"0.82714534",
"0.8176743",
"0.816352",
"0.81012005",
"0.8084295",
"0.80244744",
"0.8004604",
"0.79990846",
"0.7978181",
"0.7977953",
"0.79728544",
"0.7970495",
"0.79218864",
"0.7917247",
"0.79165107",
"0.79086816",
"0.7907498",
"0.78938866",
"0.7892199",
"0.7879... | 0.7315656 | 100 |
Returns formats and returns multiline string if the lenght of string given by data is > max_length | def limit_max_len(data, indentation, max_length=MAX_LENGTH):
buf = ''
while len(data) > MAX_LENGTH:
idx = data.rfind(' ', 0, MAX_LENGTH)
buf += '%s\n%s' % (data[:idx], indentation)
data = data[idx+1:]
else:
buf += data
return buf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output(self, minLength: int = 0, maxLength=None) -> str:\n tempLine = Textline(self._contents)\n if maxLength != None:\n if minLength > maxLength:\n return(\"Error: minLength must be less than maxLength\")\n elif len(self._contents) > maxLength:\n ... | [
"0.621712",
"0.60925525",
"0.60365343",
"0.59895784",
"0.5963645",
"0.595197",
"0.59290755",
"0.590417",
"0.58811843",
"0.58361816",
"0.58357406",
"0.579487",
"0.5783673",
"0.5783443",
"0.5765949",
"0.5710675",
"0.56781965",
"0.56301737",
"0.56282365",
"0.5626684",
"0.562447"... | 0.75504667 | 0 |
Neat uses a modified sigmoidal transfer function | def sigmoid(self, x):
return 1 / (1 + np.exp(-4.9 * x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(z):\r\n \r\n return vSigmoid(z);",
"def sigmoid(z):\n \n return 1 / (1 + np.exp(-z))#your code here",
"def _tanh_to_sigmoid(x):\n return x * 0.5 + 0.5",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n\tretur... | [
"0.7642052",
"0.74578243",
"0.73868525",
"0.73336315",
"0.73336315",
"0.7330344",
"0.7287802",
"0.72785616",
"0.7275636",
"0.7270223",
"0.72665197",
"0.72391254",
"0.72304904",
"0.7230279",
"0.7225399",
"0.72216505",
"0.72141784",
"0.7211291",
"0.7194375",
"0.7194375",
"0.719... | 0.67851716 | 92 |
Update parameters using one step of gradient descent | def update_parameters_with_gd(parameters, grads, learning_rate):
L = len(parameters) // 2 # number of layers in the neural networks
# Update rule for each parameter
for l in range(L):
### START CODE HERE ### (approx. 2 lines)
parameters["W" + str(l+1)] = parameters["W" + str(l+1)]-learnin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_parameters(self, loss):\n self.optimizer.zero_grad()\n loss.backward()\n self.optimizer.step()",
"def updateParams(self,gradients):\n for i in xrange(len(self.params)):\n self.params[i].set_value(self.params[i].get_value()-gradients[i]/(1/self.learning_rate+self... | [
"0.7269349",
"0.7062195",
"0.7061314",
"0.7021435",
"0.6942396",
"0.693245",
"0.69282365",
"0.6900024",
"0.68978393",
"0.68952733",
"0.6880095",
"0.6862448",
"0.68579733",
"0.6851211",
"0.6844264",
"0.68293726",
"0.6826274",
"0.67916423",
"0.67859596",
"0.67605203",
"0.675119... | 0.6661977 | 32 |
Generate a random string of fixed length | def randomString(stringLength):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8678995",
"0.8572973",
"0.85470647",
"0.85287195",
"0.851963",
"0.84313273",
"0.8431233",
"0.841402",
"0.8410922",
"0.8388024",
"0.8344134",
"0.834275",
"0.8339172",
"0.8333347",
"0.8322633",
"0.8296847",
"0.82919496",
"0.8280664",
"0.82805336",
"0.8279507",
"0.8263187",
... | 0.0 | -1 |
Dataset constructor method from multiple dataframes | def from_dataframes(cls, data_df, sample_meta_df, gene_meta_df):
data = data_df.join(sample_meta_df)
return cls(data, gene_meta_df, len(gene_meta_df)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dataset(self, df, **kwargs):\n\t\treturn df",
"def __init__(self, datasets: Union[str, list], **kwargs) -> None:\n if isinstance(datasets, str):\n datasets = [datasets]\n\n self._data = None\n for dataset in datasets:\n assert dataset in DATASETS, f\"[!] Datase... | [
"0.71293575",
"0.69071376",
"0.66929203",
"0.6691325",
"0.66674",
"0.6589145",
"0.65762496",
"0.6575648",
"0.6554245",
"0.65226233",
"0.6510982",
"0.6480016",
"0.6474792",
"0.6419009",
"0.63920635",
"0.6383454",
"0.6383454",
"0.6383454",
"0.63613635",
"0.63558775",
"0.6354135... | 0.72202486 | 0 |
Dataset constructor method from yaml specification | def from_yaml(cls, path, sample_ids=None, only_landmark=True, **filter_kwargs):
data_df, sample_meta_df, gene_meta_df = yaml_to_dataframes(
path, sample_ids, only_landmark, **filter_kwargs
)
data = data_df.join(sample_meta_df)
return cls(data, gene_meta_df, len(gene_meta_df)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset: Dataset):\n self.dataset = dataset",
"def __init__(self, dataset):\n self._dataset = dataset",
"def __init__(self, dataset):\n\n if isinstance(dataset, DataConfig):\n self.__data_config = dataset\n self.dataset = dataset.dataset\n el... | [
"0.75934976",
"0.7238428",
"0.70947915",
"0.6867152",
"0.6838301",
"0.67752695",
"0.67425424",
"0.67357945",
"0.6708731",
"0.66399395",
"0.66042507",
"0.65969867",
"0.6571456",
"0.65372866",
"0.65185016",
"0.6508925",
"0.65066224",
"0.6470634",
"0.64257944",
"0.6415059",
"0.6... | 0.0 | -1 |
Returns a Dataset with select metadata fields. | def select_meta(self, meta_fields):
selected = self._data[[*self.data.columns.values, *meta_fields]]
return self._copy(selected) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dataset_metadata(fields=[]):\n return get_dict_from_db(key='metadata', fields=fields)",
"def sel(\n self,\n **kwargs,\n ) -> \"Dataset\":\n res = [da.sel(**kwargs) for da in self]\n return Dataset(data=res, validate=False)",
"def make_dataset(self, df, **kwargs):\n\t\t... | [
"0.7067491",
"0.67166615",
"0.6299369",
"0.60428506",
"0.6025771",
"0.6001378",
"0.5992442",
"0.5939083",
"0.59160644",
"0.5907619",
"0.58805674",
"0.5873834",
"0.5871108",
"0.58599335",
"0.584773",
"0.5843115",
"0.58418554",
"0.57986784",
"0.5768313",
"0.57509047",
"0.572792... | 0.6424863 | 2 |
Splits dataset into training, validation, and test datasets | def train_val_test_split(self, p1=0.2, p2=0.2):
X_train, X_test = train_test_split(self._data, test_size=p1)
X_train, X_val = train_test_split(X_train, test_size=p2)
train = KerasDataset(X_train, self.gene_meta.copy(), self.n_genes, "train")
val = KerasDataset(X_val, self.gene_meta.copy(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __split_dataset(self):\n self.train, self.valid, _, _ = train_test_split(self.data, self.data, test_size=0.2)\n self.valid, self.test, _, _ = train_test_split(self.valid, self.valid, test_size=0.5)",
"def split_data_into_train_and_test(raw_training_data):\n train_set, test_set = train_test_s... | [
"0.8721865",
"0.84217954",
"0.8101666",
"0.80975294",
"0.80192214",
"0.79630756",
"0.7862547",
"0.78286093",
"0.7793369",
"0.7773168",
"0.77310103",
"0.77288634",
"0.7715786",
"0.77084535",
"0.7687997",
"0.76761836",
"0.7659466",
"0.7647396",
"0.76465744",
"0.7621228",
"0.761... | 0.0 | -1 |
Write Dataset object to a tsv file | def to_tsv(self, out_dir, sep="\t", prefix=None, **kwargs):
os.makedirs(out_dir, exist_ok=True) # create dirs if non-existent
prefix = f"{prefix}_" if prefix else ""
fpaths = [
os.path.join(out_dir, f"{prefix}{suf}.tsv")
for suf in ["data", "sample_meta"]
]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_tsv(self, filename):\n f = open(filename,'wb')\n wr = csv.writer(f,delimiter='\\t',quoting=csv.QUOTE_ALL)\n colrow = []\n for col in self.cols:\n colrow.append('<undefined>' if len(col) == 0 else unicode(iter(col).next()).encode('unicode-escape'))\n wr.writerow(colrow)\n for row in... | [
"0.7719545",
"0.74386257",
"0.74161845",
"0.7226882",
"0.7200748",
"0.70647633",
"0.6988377",
"0.69810003",
"0.68675995",
"0.6723733",
"0.6621601",
"0.6421397",
"0.6407337",
"0.63885874",
"0.6340994",
"0.62710464",
"0.6268424",
"0.6222899",
"0.6206889",
"0.6182776",
"0.614414... | 0.65519196 | 11 |
Return a onehot vector for a metadata field for all profiles | def one_hot_encode(self, meta_field):
one_hot = pd.get_dummies(self.sample_meta[meta_field]).values
return one_hot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(y_):\n y_ = y_.reshape(len(y_))\n n_values = int(np.max(y_)) + 1\n n_values = 6\n return np.eye(n_values)[np.array(y_, dtype=np.int32)] # Returns FLOATS",
"def _one_hot(self, proba, y):\n hm_1hot = []\n for label in np.unique(y):\n mask_ = y == label\n ... | [
"0.6644739",
"0.6598635",
"0.658925",
"0.65063596",
"0.6482598",
"0.64801663",
"0.6469779",
"0.64669275",
"0.644936",
"0.64050746",
"0.63893735",
"0.637714",
"0.634223",
"0.63304734",
"0.63269407",
"0.6326474",
"0.6300371",
"0.62841266",
"0.6269356",
"0.6240017",
"0.62311256"... | 0.7048277 | 0 |
Constructor from base Dataset class | def from_lincs_dataset(cls, lincs_dataset, name):
return cls(
lincs_dataset._data, lincs_dataset.gene_meta, lincs_dataset.n_genes, name
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset: Dataset):\n self.dataset = dataset",
"def __init__(self, dataset):\n self._dataset = dataset",
"def __init__(self):\n self.__dataset = None",
"def __init__(self, data, aggregate=np.mean, base=None, time_slices=None):\n\n # Check that the arguments have ... | [
"0.82540244",
"0.8015527",
"0.7620166",
"0.73016286",
"0.71959066",
"0.7169366",
"0.7128433",
"0.7070275",
"0.702973",
"0.7013076",
"0.6970159",
"0.6915746",
"0.6890461",
"0.68683475",
"0.68530786",
"0.6846341",
"0.68414545",
"0.6833567",
"0.6833567",
"0.6833567",
"0.68294567... | 0.0 | -1 |
Load a .json object from filepath and return it as a tab separated string ending with a newline. | def transform_song(filepath):
f = json.load(open(filepath))
return '\t'.join([str(v) if (v := f[k]) else ''
for k in song_cols.keys()]) + '\n' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_json(file) -> Table:\n try:\n with Path(file).open(mode=\"r\", encoding=\"utf-8\") as __f:\n res = load(__f)\n print(str(res)[:100])\n return res\n except JSONDecodeError as err:\n if err.msg != \"Extra data\":\n raise\n # Extra data, so t... | [
"0.6771064",
"0.67130977",
"0.66579914",
"0.6637201",
"0.6632642",
"0.64046735",
"0.6403201",
"0.6279003",
"0.62481284",
"0.62403476",
"0.62328875",
"0.62197894",
"0.6215612",
"0.62146175",
"0.6199946",
"0.61840767",
"0.6171043",
"0.61342794",
"0.6132142",
"0.61204296",
"0.61... | 0.5789779 | 64 |
Load .json objects (separated by newlines) from filepath, transform them, and return them as tab separated strings on separate lines. | def transform_log(filepath):
cols = ['song', 'artist', 'userId', 'firstName', 'lastName',
'gender', 'level', 'sessionId', 'location', 'userAgent']
result = ''
with open(filepath, 'rt') as f:
for line in f:
jf = json.loads(line)
if jf['userId'] and (jf['page'] == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_file(input_file_path: str, output_file_path: str):\n\n # Open json\n with open(input_file_path, mode=\"r\") as in_file:\n input_data = json.load(in_file)\n\n # Transform and write\n with jsonlines.open(output_file_path, mode=\"w\", compact=True) as out_file:\n for item in in... | [
"0.643142",
"0.6375164",
"0.63000417",
"0.61742127",
"0.6046418",
"0.5987578",
"0.5959751",
"0.5943822",
"0.59085953",
"0.5884478",
"0.5844225",
"0.5837986",
"0.5791012",
"0.5788993",
"0.576968",
"0.5765325",
"0.5763136",
"0.5741185",
"0.57315063",
"0.5719402",
"0.5702134",
... | 0.54143065 | 59 |
Initialises a new 'TransformerEndInfo' instance. | def __init__(self, ratedU=0.0, endNumber=0, phaseAngleClock=0, emergencyS=0.0, ratedS=0.0, shortTermS=0.0, r=0.0, insulationU=0.0, connectionKind="Z", TransformerTankInfo=None, TransformerEnd=None, *args, **kw_args):
#: Rated voltage: phase-phase for three-phase windings, and either phase-phase or phase-neutral... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTransformerEnd(self):\n return self._TransformerEnd",
"def __init__(self, transformer):\n self.transformer = transformer",
"def __init__(self):\n _snap.TStdOut_swiginit(self, _snap.new_TStdOut())",
"def __init__(self, extractionCtx: ExtractionContext) -> None:\n\n\t\tsuper().__ini... | [
"0.5994626",
"0.5252831",
"0.522783",
"0.51063573",
"0.5081758",
"0.47394088",
"0.47240144",
"0.46955857",
"0.46900004",
"0.46658847",
"0.4660177",
"0.4575002",
"0.45437035",
"0.45135203",
"0.45129088",
"0.45046535",
"0.44867674",
"0.44864896",
"0.4475275",
"0.44621792",
"0.4... | 0.61361396 | 0 |
CrossEntropy for logistic regression | def getCost(Y_predicted, Y):
delta = 1e-47 # threshold to avoid log(0)
_, m = Y.shape
if __debug__:
print("~~~~~~~~~ COST ~~~~~~~~~")
print("m: {}".format(m))
print("Max and min values predicted: {} & {}".format(np.max(Y_predicted), np.min(Y_predicted)))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_entropy(X, y):\n return lambda theta: -y * np.log(logistic_hypothesis(theta)(X) + 1e-9) - (\n 1 - y\n ) * np.log(1 - logistic_hypothesis(theta)(X) + 1e-9)",
"def get_cross_entropy(self):\n assert (self.dataset is not None) and (self.labels is not None), 'Logistic Regression requires... | [
"0.7867875",
"0.7549259",
"0.742597",
"0.7410569",
"0.7373794",
"0.7357459",
"0.7336996",
"0.72690314",
"0.72373444",
"0.72174317",
"0.7166401",
"0.7159649",
"0.7158214",
"0.7110195",
"0.70936984",
"0.7088301",
"0.7070278",
"0.70475334",
"0.6971626",
"0.69586384",
"0.69523174... | 0.0 | -1 |
Check if a phone is correct to be used with HTK toolkit. A phone can't start by a digit nor '' nor '+', and must be ASCII. | def check_as_htk_phone(phone):
try:
phone = str(phone)
except UnicodeEncodeError:
return False
# Must not contain spaces
phone_copy = phone.strip()
if len(phone_copy) != len(phone):
return False
# Must contain characters!
if l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_phone(phone:str) -> bool:\r\n phone = phone.replace(\"-\", \"\").replace(\"(\", \"\").replace(\")\", \"\")\r\n return phone.isdigit() and len(phone) == 10",
"def check_format_user_phone(phone):\n match = re.match(r'^\\+[0-9]{10,}$', phone)\n if not match:\n raise excep... | [
"0.7762896",
"0.7369761",
"0.7307151",
"0.72207594",
"0.71497726",
"0.695266",
"0.68809444",
"0.68564767",
"0.6834683",
"0.6758646",
"0.67464644",
"0.6733163",
"0.6724304",
"0.67112607",
"0.66967034",
"0.6672274",
"0.6655508",
"0.66357243",
"0.66180253",
"0.66014075",
"0.6589... | 0.83398336 | 0 |
Returns some info about the guild. | async def serverinfo_command(self, ctx):
owner = str(ctx.guild.owner.mention)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)
textChannels = len(ctx.guild.text_channels)
voiceChannels = len(ctx.guild.voice_channels)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieveGuildsInfo(self):\n serverInfo = self.con.getGuildsInfo()\n\n for server in serverInfo:\n serverData = server.split(', ')\n self.serverSettings[serverData[0]] = serverData[1]",
"async def server_info(self, ctx):\n guild = ctx.guild\n id = guild.id\n ... | [
"0.7464551",
"0.727364",
"0.7204085",
"0.7002472",
"0.69663215",
"0.6888145",
"0.67988193",
"0.6648769",
"0.65901756",
"0.65618354",
"0.6552789",
"0.6397596",
"0.63721",
"0.63506585",
"0.6343437",
"0.6319326",
"0.6316348",
"0.63098174",
"0.63068444",
"0.6300289",
"0.6296174",... | 0.6709114 | 7 |
Update weights by one step | def __update_weights_grad_desc(self, x_train, y_train):
predictions = self.__compute_prediction(x_train)
weights_delta = np.dot(x_train.T, y_train - predictions)
m = y_train.shape[0]
self.__weights += self.__learning_rate / float(m) * weights_delta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weights(self):\n\n self.wei... | [
"0.8801319",
"0.8790046",
"0.85257936",
"0.8106246",
"0.80620784",
"0.79160404",
"0.7851149",
"0.78053564",
"0.7771207",
"0.7735158",
"0.7634865",
"0.75403994",
"0.746698",
"0.74437726",
"0.73169446",
"0.73119795",
"0.7294702",
"0.7285199",
"0.7285199",
"0.7285199",
"0.728519... | 0.6787023 | 82 |
For a dictionary this removes all None values, and for a list this removes all None elements; otherwise it returns the input itself. | def compact(x):
if isinstance(x, dict):
return dict((k, v) for k, v in x.items() if v is not None)
elif isinstance(x, list):
return [elem for elem in x if elem is not None]
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_none(x):\n if isinstance(x, dict):\n return {k: filter_none(v) for k, v in x.items() if v is not None}\n elif isinstance(x, list):\n return [filter_none(i) for i in x if x is not None]\n else:\n return x",
"def _drop_nulls(o):\n if isinstance(o, (dict, Mapping)):\n ... | [
"0.79326075",
"0.78136176",
"0.7595864",
"0.75605136",
"0.73615044",
"0.7294572",
"0.7242636",
"0.72360003",
"0.7209969",
"0.72053266",
"0.7067895",
"0.70627165",
"0.7060021",
"0.69923913",
"0.68471134",
"0.6839638",
"0.6796231",
"0.6788249",
"0.6784322",
"0.67492133",
"0.674... | 0.7034449 | 13 |
Add a new experience to memory | def add(self, state, action, reward, next_state, done):
e = self.experience(state, action, reward, next_state, done)
self.memory.append(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_experience(self, state, action, reward, next_state, done):\n e = self.experience(state, action, reward, next_state, done, self.max_priority)\n self.memory.append(e)",
"def add(self, experience):\n self.buffer.append(experience)",
"def add(self, state, action, reward, next_state... | [
"0.7760072",
"0.7590868",
"0.755468",
"0.752751",
"0.7450783",
"0.72245246",
"0.7153905",
"0.70797545",
"0.6969529",
"0.6956846",
"0.6853843",
"0.68222356",
"0.6735355",
"0.66815466",
"0.6625817",
"0.6517295",
"0.64274824",
"0.64173156",
"0.63134074",
"0.6311642",
"0.6288281"... | 0.691223 | 12 |
Get primes >=1 and <=n | def get_primes(n):
return list(primes_sieve(n)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]",
"def get_primes(n):\n primes = [True] * (n / 2)\n for i in range(int((n / 2 - 1) / 2) >> 1):\n for j in range((i * (i + 3) << 1) + 3, n / 2, (i << 1) + 3): \n primes[j] = False\n return [2] + [((i << 1) + 3) for ... | [
"0.8374655",
"0.7943893",
"0.7917836",
"0.78941464",
"0.7885002",
"0.7847401",
"0.7833597",
"0.78157985",
"0.78133935",
"0.781276",
"0.7796558",
"0.7795043",
"0.7795043",
"0.7782278",
"0.7743964",
"0.7708098",
"0.77040714",
"0.76803917",
"0.7678948",
"0.7674104",
"0.7673269",... | 0.7831246 | 7 |
Test Create an Application | def test_01_create(self, namespace=None, name=None, contact_user=None):
self.direct_login_user_1()
data = {}
if namespace:
data['namespace'] = namespace
if name:
data['name'] = name
if contact_user:
data['contact_user'] = contact_user
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_11_create_application(self, mock):\r\n # Create an app as an anonymous user\r\n with self.flask_app.app_context():\r\n res = self.new_application(method=\"GET\")\r\n assert self.html_title(\"Sign in\") in res.data, res\r\n assert \"Please sign in to access th... | [
"0.81853795",
"0.8128185",
"0.80447745",
"0.8038618",
"0.7966533",
"0.75807536",
"0.74990994",
"0.7441424",
"0.73540187",
"0.7311173",
"0.73024106",
"0.728025",
"0.7231984",
"0.72097087",
"0.72071403",
"0.7194391",
"0.71878994",
"0.71844286",
"0.7140601",
"0.71331936",
"0.710... | 0.7139851 | 19 |
Computes the \alpha_2 value for the distribution | def _alpha2(edges,count):
# normalize count
tmp_count = count/np.sum(count)
return (
np.sum(
(edges**4) *tmp_count )/
(3*(np.sum((edges**2)*tmp_count)
**2))
) -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha_from_c2(c2p, c2s):\n return 0.55 * ((c2s/c2p) / 2.)**(-1./3.)",
"def alpha(self,k1,k2,c):\n if k1 == 0.:\n return 0.\n else:\n return 1. + k2*c/k1",
"def stdProbabilityNorm(self):\n return 1./factorial(self.alpha-1)",
"def fdist(param1, param2):\n ... | [
"0.68390465",
"0.6489389",
"0.6449515",
"0.6375179",
"0.63552225",
"0.62740016",
"0.6258322",
"0.62138116",
"0.61916494",
"0.61835694",
"0.6126673",
"0.6089308",
"0.60888416",
"0.60594577",
"0.6050831",
"0.6026883",
"0.5986022",
"0.5982585",
"0.5978657",
"0.597836",
"0.590980... | 0.6209902 | 8 |
Escapes invalid characters (| char) within a table column value. | def column(self, value):
# Escape |
return value.replace("|", "|") if value else value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escape_cell(cell):\n cell = cell.replace(u'\\\\', u'\\\\\\\\')\n cell = cell.replace(u'\\n', u'\\\\n')\n cell = cell.replace(u'|', u'\\\\|')\n return cell",
"def test_escape(self):\n bad_str = '''`~!@#$%^&*()_+-={}[]|\\\\;:'\",./<>?\\n\\r\\t '''\n self.run_escape_case(bad_str)",
"... | [
"0.697736",
"0.60197705",
"0.59854263",
"0.593867",
"0.593867",
"0.593867",
"0.588756",
"0.5843186",
"0.57952434",
"0.5793849",
"0.57811064",
"0.57575995",
"0.57279104",
"0.57268155",
"0.5720709",
"0.57190883",
"0.56494975",
"0.5637369",
"0.56271106",
"0.56192166",
"0.5547293... | 0.65204626 | 1 |
Provide equality checking for numpy arrays, with informative error messages when applicable. A and B are equal if they have the same dimensions and for all elements a in A and corresponding elements b in B, a == b +/ delta | def assertNdArrayEqual(self, A, B, msg=None, delta=.00001):
if A.shape != B.shape:
reason = "Tried to compare ndarray of size %s to ndarray of size %s\n" % (str(A.shape),str(B.shape))
if self.longMessage and msg:
reason += msg
raise self.failureException(reas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkArraysEqual(self, a, b):\n # Modified from GNUplot would be better to have this in some module\n self.checkArrayAttrs(a, b)\n np.testing.assert_array_equal(a, b)\n if len(a.set_arrays) > 1:\n for i, set_arr in enumerate(a.set_arrays):\n np.testing.asse... | [
"0.73481685",
"0.7186585",
"0.6935465",
"0.6921428",
"0.6863389",
"0.6838223",
"0.68146884",
"0.67457914",
"0.67170143",
"0.6696865",
"0.66589916",
"0.6644993",
"0.66360015",
"0.6629034",
"0.66192925",
"0.65839696",
"0.65367126",
"0.6534698",
"0.6529117",
"0.652243",
"0.64875... | 0.81438303 | 0 |
Decrement the number of votes of message_id | def downvote(message_id, url_path):
comment_obj.decrement_message_votes(url_path, message_id)
dir_list = url_path.split('/')
if len(dir_list) == 1:
corresponding_dict = list[dir_list[0]]
else:
corresponding_dict = list[dir_list[0]]
for idx in range(1, len(dir_list)-1):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relation_downvote(request, pk):\n try:\n relation = Relation.objects.get(pk=pk)\n except Relation.DoesNotExist:\n return Response(status=status.HTTP_404_NOT_FOUND)\n\n if request.method == 'PUT':\n relation.negative_reaction_count += 1\n relation.save()\n serializer ... | [
"0.65959334",
"0.608145",
"0.5981078",
"0.5883776",
"0.580409",
"0.5802436",
"0.5777887",
"0.5745174",
"0.5723392",
"0.5692763",
"0.5667326",
"0.56356776",
"0.5603125",
"0.5601504",
"0.5596755",
"0.555559",
"0.5535807",
"0.55166066",
"0.549937",
"0.54788166",
"0.54646266",
... | 0.64357865 | 1 |
Creates a dataframe self.df from the file path. | def extract(self):
print('Extracting Metrics data... ',end=''),
self.df = pd.read_excel(self.file_path, index_col=0)
print('Done') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_file_to_dataframe(self, file_path: str) -> pd.DataFrame:\n return pd.read_csv(file_path, sep=\"\\t\")",
"def load(self) -> pd.DataFrame:\n if os.path.exists(self.file_name):\n df = pd.read_csv(self.file_name, index_col=0)\n df = self._clean(df)\n else:\n ... | [
"0.81163096",
"0.77929723",
"0.74120545",
"0.72111285",
"0.72111285",
"0.72111285",
"0.72037935",
"0.72021824",
"0.7144905",
"0.7134051",
"0.71276885",
"0.70895875",
"0.70845115",
"0.7040705",
"0.7024183",
"0.6974979",
"0.69591576",
"0.6955939",
"0.69370836",
"0.692673",
"0.6... | 0.0 | -1 |
The time complexity is O(n) Note that even though find_min_max_fast and find_min_max have the same order of time complexity, If you count the comparison operations carefully, you would find that find_min_max_fast takes O(3n/2 2) comparisons and find_min_max takes O(2n 2) comparisons | def find_min_max_fast(x):
import math
if not x: return None
if len(x) == 1:
return x[0], x[0] # the first is min and the second is max
min_val, max_val = min_max(x[0], x[1])
for i in xrange(2, (len(x) - 1), 2):
smaller, larger = min_max(x[i], x[i+1])
min_val = min(smaller, min_val)
max_val = m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min_max(x):\n if not x: return None\n if len(x) == 1:\n return x[0], x[0] # the first is min and the second is max\n min_val = x[0]\n max_val = x[0]\n for i in xrange(1, len(x)):\n if x[i] < min_val:\n min_val = x[i]\n elif x[i] > max_val:\n max_val = x[i]",
"def min_max(lst):\r\... | [
"0.7237612",
"0.7102269",
"0.69250995",
"0.6907554",
"0.69000757",
"0.6766562",
"0.67161334",
"0.6711951",
"0.6632182",
"0.6626001",
"0.66068983",
"0.6567052",
"0.6559828",
"0.65277743",
"0.65148324",
"0.6500452",
"0.6491945",
"0.64915735",
"0.6480213",
"0.64735055",
"0.64583... | 0.74365497 | 0 |
dc.build_portrait_filename( str ) > str Returns the portrait filename for the given "expression" key. (usually refers to different facial expressions for NPCs) | def build_portrait_filename(self, key):
name = self.source.get_name()
if name == None:
return None
return "portrait_" + name + "_" + key + ".bmp" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filename(self, key):\n return os.path.join(self.root, key[:2], key)",
"def make_filename(key, extension):\n key = unicode(key.strip())\n return '{}.{}'.format(slugify(key), extension)",
"def acquire_image_filename(self):\n\t\titem_key = self.contents_data[ITEM_KEY]\n\t\tif not item_key: retur... | [
"0.59755117",
"0.57916135",
"0.5744576",
"0.53890514",
"0.53643423",
"0.5349184",
"0.5306746",
"0.5284465",
"0.5267519",
"0.5219435",
"0.52007765",
"0.51957303",
"0.51699454",
"0.5164805",
"0.5163554",
"0.51582795",
"0.50764096",
"0.50707155",
"0.5068605",
"0.50632167",
"0.50... | 0.7643361 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.