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 |
|---|---|---|---|---|---|---|
Allows all crossorigin traffic. This method can be used to restrict traffic from specific origins. | def check_origin(self, origin):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_origins(self, allow_origins):\n\n self._allow_origins = allow_origins",
"def crossorigin():\n if absolute_uri(settings.STATIC_URL).startswith(options.get('system.url-prefix')):\n # They share the same domain prefix, so we don't need CORS\n return ''\n return ' crossorigin=\"a... | [
"0.7331257",
"0.6995993",
"0.67794615",
"0.6632004",
"0.6494943",
"0.6382702",
"0.63460565",
"0.62882674",
"0.6132412",
"0.6128998",
"0.59765357",
"0.59584856",
"0.5919484",
"0.5883876",
"0.5848344",
"0.58368444",
"0.57624024",
"0.57331353",
"0.57331353",
"0.5718",
"0.5689661... | 0.5182645 | 57 |
Apply a [0.5, 0.5] sigmoid function. | def sigmoid(x, exponent):
return 1/(1+np.exp(-exponent*x))-0.5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(x):\r\n return 1 / (1 + np.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1.0 / (1.0 + np.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + np.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + np.exp(-... | [
"0.8269099",
"0.82455605",
"0.82455605",
"0.8243822",
"0.82157654",
"0.82157654",
"0.82157654",
"0.82157654",
"0.82157654",
"0.82157654",
"0.82046235",
"0.81962657",
"0.81948197",
"0.8194068",
"0.81881464",
"0.8175757",
"0.8136257",
"0.81220436",
"0.8094479",
"0.80868375",
"0... | 0.77242285 | 44 |
Differential A' rate per p.o.t. as a function of P and theta | def dNdPdTheta(p, theta, mDarkPhoton, epsilon):
diffRate = dNdZdPtSquare(p,mDarkPhoton,theta,epsilon) * dPt2dTheta(p,theta) * dZdP(p,theta)
return math.fabs(diffRate) # integrating in (-pi, pi)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_delta_v_tot(f, e, a, P):\n\n coeff = (2.0*np.pi/P) * a / np.sqrt(1.0 - e*e)\n delta_v_tot = coeff * (1.0 + 2.0*e*np.cos(f) + e*e) / 1.0e5\n\n return delta_v_tot",
"def zeta(p, theta):\n return p / (protonMomentum * math.sqrt(theta*theta + 1.))",
"def taucurveder(self, p, x):\n y = -(... | [
"0.63927",
"0.6356196",
"0.6267876",
"0.62386954",
"0.6190734",
"0.6050173",
"0.5943602",
"0.5923434",
"0.5910197",
"0.589651",
"0.58923393",
"0.58054423",
"0.580167",
"0.5772672",
"0.57698905",
"0.5760307",
"0.57457495",
"0.57161117",
"0.57109064",
"0.5690813",
"0.5688927",
... | 0.60691804 | 5 |
Creates aiohttp.ClientSession and returns it | async def create_session() -> aiohttp.ClientSession:
headers = generate_header()
client_session = aiohttp.ClientSession(headers=headers)
return client_session | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_session():\n import aiohttp\n conn = aiohttp.TCPConnector(limit_per_host=int(\n os.getenv('AIO_CONN_LIMIT', 10)))\n timeout = aiohttp.ClientTimeout(\n total=int(os.getenv('AIO_TOTAL_TIMEOUT', 80)),\n connect=int(os.getenv('AIO_CONN_TIMEOUT', 15)),\n sock_read=int(os.ge... | [
"0.8186444",
"0.77997327",
"0.72975147",
"0.7164132",
"0.7138179",
"0.7120649",
"0.6934428",
"0.68733054",
"0.67355704",
"0.67332464",
"0.6698366",
"0.6689121",
"0.6685307",
"0.66821074",
"0.6673545",
"0.66726273",
"0.6584333",
"0.652967",
"0.6503259",
"0.64801055",
"0.645224... | 0.89829504 | 0 |
Return a normal ordered FermionOperator or BosonOperator corresponding to single term. | def normal_ordered_ladder_term(term, coefficient, parity=-1):
# Iterate from left to right across operators and reorder to normal
# form. Swap terms operators into correct position by moving from
# left to right across ladder operators.
term = list(term)
if parity == -1:
Op = FermionOperato... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _normal_ordered_term(term, coefficient):\n term = list(term)\n ordered_term = FermionOperator()\n for i in range(1, len(term)):\n for j in range(i, 0, -1):\n left_sub_term = term[j - 1]\n right_sub_term = term[j]\n # Swap operators if left operator is annihilati... | [
"0.69149154",
"0.66542435",
"0.6637153",
"0.6441744",
"0.6411041",
"0.6291217",
"0.62853724",
"0.62853724",
"0.62853724",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124",
"0.6225124"... | 0.57027787 | 44 |
r"""Compute and return the normal ordered form of a FermionOperator, BosonOperator, QuadOperator, or InteractionOperator. Due to the canonical commutation/anticommutation relations satisfied by these operators, there are multiple forms that the same operator can take. Here, we define the normal ordered form of each ope... | def normal_ordered(operator, hbar=1.):
kwargs = {}
if isinstance(operator, FermionOperator):
ordered_operator = FermionOperator()
order_fn = normal_ordered_ladder_term
kwargs['parity'] = -1
elif isinstance(operator, BosonOperator):
ordered_operator = BosonOperator()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_ordered(fermion_operator):\n if not isinstance(fermion_operator, FermionOperator):\n raise ValueError(\"The operator should be FermionOperator!\")\n ordered_op = FermionOperator()\n for term, coeff in fermion_operator.terms.items():\n ordered_op += _normal_ordered_term(term, coeff... | [
"0.7696889",
"0.6421614",
"0.6131649",
"0.5219839",
"0.51665723",
"0.5131124",
"0.51244485",
"0.5096591",
"0.50751436",
"0.50321573",
"0.500762",
"0.4962916",
"0.49244088",
"0.4923696",
"0.48865762",
"0.4873591",
"0.4871458",
"0.48685223",
"0.4853055",
"0.4816735",
"0.4805438... | 0.69774884 | 1 |
Gets the float value of the length of the lane. | def get_length(self):
if(type(self._length) != float):
self._logger.write("Error! length must be of type float")
elif(self._length == None):
self._logger.write("Error! length contains no value")
else:
try:
return self._length
except... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLength(self) -> float:\n return self.length",
"def get_length(self):\n return math.sqrt(self.x**2 + self.y**2)",
"def _get_length(self):\n from math import sqrt\n\n if self._length is None:\n sum1 = 0\n for a in self.diff:\n sum1 += a * a\... | [
"0.75100625",
"0.73795766",
"0.7362234",
"0.73285455",
"0.72898537",
"0.724121",
"0.7225307",
"0.7168905",
"0.7129496",
"0.7118933",
"0.7066373",
"0.70571905",
"0.70181435",
"0.70131433",
"0.7010303",
"0.69489443",
"0.6907625",
"0.68812555",
"0.6880146",
"0.68419427",
"0.6817... | 0.7364733 | 2 |
Gets the integer value of max_vehicle_capacity. | def get_max_vehicle_capacity(self):
if(type(self._max_vehicle_capacity) != int):
self._logger.write("Error! max_vehicle_capacity must be of type int")
elif(self._max_vehicle_capacity == None):
self._logger.write("Error! max_vehicle_capacity contains no value")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_capacity(self) -> int:\n return self._max_capacity",
"def max_capacity_gb(self) -> str:\n return pulumi.get(self, \"max_capacity_gb\")",
"def max_capacity(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"max_capacity\")",
"def max_capacity(self) -> Optional[pulum... | [
"0.8318053",
"0.7822479",
"0.77320015",
"0.77320015",
"0.77320015",
"0.74360806",
"0.7258341",
"0.7134526",
"0.71276",
"0.71276",
"0.71276",
"0.71276",
"0.7111698",
"0.70257664",
"0.70257664",
"0.6982312",
"0.6982312",
"0.6982312",
"0.6982312",
"0.6982312",
"0.6982312",
"0.... | 0.90556926 | 0 |
Gets the float value of total_lane_wait_time. | def get_total_lane_wait_time(self):
if(type(self._total_lane_wait_time) != float):
self._logger.write("Error! total_lane_volume must be of type int")
elif(self._total_lane_wait_time == None):
self._logger.write("Error! total_lane_wait_time contains no value")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_total_lane_wait_time(self):\n\n if(self._vehicle_list == None):\n self._logger.write(\"Error! vehicle_list contains no value\")\n elif(len(self._vehicle_list) == 0):\n self._logger.write(\"Error! vehicle_list is empty\")\n else:\n try:\n ... | [
"0.7588522",
"0.70940036",
"0.6818951",
"0.67266107",
"0.65546113",
"0.6380548",
"0.63365346",
"0.633364",
"0.6331705",
"0.6285145",
"0.6216036",
"0.6160186",
"0.61535776",
"0.61479473",
"0.61443263",
"0.61423737",
"0.61175954",
"0.611549",
"0.61075336",
"0.6080555",
"0.60637... | 0.87386036 | 0 |
Adds a vehicle to the to the bottom of end_list | def enqueue(self, vehicle):
if(vehicle == None):
self._logger.write("Error! vehicle cannot be a NoneType")
else:
try:
self._vehicle_list.append(vehicle)
except Exception as e:
self._logger.write("Error! Could not add vehicle to end_lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_end(self, cargo):\r\n if self.size() == 0: # si la liste est encore vide,\r\n self.add(cargo) # ajouter à la fin correspond au ajouter au début\r\n else: # si la liste contient déjà au moins un noeud (et donc une dernier noeud)\r\n node = self.Node(cargo)\r\n ... | [
"0.6143113",
"0.60612625",
"0.59549314",
"0.5903752",
"0.56560403",
"0.5603141",
"0.55811894",
"0.5517956",
"0.54649156",
"0.5461964",
"0.5456554",
"0.5445067",
"0.5410161",
"0.5382731",
"0.5375098",
"0.5360001",
"0.5332862",
"0.53050184",
"0.5263104",
"0.5262495",
"0.5257435... | 0.682744 | 0 |
Warp of python builtin reversed(). | def reversed(self):
return QuerySet(reversed(list(self))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse(self): # real signature unknown; restored from __doc__\n pass",
"def __reversed__(self):\n return reverse(self)",
"def reverse(seq):\n return seq[::-1]",
"def reverse(seq):\n return seq[::-1]",
"def __reversed__(self): # real signature unknown; restored from __doc__\n ... | [
"0.80165666",
"0.7953324",
"0.7648779",
"0.7648779",
"0.7538703",
"0.7517617",
"0.7495599",
"0.7486679",
"0.738936",
"0.738152",
"0.72426414",
"0.7223636",
"0.7217082",
"0.7210185",
"0.71439",
"0.7131494",
"0.71108633",
"0.70916826",
"0.70330644",
"0.700394",
"0.699734",
"0... | 0.0 | -1 |
Performs one hot encoding for categorical features for both dependent and indepedent variables. This is defined as static method as it will be used by embedded and wrapper method as well. | def one_hot_encoding(self):
try:
# Encode dependent variable
le = LabelEncoder()
le.fit(self.data["consumption"])
df_dependent_enc = pd.DataFrame(le.transform(self.data["consumption"]))
# Encode independent variable
categorical_feat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __encode_one_hot_util(self):\n for col in self.cat_cols:\n if (\n col in self.train_df\n and col + str(\"Encoded\") not in self.ord_cols\n ):\n if self.test_df is not None:\n self.test_df = pd.concat(\n ... | [
"0.79611015",
"0.7564052",
"0.7502653",
"0.74452317",
"0.7320468",
"0.7310081",
"0.72088337",
"0.717355",
"0.71512437",
"0.71280813",
"0.7122601",
"0.7109313",
"0.71020657",
"0.70976627",
"0.7081373",
"0.7049666",
"0.7042576",
"0.7035946",
"0.70229596",
"0.7022638",
"0.701868... | 0.8036344 | 0 |
returns char at pos of words, or None if out of bounds | def getchar(words,pos):
if pos<0 or pos>=len(words): return None
return words[pos] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_word_at(self, position: Position) -> Optional[str]:\n line = self._get_line(position.line)\n\n for match in re.finditer(r'\\w+', line):\n if match.start() <= position.character <= match.end():\n return match.group(0)\n\n return None",
"def word_at(self, ind... | [
"0.71591806",
"0.68961275",
"0.6779056",
"0.66462135",
"0.6565805",
"0.6362004",
"0.63036036",
"0.6293876",
"0.6258504",
"0.6187516",
"0.60633963",
"0.6044457",
"0.5988862",
"0.5903006",
"0.5890581",
"0.58828115",
"0.5877637",
"0.5867",
"0.5828091",
"0.5815339",
"0.58035606",... | 0.8391957 | 0 |
Scans `text` while transitions exist in 'transition_table'. After that, if in a state belonging to `accept_states`, returns the corresponding token, else ERROR_TOKEN. | def scan(text,transition_table,accept_states):
# initial state
pos = 0
state = 'q0'
while True:
c = getchar(text,pos) # get next char
if state in transition_table and c in transition_table[state]:
state = transition_table[state][c] # set new state
pos += 1 # advance to next char
else: #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __finite_state_matching(text, transitions, pattern_length):\n occurence_positions = []\n n = len(text)\n # start state\n q = 0\n # Run the text through the FSM\n for i in range(n):\n q = transitions[(q, text[i])]\n # The accepting state is reached... | [
"0.5611486",
"0.5377776",
"0.5354928",
"0.53288025",
"0.5180156",
"0.5099379",
"0.508063",
"0.50794417",
"0.5054382",
"0.49765158",
"0.49717027",
"0.4931228",
"0.49119756",
"0.48990893",
"0.48825818",
"0.48725876",
"0.48596367",
"0.48568997",
"0.4852104",
"0.48396894",
"0.482... | 0.77254903 | 0 |
Center anchors for pyglet images | def center_image_anchor(image):
image.anchor_x = image.height/2
image.anchor_y = image.height/2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_anchor_center(img):\n img.anchor_x = int(img.width / 2)\n img.anchor_y = int(img.height / 2)",
"def center_image_grid_anchors(image_grid):\n for image in image_grid:\n center_image_anchor(image)",
"def set_anchors(mc):\n H, W, C = _get_output_shape(mc)\n B = mc.ANCHOR_PER_GRID\n X =... | [
"0.7279401",
"0.69346374",
"0.6751037",
"0.64908564",
"0.64908564",
"0.6446656",
"0.6441182",
"0.6412637",
"0.6398208",
"0.63202286",
"0.62647927",
"0.6165228",
"0.59464747",
"0.5857066",
"0.5791311",
"0.5785398",
"0.5714562",
"0.57082295",
"0.5707654",
"0.57002115",
"0.56736... | 0.70592046 | 1 |
Generates a random 10 digit alpha numeric which is used as location for the registered endpoint(or client) | def locID_generator(self, str_size, chars=string.ascii_uppercase + string.digits):
return ''.join([random.choice(chars) for _ in range(str_size)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __generate_random_string():\n return uuid4().hex[:6].upper()",
"def _generate_id() -> str:\n return \"\".join(sample(\"abcdefghjkmopqrstuvqxyz\", 16))",
"def random_ticket():\n ts = time.time()\n return \"%s_%s\" % (ts, random_str(6, string.digits))",
"def generate_id():\n return str(u... | [
"0.74708587",
"0.7408521",
"0.72505486",
"0.7191584",
"0.7158277",
"0.71438164",
"0.7105089",
"0.7097584",
"0.70595837",
"0.7025476",
"0.6982906",
"0.6961109",
"0.69574195",
"0.6945312",
"0.69432604",
"0.69432604",
"0.6917869",
"0.6916764",
"0.69073194",
"0.69068253",
"0.6905... | 0.6800406 | 32 |
converts something that might be something else to list | def controlled_list(input_list):
output_list = input_list
if not isinstance(input_list, list):
dummy_list = []
dummy_list.append(input_list)
output_list = dummy_list
print('Converting')
print('Before return')
print(output_list)
return output_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _coerce_list(self, thing):\n\t\tif isinstance(thing, basestring):\n\t\t\treturn list((thing,))\n\n\t\treturn list(thing)",
"def aslist(something):\n return something if isinstance(something, list) else [something]",
"def tolist(x):\n return x if isinstance(x, list) else [x]",
"def to_list(x):\n if... | [
"0.8281358",
"0.8244671",
"0.81210214",
"0.80391115",
"0.78696966",
"0.7861915",
"0.7854082",
"0.7843001",
"0.78200024",
"0.7757652",
"0.7701323",
"0.76642716",
"0.7660282",
"0.7654543",
"0.7525208",
"0.7514465",
"0.74790496",
"0.7469532",
"0.7441301",
"0.74262285",
"0.742556... | 0.64522845 | 68 |
Assert that an Org can be updated. | def test_update_org(session): # pylint:disable=unused-argument
org = factory_org_service()
org.update_org(TestOrgInfo.org2)
dictionary = org.as_dict()
assert dictionary['name'] == TestOrgInfo.org2['name'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_valid_org(self):\r\n assert self.org_tree != 0",
"def test_call_update_if_organization(self):\n Project.can_access.return_value = False\n self.mixin.check_can_access.when\\\n .called_with(MagicMock(user=self.user))\\\n .should.throw(PermissionDenied)\n... | [
"0.68411916",
"0.6517205",
"0.64363974",
"0.6339802",
"0.6235352",
"0.619402",
"0.6178408",
"0.6091369",
"0.60401523",
"0.6030907",
"0.6023797",
"0.6009505",
"0.59958184",
"0.5988592",
"0.5942303",
"0.59362507",
"0.59029377",
"0.58692527",
"0.5843885",
"0.58419997",
"0.583961... | 0.7428996 | 0 |
Assert that an org which does not exist cannot be retrieved. | def test_find_org_by_id_no_org(session, auth_mock): # pylint:disable=unused-argument
org = OrgService.find_by_org_id(99)
assert org is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_email_account_operation_with_missing_org(self):\n org_name = 'TestMissingOrg'\n self.assertRaises(error.NotFound, \\\n SpokeEmailAccount, org_name, self.user_id)",
"def test_email_address_operation_with_missing_org(self):\n org_name = 'TestMissingOrg'\n ... | [
"0.76218027",
"0.75966024",
"0.7321256",
"0.7226306",
"0.6868789",
"0.66331816",
"0.65547633",
"0.6446411",
"0.6420386",
"0.64091414",
"0.63939005",
"0.63769454",
"0.6361881",
"0.6349921",
"0.63425094",
"0.6338863",
"0.632408",
"0.6282195",
"0.6272567",
"0.62679374",
"0.62646... | 0.69869536 | 4 |
Assert that a contact cannot be added to an Org if that Org already has a contact. | def test_add_contact_duplicate(session): # pylint:disable=unused-argument
org = factory_org_service()
org.add_contact(TestContactInfo.contact1)
with pytest.raises(BusinessException) as exception:
org.add_contact(TestContactInfo.contact2)
assert exception.value.code == Error.DATA_ALREADY_EXISTS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_contact_no_contact(session): # pylint:disable=unused-argument\n org = factory_org_service()\n\n with pytest.raises(BusinessException) as exception:\n org.update_contact(TestContactInfo.contact2)\n assert exception.value.code == Error.DATA_NOT_FOUND.name",
"def test_delete_contact... | [
"0.69058305",
"0.67744225",
"0.67416173",
"0.658693",
"0.6173459",
"0.61460847",
"0.60964715",
"0.60521656",
"0.6009104",
"0.59450144",
"0.59390444",
"0.5928479",
"0.5908564",
"0.58901596",
"0.5888123",
"0.5852358",
"0.5832104",
"0.5801254",
"0.5696305",
"0.56844974",
"0.5675... | 0.7614068 | 0 |
Assert that a contact for an existing Org can be updated. | def test_update_contact(session): # pylint:disable=unused-argument
org = factory_org_service()
org.add_contact(TestContactInfo.contact1)
dictionary = org.as_dict()
assert len(dictionary['contacts']) == 1
assert dictionary['contacts'][0]['email'] == TestContactInfo.contact1['email']
org.update... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_contact_no_contact(session): # pylint:disable=unused-argument\n org = factory_org_service()\n\n with pytest.raises(BusinessException) as exception:\n org.update_contact(TestContactInfo.contact2)\n assert exception.value.code == Error.DATA_NOT_FOUND.name",
"def test_update_org(ses... | [
"0.7465451",
"0.7222896",
"0.6961634",
"0.6729569",
"0.66567796",
"0.65856",
"0.64966726",
"0.64748096",
"0.6464287",
"0.6452577",
"0.63893163",
"0.637902",
"0.635146",
"0.62835795",
"0.6273097",
"0.6256001",
"0.6220993",
"0.6211471",
"0.61494195",
"0.6077241",
"0.6075179",
... | 0.79693437 | 0 |
Assert that a contact for a nonexistent contact cannot be updated. | def test_update_contact_no_contact(session): # pylint:disable=unused-argument
org = factory_org_service()
with pytest.raises(BusinessException) as exception:
org.update_contact(TestContactInfo.contact2)
assert exception.value.code == Error.DATA_NOT_FOUND.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_existent_campaign_by_non_admin_fails(self):\n response = self.client.patch(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n json={\n \"logo\": None,\n \"name\": NEW_CAMPAIGN_NAME,\n \"organisations\": [self.test_org.id]... | [
"0.66648597",
"0.65505505",
"0.6422997",
"0.6412745",
"0.6373296",
"0.6329859",
"0.62779623",
"0.6251437",
"0.6119856",
"0.6116841",
"0.6111836",
"0.61022866",
"0.6101629",
"0.60032636",
"0.59809005",
"0.59626764",
"0.595236",
"0.5942009",
"0.5929719",
"0.59160864",
"0.589911... | 0.79313135 | 0 |
Assert that invitations for an org can be retrieved. | def test_get_invitations(session, auth_mock): # pylint:disable=unused-argument
with patch.object(InvitationService, 'send_invitation', return_value=None):
user = factory_user_model()
org = OrgService.create_org(TestOrgInfo.org1, user.id)
invitation_info = factory_invitation(org.as_dict()['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_find_invitations_by_org(session): # pylint:disable=unused-argument\n invitation = factory_invitation_model(session=session, status='PENDING')\n session.add(invitation)\n session.commit()\n\n found_invitations = InvitationModel.find_invitations_by_org(invitation.membership[0].org_id)\n asse... | [
"0.7739422",
"0.7196728",
"0.6276484",
"0.61260194",
"0.608113",
"0.6078175",
"0.6073911",
"0.5997388",
"0.59892064",
"0.5969022",
"0.5900634",
"0.58421487",
"0.57992536",
"0.57687056",
"0.57492363",
"0.5733681",
"0.57169443",
"0.57067585",
"0.5702592",
"0.57006395",
"0.56987... | 0.72009486 | 1 |
Assert that a contact can not be deleted without org. | def test_delete_contact_no_org(session, auth_mock): # pylint:disable=unused-argument
org = factory_org_service()
org.add_contact(TestContactInfo.contact1)
updated_org = org.delete_contact()
with pytest.raises(BusinessException) as exception:
updated_org.delete_contact()
assert exception.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_contact(self):\n self.new_contact.save_contact()\n # new contact\n test_contact = Contact(\"Test\", \"user\", \"0745639300\", \"test@usr.com\")\n # new contact saved\n test_contact.save_contact()\n # For deleting the new contact\n self.new_contact.del... | [
"0.6892247",
"0.6890623",
"0.6838396",
"0.6799358",
"0.665724",
"0.6652282",
"0.6599184",
"0.6584224",
"0.6549426",
"0.6518858",
"0.6471591",
"0.6421017",
"0.63198406",
"0.62738705",
"0.6252227",
"0.6251059",
"0.6226606",
"0.62125826",
"0.6204512",
"0.62038416",
"0.6180473",
... | 0.75665534 | 0 |
Assert that a contact can not be deleted without entity. | def test_delete_contact_org_link(session, auth_mock): # pylint:disable=unused-argument
entity_model = factory_entity_model()
entity = EntityService(entity_model)
org = factory_org_service()
org_dictionary = org.as_dict()
org_id = org_dictionary['id']
contact = factory_contact_model()
con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_contact_no_org(session, auth_mock): # pylint:disable=unused-argument\n org = factory_org_service()\n org.add_contact(TestContactInfo.contact1)\n\n updated_org = org.delete_contact()\n\n with pytest.raises(BusinessException) as exception:\n updated_org.delete_contact()\n\n ass... | [
"0.7189604",
"0.7127401",
"0.7095772",
"0.6497767",
"0.642826",
"0.6379965",
"0.6373825",
"0.6358681",
"0.6350356",
"0.6331326",
"0.63270575",
"0.632315",
"0.63194174",
"0.6292333",
"0.62780225",
"0.62780225",
"0.62718034",
"0.62715614",
"0.6263566",
"0.62406677",
"0.623556",... | 0.64006704 | 5 |
Constructs a new WeightedExpert from the provided base_estimator. | def _construct_new_expert(self):
return self.WeightedExpert(
cp.deepcopy(self.base_estimator), 1, self.labels) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(\n self,\n estimator = SGDClassifier(),\n ):\n self.estimator = estimator",
"def __init__(self, estimator, **kwargs):\n super(LogisticRegression, self).__init__(\n estimator, **kwargs)\n\n self.estimator = estimator",
"def __init__(s... | [
"0.564991",
"0.5644063",
"0.5633319",
"0.5478223",
"0.5449161",
"0.5415781",
"0.5389978",
"0.5375458",
"0.53172857",
"0.53038704",
"0.5303585",
"0.5286297",
"0.5248096",
"0.52172697",
"0.52108043",
"0.5189471",
"0.51542145",
"0.514781",
"0.5129843",
"0.5115849",
"0.5095412",
... | 0.75929576 | 0 |
Returns a tensor with the same elements as `input` but a different shape. The order of the elements may not be preserved. | def view(input, shape, _builder=None):
shape = _shape_check_impl(shape)
return semantic.view(input, shape, _builder) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GraphFn(self, inp):\n tensor = inp * 2.0\n tensor = array_ops.reshape(tensor, self.tensor_shapes[1])\n tensor = tensor + 3.0\n tensor = array_ops.reshape(tensor, self.tensor_shapes[2])\n tensor = tensor * 4.0\n tensor = array_ops.reshape(tensor, self.tensor_shapes[3])\n tensor += tensor + ... | [
"0.6574174",
"0.6429301",
"0.63215184",
"0.62964654",
"0.6284243",
"0.6263491",
"0.6237204",
"0.62065697",
"0.6199366",
"0.6185573",
"0.61259073",
"0.6118474",
"0.61109847",
"0.60921794",
"0.6007493",
"0.5986783",
"0.59781337",
"0.5976647",
"0.5958359",
"0.59511656",
"0.59482... | 0.0 | -1 |
Expand the shape of a tensor, by inserting new length1 dimensions. Axis indices are with respect to the resulting tensor, so ``result.shape[axis]`` will be 1 for each axis. | def expand_dims(input, axis, _builder=None):
axis = _constexpr_to_value(axis)
axes = list(axis) if isinstance(axis, Sequence) else [axis]
new_ndim = len(input.shape) + len(axes)
axes = [_wrap_axis(_constexpr_to_value(d), new_ndim) for d in axes]
if len(set(axes)) != len(axes):
raise ValueEr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _expand_dims(st, axis):\n if not isinstance(st, structured_tensor.StructuredTensor):\n return tf.expand_dims(st, axis)\n nn_axis = _expand_dims_nonnegative_axis(axis, st.rank)\n if st.rank == 0:\n return _expand_dims_scalar(st)\n if nn_axis == 0:\n # Here, we can add a dimension 1 at the front.\n ... | [
"0.7041271",
"0.68484265",
"0.6541692",
"0.6325533",
"0.629905",
"0.6261965",
"0.6182974",
"0.61678433",
"0.6139847",
"0.61207235",
"0.6090782",
"0.6044614",
"0.6011727",
"0.58876264",
"0.5863356",
"0.5854975",
"0.58254886",
"0.57854456",
"0.5770374",
"0.57104844",
"0.5707115... | 0.66365474 | 2 |
Determine whether the given arm links touch obstacles | def doesArmTouchObstacles(armPos, obstacles):
for i in range(len(armPos)):
cur_arm = armPos[i]
arm_x = [cur_arm[0][0],cur_arm[1][0]]
arm_y = [cur_arm[0][1],cur_arm[1][1]]
if (arm_x[0] != arm_x[1]):
arm_a = (arm_y[1]-arm_y[0])/(arm_x[1]-arm_x[0])
arm_b = arm_y[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_obstructed(r1,r2): \n \n if r1==r2:\n return False\n \n #Densely sample line connecting r1 and r2.\n #If any of those sampled points is inside the rectangle, then the \n #line of sight intersects the rectangle and... | [
"0.683175",
"0.64634794",
"0.6197695",
"0.6196708",
"0.6113663",
"0.59779316",
"0.5888393",
"0.5876745",
"0.58755356",
"0.58617",
"0.5859707",
"0.5858954",
"0.58245873",
"0.58218783",
"0.57790697",
"0.5778207",
"0.57563525",
"0.57480556",
"0.5742078",
"0.57322615",
"0.5728252... | 0.74999887 | 0 |
Initializes a new instance of the ISimpleITKImageMetric class. | def __init__(self):
super(ISimpleITKImageMetric, self).__init__()
self.metric = 'ISimpleITKImageMetric'
self.ground_truth = None # SimpleITK.Image
self.segmentation = None # SimpleITK.Image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n super(INumpyArrayMetric, self).__init__()\n self.metric = 'INumpyArrayMetric'\n self.ground_truth = None # np.ndarray\n self.segmentation = None # np.ndarray",
"def New(*args, **kargs):\n obj = itkScalarImageKmeansImageFilterIF2IUC2.__New_orig__()\n ... | [
"0.67097676",
"0.6172639",
"0.6141458",
"0.6137424",
"0.61133033",
"0.6086703",
"0.6052344",
"0.60521585",
"0.6043692",
"0.603058",
"0.60249686",
"0.6021736",
"0.6013815",
"0.6010834",
"0.6010454",
"0.59954524",
"0.5994829",
"0.59731656",
"0.5959789",
"0.5936591",
"0.59326595... | 0.90226203 | 0 |
Initializes a new instance of the INumpyArrayMetric class. | def __init__(self):
super(INumpyArrayMetric, self).__init__()
self.metric = 'INumpyArrayMetric'
self.ground_truth = None # np.ndarray
self.segmentation = None # np.ndarray | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data_array):\n self._data_array = data_array\n self._units = self._data_array.attrs.get('units', 'dimensionless')",
"def __init__(self):\n super(ISimpleITKImageMetric, self).__init__()\n self.metric = 'ISimpleITKImageMetric'\n self.ground_truth = None # Simp... | [
"0.6483665",
"0.64198416",
"0.64124113",
"0.621546",
"0.6180227",
"0.60625666",
"0.60592586",
"0.6047309",
"0.60217965",
"0.599438",
"0.5985039",
"0.5966345",
"0.59660023",
"0.59544986",
"0.5945112",
"0.59384847",
"0.5897357",
"0.58931154",
"0.5888952",
"0.5864877",
"0.583833... | 0.8709765 | 0 |
Calculates the area under the curve. | def calculate(self):
specificity = self.confusion_matrix.tn / (self.confusion_matrix.tn + self.confusion_matrix.fp)
false_positive_rate = 1 - specificity
true_positive_rate = self.confusion_matrix.tp / (self.confusion_matrix.tp + self.confusion_matrix.fn)
return (true_positive_rate -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n return 0.5*np.abs(np.dot(self.x,np.roll(self.y,1))-np.dot(self.y,np.roll(self.x,1)))",
"def area(self) -> float:\n raise NotImplementedError",
"def area(x, y):\n return x*y/2",
"def total_area(self):\n return numpy.prod([r[1] - r[0] for r in self.range_])",
"def ar... | [
"0.7602455",
"0.74112916",
"0.7332826",
"0.7115214",
"0.70717835",
"0.6972643",
"0.6901682",
"0.6878126",
"0.6871217",
"0.6864565",
"0.68639535",
"0.685557",
"0.6826705",
"0.68122953",
"0.6794928",
"0.67877954",
"0.6767313",
"0.671754",
"0.670861",
"0.66806746",
"0.6675162",
... | 0.0 | -1 |
Initializes a new instance of the DiceCoefficient class. | def __init__(self):
super().__init__()
self.metric = 'DICE' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, coefficients):\n self.coefficients = coefficients",
"def __init__(self, data, numcand=None, weights=None):\n\n CandidateDYCORS.__init__(self, data, numcand=numcand, weights=weights)\n self.weights = np.array([1.0])\n self.numcand = max([0.5*data.dim, 2])\n\n ... | [
"0.6342694",
"0.629701",
"0.61882305",
"0.61128205",
"0.5897463",
"0.583956",
"0.5804858",
"0.5797566",
"0.5777754",
"0.5760896",
"0.57299495",
"0.571543",
"0.571543",
"0.571543",
"0.5664989",
"0.5659726",
"0.5635503",
"0.5610199",
"0.560002",
"0.5585844",
"0.5583112",
"0.5... | 0.5523057 | 22 |
Initializes a new instance of the FalseNegative class. | def __init__(self):
super().__init__()
self.metric = 'FN' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neg__(self):\n return Factor().__build( VarSet(self.v) , np.negative(self.t) )",
"def __neg__(self):\n\t\tval = -self.val\n\t\tder = -self.der if len(self.der.shape) else None\n\t\treturn Var(val, der)",
"def __neg__(self):\n return 0 - self",
"def __neg__(self):\n retval = self.copy()... | [
"0.6756557",
"0.6752917",
"0.66845036",
"0.6661124",
"0.6591258",
"0.65329397",
"0.65007365",
"0.64539313",
"0.64495355",
"0.64302355",
"0.63997996",
"0.63546294",
"0.63178086",
"0.6267141",
"0.62543803",
"0.625237",
"0.622907",
"0.6190095",
"0.6142455",
"0.6139246",
"0.61200... | 0.0 | -1 |
Initializes a new instance of the GlobalConsistencyError class. | def __init__(self):
super().__init__()
self.metric = 'GCOERR' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_covar_error(self):\n self.energy_events = {}\n self._construct_energy_events(self.energy_events)\n self._update_energy_events(self.energy_events)\n self.covar_error = {}\n self._init_energy_covar(self.energy_events, self.covar_error)",
"def __init__(self, error_msg):\... | [
"0.58772963",
"0.57765025",
"0.57276607",
"0.57187855",
"0.5698556",
"0.5676905",
"0.5578353",
"0.5578353",
"0.5578353",
"0.5552325",
"0.55187726",
"0.5489844",
"0.54460084",
"0.5385364",
"0.5314191",
"0.5287482",
"0.52741",
"0.5263562",
"0.5262738",
"0.52333057",
"0.5220791"... | 0.55812883 | 6 |
Initializes a new instance of the HausdorffDistance class. | def __init__(self):
super().__init__()
self.metric = 'HDRFDST' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hausdorff_distance(self, other):\n ...",
"def hausdorff_distance(self, other):\n return _binary_op(arctern.ST_HausdorffDistance, self, other)",
"def hausdorff_distance(image1, image2):\n image1_int = image1.clone(\"unsigned int\")\n image2_int = image2.clone(\"unsigned int\")\n\n lib... | [
"0.71214753",
"0.65946466",
"0.6113186",
"0.6107732",
"0.6097238",
"0.60880584",
"0.607865",
"0.60712165",
"0.6043866",
"0.60390174",
"0.6033023",
"0.5940137",
"0.5873003",
"0.5833679",
"0.5804161",
"0.5803397",
"0.577924",
"0.5748117",
"0.57207835",
"0.5698291",
"0.5688376",... | 0.0 | -1 |
Initializes a new instance of the MahalanobisDistance class. | def __init__(self):
super().__init__()
self.metric = 'MAHLNBS' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mahalanobis_dist_factory(X):\n\t# compute the average vector location\n\tavg = class_average(X)\n\t# compute the variance-covariance matrix of the input matrix\n\tvarcovar = np.cov(X, rowvar=False)\n\t# compute the inverse of the variance-covariance matrix\n\tinv_varcovar = np.linalg.pinv(varcovar)\n\n\t# func... | [
"0.68314976",
"0.64938647",
"0.6453283",
"0.62022287",
"0.6110329",
"0.6034114",
"0.601871",
"0.5933851",
"0.593307",
"0.5895927",
"0.58431786",
"0.58345467",
"0.5779622",
"0.57260346",
"0.5617595",
"0.5608206",
"0.56061554",
"0.5598625",
"0.55748725",
"0.55388373",
"0.553257... | 0.0 | -1 |
Initializes a new instance of the ProbabilisticDistance class. | def __init__(self):
super().__init__()
self.metric = 'PROBDST' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, walk_length, p, q, neighbours, lengths, offsets, seed=0):\n self.seed, self.seed2 = random_seed.get_seed(seed)\n self.neighbours = neighbours\n self.lengths = lengths\n self.offsets = offsets\n self.walk_length = walk_length\n self.p = p\n self.q ... | [
"0.65832996",
"0.6561603",
"0.6512423",
"0.64720154",
"0.6447511",
"0.64112496",
"0.637845",
"0.63657653",
"0.6343996",
"0.63071",
"0.6300053",
"0.62949663",
"0.6207319",
"0.61995596",
"0.61995596",
"0.61995596",
"0.6187599",
"0.61671257",
"0.6128368",
"0.61264676",
"0.612228... | 0.0 | -1 |
Initializes a new instance of the VolumeSimilarity class. | def __init__(self):
super().__init__()
self.metric = 'VOLSMTY' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n super().__init__()\n self.metric = 'VOL'",
"def __init__(self):\n super().__init__()\n self.metric = 'SEGVOL'",
"def __init__(self):\n super().__init__()\n self.metric = 'GTVOL'",
"def __init__(self,distancePath,dtype='distance',aspect='biologic... | [
"0.62672853",
"0.61078566",
"0.6082165",
"0.60498005",
"0.60243267",
"0.58492583",
"0.57516885",
"0.574585",
"0.5670601",
"0.5596182",
"0.5587516",
"0.55593723",
"0.55570406",
"0.5537586",
"0.55068266",
"0.5500532",
"0.5500493",
"0.5500493",
"0.54970545",
"0.54968065",
"0.548... | 0.5918078 | 5 |
Test if the path is a remote, network URI | def is_remote(self): # -> Any | bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isurl(self, path):\n\n # We do this here to reduce the 'import numpy' initial import time.\n from urllib.parse import urlparse\n\n # BUG : URLs require a scheme string ('http://') to be used.\n # www.google.com will fail.\n # Should we prepend the scheme for thos... | [
"0.76529855",
"0.73628265",
"0.71977144",
"0.7153844",
"0.7050794",
"0.68908334",
"0.683325",
"0.68205625",
"0.6814429",
"0.67773455",
"0.6621141",
"0.6523025",
"0.6488451",
"0.6468346",
"0.6440228",
"0.64280635",
"0.6423165",
"0.64070046",
"0.64001924",
"0.63826627",
"0.6365... | 0.595652 | 52 |
Test if the path is a local URI | def is_local(self): # -> Any | bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local(self):\r\n return self._url.scheme in ('', 'file')",
"def is_local(path: str) -> str:\n import os\n\n URL = path\n if os.path.exists(path) or path.startswith(\"file\"):\n if not URL.startswith(\"file\"):\n URL = f\"file://{URL}\"\n return URL",
"def test_local_path():... | [
"0.8107993",
"0.8076783",
"0.73975825",
"0.73975575",
"0.7316179",
"0.714902",
"0.7124355",
"0.7000921",
"0.6784994",
"0.67490214",
"0.6698234",
"0.6563529",
"0.6542035",
"0.6498124",
"0.6380482",
"0.6299533",
"0.6203176",
"0.6197575",
"0.6192839",
"0.61839473",
"0.61121696",... | 0.56331366 | 66 |
The selfattention function, which performs executes the selfattention in the model. | def self_attention(self, hidden):
mul1 = self.attention1(hidden)
mul2 = self.attention2(mul1)
return self.softmax(mul2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def self_attention_model(self):\n inputs = self.prepare_inputs()\n \n features = self.prepare_features(inputs)\n support_history_context_concat_emb = features['support_history_context_concat_emb']\n support_link_info_concat_emb = features['support_link_info_concat_emb']\n ... | [
"0.6401326",
"0.637629",
"0.6088493",
"0.5995064",
"0.5870639",
"0.57339114",
"0.56490886",
"0.5540813",
"0.5532944",
"0.54966396",
"0.5398911",
"0.53168225",
"0.5276085",
"0.52657545",
"0.5215563",
"0.52126396",
"0.5173219",
"0.51490426",
"0.5141988",
"0.5128794",
"0.5115571... | 0.6732764 | 0 |
function to determine iou from 2 boxes for tensors | def bbox_iou(boxes1, boxes2):
# obtain area of from the 2 boxes
boxes1_area = boxes1[..., 2] * boxes1[..., 3]
boxes2_area = boxes2[..., 2] * boxes2[..., 3]
# obtain boxes where properties are (x_min, y_min, x_max, y_max)
boxes1 = tf.concat([boxes1[..., :2] - boxes1[..., 2:] * 0.5, boxes1[..., :2] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_iou_pared(box1, box2):\n # type: (Tensor, Tensor, str)->Tensor\n lt = torch.max(box1[:, :, :2], box2[:, :, :2])\n rb = torch.min(box1[:, :, 2:4], box2[:, :, 2:4])\n inter_wh = (rb - lt + 1).clamp(min=0)\n inter = inter_wh[:, :, 0] * inter_wh[:, :, 1]\n area1 = (box1[:, :, 2] - box1[:, :, ... | [
"0.8099974",
"0.8076909",
"0.8061127",
"0.80017126",
"0.7931114",
"0.7921171",
"0.7921171",
"0.7846362",
"0.78153664",
"0.7756713",
"0.77017415",
"0.76800114",
"0.76585114",
"0.7597734",
"0.7594102",
"0.75858045",
"0.75795233",
"0.7570881",
"0.7530234",
"0.75203574",
"0.75135... | 0.76612765 | 12 |
function to determine giou (generalised iou) from 2 boxes | def bbox_giou(boxes1, boxes2):
# obtain boxes where properties are (x_min, y_min, x_max, y_max)
boxes1 = tf.concat([boxes1[..., :2] - boxes1[..., 2:] * 0.5, boxes1[..., :2] + boxes1[..., 2:] * 0.5], axis = -1)
boxes2 = tf.concat([boxes2[..., :2] - boxes2[..., 2:] * 0.5, boxes2[..., :2] + boxes2[..., 2:] * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GIoU(self, bboxes1: torch.Tensor, bboxes2: torch.Tensor) -> float:\n iou = IoU(bboxes1, bboxes2)\n giou = 0.0\n return giou",
"def bboxes_iou(boxes1, boxes2):\n boxes1 = np.array(boxes1)\n boxes2 = np.array(boxes2)\n boxes1_area = (boxes1[..., 2] - boxes1[..., 0]) * ... | [
"0.7267697",
"0.7101333",
"0.7021718",
"0.7015424",
"0.69747066",
"0.69526684",
"0.6939766",
"0.69137967",
"0.6874293",
"0.6847086",
"0.68465817",
"0.68393517",
"0.679534",
"0.67704654",
"0.6747102",
"0.6723475",
"0.67082506",
"0.67082506",
"0.67010975",
"0.6677733",
"0.66711... | 0.62249804 | 54 |
function to scale bboxes from train input size to original image size and remove bboxes with low scores | def postprocess_boxes(pred_bbox, original_image, train_input_size, score_threshold):
# valid scle for box
valid_scale=[0, np.inf]
# turn bbox to array
pred_bbox = np.array(pred_bbox)
# obtain predicted x, y, w, h, objectiveness score, class probabilities
pred_xywh = pred_bbox[:, 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resize_bboxes(self, ori_bboxes, scale_factor):\n bboxes = ori_bboxes * scale_factor\n bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, self.img_shape[1])\n bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, self.img_shape[0])\n return bboxes",
"def _resize_bboxes(self, results):\n ... | [
"0.738287",
"0.731978",
"0.731978",
"0.7104338",
"0.68486834",
"0.68047535",
"0.6696265",
"0.65791744",
"0.65791744",
"0.65507495",
"0.6546894",
"0.6528618",
"0.64580405",
"0.6402325",
"0.6385952",
"0.6366471",
"0.63621765",
"0.6349864",
"0.6291257",
"0.62909156",
"0.6289611"... | 0.729834 | 3 |
function to implement nonmaximal suppression / softmax nonmaximal supression of bboxes | def nms(bboxes, iou_threshold, sigma = 0.3, method = 'nms'):
""" takes bboxes with the shape of (num_of_box, 6), where 6 => (xmin, ymin, xmax, ymax, score, class) """
# remove duplicates in classes
classes_in_img = list(set(bboxes[:, 5]))
# initialise list to store best bboxes
best_bboxes ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_max_suppression(bboxes, iou_threshold, threshold, box_format=\"corners\"):\n\n # 49 x 6 \n assert type(bboxes) == list\n # print(bboxes)\n bboxes = [box for box in bboxes if box[1] > threshold]\n bboxes = sorted(bboxes, key=lambda x: x[1], reverse=True)\n bboxes_after_nms = []\n # prin... | [
"0.74025226",
"0.6915437",
"0.6865243",
"0.67592657",
"0.66231173",
"0.66150546",
"0.6294615",
"0.6276118",
"0.6217095",
"0.6210983",
"0.6202102",
"0.61741483",
"0.6114613",
"0.610729",
"0.6104654",
"0.6094739",
"0.6079207",
"0.60549146",
"0.60382414",
"0.60333896",
"0.601876... | 0.6881771 | 2 |
function to draw bboxes on image | def draw_bbox(image, bboxes, classes_file_path, show_label = True, show_confidence = True, Text_colors = (255,255,0),
rectangle_colors = '', tracking = False):
# obtain list of classes name
classes = read_class_names(classes_file_path)
# obtain length of classes
num_classes = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bboxes(img, bboxes):\n colors = tf.cast(np.array([[1, 0, 0, 1]] * 10), dtype=tf.float32)\n img_with_bounding_boxes = tf.image.draw_bounding_boxes(\n img,\n bboxes,\n colors\n )\n plt.figure()\n plt.imshow(img_with_bounding_boxes[0])\n plt.show()",
"def draw_bboxes(... | [
"0.81534016",
"0.8058343",
"0.8044812",
"0.7894786",
"0.78738695",
"0.78372854",
"0.78266394",
"0.77794206",
"0.7716946",
"0.7715724",
"0.7605497",
"0.7390843",
"0.73885024",
"0.7386332",
"0.7334734",
"0.7239827",
"0.72142845",
"0.7182892",
"0.7134724",
"0.71039355",
"0.71016... | 0.66369855 | 50 |
method to generate 3D scatter plot | def generate_3D_scatter_plot(x, y, z, labels_dict, file_title, plot_title):
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.scatter(x, y, z,
marker=".")
if labels_dict:
ax.set_xlabel(labels_dict["x"])
ax.set_ylabel(labels_dict["y"])
ax.set_zlabel(label... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_3d_plot(three_d_matrix, ax, title, length):\r\n x, y, z = np.where(three_d_matrix != 0)\r\n ax.scatter(x, y, z, c='blue')\r\n ax.set_xlabel('x')\r\n ax.set_ylabel('y')\r\n ax.set_xlim(0, length)\r\n ax.set_ylim(0, length)\r\n ax.set_title(title)",
"def generate_training_data_3D():\n ... | [
"0.75674236",
"0.753292",
"0.74797493",
"0.73892623",
"0.736832",
"0.72781193",
"0.71993256",
"0.7165928",
"0.7025822",
"0.7007567",
"0.69641083",
"0.6944822",
"0.6943742",
"0.6885652",
"0.6849465",
"0.68107605",
"0.67821693",
"0.67558146",
"0.6751974",
"0.67095965",
"0.67073... | 0.73028904 | 5 |
Add a gaussian blur drop shadow to an image. image The image to overlay on top of the shadow. offset Offset of the shadow from the image as an (x,y) tuple. Can be positive or negative. background Background colour behind the image. shadow Shadow colour (darkness). border Width of the border around the image. This must ... | def dropShadow( image, offset=(5,5), background=0xffffff, shadow=0x444444,
border=8, iterations=3):
# Create the backdrop image -- a box in the background colour with a
# shadow on it.
totalWidth = image.size[0] + abs(offset[0]) + 2*border
totalHeight = image.size[1] + abs(offset[1]) + 2*bo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_shadow(image, offset, border=0, shadow_color=0x444444):\n # Caclulate size\n fullWidth = image.size[0] + abs(offset[0]) + 2 * border\n fullHeight = image.size[1] + abs(offset[1]) + 2 * border\n # Create shadow, hardcode color\n shadow = Image.new('RGBA', (fullWidth, fullHeight), (0, 0, 0))\... | [
"0.71736056",
"0.66292",
"0.65392244",
"0.645358",
"0.6399967",
"0.63977253",
"0.6396596",
"0.63827735",
"0.623564",
"0.6141279",
"0.6136365",
"0.6124058",
"0.6088617",
"0.6085698",
"0.6078954",
"0.5990218",
"0.593124",
"0.5906852",
"0.58482844",
"0.5842372",
"0.5783762",
"... | 0.8016093 | 0 |
Get size of input pixel, compute image width in meters. | def getDiameter(self):
hdr = self.header
if "cd1_1" in hdr:
self.D = abs(hdr["cd1_1"]) * hdr["naxis1"]
elif "cdelt1" in hdr:
self.D = abs(hdr["cdelt1"]) * hdr["naxis1"]
else:
print("Warning: no coordinate information found in input header;")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_width(self):\n width = np.size(self.img, 0)\n return width",
"def get_size(img):\n ih, iw = img.shape[:2]\n return iw * ih",
"def getWidth(self):\n return self._image.width()",
"def pixels_to_length(pixels, boxsize, num_pixels):\n length = (boxsize * pixels) / num_pixels... | [
"0.7677679",
"0.7587488",
"0.7385247",
"0.7233582",
"0.7149443",
"0.7149443",
"0.70930415",
"0.70841414",
"0.7082394",
"0.7079337",
"0.7007156",
"0.6959096",
"0.6905152",
"0.6890924",
"0.6890266",
"0.688586",
"0.68216383",
"0.67897856",
"0.677458",
"0.6754209",
"0.67508346",
... | 0.0 | -1 |
A generator that, given a DOM tree, yields all text fragments in that tree | def allTextGenerator(node):
if node.nodeType == node.TEXT_NODE:
yield node.data
for child in node.childNodes:
for text in allTextGenerator(child):
yield text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shallowTextGenerator(node):\n for child in node.childNodes:\n if child.nodeType == child.TEXT_NODE:\n yield child.data",
"def allText(node):\n return \"\".join(allTextGenerator(node))",
"def _get_child_text(node):\n for child in node.children:\n if isinstance(child, Naviga... | [
"0.71465194",
"0.6505877",
"0.6341776",
"0.6313069",
"0.6208987",
"0.61331975",
"0.6049018",
"0.6010867",
"0.5902996",
"0.5721751",
"0.56509244",
"0.5602479",
"0.5538833",
"0.5528797",
"0.54971707",
"0.5472538",
"0.54702145",
"0.5449357",
"0.54414344",
"0.54111284",
"0.536538... | 0.78401715 | 0 |
Concatenate all text under the given element recursively, and return it | def allText(node):
return "".join(allTextGenerator(node)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_element_text(self, element):\n text = ''\n if element.text is not None:\n text = text + element.text\n for child in element.getchildren():\n text = text + self._get_element_text(child)\n if element.tail is not None:\n text = text + element.tail\n return text",
"def concat_t... | [
"0.7476083",
"0.7238177",
"0.7155042",
"0.6381594",
"0.63180053",
"0.6168671",
"0.61297727",
"0.60860467",
"0.60681915",
"0.60440797",
"0.6019012",
"0.5995016",
"0.58992743",
"0.58555645",
"0.5831631",
"0.58067006",
"0.58049875",
"0.57526165",
"0.57024235",
"0.56474376",
"0.5... | 0.6447832 | 3 |
A generator that, given a DOM tree, yields all text fragments contained immediately within | def shallowTextGenerator(node):
for child in node.childNodes:
if child.nodeType == child.TEXT_NODE:
yield child.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allTextGenerator(node):\n if node.nodeType == node.TEXT_NODE:\n yield node.data\n for child in node.childNodes:\n for text in allTextGenerator(child):\n yield text",
"def _get_text(self, element):\n # for text in element.itertext():\n for text in self.iter_main_te... | [
"0.7660141",
"0.66082823",
"0.64660794",
"0.6397904",
"0.635378",
"0.63032055",
"0.6213505",
"0.6194677",
"0.60316443",
"0.582272",
"0.57656145",
"0.5759193",
"0.57142687",
"0.56226665",
"0.5621452",
"0.5611139",
"0.5539588",
"0.550501",
"0.54603165",
"0.5450323",
"0.54207486... | 0.70954376 | 1 |
Compare two version strings of the form N0.N1.N2... Where N[0...] are decimal integers separated by periods(.) | def cmp_version(v0, v1):
# Convert both version strings to arrays of ints
try:
a0 = [int(f) for f in v0.split('.')]
a1 = [int(f) for f in v1.split('.')]
except ValueError as error:
logger.error("invalid version comparison: {} <> {}".format(v0, v1))
raise error
# Make s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_two_version_strings(version1, version2):\n _version1 = version1.split('.')\n _version2 = version2.split('.')\n version1_len = len(_version1)\n version2_len = len(_version2)\n upper_bound = version1_len if version1_len < version2_len else version2_len\n for i in range(0, upper_bound):\... | [
"0.782437",
"0.77762115",
"0.76624346",
"0.7596419",
"0.7563813",
"0.74166566",
"0.74079436",
"0.7347602",
"0.731061",
"0.7240587",
"0.6969875",
"0.6900846",
"0.6692955",
"0.6575106",
"0.65666085",
"0.65629387",
"0.6537446",
"0.64507836",
"0.64374435",
"0.6404391",
"0.6350561... | 0.6760001 | 12 |
Check if two version strings are equivalent | def eq_version(v0, v1):
return cmp_version(v0, v1) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_literal_comparison_different(self):\n\n given = \"1.0.0.dev (Hello, World!)\"\n expected = False\n actual = Version.literally_compare(given, given.replace(\".\", \"_\"))\n\n self.assertEqual(expected, actual)",
"def test_literal_comparison(self):\n\n given = \"1.0.0.de... | [
"0.7253761",
"0.7080029",
"0.69020677",
"0.68730366",
"0.6816865",
"0.68077374",
"0.67947614",
"0.67156863",
"0.6705432",
"0.6687337",
"0.6645401",
"0.65992266",
"0.6587252",
"0.6555264",
"0.6551205",
"0.64862543",
"0.64862156",
"0.645905",
"0.64512753",
"0.6446384",
"0.64365... | 0.6571167 | 13 |
Construct Multivariate Normal distribution on `R^k`. The `batch_shape` is the broadcast shape between `loc` and `scale` arguments. The `event_shape` is given by last dimension of the matrix implied by `scale`. The last dimension of `loc` (if provided) must broadcast with this. Recall that `covariance = scale @ scale.T`... | def __init__(self,
loc=None,
scale=None,
validate_args=False,
allow_nan_stats=True,
experimental_use_kahan_sum=False,
name='MultivariateNormalLinearOperator'):
parameters = dict(locals())
self._experimental_use_kahan_sum =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch(\n bottom,\n name,\n scale=True,\n center=True,\n fused=False,\n renorm=False,\n data_format='NHWC',\n dtype=tf.float32,\n reuse=False,\n momentum=0.99,\n training=True,\n trainable=None):\n if trainable is None:\n ... | [
"0.56068945",
"0.558533",
"0.55352217",
"0.54480374",
"0.54281026",
"0.5373338",
"0.5348993",
"0.534293",
"0.53155196",
"0.5298864",
"0.5228155",
"0.5228155",
"0.52274436",
"0.51956904",
"0.5165971",
"0.51586795",
"0.5144612",
"0.51437366",
"0.51434505",
"0.5129371",
"0.51289... | 0.55445164 | 2 |
Batched KL divergence `KL(a || b)` for multivariate Normals. With `X`, `Y` both multivariate Normals in `R^k` with means `mu_a`, `mu_b` and covariance `C_a`, `C_b` respectively, ``` KL(a || b) = 0.5 ( L k + T + Q ), | def _kl_brute_force(a, b, name=None):
def squared_frobenius_norm(x):
"""Helper to make KL calculation slightly more readable."""
# http://mathworld.wolfram.com/FrobeniusNorm.html
# The gradient of KL[p,q] is not defined when p==q. The culprit is
# tf.norm, i.e., we cannot use the commented out code.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def KL_divergence(model_1, model_2, samples):\n posterior_1 = create_posterior_object(model_1, samples)\n posterior_2 = create_posterior_object(model_2, samples)\n return posterior_1.KL(posterior_2)",
"def MyKLD(X,Y): \n mu1,mu2 = tuple(np.mean(X,axis=0))\n sigma1,sigma2 = tuple(np.std(X,axis=0... | [
"0.658404",
"0.6311214",
"0.62525827",
"0.6197443",
"0.6048815",
"0.6012848",
"0.5933193",
"0.5931558",
"0.58591413",
"0.5849715",
"0.5815837",
"0.5800051",
"0.5774561",
"0.5740252",
"0.57145333",
"0.57052726",
"0.5697698",
"0.5600439",
"0.55989295",
"0.5567024",
"0.55540746"... | 0.5721349 | 14 |
Inititializing name and age attributes of dog | def __init__(self, name, age):
self.name = name
self.age = age | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age\n\t\tprint(\"Dog initialization is complete\")",
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age",
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age",
"def __init__(self, name, age):\n\t... | [
"0.7660444",
"0.6837803",
"0.6837803",
"0.6837803",
"0.6767654",
"0.67561054",
"0.67561054",
"0.67561054",
"0.67561054",
"0.6583374",
"0.65085125",
"0.65085125",
"0.65085125",
"0.65085125",
"0.65085125",
"0.65085125",
"0.65085125",
"0.65085125",
"0.6506186",
"0.63915575",
"0.... | 0.67424846 | 9 |
Returns a tree of processes | def pstree(flags='-a'):
system_command("pstree {0}".format(flags)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processes(self):\n nodes = (self.nodes.exclude(process__isnull=True)\n .values_list('process_id', flat=True))\n return Process.objects.filter(id__in=nodes).distinct()",
"def pslist(self) -> Generator[dict, None, None]:\n\n # Function to switch fields to represen... | [
"0.7100633",
"0.6870322",
"0.6783588",
"0.6770188",
"0.6622113",
"0.66027844",
"0.6592738",
"0.6571604",
"0.6506026",
"0.6309497",
"0.6301092",
"0.62224627",
"0.62101513",
"0.617808",
"0.6111363",
"0.6105415",
"0.60873955",
"0.6077496",
"0.5935122",
"0.5927807",
"0.59078175",... | 0.5721147 | 32 |
Returns operating system name | def uname(flags='-a'):
system_command("uname {0}".format(flags)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetOSName():\n return Config.osName_",
"def _get_osname():\n osname = sys.platform.lower()\n if osname == \"linux2\":\n osname = \"linux\"\n return osname",
"def get_os() -> str:\n system = platform.system().lower()\n\n if system == \"linux\":\n machine = os.uname().machine... | [
"0.83773994",
"0.8279905",
"0.81569976",
"0.8150991",
"0.81152725",
"0.8065729",
"0.80242413",
"0.798916",
"0.7968415",
"0.7898788",
"0.78795296",
"0.78795296",
"0.78149897",
"0.77735364",
"0.7747724",
"0.7722913",
"0.76965964",
"0.76950985",
"0.7667121",
"0.76587385",
"0.762... | 0.0 | -1 |
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(IrTransformMsg, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.s1 is None:
self.s1 = False
if self.s2 is None:
self.s2 = False
if self.s3 is None:
... | {
"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.77949196",
"0.77207184",
"0.77207184",
"0.7687274",
"0.7626665",
"0.75640404",
"0.7440775",
"0.7417612",
"0.7351781",
"0.7308563",
"0.7280241",
"0.7237561",
"0.7227551",
"0.72248346",
"0.72248346",
"0.7218737",
"0.721217",
"0.721217",
"0.721217",
"0.721217",
"0.721217",
... | 0.7139067 | 34 |
Should return a list of two words. | def test_single_word_with_junk(self):
score = location.match_weight('clevedon UK', ['clevedon'])
self.assertEqual(score, 1000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_word_list(sentence):\n sentence = space1.sub(r'\\1 \\2', sentence)\n sentence = space2.sub(r\"\\1 \\2\", sentence)\n sentence = space3.split(sentence)\n sentence = \" \".join(sentence)\n wordlist = [i for i in sentence.split()]\n return \" \".join(wordlist)",
"def crossword_words(crossw... | [
"0.72570837",
"0.72046727",
"0.7069434",
"0.6990114",
"0.69727683",
"0.6948797",
"0.68982446",
"0.68766356",
"0.68631524",
"0.68228734",
"0.68228734",
"0.6808646",
"0.6772686",
"0.6742592",
"0.67259824",
"0.6721441",
"0.6718466",
"0.6698988",
"0.6674042",
"0.6660404",
"0.6643... | 0.0 | -1 |
Function to export preprocessed data to a csv file | def preproc2csv(self, file_path, export_index = True, export_header = True):
self.pre_proc_data.to_csv(file_path+'.csv', index = export_index, header = export_header)
print('Pre-processed data saved to .csv succesfully. \n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_preprocessed_csv(self):\n self.process_report_data().to_csv(self.out_file_path, index=False)",
"def save_csv(self, filename): # DONE\n self.data.to_csv(filename)",
"def csv_file(data,output_dir,filename,order = [],head = True):\n with open(output_dir + filename + '.csv', 'w') as f:\... | [
"0.7475848",
"0.7361879",
"0.7313685",
"0.71949476",
"0.71727455",
"0.71075267",
"0.69587564",
"0.6955538",
"0.69286054",
"0.6883265",
"0.6881506",
"0.68803203",
"0.687411",
"0.6871328",
"0.68420494",
"0.68386006",
"0.6827709",
"0.6819446",
"0.6819446",
"0.6817574",
"0.681086... | 0.80190265 | 0 |
Function to return the maximum absorbance in the timelapse | def max_abs(self):
return np.nanmax(self.abs_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_time(self):\n return self.time[np.argmax(self.flux)]",
"def getMaxAbundanceOfSample(self):\n try: maximum = max(self.sample[self.sample['masked'] == False]['abundance'])+0.01\n except: maximum = 0\n return maximum",
"def max(self):\n\n return time_stat(self, stat=\"max\")... | [
"0.69801533",
"0.68877816",
"0.6874527",
"0.6819879",
"0.66570175",
"0.6527111",
"0.65086555",
"0.64958",
"0.64427745",
"0.6397908",
"0.6377062",
"0.6304347",
"0.62882537",
"0.6276951",
"0.6272387",
"0.62265176",
"0.6181445",
"0.6172777",
"0.61725163",
"0.61337143",
"0.612818... | 0.5723995 | 69 |
r"""Fills the input `Tensor` with values according to the method described in `Understanding the difficulty of training deep feedforward neural networks` Glorot, X. & Bengio, Y. (2010), using a normal distribution. The resulting tensor will have values sampled from | def xavier_normal_init(tensor, gain=1., random_state=None):
# type: (Tensor, float) -> Tensor
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
std = gain * math.sqrt(2.0 / float(fan_in + fan_out))
normal_init(tensor, 0., std, random_state)
return tensor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randn(self, *args, **kwargs):\n # TODO: Put this in torch.cuda.randn\n return torch.empty(*args, **kwargs).normal_()",
"def WeightInitializer():\n return np.random.uniform(-1, 1)",
"def _sampling_normal(self, args):\n z_mean, z_log_var = args\n return sampling_normal(z_mean, ... | [
"0.61725956",
"0.6070464",
"0.60264194",
"0.60264194",
"0.60264194",
"0.60264194",
"0.60264194",
"0.5985324",
"0.5977713",
"0.5937544",
"0.59191823",
"0.5911526",
"0.5907372",
"0.5898523",
"0.58974665",
"0.5875607",
"0.58514076",
"0.58495027",
"0.5823291",
"0.5820147",
"0.581... | 0.0 | -1 |
r"""Fills the 2D input `Tensor` as a sparse matrix, where the nonzero elements will be drawn from the normal distribution | def sparse_init(tensor, sparsity, std=0.01, random_state=None):
if tensor.ndimension() != 2:
raise ValueError("Only tensors with 2 dimensions are supported")
rows, cols = tensor.shape
num_zeros = int(math.ceil(sparsity * rows))
if random_state is not None:
gen = torch.Generator()
gen.manual_seed(random_stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makesparse(matrix):\n n = matrix[0].size\n elements = []\n for i in range(n):\n for j in range(n):\n if matrix[i][j] != 0 :\n temp = MatrixElement(i, j, matrix[i][j])\n elements.append(temp)\n return SparseMatrix(n, elements)",
"def spzeros(size, de... | [
"0.67311174",
"0.66716176",
"0.64965165",
"0.63598454",
"0.63387793",
"0.6238487",
"0.62327516",
"0.61652976",
"0.6108471",
"0.60718554",
"0.6067091",
"0.60586315",
"0.603004",
"0.5993939",
"0.59564877",
"0.5950967",
"0.59054613",
"0.5886422",
"0.5877167",
"0.58765334",
"0.58... | 0.6960967 | 0 |
Building CNN Model using Keras 2 Functional API | def build_cnn_classification_model(self, input_shape):
input_image = Input(shape=input_shape)
conv_1 = Conv2D(32, (3, 3), activation='relu')(input_image)
pool_1 = MaxPooling2D((2, 2))(conv_1)
conv_2 = Conv2D(32, (3, 3), activation='relu')(pool_1)
pool_2 = MaxPooling2D((2, 2))(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_model():\n\n if K.image_data_format() == 'channels_first':\n input_shape = (3, img_width, img_height)\n else:\n input_shape = (img_width, img_height, 3)\n\n model = Sequential()\n model.add(Conv2D(32, (3, 3), input_shape=input_shape))\n model.add(Activation('relu'))\n mode... | [
"0.79656893",
"0.7958207",
"0.7817639",
"0.7698621",
"0.7653019",
"0.7582791",
"0.7561601",
"0.75297076",
"0.75131255",
"0.7422548",
"0.73869014",
"0.737296",
"0.73530495",
"0.73505014",
"0.7336627",
"0.7306447",
"0.7295593",
"0.72819936",
"0.72589046",
"0.7256983",
"0.725078... | 0.7019755 | 48 |
Checks whether a user can be created with username email and password | def test_create_user(self):
self.assertIsInstance(
User.objects.create_user(username="username", email="username@mail.com", password="password"), User) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_valid_user_success(self):\n payload = {\n 'email': 'test@test1.com',\n 'password': 'testpass',\n 'name': 'TestName'\n }\n res = self.client.post(CREATE_USER_URL, payload)\n self.assertEqual(res.status_code, status.HTTP_201_CREATED)\n ... | [
"0.7756845",
"0.7741258",
"0.7736343",
"0.7733922",
"0.7677574",
"0.767662",
"0.76544",
"0.7653951",
"0.76383364",
"0.763251",
"0.7613336",
"0.76109636",
"0.760976",
"0.7597538",
"0.75855196",
"0.7582497",
"0.75782627",
"0.75762373",
"0.7569223",
"0.75680345",
"0.75503266",
... | 0.71962583 | 49 |
Ensure a user cannot be created without an email | def test_cannot_create_user_without_email(self):
with self.assertRaises(TypeError):
User.objects.create_user(username="username", password="password", email=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_private_create_user_without_email(self):\n with pytest.raises(ValueError) as exinfo:\n EmailUser.objects._create_user(None, None, False, False)\n self.assertIn('email must be set', str(exinfo.value))",
"def test_creating_a_new_user_without_email(self):\n\n with self.asser... | [
"0.82582766",
"0.7919107",
"0.7875968",
"0.7741182",
"0.7733113",
"0.77283794",
"0.77254593",
"0.7721021",
"0.76949185",
"0.7693235",
"0.7693235",
"0.7693235",
"0.7693235",
"0.7693235",
"0.7690692",
"0.76710504",
"0.76565343",
"0.7654827",
"0.75902516",
"0.7588441",
"0.757935... | 0.7850715 | 3 |
Ensure a superuser can be created | def test_create_superuser(self):
user = User.objects.create_superuser(username="admin", email="admin@admin.com", password="password")
self.assertTrue(user.is_staff)
self.assertTrue(user.is_superuser) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_if_created_superusers_permissions(self):\r\n payload = {\r\n \"email\": \"t@t.pl\",\r\n \"password\": \"password\",\r\n \"name\": \"asdasd\",\r\n \"is_superuser\": False,\r\n }\r\n\r\n res = self.client_superuser.post(reverse(CREATE_USER_URL... | [
"0.8124481",
"0.7641515",
"0.7616243",
"0.74287134",
"0.74168247",
"0.73632073",
"0.7360824",
"0.7311047",
"0.7307638",
"0.72554475",
"0.7249822",
"0.7238858",
"0.7235135",
"0.7224442",
"0.7224177",
"0.7223552",
"0.7209373",
"0.71918464",
"0.7186527",
"0.71835196",
"0.7138508... | 0.7200312 | 17 |
Getter for path of postfile. | def getWriteFilePath(self):
return self.file_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_path(self):\n try:\n return self._file.path\n except AttributeError:\n return os.path.abspath(self._file.name)",
"def path(self):\n return self.file_path()",
"def path(self):\n return self.get_upload_set().path(self.filename)",
"def __get_path(self):\... | [
"0.7684424",
"0.7634675",
"0.7584958",
"0.7500743",
"0.74892503",
"0.7436438",
"0.74001753",
"0.73950005",
"0.7212271",
"0.7194952",
"0.71715444",
"0.7152331",
"0.71349305",
"0.712261",
"0.712261",
"0.712261",
"0.712261",
"0.712261",
"0.712261",
"0.712261",
"0.712261",
"0.7... | 0.6561106 | 61 |
Date commonly used for Expires response header | def expires_date(hours):
dt = datetime.datetime.now() + datetime.timedelta(hours=hours)
return rfc1123date(dt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_expires(self):\n # We aren't bother going to test the actual time in expires, that\n # way lies pain with broken tests later.\n up = self.get(self.good_data)\n hdrs = dict(up.get_headers(1))\n lm = datetime(*utils.parsedate_tz(hdrs['Last-Modified'])[:7])\n exp = d... | [
"0.7195939",
"0.6907186",
"0.6881916",
"0.6744938",
"0.6724165",
"0.66852033",
"0.65854144",
"0.6536665",
"0.6499758",
"0.64993864",
"0.6485234",
"0.6301679",
"0.62763596",
"0.62661",
"0.6180781",
"0.6173712",
"0.613423",
"0.6105018",
"0.60970664",
"0.608861",
"0.60184294",
... | 0.6574573 | 7 |
String commonly used for CacheControl response headers | def cache_max_age(hours):
seconds = hours * 60 * 60
return 'max-age=' + str(seconds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def surrogate_control(self):\n def on_update(surrogate_control):\n if not surrogate_control and \"surrogate-control\" in self.headers:\n del self.headers[\"surrogate-control\"]\n elif surrogate_control: # pragma: no cover\n self.headers[\"Surrogate-Contro... | [
"0.6768353",
"0.6566287",
"0.65467256",
"0.6538585",
"0.6342155",
"0.61724174",
"0.61724174",
"0.6127087",
"0.6127087",
"0.61033094",
"0.60564166",
"0.6011409",
"0.6011409",
"0.6001654",
"0.5991665",
"0.5977934",
"0.59726334",
"0.5960509",
"0.5953296",
"0.5953296",
"0.5953296... | 0.0 | -1 |
Add all the strided dst_ops of the first cat to the second and make an appropriate slice op between the second cat and each dst_ops. cat_dim_offset represents the offset of the first cat output appearing in the second cat along the cat_dim dimension. | def _update_cat_dst_ops(
first_cat: Operator, second_cat: Operator, cat_dim_offset: int
) -> None:
first_cat_output = first_cat._attrs["outputs"][0]
first_cat_dst_ops = first_cat_output._attrs["dst_ops"]
# the first cat does not have any strided ops
if len(first_cat_dst_ops) <= 1:
return
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_first_cat(first_cat: Operator, second_cat: Operator) -> bool:\n # Make sure input_accessors do not carry any strided information.\n # It may happen. For example, an input of the cat can be of a strided\n # tensor generated by slice, which takes another concat's output.\n # Something like bel... | [
"0.6612727",
"0.5544993",
"0.5439845",
"0.53585875",
"0.5300117",
"0.52778655",
"0.521713",
"0.5149487",
"0.51412314",
"0.51373166",
"0.5121676",
"0.5056443",
"0.50411654",
"0.5012992",
"0.50077736",
"0.50072813",
"0.49859685",
"0.49837145",
"0.49785277",
"0.49754632",
"0.496... | 0.8834131 | 0 |
A helper function that returns True if the given dst_op is a supported strided op; or a view op that is only used by a supported stride op; or a view op that is indirectly (via another singledst view op) used by a supported strided op. Note that technically, this checking is not necessary, because we could let other pa... | def _is_supported_dst_op_for_first_cat(
dst_op: Operator,
) -> bool:
view_ops = ["reshape", "flatten", "dynamic_slice", "squeeze", "unsqueeze"]
# FIXME: enable other ops with input_accessors
supported_strided_ops = ["elementwise", "fused_elementwise"]
def _supported_op_type(op_type):
if op_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_broadcast(self, op, op_reg_manager):\n op_slices = op_reg_manager.get_op_slices(op)\n op_groups = [op_reg_manager.get_op_group(op_slice)\n for op_slice in op_slices]\n return op_handler_util.get_op_size(op) == 1 and all(op_groups)",
"def _check_first_cat(first_cat: Operator, seco... | [
"0.6025673",
"0.58237857",
"0.55752563",
"0.53833795",
"0.52820736",
"0.5281718",
"0.5199627",
"0.51538306",
"0.5042549",
"0.50408286",
"0.49940622",
"0.4991036",
"0.4928692",
"0.48980138",
"0.48713082",
"0.48710307",
"0.48587143",
"0.48244345",
"0.48205978",
"0.4820422",
"0.... | 0.8079707 | 0 |
Wrapper function for printing to STDERR | def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printerr(*args, **kwargs):\n console_print(sys.stderr, *args, **kwargs)",
"def eprint(errmsg):\n print(errmsg, file=STDERR)",
"def err_print(*args, **kwargs):\n print(*args, file=sys.stderr, **kwargs)",
"def print_err(*args, **kwargs):\n print(*args, file=stderr, **kwargs)",
"def errprint(*... | [
"0.76097333",
"0.7591649",
"0.74702775",
"0.74254733",
"0.7383956",
"0.7311232",
"0.7297354",
"0.7272107",
"0.7193542",
"0.7187452",
"0.7010251",
"0.6952484",
"0.6948659",
"0.6901616",
"0.6831819",
"0.6814909",
"0.6779725",
"0.6747327",
"0.67462695",
"0.66478425",
"0.6627871"... | 0.6609267 | 26 |
When given a `pk` value, this view will list all the configuration profiles for a given device. When `pk` is not supplied, the view will list all the profiles in the MDM. | def list_profiles(request, pk=0):
context = {'items': [], 'resource_type': 'Profile'}
handle_expired_profiles()
if pk == 0:
context['h2'] = "Configuration Profiles"
context['header_1'] = "Type"
context['header_2'] = "Last Modified"
profiles = ConfigurationProfile.objects.all(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_devices(request, pk):\n context = {}\n profile = get_object_or_404(ConfigurationProfile, pk=pk)\n to_remove = InstallationRecord.objects.filter(profile=profile, device__pending__in=[profile], active=True,\n version=\"RM\")\n pending = Laptop.... | [
"0.6888834",
"0.5336745",
"0.52153695",
"0.52136016",
"0.51638395",
"0.50880617",
"0.5059607",
"0.504103",
"0.5034145",
"0.50094795",
"0.4929928",
"0.4871672",
"0.48644266",
"0.48373175",
"0.4781555",
"0.47694975",
"0.47589234",
"0.47347584",
"0.46774995",
"0.46605673",
"0.45... | 0.64643496 | 1 |
Aggregate all columns in the input data frame, assuming the data is "count" data that can be summed. Note The geometry of the returned object is aggregated geometry of all input geometries (the unary union). | def aggregate_count_data(df, groupby, id_vars=[]):
# Make sure we have the column we are grouping by
if groupby not in df.columns:
raise ValueError(
f"the specified column to group by '{by}' is not in the input data"
)
# data columns
data_columns = [
col
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _aggregate(group_df):\n out = {}\n for col in data_columns:\n # The name of the error column (if it exists)\n error_col = f\"{col}_moe\"\n\n # remove any NaN rows\n subset = group_df.dropna(subset=[col], how=\"any\")\n\n # aggregat if we had ... | [
"0.6704904",
"0.6203286",
"0.58382016",
"0.5811576",
"0.5790583",
"0.5765033",
"0.5745803",
"0.56839",
"0.56277764",
"0.5618349",
"0.5607276",
"0.5562513",
"0.5506225",
"0.5492474",
"0.5485867",
"0.5466448",
"0.54351276",
"0.54331636",
"0.53565496",
"0.5348488",
"0.53447205",... | 0.6208687 | 1 |
Check that the sigmoid function returns the expected values for certain test cases | def test_sigmoid_function_returns_correct_value(self):
self.assertAlmostEqual(sigmoid(0), 0.5)
self.assertAlmostEqual(sigmoid(1), 1 / (1 + math.e**-1))
np.testing.assert_array_almost_equal(sigmoid([0, 0, 0]),
np.array([0.5, 0.5, 0.5])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sigmoid_activation(self):\n self.assertEqual([0.5, 0.5], list(\n af.Sigmoid().output(np.array([0, 0]))))\n self.assertEqual([0.25, 0.25], list(\n af.Sigmoid().derivative(np.array([0, 0]))))",
"def test_activation_sigmoid(self):\r\n senal = 1\r\n result =... | [
"0.83076197",
"0.82581586",
"0.81059945",
"0.7922861",
"0.7910582",
"0.7693582",
"0.75288785",
"0.747376",
"0.73051524",
"0.7269971",
"0.7269971",
"0.7269971",
"0.7269971",
"0.7269971",
"0.7269971",
"0.726492",
"0.726492",
"0.7261148",
"0.7260175",
"0.7259793",
"0.72550905",
... | 0.8721928 | 0 |
Check that the sigmoid derivative function returns the expected values for certain test cases | def test_sigmoid_derivative_returns_correct_value(self):
self.assertAlmostEqual(sigmoid_derivative(0), 0.25)
self.assertAlmostEqual(sigmoid_derivative(1), 0.19661193324) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sigmoid_function_returns_correct_value(self):\n self.assertAlmostEqual(sigmoid(0), 0.5)\n self.assertAlmostEqual(sigmoid(1), 1 / (1 + math.e**-1))\n np.testing.assert_array_almost_equal(sigmoid([0, 0, 0]),\n np.array([0.5, 0.5, 0.5]))",
"d... | [
"0.800912",
"0.79653865",
"0.77460605",
"0.7609893",
"0.7427794",
"0.74054325",
"0.74054325",
"0.7382616",
"0.7380849",
"0.735495",
"0.734648",
"0.7110635",
"0.7073369",
"0.70732284",
"0.7010165",
"0.69350487",
"0.69266385",
"0.69154626",
"0.690125",
"0.6846333",
"0.6807472",... | 0.8694649 | 0 |
Check that the sigmoid function saturates to one at high input values | def test_sigmoid_saturates_to_one_and_zero(self):
self.assertAlmostEqual(sigmoid(50), 1.0)
self.assertAlmostEqual(sigmoid(-36), 0.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sigmoid_function_returns_correct_value(self):\n self.assertAlmostEqual(sigmoid(0), 0.5)\n self.assertAlmostEqual(sigmoid(1), 1 / (1 + math.e**-1))\n np.testing.assert_array_almost_equal(sigmoid([0, 0, 0]),\n np.array([0.5, 0.5, 0.5]))",
"d... | [
"0.7840822",
"0.78328764",
"0.7658974",
"0.7566247",
"0.75269365",
"0.74784154",
"0.74627495",
"0.7444658",
"0.7440511",
"0.7440511",
"0.74286145",
"0.74239683",
"0.74051744",
"0.7400626",
"0.7384288",
"0.73818886",
"0.7373797",
"0.7373797",
"0.7373797",
"0.7373797",
"0.73737... | 0.7862481 | 0 |
The fully resolved URI string for this target. | def uri_string(self):
if isinstance(self.entity, int):
uri_string = "{{{0}}}".format(self.entity)
elif isinstance(self.entity, NodePointer):
uri_string = "{{{0}}}".format(self.entity.address)
else:
try:
uri_string = self.entity.ref
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri(self) -> str:\n return self._uri",
"def full_url(self):\n return \"%s://%s%s\" % (self.protocol, self.host, self.uri)",
"def get_uri(self):\n return self.__uri",
"def uri(self):\n return self._uri",
"def uri(self):\n return self._uri",
"def uri(self):\n r... | [
"0.79681325",
"0.78171605",
"0.77143604",
"0.77074355",
"0.77074355",
"0.77074355",
"0.77074355",
"0.77074355",
"0.77074355",
"0.7666865",
"0.76534194",
"0.7589608",
"0.756532",
"0.75619304",
"0.75571066",
"0.74762946",
"0.74659306",
"0.7406349",
"0.736927",
"0.7322809",
"0.7... | 0.7216512 | 23 |
Get reward from given state | def getReward(game):
reward = 0
# Reward +10 if destroys asteroid
if game.gameLevel.asteroidDestroyed():
reward += 10
# Reward +20 if level cleared
if game.gameLevel.levelCleared:
reward += 20
# Reward -10 if hits asteroid
if game.gameLevel.gameOver:
reward -= 10
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reward(self, state, action, next_state, absorbing):\n raise NotImplementedError",
"def get_reward(self, state, action, next_state):\n assert action in self.get_possible_actions(state), \"cannot do action %s from state %s\" % (action, state)\n return self._rewards.get(state, {}).get(a... | [
"0.8045687",
"0.8026533",
"0.79626703",
"0.79564565",
"0.7616803",
"0.75947267",
"0.7569971",
"0.7482292",
"0.7471966",
"0.74115306",
"0.7394233",
"0.7372406",
"0.72931135",
"0.7243583",
"0.7222978",
"0.7184763",
"0.7159693",
"0.71118283",
"0.7111579",
"0.7102477",
"0.7058823... | 0.0 | -1 |
Returns true if this process has a fixed smp affinity mask, not allowing it to be moved to a different set of CPUs. | def is_bound_to_cpu(self):
return self.fields["flags"] & self.PF_THREAD_BOUND and \
True or False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session_affinity_enabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"session_affinity_enabled\")",
"def session_affinity_enabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"session_affinity_enabled\")",
"def session_affinity_enabled(self) -> pulum... | [
"0.6239417",
"0.6239417",
"0.597791",
"0.56544566",
"0.56213695",
"0.5586835",
"0.55038387",
"0.548722",
"0.5473159",
"0.544503",
"0.543302",
"0.5388909",
"0.5388909",
"0.5351124",
"0.53324836",
"0.52388155",
"0.52211",
"0.5182524",
"0.5160681",
"0.51578665",
"0.51391023",
... | 0.5746601 | 3 |
Loads the environment variables for this process. The entries then become available via the 'environ' member, or via the 'environ' dict key when accessing as p["environ"]. | def load_environ(self):
self.environ = {}
f = file("/proc/%d/environ" % self.pid)
for x in f.readline().split('\0'):
if len(x) > 0:
y = x.split('=')
self.environ[y[0]] = y[1]
f.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_evironment():\n environment = Utility.load_yaml(os.getenv(\"system_file\", \"./system.yaml\"))\n for key in environment:\n if key in os.environ:\n environment[key] = os.getenv(key)\n Utility.environment = environment",
"def get_process_env(pid=1):\n\n tr... | [
"0.72640723",
"0.67112094",
"0.6643739",
"0.6579186",
"0.64578545",
"0.64321744",
"0.64190364",
"0.63612753",
"0.6336438",
"0.6309374",
"0.6309374",
"0.6309374",
"0.6309374",
"0.6309374",
"0.6309374",
"0.6308915",
"0.6305903",
"0.63039196",
"0.6287894",
"0.6287856",
"0.628616... | 0.8507662 | 0 |
Euclidean distance between two points. | def euclidean(x, y):
return np.sqrt(np.sum((x - y) ** 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, point2)]))",
"def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array(point2))",
"def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-p... | [
"0.84279233",
"0.83612895",
"0.8324174",
"0.83092695",
"0.8306929",
"0.82199126",
"0.8209069",
"0.82086724",
"0.8176723",
"0.805556",
"0.80503225",
"0.8045459",
"0.80258095",
"0.7958847",
"0.7943932",
"0.79337907",
"0.79223317",
"0.78885055",
"0.7877786",
"0.78511626",
"0.784... | 0.7513078 | 49 |
Quadratic distance between two points. | def l2(x, y):
return np.sum(((x - y) ** 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_between_sq(x1: float, y1: float, x2: float, y2: float) -> float:\n dx = x2 - x1\n dy = y2 - y1\n return dx**2 + dy**2",
"def point_sqr_distance(point_a:tuple, point_b:tuple)->float:\n return (point_b[1]-point_a[1]) ** 2 + (point_b[0] - point_a[0]) ** 2",
"def distance(pt1, pt2):\n\tx1,... | [
"0.73594093",
"0.68154496",
"0.6797626",
"0.67503107",
"0.6729357",
"0.65785533",
"0.64868337",
"0.6474658",
"0.6469908",
"0.6450345",
"0.6420173",
"0.6415566",
"0.63962483",
"0.6381101",
"0.6363967",
"0.6362239",
"0.6341671",
"0.63354266",
"0.63243765",
"0.6319101",
"0.63175... | 0.0 | -1 |
Returns the X coordinate for the bus. | def bus_read_x(self) -> float:
return self.dss_obj.BUSF(1, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_x(self):\n return self.coords[0]",
"def Getxcoord(self):\n return self.x_coord",
"def _get_x(self):\n return self.position.x",
"def get_x_position(self):\n return self.actual_coordinates[0]",
"def getXCoordinate(self) -> float:\n return self.x_coord",
"def x(sel... | [
"0.80993617",
"0.7988393",
"0.79276025",
"0.7882585",
"0.7859119",
"0.77510834",
"0.7740236",
"0.7716511",
"0.7660599",
"0.76177466",
"0.7482796",
"0.7402999",
"0.7389607",
"0.73621637",
"0.7351837",
"0.7350878",
"0.734291",
"0.7341933",
"0.7339877",
"0.73084044",
"0.7281881"... | 0.67632663 | 34 |
Allows to write the X coordinate for the bus. Returns 0. | def bus_write_x(self, param_coordinate) -> int:
param_coordinate = Base.check_float_param(param_coordinate)
result = self.dss_obj.BUSF(2, ctypes.c_double(param_coordinate))
Base.check_assertion_result(result, "Write X coordinate failed!", "Something wrong when tried defined the X "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Getxcoord(self):\n return self.x_coord",
"def _get_x(self):\n return self.position.x",
"def x(self):\r\n return self.position.x",
"def get_x(self):\n return self.posX",
"def setX(self, value):\n self.position[0] = value",
"def x(self):\n return self.coords[0]",
... | [
"0.6805958",
"0.675453",
"0.6699914",
"0.669043",
"0.6583456",
"0.6578621",
"0.6551312",
"0.6539589",
"0.6512612",
"0.6468095",
"0.6468062",
"0.6466091",
"0.6410193",
"0.6367617",
"0.6351005",
"0.63464594",
"0.6322574",
"0.6318194",
"0.6302353",
"0.62887406",
"0.62839437",
... | 0.7504362 | 0 |
Returns the X coordinate for the bus. | def bus_read_y(self) -> float:
return self.dss_obj.BUSF(3, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_x(self):\n return self.coords[0]",
"def Getxcoord(self):\n return self.x_coord",
"def _get_x(self):\n return self.position.x",
"def get_x_position(self):\n return self.actual_coordinates[0]",
"def getXCoordinate(self) -> float:\n return self.x_coord",
"def x(sel... | [
"0.80993617",
"0.7988393",
"0.79276025",
"0.7882585",
"0.7859119",
"0.77510834",
"0.7740236",
"0.7716511",
"0.7660599",
"0.76177466",
"0.7482796",
"0.7402999",
"0.7389607",
"0.73621637",
"0.7351837",
"0.7350878",
"0.734291",
"0.7341933",
"0.7339877",
"0.73084044",
"0.7281881"... | 0.0 | -1 |
Allows to write the Y coordinate for the bus. Returns 0. | def bus_write_y(self, param_coordinate: float) -> int:
param_coordinate = Base.check_float_param(param_coordinate)
result = self.dss_obj.BUSF(4, ctypes.c_double(param_coordinate))
Base.check_assertion_result(result, "Write Y coordinate failed!", "Something wrong when tried defined the Y "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_y__(self):\n return self.Direction['y']",
"def bus_read_y(self) -> float:\n return self.dss_obj.BUSF(3, 0)",
"def y_coord(self):\n\n return self.y0 + np.arange(self.ny) * self.dy",
"def getYCoordinate(self) -> float:\n return self.y_coord",
"def y(self):\n retur... | [
"0.7204729",
"0.7133915",
"0.70421714",
"0.7035175",
"0.7029254",
"0.7027589",
"0.7025204",
"0.69881326",
"0.6954376",
"0.69359756",
"0.69286776",
"0.69241136",
"0.69053024",
"0.6893719",
"0.6874418",
"0.68630475",
"0.68284446",
"0.68284446",
"0.6804384",
"0.67853445",
"0.678... | 0.7932193 | 0 |
Read serialized data from JSON file, decode into Python object(s). | def read(fname):
# Read string from JSON file.
with open(fname, 'r') as fi:
serial = fi.read()
# Decode.
decoder = json.JSONDecoder(object_hook=numpy_hook)
data = decoder.decode(serial)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_loader(filename):\n\n with open(filename, \"r\", encoding=\"UTF-8\") as source:\n data = json.load(source, object_hook=object_decode)\n return data",
"def deserialize(self):\n with open(os.path.join(self.root_path, self._data_file), 'r') as file:\n data = json.load(file)\n for ke... | [
"0.7427025",
"0.7401203",
"0.73061746",
"0.73061746",
"0.7266844",
"0.7232876",
"0.7217766",
"0.7144292",
"0.71408784",
"0.71408373",
"0.71408373",
"0.71165866",
"0.710775",
"0.71004343",
"0.7082682",
"0.70816326",
"0.7022214",
"0.7020085",
"0.69943637",
"0.6984892",
"0.69675... | 0.72445816 | 5 |
Return a generator of rowtype dictionary objects. Each row emitted should be a dictionary of property names to their values. | def get_records(self, context: Optional[dict] = None) -> Iterable[Dict[str, Any]]:
if context and context.get("comments", None) == 0:
self.logger.debug(f"No comments detected. Skipping '{self.name}' sync.")
return []
return super().get_records(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_dict(self):\n\n itr = iter(self)\n\n headers = next(itr)\n\n for row in itr:\n yield dict(zip(headers, row))",
"def objects(self):\n _, c = self.get_column(0)\n size = len(c)\n headers = self.headers()\n for i in range(size):\n obj =... | [
"0.6687146",
"0.66758406",
"0.65323836",
"0.6425175",
"0.63274896",
"0.62857723",
"0.6259711",
"0.6259711",
"0.610761",
"0.61050224",
"0.60067976",
"0.58888286",
"0.5881483",
"0.5859894",
"0.5858678",
"0.5857102",
"0.5835678",
"0.5800577",
"0.57668644",
"0.5720909",
"0.569728... | 0.0 | -1 |
Calculate and round number of filters based on depth multiplier. | def round_filters(filters, global_params):
multiplier = global_params.width_coefficient
if not multiplier:
return filters
divisor = global_params.depth_divisor
min_depth = global_params.min_depth
filters *= multiplier
min_depth = min_depth or divisor
new_filters = max(min_depth, int(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _round_filters(self, filters):\n filters *= self.width_coefficient\n new_filters = max(\n self.depth_divisor,\n int(filters + self.depth_divisor / 2)\n // self.depth_divisor\n * self.depth_divisor,\n )\n # Make sure that round down does no... | [
"0.79212844",
"0.77277",
"0.77277",
"0.76260203",
"0.73904824",
"0.73495585",
"0.71545386",
"0.71514016",
"0.6494475",
"0.64639574",
"0.62070477",
"0.61848557",
"0.61825573",
"0.6107263",
"0.6089815",
"0.6086534",
"0.59294385",
"0.58493793",
"0.5784097",
"0.5751723",
"0.56976... | 0.7674134 | 4 |
Chooses static padding if you have specified an image size, and dynamic padding otherwise. Static padding is necessary for ONNX exporting of models. | def get_same_padding_conv2d(image_size=None):
if image_size is None:
return Conv2dDynamicSamePadding
else:
return partial(Conv2dStaticSamePadding, image_size=image_size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def padding_width(self):\n ...",
"def padding(img, n):\n img = np.pad(img, [(n, n), (n, n)], mode='constant', constant_values=0)\n\n return img",
"def run_padding(self):\n\n image_padded, mask, self.pad_to_right, self.pad_to_bottom = gen_padded_image_and_mask (os.path.join('utils_dfn/temp',... | [
"0.66277635",
"0.64855933",
"0.6460414",
"0.6414065",
"0.6413534",
"0.6340561",
"0.6336683",
"0.63226736",
"0.6322462",
"0.6312314",
"0.62720925",
"0.61532396",
"0.61212975",
"0.6105602",
"0.60911524",
"0.60413617",
"0.6026047",
"0.6025298",
"0.5991839",
"0.59883153",
"0.5968... | 0.5830092 | 31 |
Map EfficientNet model name to parameter coefficients. | def efficientnet_params(model_name):
params_dict = {
# Coefficients: width,depth,res,dropout
'efficientnet-b0': (1.0, 1.0, 224, 0.2),
'efficientnet-b1': (1.0, 1.1, 240, 0.2),
'efficientnet-b2': (1.1, 1.2, 260, 0.3),
'efficientnet-b3': (1.2, 1.4, 300, 0.3),
'efficien... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def efficientnet_params(model_name):\n params_dict = {\n # Coefficients: width,depth,res,dropout\n 'efficientnet-b0': (1.0, 1.0, 224, 0.2),\n 'efficientnet-b1': (1.0, 1.1, 240, 0.2),\n 'efficientnet-b2': (1.1, 1.2, 260, 0.3),\n 'efficientnet-b3': (1.2, 1.4, 300, 0.3),\n ... | [
"0.68057907",
"0.65481",
"0.6298889",
"0.6029276",
"0.5877488",
"0.5838003",
"0.5772829",
"0.57585347",
"0.57317084",
"0.5586488",
"0.55061686",
"0.54998165",
"0.54380655",
"0.5390309",
"0.53836536",
"0.5380048",
"0.53270173",
"0.5286134",
"0.52834225",
"0.52834225",
"0.52664... | 0.67349935 | 1 |
Generates multiscale anchor boxes. | def forward(self, image, dtype=torch.float32):
image_shape = image.shape[2:]
if image_shape == self.last_shape and image.device in self.last_anchors:
return self.last_anchors[image.device]
if self.last_shape is None or self.last_shape != image_shape:
self.last_shape = i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_anchor_boxes(image_size, feature_map_size, sizes, scales):\n image_height, image_width = image_size\n fm_height, fm_width = feature_map_size\n height_stride = int(image_height / fm_height)\n width_stride = int(image_width / fm_width)\n\n # Compose horizontal and vertical positions into ... | [
"0.7095319",
"0.7087414",
"0.676033",
"0.67057395",
"0.6698711",
"0.66437685",
"0.66208327",
"0.65511936",
"0.6535815",
"0.64397883",
"0.64372414",
"0.6420171",
"0.6420171",
"0.62874",
"0.6277956",
"0.6263748",
"0.6261684",
"0.6235041",
"0.6204222",
"0.6189743",
"0.61732316",... | 0.5288869 | 74 |
Converts a session JSON dict back to a session object. | def dict_to_session(dct):
session = classes.Session(dct['name'])
session.sets = set(dct['sets'])
session.banlist = set(dct['banlist'])
session.players = []
for p in dct['players']:
player = classes.Player(p['name'])
player.uid = p['uid']
player.sets = set(p['sets'])
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_session(path):\n dct = {}\n with open(path, 'r', encoding='utf-8') as f:\n dct = json.load(f)\n return dict_to_session(dct)",
"def load_from_session(cls, serializer: URLSafeSerializer, session):\n return cls.load(serializer, session.get(SESSION_STORE_KEY, None))",
"def _deserial... | [
"0.68154377",
"0.671255",
"0.6576613",
"0.63816625",
"0.6081353",
"0.60064596",
"0.59257865",
"0.58779347",
"0.5821056",
"0.57519543",
"0.57486",
"0.57320344",
"0.5722132",
"0.5694485",
"0.5694358",
"0.56442887",
"0.5597721",
"0.5570776",
"0.5560245",
"0.5545202",
"0.55329657... | 0.70577866 | 0 |
Remove stop words from list of tokenized words | def remove_stopwords(words):
new_words = []
for word in words:
if word not in stopwords.words('english'):
new_words.append(word)
return new_words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stop_words(stop_list, tokens):\n return [t for t in tokens if len(t) > 2 and not t in stop_list]",
"def remove_stopwords(tokens):\n stop_words = set(stopwords.words('english'))\n\n tokens = [w for w in tokens if w not in stop_words]\n\n return tokens",
"def remove_stop_words(tokenized_wo... | [
"0.86644375",
"0.86184067",
"0.8597777",
"0.8597093",
"0.8581807",
"0.8363134",
"0.8351681",
"0.8328106",
"0.83188903",
"0.8264969",
"0.82471436",
"0.82020384",
"0.8179686",
"0.8164016",
"0.81590205",
"0.8138802",
"0.8127921",
"0.81133604",
"0.81009424",
"0.8049209",
"0.80285... | 0.800315 | 24 |
Lemmatize verbs in list of tokenized words | def lemmatize_verbs(words):
lemmatizer = WordNetLemmatizer()
lemmas = []
for word in words:
lemma = lemmatizer.lemmatize(word, pos='v')
lemmas.append(lemma)
return lemmas | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatization(tokenized_word_list):\n porter=nltk.stem.PorterStemmer()\n filtered_tokens = [porter.stem(word) for word in tokenized_word_list]\n return filtered_tokens",
"def lemmatize_verbs(self):\n lemmas = []\n # lemmas = \"\"\n for word in self.words:\n lemma = wn.lemmatize(word, p... | [
"0.8030157",
"0.79708034",
"0.7929658",
"0.78893584",
"0.7825038",
"0.77570516",
"0.7734948",
"0.7710127",
"0.7703662",
"0.77004546",
"0.7636745",
"0.7632275",
"0.7570557",
"0.7545994",
"0.7536599",
"0.7523452",
"0.7493259",
"0.7472224",
"0.74654067",
"0.7435876",
"0.7369798"... | 0.774135 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.