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 |
|---|---|---|---|---|---|---|
Initialize the model by setting up the layers. | def __init__(self, vocab_size, output_size, embedding_dim, hidden_dim, n_layers, drop_prob=0.7):
super(SentimentLSTM, self).__init__()
self.output_size = output_size
self.n_layers = n_layers
self.hidden_dim = hidden_dim
# define all layers
self.embed = nn.Embedding(voc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_layers(self):\n self._init_predictor()\n if self.use_edge_fusion:\n self._init_edge_module()",
"def initialisation(self):\n self.create_variables()\n self.create_placeholders()\n self.build_model()\n self.reset_lr(None, True)\n self.build_loss... | [
"0.7877656",
"0.740135",
"0.73939556",
"0.73799825",
"0.72304994",
"0.72242755",
"0.7183698",
"0.7181406",
"0.7175707",
"0.71491647",
"0.70773673",
"0.70694804",
"0.7036073",
"0.70194495",
"0.7018242",
"0.69936645",
"0.6969751",
"0.6949472",
"0.69274527",
"0.6899944",
"0.6853... | 0.0 | -1 |
Checks rows, columns and diagonals for a winner and returns player name if winner found | def check_winner(self):
for row in self.board.values():
if all([mark == "x" for mark in row]):
return self.player_1
elif all([mark == "o" for mark in row]):
return self.player_2
# checks every column
for i in range(3):
first_ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner_found(self):\n\n first_row = self.find_three_in_row([self._board[0][0], self._board[0][1], self._board[0][2]])\n second_row = self.find_three_in_row([self._board[1][0], self._board[1][1], self._board[1][2]])\n third_row = self.find_three_in_row([self._board[2][0], self._board[2][1],... | [
"0.7850276",
"0.7844686",
"0.78040963",
"0.77991927",
"0.7786862",
"0.7772859",
"0.7772767",
"0.775103",
"0.77378315",
"0.77017176",
"0.769776",
"0.7691695",
"0.76738596",
"0.7589716",
"0.7542575",
"0.7541765",
"0.7540349",
"0.753474",
"0.75276124",
"0.7417552",
"0.74025553",... | 0.8051105 | 0 |
If the input is unicode, it will be converted to utf8 encoded bytes; others will be returned to original way. | def to_bytes(data):
if isinstance(data, unicode):
return data.encode('utf-8')
else:
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_utf8(text):\n if isinstance(text, binary_type):\n return text\n else:\n return text.encode('utf-8')",
"def unicode2utf8(arg):\n\n try:\n if isinstance(arg, unicode):\n return arg.encode('utf-8')\n except NameError:\n pass # Python 3\n return arg",
... | [
"0.72585714",
"0.7057726",
"0.705013",
"0.70202917",
"0.69109493",
"0.68745905",
"0.6828343",
"0.6787694",
"0.6770514",
"0.6762633",
"0.6759491",
"0.67589563",
"0.6746645",
"0.6735249",
"0.6671572",
"0.66674966",
"0.66594577",
"0.66577935",
"0.6628185",
"0.6556121",
"0.653581... | 0.6503458 | 23 |
Convert the input to unicode, input is required to be unicode or utf8 encoded bytes. | def to_unicode(data):
if isinstance(data, bytes):
return data.decode('utf-8')
else:
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_unicode(value):\r\n if isinstance(value, _TO_UNICODE_TYPES):\r\n return value\r\n if not isinstance(value, bytes_type):\r\n raise TypeError(\r\n \"Expected bytes, unicode, or None; got %r\" % type(value)\r\n )\r\n return value.decode(\"utf-8\")",
"def utf8tounicode... | [
"0.7793887",
"0.77113724",
"0.75553405",
"0.7408156",
"0.7390316",
"0.7390316",
"0.738984",
"0.736352",
"0.73187596",
"0.72773427",
"0.7253526",
"0.7247552",
"0.7231445",
"0.71971655",
"0.71865135",
"0.7123094",
"0.7112982",
"0.70650494",
"0.703904",
"0.703389",
"0.70170397",... | 0.75615406 | 2 |
If the string subobject in the input object is unicode encoded, it is converted to a byte of utf8; the other is returned as it is. | def stringify(input):
if isinstance(input, dict):
return dict([(stringify(key), stringify(value)) for key, value in input.iteritems()])
elif isinstance(input, list):
return [stringify(element) for element in input]
elif isinstance(input, unicode):
return input... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_unicode(obj, encoding=\"UTF-8\"):\n if isinstance(obj, basestring):\n if not isinstance(obj, unicode):\n obj = unicode(obj, encoding)\n return obj",
"def as_utf8(value):\n assert value is None or isinstance(value,types.StringTypes)\n if isinstance(value,types.UnicodeType):\n... | [
"0.70804787",
"0.7054887",
"0.70273423",
"0.70273423",
"0.70273423",
"0.70273423",
"0.70273423",
"0.70273423",
"0.69450444",
"0.6890117",
"0.6826282",
"0.67923164",
"0.6772603",
"0.6772084",
"0.6770586",
"0.67700917",
"0.67441547",
"0.6667456",
"0.66381395",
"0.66276354",
"0.... | 0.0 | -1 |
If the input is str (ie unicode), it will be converted to utf8 encoded bytes; others will return as they are. | def to_bytes(data):
if isinstance(data, str):
return data.encode(encoding='utf-8')
else:
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def give_me_bytes(string):\n return string.encode('utf8') if isinstance(string, str) else string",
"def as_utf8(value):\n assert value is None or isinstance(value,types.StringTypes)\n if isinstance(value,types.UnicodeType):\n return value.encode('utf-8')\n else:\n return value",
"def ... | [
"0.7504459",
"0.7472167",
"0.7422524",
"0.7396655",
"0.73131263",
"0.7242583",
"0.7220387",
"0.7214761",
"0.7203917",
"0.71764106",
"0.7152591",
"0.7113217",
"0.70409924",
"0.6968084",
"0.69579387",
"0.6933949",
"0.69033337",
"0.6884524",
"0.68819547",
"0.68632",
"0.68306863"... | 0.6585055 | 42 |
If the input is bytes, it is considered to be utf8 encoding, and returns str | def to_string(data):
if isinstance(data, bytes):
return data.decode('utf-8')
else:
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def utf8(value):\r\n if isinstance(value, _UTF8_TYPES):\r\n return value\r\n elif isinstance(value, unicode_type):\r\n return value.encode(\"utf-8\")\r\n else:\r\n return str(value)",
"def _encode_to_utf8(s):\n return s.encode('utf-8')",
"def utf8(value):\r\n if isinstance(v... | [
"0.76432323",
"0.76154476",
"0.7567259",
"0.75092566",
"0.7471273",
"0.74313176",
"0.7378342",
"0.73617756",
"0.73536265",
"0.7344269",
"0.7342175",
"0.73386896",
"0.7317219",
"0.7298769",
"0.7298769",
"0.72802126",
"0.72549284",
"0.7251981",
"0.7217084",
"0.72070533",
"0.718... | 0.68467027 | 37 |
Convert the input to unicode, input is required to be unicode or utf8 encoded bytes. | def to_unicode(data):
return to_string(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_unicode(value):\r\n if isinstance(value, _TO_UNICODE_TYPES):\r\n return value\r\n if not isinstance(value, bytes_type):\r\n raise TypeError(\r\n \"Expected bytes, unicode, or None; got %r\" % type(value)\r\n )\r\n return value.decode(\"utf-8\")",
"def utf8tounicode... | [
"0.7793887",
"0.77113724",
"0.75615406",
"0.75553405",
"0.7408156",
"0.7390316",
"0.7390316",
"0.738984",
"0.736352",
"0.73187596",
"0.72773427",
"0.7253526",
"0.7247552",
"0.7231445",
"0.71971655",
"0.71865135",
"0.7123094",
"0.7112982",
"0.70650494",
"0.703904",
"0.703389",... | 0.68372756 | 34 |
Returns the ManagementForm instance for this FormSet. | def _management_form(self):
if self.is_bound:
form = ConcurrentManagementForm(self.data, auto_id=self.auto_id,
prefix=self.prefix)
if not form.is_valid():
raise ValidationError('ManagementForm data is missing or has been tampere... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def management_form(self):\n if self.is_bound:\n form = AttachmentManagementForm(self.data, auto_id=self.auto_id, prefix=self.prefix)\n if not form.is_valid():\n raise ValidationError('ManagementForm data is missing or has been tampered with')\n else:\n ... | [
"0.71396756",
"0.66645527",
"0.66645527",
"0.63575435",
"0.6231655",
"0.62000716",
"0.61292356",
"0.6125592",
"0.6120834",
"0.6112439",
"0.6102003",
"0.60750073",
"0.5939128",
"0.5879666",
"0.58429885",
"0.57521427",
"0.5715844",
"0.56427836",
"0.557819",
"0.5555635",
"0.5554... | 0.7361751 | 0 |
Desirializing of nonuuid formatted value should raise an error. | def test_invlalid_uuid_load():
schema = UUIDSchema()
result = schema.load({
"uuid_str": INVALID_UUID_STR,
"uuid_uuid": UUID(UUID_STR),
})
assert_that(result.errors["uuid_str"], contains('Not a valid UUID.')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_uuid(value: Any, none_allowed: bool, display_name: str) -> None:\n if none_allowed and value is None:\n return\n\n if not isinstance(value, UUID) or value.version != 4:\n raise TypeError(f\"{display_name} must be a UUID version 4\")",
"def validateUuid(sValue, aoNilValues = tuple... | [
"0.68983275",
"0.66873175",
"0.65473825",
"0.65364915",
"0.64650166",
"0.6401455",
"0.6399042",
"0.6303111",
"0.62995964",
"0.6214849",
"0.62138045",
"0.60851914",
"0.6074883",
"0.6074883",
"0.60541576",
"0.6017049",
"0.6000152",
"0.6000152",
"0.6000152",
"0.59587204",
"0.594... | 0.60952204 | 11 |
compute dot production of two vectors | def dot_product(v1, v2):
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot(a, b):\n\n if len(a) != len(b):\n raise Exception(\"Input vectors must be of same length, not %d and %d\" % (len(a), len(b)))\n\n return float(sum([a[i] * b[i] for i in range(len(a))]))",
"def dot(vector1, vector2):\n return sum(a1 * a2 for a1, a2 in zip(vector1, vector2))",
... | [
"0.8511496",
"0.84440446",
"0.8402081",
"0.8395364",
"0.83690804",
"0.8349456",
"0.8316363",
"0.83106387",
"0.8247005",
"0.8224876",
"0.8203073",
"0.8202561",
"0.8144584",
"0.8127831",
"0.80985284",
"0.80964756",
"0.80841047",
"0.8082877",
"0.80808747",
"0.80802584",
"0.80544... | 0.8106549 | 14 |
compute cross production of two vectors | def cross_product(v1, v2):
return cg3d_vector.CG3dVector(
v1[1] * v2[2] - v2[1] * v1[2],
v1[2] * v2[0] - v2[2] * v1[0],
v1[0] * v2[1] - v2[0] * v1[1]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross(a, b):\n #return np.cross(a,b)\n\n return vector(a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0])",
"def vec_cross(a,b):\r\n return [a[1] * b[2] - a[2] * b[1],\r\n a[2] * b[0] - a[0] * b[2],\r\n a[0] * b[1] -... | [
"0.8276196",
"0.8221919",
"0.80771583",
"0.8044745",
"0.79784995",
"0.7958217",
"0.7818568",
"0.7786286",
"0.7779489",
"0.777509",
"0.7701375",
"0.76462483",
"0.76118815",
"0.7483775",
"0.74591064",
"0.7422321",
"0.7417814",
"0.74160844",
"0.73222435",
"0.7279918",
"0.7129102... | 0.79456735 | 6 |
Get all legal moves for the current board_state. For Tictactoe that is all positions that do not currently have pieces played. | def available_moves(board_state):
for x, y in itertools.product(range(len(board_state)), range(len(board_state[0]))):
if board_state[x][y] == 0:
yield (x, y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_legal_moves(self):\n # for each square in the castle figure out if an moves can occur from it.\n moves = []\n allowed = [self.turn]\n if self.turn == DEFENDER:\n allowed.extend((KING, CASTLE_OCCUPIED))\n it = np.nditer(self.board_state, flags=['multi_index'])\n... | [
"0.8104835",
"0.79265124",
"0.78373796",
"0.7735789",
"0.77165693",
"0.7643346",
"0.75891775",
"0.7550649",
"0.7538445",
"0.74807423",
"0.7466644",
"0.7418224",
"0.7406417",
"0.7396408",
"0.7373833",
"0.73277944",
"0.7315183",
"0.7275858",
"0.7267511",
"0.7243297",
"0.7232759... | 0.7168862 | 29 |
x component of the coordinates in the interior domain. | def x(self):
return self.coords[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_coord(self):\n\n return self.x0 + np.arange(self.nx) * self.dx",
"def x(self):\n return self._coords[0]",
"def x(self):\n if self._x is None:\n self.compute_coordinates()\n return self._x",
"def get_x(self):\n return self.coords[0]",
"def Getxcoord(self):... | [
"0.8358697",
"0.8154594",
"0.8109607",
"0.8066341",
"0.8036693",
"0.7739915",
"0.7691257",
"0.7688244",
"0.7548885",
"0.7508032",
"0.74587315",
"0.74127597",
"0.7358614",
"0.73565143",
"0.7294545",
"0.7292517",
"0.7270111",
"0.72684973",
"0.72265565",
"0.72084564",
"0.7204393... | 0.8181522 | 1 |
y component of the coordinates in the interior domain. | def y(self):
return self.coords[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y_coord(self):\n\n return self.y0 + np.arange(self.ny) * self.dy",
"def y(self):\n return self._coords[1]",
"def y(self) -> int:\n return self.data.y_centre >> 4",
"def get_y(self):\n return self.coords[1]",
"def y(self):\n if self._y is None:\n self.comput... | [
"0.84114426",
"0.81654555",
"0.80646",
"0.79960674",
"0.78949875",
"0.7806516",
"0.77400583",
"0.77166253",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.7681602",
"0.76600176",
"0.76600176",
"0.7660017... | 0.82379454 | 1 |
x component of the coordinates of the whole domain (halo points included). | def x_halo(self):
return self.coords_halo[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_coord(self):\n\n return self.x0 + np.arange(self.nx) * self.dx",
"def x(self):\n if self._x is None:\n self.compute_coordinates()\n return self._x",
"def x(self):\n return self.coords[0]",
"def x(self):\n return self._coords[0]",
"def get_x(self):\n ... | [
"0.7628023",
"0.7627613",
"0.7605079",
"0.7560858",
"0.75197285",
"0.73364943",
"0.7319262",
"0.7208585",
"0.7040728",
"0.70402396",
"0.700919",
"0.6968909",
"0.69673264",
"0.6955738",
"0.69547075",
"0.69454676",
"0.69199395",
"0.682559",
"0.681483",
"0.6806043",
"0.6782578",... | 0.77378696 | 0 |
y component of the coordinates of the whole domain (halo points included). | def y_halo(self):
return self.coords_halo[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y_coord(self):\n\n return self.y0 + np.arange(self.ny) * self.dy",
"def y(self):\n return self.coords[1]",
"def get_y(self):\n return self.__y",
"def y(self):\n return self._coords[1]",
"def y(self):\n if self._y is None:\n self.compute_coordinates()\n ... | [
"0.7791334",
"0.7649934",
"0.7597563",
"0.75450903",
"0.75338155",
"0.75070745",
"0.74508405",
"0.7420105",
"0.74109304",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.7409863",
"0.73475975",
"0.7347597... | 0.80401057 | 0 |
Return the coordinates of the bottom right and upper left corner of the interior domain. | def get_bounds(self):
bottom_right = np.asarray([self.coords[k][0] for k in range(self.dim)])
upper_left = np.asarray([self.coords[k][-1] for k in range(self.dim)])
return bottom_right, upper_left | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bounds_halo(self):\n bottom_right = np.asarray([self.coords_halo[k][0] for k in range(self.dim)])\n upper_left = np.asarray([self.coords_halo[k][-1] for k in range(self.dim)])\n return bottom_right, upper_left",
"def bottomLeftCorner(self):\n self._updateExtents()\n ret... | [
"0.76211905",
"0.7292665",
"0.69914323",
"0.67774415",
"0.6669149",
"0.6615716",
"0.6581587",
"0.6549148",
"0.6523538",
"0.65019536",
"0.64836305",
"0.64644194",
"0.64228207",
"0.6417498",
"0.6398502",
"0.63445574",
"0.63234276",
"0.6316152",
"0.6315162",
"0.6314326",
"0.6278... | 0.77522284 | 0 |
Mock the requests.get return value. If we try to set attributes on requests.get directly, we'll | def mock_requests_get(mocker, mocked_requests_get):
def _requests_get(module, content, status):
mock_func = mocker.patch(f'{module}.requests.get')
mock_func.return_value = mocked_requests_get(content, status)
return _requests_get | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_requests_get(self, mocker):\n mock = mocker.patch(\"requests.get\")\n mock.return_value.__enter__.return_value.json.return_value = {\n \"item\": {\n \"icon\": \"\",\n \"icon_large\": \"\",\n \"id\": 21787,\n \"type\": \"M... | [
"0.72807246",
"0.72359955",
"0.7179954",
"0.70539004",
"0.7024782",
"0.69704086",
"0.69374245",
"0.68708456",
"0.6863891",
"0.68198556",
"0.67906505",
"0.6764723",
"0.67489815",
"0.6732757",
"0.6729054",
"0.6710932",
"0.66979325",
"0.6666944",
"0.6651065",
"0.66106665",
"0.65... | 0.719874 | 2 |
Create a fake requests.Response object. | def mocked_requests_get():
class MockResponse:
def __init__(self, _content, _status):
self.content = _content
self.status_code = _status
def content(self):
return self.content
return MockResponse | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response():\n def inner(ret_code, ret_value):\n \"\"\"Set up response with the given parameters.\n\n :param ret_code: Return code for the response\n :param ret_value: Return value for the response\n :return: Mocked Responce object with the given parameters\n \"\"... | [
"0.736011",
"0.71040297",
"0.7098835",
"0.6869094",
"0.6854902",
"0.6733961",
"0.6733961",
"0.6719025",
"0.6631267",
"0.6599584",
"0.6549238",
"0.65430015",
"0.6531704",
"0.6485677",
"0.64722425",
"0.643935",
"0.64389443",
"0.6423061",
"0.642237",
"0.6392279",
"0.63886",
"0... | 0.73249215 | 1 |
Get the string representation of the model | def __str__(self):
return json.dumps(self.to_dict()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self) -> str:\n # noinspection PyUnresolvedReferences\n opts = self._meta\n if self.name_field:\n result = str(opts.get_field(self.name_field).value_from_object(self))\n else:\n ... | [
"0.8463654",
"0.7898162",
"0.77145106",
"0.77145106",
"0.76879215",
"0.7655091",
"0.7650248",
"0.757232",
"0.75623566",
"0.7551965",
"0.7551965",
"0.7551292",
"0.7549884",
"0.7536579",
"0.7519798",
"0.7517772",
"0.75146",
"0.745953",
"0.74590117",
"0.74517524",
"0.7426484",
... | 0.0 | -1 |
Computes cross entropy between targets (encoded as onehot vectors) and predictions. | def cross_entropy_loss(predictions, targets, epsilon=1e-12):
predictions = np.clip(predictions, epsilon, 1. - epsilon)
N = predictions.shape[0]
ce = -np.sum(targets*np.log(predictions+1e-9))/N
return ce | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_entropy(predictions, targets):\n likelihood = targets * np.log(predictions)\n return -np.sum(likelihood) / predictions.shape[0]",
"def cross_entropy(predicted, target):\n batch_size, num_classes = predicted.shape\n\n e_x = predicted.exp()\n log_e_x = e_x.log()\n a = log_sum_x_trick(pr... | [
"0.7892568",
"0.75793386",
"0.75247025",
"0.751529",
"0.7430935",
"0.73616475",
"0.73616475",
"0.7344533",
"0.7198154",
"0.7078395",
"0.7066774",
"0.7011896",
"0.69843245",
"0.6977101",
"0.69487417",
"0.69227016",
"0.6911786",
"0.68707484",
"0.685989",
"0.68182206",
"0.679910... | 0.7006511 | 12 |
get the domain ldap root for the given dn >>> dn = "sambaDomainName=IEPERTEST,dc=Ieper,dc=elex" >>> domainroot(dn) 'dc=Ieper,dc=elex' | def domainroot(d):
dn = str2dn(d)
dn.pop(0)
return dn2str(dn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root_domain(url):\n if url is None:\n return ''\n\n http = text.find_between(url, 'http://', '/')\n https = text.find_between(url, 'https://', '/')\n if http != '':\n if http.startswith('www.'):\n return http[4:]\n else:\n return http\n else:\n ... | [
"0.59731376",
"0.58926845",
"0.58213747",
"0.57498807",
"0.5353788",
"0.53386265",
"0.5327255",
"0.53180313",
"0.52835435",
"0.5229424",
"0.51967984",
"0.51759446",
"0.5168741",
"0.512568",
"0.51203126",
"0.5037568",
"0.5010395",
"0.49844295",
"0.49844295",
"0.49776703",
"0.4... | 0.78520805 | 0 |
Returns a Polynomial Decomposition impedance. | def forward(self, theta, w):
return Decomp_cyth(w, self.taus, self.log_taus, self.c_exp,
R0=theta[0], a=theta[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deriv(self):\n poly_deriv = []\n for i, val in enumerate(self.coeff):\n poly_deriv.append(i*val)\n # Removes the differentiated constant (which is always 0).\n del poly_deriv[0]\n return Poly(poly_deriv)",
"def anti_deriv(self):\n poly_anti_deriv = [0]\n ... | [
"0.6602687",
"0.6434507",
"0.61124486",
"0.594507",
"0.59432936",
"0.5882449",
"0.5757533",
"0.571267",
"0.5697987",
"0.56913066",
"0.5650294",
"0.5599147",
"0.55832195",
"0.55588233",
"0.5545277",
"0.5538527",
"0.5534198",
"0.55121106",
"0.55069256",
"0.5482732",
"0.54679424... | 0.0 | -1 |
Find input channels of the yolo model from layer configs. | def get_c(layer_configs):
net_config = layer_configs['000_net']
return net_config.get('channels', 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_channels(self, input_channels):\n return input_channels",
"def infer_channels(inputs, transpose=False):\n out_type = infer_type(inputs)\n out_shapes = [get_const_tuple(out_type.checked_type.shape)]\n channels = out_shapes[0][0] if not transpose else out_shapes[0][1]\n return channel... | [
"0.58312744",
"0.5742968",
"0.56544346",
"0.5654426",
"0.5552283",
"0.54746956",
"0.5446388",
"0.5428018",
"0.5343479",
"0.5341048",
"0.53252137",
"0.53120375",
"0.52911556",
"0.5288412",
"0.5281511",
"0.52737856",
"0.527295",
"0.52729017",
"0.5260956",
"0.52438396",
"0.52409... | 0.63726634 | 0 |
Initializes the model with weights and bias Conv layers get random weights from a normal distribution and bias is set to 0 | def _initialize_weights(self):
for m in self.modules():
if isinstance(m, nn.Conv2d):
m.weight.data.normal_(0, 0.05)
if m.bias is not None:
m.bias.data.zero_() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weights_init(model):\n classname = model.__class__.__name__\n if classname.find('Conv') != -1:\n nn.init.normal_(model.weight.data, 0.0, 0.02)\n elif classname.find('BatchNorm') != -1:\n nn.init.normal_(model.weight.data, 1.0, 0.02)\n nn.init.constant_(model.bias.data, 0)",
"def... | [
"0.7880966",
"0.77078766",
"0.76977557",
"0.7682001",
"0.7630087",
"0.7623425",
"0.7612172",
"0.7602894",
"0.7602894",
"0.7602894",
"0.75905013",
"0.7564779",
"0.7564779",
"0.75269467",
"0.7512145",
"0.751193",
"0.75105506",
"0.75105506",
"0.75105506",
"0.7505411",
"0.748072"... | 0.7725655 | 1 |
Iterates the model for a single batch of data, calculates the loss and updates the model parameters. | def step(self, data: torch.Tensor) -> Tuple:
image, _ = data
image = image.to(self.device)
batch_size = image.shape[0]
label = torch.full(
(batch_size,), self.label, dtype=torch.float, device=self.device
)
self.zero_grad()
# Forward pass
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _step(self):\n # Make a minibatch of training data\n num_train = self.X_train.shape[0]\n # random choose the samples\n batch_mask = np.random.choice(num_train, self.batch_size)\n X_batch = self.X_train[batch_mask]\n y_batch = self.y_train[batch_mask]\n\n # Compu... | [
"0.7212915",
"0.7017608",
"0.6971652",
"0.6964363",
"0.69216657",
"0.69077504",
"0.6877378",
"0.6855926",
"0.68448675",
"0.6819717",
"0.6796839",
"0.6751691",
"0.67510575",
"0.6746935",
"0.6739293",
"0.6734196",
"0.6725004",
"0.67016226",
"0.66975546",
"0.66851646",
"0.667173... | 0.0 | -1 |
Replaces `suffix` of `word` with `replacement | def _replace_suffix(self, word, suffix, replacement):
assert word.endswith(suffix), "Given word doesn't end with given suffix"
if suffix == "":
return word + replacement
else:
return word[: -len(suffix)] + replacement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_suffix(word, suffix):\n suffix, sep, rest = suffix.partition(' ')\n expanded = _add_suffix(word, suffix)\n return expanded + sep + rest",
"def suffix_replace(original, old, new):\n ...",
"def replace_suffix (name, new_suffix):\n assert isinstance(name, basestring)\n assert isinstance(... | [
"0.7701713",
"0.7665795",
"0.66624486",
"0.64749455",
"0.63054746",
"0.6149442",
"0.61022633",
"0.6039127",
"0.6027953",
"0.6017234",
"0.59906757",
"0.59685665",
"0.5966546",
"0.5966546",
"0.5966546",
"0.5966546",
"0.5965606",
"0.5955456",
"0.59381366",
"0.59128815",
"0.58945... | 0.89509475 | 0 |
Applies the first applicable suffixremoval rule to the word Takes a word and a list of suffixremoval rules represented as 3tuples, with the first element being the suffix to remove, the second element being the string to replace it with, and the final element being the condition for the rule to be applicable, or None i... | def _apply_rule_list(self, word, rules):
for rule in rules:
suffix, replacement, condition = rule
if suffix == "*d" and self._ends_double_consonant(word):
stem = word[:-2]
if condition is None or condition(stem):
return stem + replaceme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_rule(word):\n return re.sub(search, replace, word)",
"def word_clean(self, word):\n word_ori = word\n if word not in self.vocab_list: # if the word is not in the vocabulary\n word = word.strip(\",.!?\") # delete punctuation, such as periods, commas\n for i in ra... | [
"0.6241091",
"0.6044743",
"0.58442014",
"0.56673056",
"0.5549546",
"0.55156666",
"0.5505275",
"0.53335893",
"0.53203624",
"0.52443767",
"0.5229112",
"0.52215064",
"0.5208779",
"0.51806766",
"0.51736385",
"0.5163402",
"0.51501673",
"0.51331615",
"0.5123183",
"0.5071901",
"0.50... | 0.68673265 | 0 |
Implements Step 1b from "An algorithm for suffix stripping" | def _step1b(self, word):
# this NLTK-only block extends the original algorithm, so that
# 'spied'->'spi' but 'died'->'die' etc
if self.mode == self.NLTK_EXTENSIONS:
if word.endswith("ied"):
if len(word) == 4:
return self._replace_suffix(word, "ied"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removesuffix(self, x) -> String:\n pass",
"def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s",
"def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ... | [
"0.71120393",
"0.6927874",
"0.68953496",
"0.6655125",
"0.6539592",
"0.64849085",
"0.6369599",
"0.6365083",
"0.62968457",
"0.6283579",
"0.62531453",
"0.6191985",
"0.6188154",
"0.6157653",
"0.61504936",
"0.6122239",
"0.6086603",
"0.6043726",
"0.60027677",
"0.59654695",
"0.59466... | 0.54680014 | 60 |
Implements Step 1c from "An algorithm for suffix stripping" | def _step1c(self, word):
def nltk_condition(stem):
"""
This has been modified from the original Porter algorithm so
that y->i is only done when y is preceded by a consonant,
but not if the stem is only a single consonant, i.e.
(*c and not c) Y -> ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removesuffix(self, x) -> String:\n pass",
"def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s",
"def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ... | [
"0.7151827",
"0.7035866",
"0.68370575",
"0.6659626",
"0.658684",
"0.65657824",
"0.6438374",
"0.6393294",
"0.638715",
"0.633172",
"0.62455475",
"0.6197732",
"0.61885804",
"0.61792827",
"0.61698663",
"0.6149805",
"0.61285746",
"0.60832727",
"0.60544956",
"0.60506916",
"0.597244... | 0.0 | -1 |
Return if ingestion mode is on. | def force_run_ingestion(self):
# Set this value when you want to run the ingestion forcefully (ignores runtime).
return os.environ.get('SNYK_INGESTION_FORCE_RUN', 'false').lower() in ('1', 'yes', 'true') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ingestion_mode(self) -> str:\n return pulumi.get(self, \"ingestion_mode\")",
"def ingestion_mode(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"ingestion_mode\")",
"def ingestion_mode(self) -> pulumi.Input[Union[str, 'IngestionMode']]:\n return pulumi.get(self, \"ingestion_mo... | [
"0.7885129",
"0.77932876",
"0.7579588",
"0.6684772",
"0.65818673",
"0.64385766",
"0.6314662",
"0.62913567",
"0.6282229",
"0.6282229",
"0.6282229",
"0.6250472",
"0.6242138",
"0.6233455",
"0.6213318",
"0.62132466",
"0.61894625",
"0.61894625",
"0.61894625",
"0.61894625",
"0.6189... | 0.6460671 | 5 |
Return if the vuln mode is on. | def is_vuln_mode_disabled(self):
# Set this value if you want the vuln data to be collected in the S3 file.
return os.environ.get('DISABLE_VULN_MODE', 'false').lower() in ('1', 'yes', 'true') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on(self):\n return self._program.get(\"enabled\") is True",
"def is_complete_vuln_mode(self):\n return os.environ.get('COMPLETE_VULN_MODE', 'false').lower() in ('1', 'yes', 'true')",
"def is_production_mode(self):\n return getattr(self.env, 'mode', None) == 'production'",
"def in_... | [
"0.66916114",
"0.66532433",
"0.6499631",
"0.64198023",
"0.6398497",
"0.6380015",
"0.6346437",
"0.633201",
"0.63165367",
"0.63053477",
"0.6267307",
"0.6243341",
"0.6215645",
"0.62144536",
"0.6212919",
"0.61458015",
"0.6141528",
"0.61412394",
"0.6140185",
"0.6138267",
"0.613293... | 0.69225055 | 0 |
Get a User object from the user_id. | def get_user(self, user_id):
try:
return Account.objects.get(pk=user_id)
except Account.DoesNotExist:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(user_id):\n\n return User.query.get(user_id)",
"def get_user_from_id(user_id):\n return Users.query.filter_by(id=user_id).first()",
"def get_user_by_id(user_id):\n return User.query.get(user_id)",
"def get_user(cls, user_id):\n try:\n return User.objects.... | [
"0.89135295",
"0.8838515",
"0.8776147",
"0.8770163",
"0.87386477",
"0.8667805",
"0.8667805",
"0.8667805",
"0.8667805",
"0.86468965",
"0.8629112",
"0.85356957",
"0.8495958",
"0.8457728",
"0.83978903",
"0.8372216",
"0.8274367",
"0.8245512",
"0.82040536",
"0.82040536",
"0.820405... | 0.79216135 | 71 |
Sets the created_at of this ChannelReturnResponse. | def created_at(self, created_at):
self._created_at = created_at | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def created_at(self, created_at):\n self._created_at = created_at",
"def created_at(self, created_at: \"datetime\"):\n self._attrs[\"createdAt\"] = created_at",
"def created_at(self, created_at: \"datetime\"):\n self._attrs[\"createdAt\"] = created_at",
"def created_at(self, created_at: ... | [
"0.65770507",
"0.6559553",
"0.6559553",
"0.6559553",
"0.6474776",
"0.6138583",
"0.6138583",
"0.6078942",
"0.58889717",
"0.58354366",
"0.57629526",
"0.5630299",
"0.55852574",
"0.5564892",
"0.5560603",
"0.5560603",
"0.5560603",
"0.5560603",
"0.5516017",
"0.54996145",
"0.549091"... | 0.65525055 | 20 |
Sets the updated_at of this ChannelReturnResponse. | def updated_at(self, updated_at):
self._updated_at = updated_at | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_at(self, updated_at: \"datetime\"):\n self._attrs[\"updatedAt\"] = updated_at",
"def updated_at(self, updated_at: \"datetime\"):\n self._attrs[\"updatedAt\"] = updated_at",
"def updated_at(self, updated_at: \"datetime\"):\n self._attrs[\"updatedAt\"] = updated_at",
"def updat... | [
"0.68167144",
"0.68167144",
"0.68167144",
"0.6386273",
"0.63290477",
"0.5913079",
"0.5913079",
"0.5913079",
"0.5907891",
"0.5907891",
"0.5907891",
"0.58465546",
"0.58141243",
"0.5764128",
"0.57118255",
"0.5696651",
"0.56540555",
"0.56540555",
"0.5617201",
"0.56079227",
"0.557... | 0.659471 | 12 |
Sets the id of this ChannelReturnResponse. | def id(self, id):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_id(self, response_id):\n\n self._response_id = response_id",
"def set_id(self, id):\n self.data['id'] = id",
"def rc_response_sets_id(self, rc_response_sets_id):\n\n self._rc_response_sets_id = rc_response_sets_id",
"def setID(self, id):\n self._id = id\n retur... | [
"0.6502312",
"0.62223506",
"0.60702217",
"0.6044452",
"0.603114",
"0.59509647",
"0.587993",
"0.5855515",
"0.58248156",
"0.58248156",
"0.58248156",
"0.58248156",
"0.58248156",
"0.58175635",
"0.5816122",
"0.5767343",
"0.57582766",
"0.57190806",
"0.57190806",
"0.57190806",
"0.57... | 0.0 | -1 |
Sets the customer_comment of this ChannelReturnResponse. | def customer_comment(self, customer_comment):
if (self.local_vars_configuration.client_side_validation and
customer_comment is not None and len(customer_comment) > 4001):
raise ValueError("Invalid value for `customer_comment`, length must be less than or equal to `4001`") # noqa: E5... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer(self, customer):\n if customer is None:\n raise ValueError(\"Invalid value for `customer`, must not be `None`\") # noqa: E501\n\n self._customer = customer",
"def customer(self, customer):\n\n self._customer = customer",
"def customer(self, customer):\n\n se... | [
"0.6495456",
"0.6428357",
"0.6428357",
"0.64145833",
"0.6283955",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.6139833",
"0.60955757",
"0.60955757",
"0.60955757",
"0.60955757",
"0.60454875",
"0.595792"... | 0.77025354 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ChannelReturnResponse):
return False
return self.to_dict() == other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, ChannelReturnResponse):
return True
return self.to_dict() != other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
... | 0.0 | -1 |
Returns a key having "version_number" as its name. | def GetKey(self, version_number):
return self.dict[str(version_number)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version_key(self, version):\n if self._generic_only:\n return GENERIC_VERSION\n else:\n self.check_version_exists(version)\n return version",
"def kms_key_version_name(self) -> str:\n return pulumi.get(self, \"kms_key_version_name\")",
"def key_vers... | [
"0.79072005",
"0.7538215",
"0.72869647",
"0.6993121",
"0.6867462",
"0.6741636",
"0.6617988",
"0.64844215",
"0.6324501",
"0.63166916",
"0.6312392",
"0.6282849",
"0.62616396",
"0.6225029",
"0.62159294",
"0.61619556",
"0.6107714",
"0.6094575",
"0.609297",
"0.6043491",
"0.6031558... | 0.88732076 | 0 |
get train_loader and test_loader | def getloader(self):
return self.train_loader, self.test_loader | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_loader(mode):\n\tglobal train_loader, valid_loader\n\tconfig = Config\n\ttransform_list_train = []\n\ttransform_list_test = []\n\tis_train = mode == \"train\"\n\tif config.train.use_augmentation:\n\t\ttransform_list_train.extend([transforms.Resize((config.data.image_size, config.data.image_size)), ImageNet... | [
"0.77100426",
"0.76738524",
"0.76040876",
"0.7384658",
"0.7363785",
"0.72057515",
"0.71765244",
"0.71735513",
"0.7090515",
"0.6992934",
"0.6848907",
"0.6813013",
"0.67717856",
"0.6755532",
"0.6742161",
"0.6734493",
"0.67340785",
"0.67340785",
"0.67340785",
"0.67340785",
"0.67... | 0.90590286 | 0 |
Create the number of hidden units in each layer if the HYPER_PARAMS.layer_sizes_scale_factor > 0 then it will use a "decay" mechanism to define the number of units in each layer. Otherwise, parameters.HYPER_PARAMS.hidden_units will be used asis. | def construct_hidden_units():
hidden_units = list(map(int, parameters.HYPER_PARAMS.hidden_units.split(',')))
if parameters.HYPER_PARAMS.layer_sizes_scale_factor > 0:
first_layer_size = hidden_units[0]
scale_factor = parameters.HYPER_PARAMS.layer_sizes_scale_factor
num_layers = parameter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def layers_sizes(self):\n return iter([self.delta_h*l for l in range(int(self.h/self.delta_h)-1)])",
"def get_hidden_layer_size(self):\r\n return self.hidden_layer_size",
"def init(InputUnits, OutputUnits, numHiddenLayer, HiddenUnits=None):\n global HiddenUnit\n all_weights = []\n ... | [
"0.6702567",
"0.64026886",
"0.6389147",
"0.6316787",
"0.6186162",
"0.61597973",
"0.6137765",
"0.6114793",
"0.61083937",
"0.6039899",
"0.6028688",
"0.6006836",
"0.59841716",
"0.5980518",
"0.5980518",
"0.5961161",
"0.5955761",
"0.5954433",
"0.5954433",
"0.5954433",
"0.5954433",... | 0.7744325 | 0 |
Connects node to topics for publish tau and extract dynamic parameters. | def run(self):
old_sampling = rospy.Time(0)
while not rospy.is_shutdown():
self.mutex.acquire()
reference_received = all(self.reference_flags.values())
if reference_received:
if not self.ready:
# first value of ni_ref
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish(self, node, topic, data={}, on_publish=None, on_response=None):\n pass",
"def publish_and_wait(self, node, topic, data={}):\n pass",
"def publish(self, node, topic, **kwargs):\n topic = self.generate_node_topic(node, topic)\n\n return self.publish_mqtt(topic, **kwargs)",... | [
"0.63137764",
"0.6111883",
"0.6041055",
"0.6023848",
"0.59356666",
"0.5801089",
"0.5713184",
"0.56949735",
"0.5686285",
"0.5680989",
"0.56607276",
"0.5635899",
"0.5633615",
"0.561198",
"0.560544",
"0.55918163",
"0.5556044",
"0.5550037",
"0.5547674",
"0.5534404",
"0.5524704",
... | 0.0 | -1 |
Token ids from Tokenizer vocab | def get_ids(self,tokens, tokenizer, max_seq_length):
token_ids = tokenizer.convert_tokens_to_ids(tokens,)
input_ids = token_ids + [0] * (max_seq_length-len(token_ids))
return input_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_to_token_ids(sentence, vocabulary):\n return [vocabulary.get(w, UNK_ID) for w in sentence.strip().split()]",
"def vectorize(tokens, vocab):\n ids = []\n for token in tokens:\n if token in vocab.tok2id:\n ids.append(vocab.tok2id[token])\n else:\n ids.appen... | [
"0.74453104",
"0.7427918",
"0.72003746",
"0.7193835",
"0.71358985",
"0.7134197",
"0.7128639",
"0.70729506",
"0.70416474",
"0.7035099",
"0.69734365",
"0.69675064",
"0.69156736",
"0.68288344",
"0.6781958",
"0.6779992",
"0.67489445",
"0.6704759",
"0.6686456",
"0.6618584",
"0.661... | 0.7092017 | 7 |
returns true if building is placeable at pos, else false | def building_isplaceable(self, building, pos):
x_pos, y_pos = pos
m = building.mask_full()
y_size, x_size = m.shape
if x_pos + x_size > AIV_SIZE or y_pos + y_size > AIV_SIZE:
return False
for x in range(0,x_size):
for y in range(0,y_size):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isPositionInRoom(self, pos):\n if pos in self.tiles:\n return True\n else:\n return False",
"def _can_place(self, loc):\n non_blocks = [_AIR, _WATER, _LAVA]\n player = [self._pos, self._pos + _Vec3(0, 1, 0)]\n for dir_ in _adj_dirs + [_Vec3(0, 1, 0), _... | [
"0.69598156",
"0.69421697",
"0.6878886",
"0.685575",
"0.67933196",
"0.67796236",
"0.6751459",
"0.6727748",
"0.6723218",
"0.66230464",
"0.66161877",
"0.66148025",
"0.66137296",
"0.6579545",
"0.65682584",
"0.65298176",
"0.6518893",
"0.651155",
"0.65102607",
"0.64806265",
"0.647... | 0.716373 | 0 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def haversine(lon1, lat1, lon2, lat2):
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
r = 6371... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.8146062",
"0.78638023",
"0.7632202",
"0.7604661",
"0.7595527",
"0.75950956",
"0.7592873",
"0.757031",
"0.7564319",
"0.75560796",
"0.75300086",
"0.7516366",
"0.7493803",
"0.746558",
"0.7450864",
"0.7432722",
"0.7391925",
"0.7355981",
"0.7347892",
"0.7330029",
"0.73271745",
... | 0.0 | -1 |
Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. | def open_and_read_file():
file_path = sys.argv[1]
#print file_path
file_data = open(file_path, 'r')
gettysburg = file_data.read()
return gettysburg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_and_read_file(file_path):\n\n # your code goes here\n text_file = open(file_path)\n text_string= text_file.read()\n text_file.close()\n return text_string",
"def open_and_read_file(file_path):\n\n text_file = open(file_path)\n full_text = text_file.read()\n\n return full_text",
... | [
"0.80703825",
"0.8048914",
"0.8015025",
"0.79924196",
"0.7922689",
"0.7865267",
"0.780107",
"0.768055",
"0.76599956",
"0.76151365",
"0.76083297",
"0.75717854",
"0.7540605",
"0.7529533",
"0.75045687",
"0.75038856",
"0.7500699",
"0.74132633",
"0.7371461",
"0.7362938",
"0.732943... | 0.0 | -1 |
Gives a list of bounding boxes containg faces in the given image | def get_faceboxes(self,img,threshold):
faces = self.mark_detector.extract_cnn_facebox(img,threshold)
faceboxes = []
for face in faces:
start = (face[0],face[1])
end = (face[2],face[3])
box = Box.setStartEnd(start,end)
faceboxes.append(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _box_faces(image):\n for face in image.faces:\n _box_face(image, face)\n return image",
"def get_faceboxes(self, image, threshold):\n rows, cols, _ = image.shape\n\n confidences = []\n faceboxes = []\n\n self.face_net.setInput(cv2.dnn.blobFromImage(image, 1.0, (300, 3... | [
"0.8085123",
"0.7980415",
"0.79564846",
"0.7850688",
"0.7760176",
"0.77158284",
"0.76029724",
"0.760038",
"0.75674653",
"0.7496214",
"0.74177533",
"0.74149823",
"0.7411155",
"0.727319",
"0.72631246",
"0.7260427",
"0.7202723",
"0.7196494",
"0.7174461",
"0.7151705",
"0.71304613... | 0.7947982 | 3 |
Define and evaluate the limit state functions that may be computationally expensive | def lsf_multimodal_function(theta):
y_out = -((theta[:, 0] ** 2 + 4) * (theta[:, 1] - 1) / 20 - np.sin(5 * theta[:, 0] / 2) - 2)
return y_out.reshape(y_out.shape[0], -1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPolicy(self, state):\n \"\"\"Description:\n Find all of q-values of current state, and choose the action \n with the hight q-value as optimal policy\n \"\"\"\n \"\"\" YOUR CODE HERE \"\"\"\n legalActions = self.getLegalActions(state)\n action = None\n policy = util.Counter() # us... | [
"0.60537744",
"0.5802507",
"0.57057804",
"0.570512",
"0.5688094",
"0.5668728",
"0.56588054",
"0.5634615",
"0.5567792",
"0.55573106",
"0.5543706",
"0.5541091",
"0.5526567",
"0.55199945",
"0.5508761",
"0.55018425",
"0.5476276",
"0.5455228",
"0.5455228",
"0.5450378",
"0.5447722"... | 0.0 | -1 |
Incorporate any useable fields in this record, and if it gives us a new true wind value, return it. | def transform(self, record):
if not record:
return None
if not type(record) is DASRecord:
logging.warning('Improper format record: %s',record)
return None
update = False
for field_name in record.fields:
if field_name in self.course_fields:
self.course_val = record.field... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wind_meta(self):\n return self.data.wind_meta",
"def wind(self):\n return self._wind",
"def _get_wred(self):\n return self.__wred",
"def _get_wred(self):\n return self.__wred",
"def _get_wred(self):\n return self.__wred",
"def calc_generation_wind_proposed (self):\n if s... | [
"0.5335317",
"0.52828914",
"0.52291673",
"0.52291673",
"0.52291673",
"0.51694596",
"0.49782172",
"0.49209738",
"0.49078652",
"0.48731014",
"0.48608252",
"0.48421362",
"0.48118705",
"0.4774674",
"0.47562644",
"0.47545525",
"0.4751787",
"0.4737342",
"0.47335005",
"0.472048",
"0... | 0.6221449 | 0 |
Return a dataset for testing the FieldLoader class. | def get_test_dataset_SetLoader(self, set_name='train'):
set_loader = self.load_hdf5_file_SetLoader(set_name)
set_data = self.dataset[set_name]
set_fields = self.data_fields[set_name]
return set_loader, set_data, set_fields | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_dataset_DataLoader(self):\n test_info = self.get_test_DataLoader_info()\n name = test_info[\"name\"]\n task = test_info[\"task\"]\n data_dir = test_info[\"data_dir\"]\n hdf5_file = test_info[\"hdf5_file\"]\n\n data_loader = DataLoader(name, task, data_dir, hdf... | [
"0.78888327",
"0.7603223",
"0.73044086",
"0.72188866",
"0.7082152",
"0.7069775",
"0.69244474",
"0.6873793",
"0.6871499",
"0.68013656",
"0.6789716",
"0.6701403",
"0.67012626",
"0.66969347",
"0.65904266",
"0.6579232",
"0.6568345",
"0.65629375",
"0.6548726",
"0.65372163",
"0.652... | 0.6751672 | 11 |
Return a dataset for testing the FieldLoader class. | def get_test_dataset_DataLoader(self):
test_info = self.get_test_DataLoader_info()
name = test_info["name"]
task = test_info["task"]
data_dir = test_info["data_dir"]
hdf5_file = test_info["hdf5_file"]
data_loader = DataLoader(name, task, data_dir, hdf5_file)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_data_FieldLoader(self, set_name='train', field='data'):\n path = \"/{set_name}/{field}\".format(set_name=set_name, field=field)\n field_loader = self.load_hdf5_file_FieldLoader(path)\n set_data = self.dataset[set_name]\n return field_loader, set_data",
"def test_dataloade... | [
"0.76030594",
"0.73050845",
"0.7218909",
"0.70823777",
"0.707011",
"0.6923885",
"0.6874425",
"0.68715763",
"0.680077",
"0.67888016",
"0.6751399",
"0.670098",
"0.67003936",
"0.66979426",
"0.6590271",
"0.6578667",
"0.65673375",
"0.6562923",
"0.6548202",
"0.65370923",
"0.6524199... | 0.7889583 | 0 |
Gets the type of this Scheduler. | def type(self):
return self._type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_type(self):\n return self._schedule_type",
"def get_type(self):\n return self._TYPE",
"def get_type (self):\n return self._stype",
"def get_type(self):\n return self._type",
"def get_type(self):\n return self._type",
"def get_type(self):\n return sel... | [
"0.8195117",
"0.71118546",
"0.71044254",
"0.70377827",
"0.70377827",
"0.7005059",
"0.698471",
"0.6981658",
"0.6981658",
"0.6939486",
"0.69035137",
"0.6889826",
"0.68877524",
"0.68441236",
"0.6835996",
"0.6827982",
"0.6810675",
"0.68067247",
"0.6794449",
"0.67832",
"0.6767924"... | 0.69478595 | 27 |
Sets the type of this Scheduler. | def type(self, type):
if type is None:
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
self._type = type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_type(self, schedule_type):\n\n self._schedule_type = schedule_type",
"def schedule_type(self, schedule_type):\n\n self._schedule_type = schedule_type",
"def set_type(self, type):\n self.type = type",
"def set_type(self, type):\n self.type = type",
"def set_type(self... | [
"0.80057335",
"0.80057335",
"0.75507337",
"0.75507337",
"0.7483278",
"0.7115609",
"0.7019111",
"0.70181847",
"0.69953287",
"0.6979536",
"0.6979536",
"0.695165",
"0.695165",
"0.69398105",
"0.69398105",
"0.69398105",
"0.69398105",
"0.69398105",
"0.69398105",
"0.69398105",
"0.69... | 0.6880235 | 43 |
Return the partial density of states | def get_partial_dos(self, full=False):
partial_dos = self.get_array('partial_dos')
if full:
return partial_dos
indices, weights = self._get_equivalent_atom_list(with_weights=True)
partial_dos = [partial * weight for weight, partial in zip(weights, partial_dos[indices])]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\r\n return self.count_ones() / float(self.xspan * self.yspan)",
"def getDensityOfStates(self, Elist):\n\t\treturn _modes.freerotor_densityofstates(Elist, self.frequencies, 1 if self.linear else 0)",
"def getDensityOfStates(self, Elist):\n\t\tpass",
"def getDensityOfStates(self, Elist):\... | [
"0.6990002",
"0.68468076",
"0.6540495",
"0.64641935",
"0.64567894",
"0.6429281",
"0.6427787",
"0.6427787",
"0.6427787",
"0.6426647",
"0.6402431",
"0.6341133",
"0.633433",
"0.6293956",
"0.62743706",
"0.62305063",
"0.61604667",
"0.6110642",
"0.6062941",
"0.6012021",
"0.5964267"... | 0.0 | -1 |
Returns true if no imaginary modes (shown as negative frequency DOS) | def is_stable(self, tol=1e-6):
import numpy as np
dos = self.get_dos()
freq = self.get_frequencies()
mask_neg = np.ma.masked_less(freq, 0.0).mask
mask_pos = np.ma.masked_greater(freq, 0.0).mask
if mask_neg.any() == False:
return True
if mask_pos.an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_imaginary(self):\r\n return self._real.is_zero()",
"def is_imaginary(self) -> bool:\n return self < 0",
"def is_real(self):\r\n return self._imag.is_zero()",
"def is_isotropic(self):\n return self.fibres is None",
"def is_zero(self):\r\n return self._real.is_zero()... | [
"0.7435767",
"0.7236454",
"0.70290595",
"0.677156",
"0.6736559",
"0.64063257",
"0.64053893",
"0.6321965",
"0.6316691",
"0.6256833",
"0.620375",
"0.615895",
"0.61450577",
"0.6060106",
"0.6021838",
"0.60216886",
"0.59767884",
"0.59512895",
"0.5950726",
"0.594923",
"0.5943724",
... | 0.0 | -1 |
Set all parameters of the model to 0 Parameters. layers_dims list, the number of layers of the model and the number of nodes corresponding to each layer Returns parameters a dictionary containing all W and b W1 weight matrix with dimension (layers_dims[1], layers_dims[0]) b1 bias vector, dimension (layers_dims[1], 1) W... | def initialize_parameters_zeros(layers_dims):
parameters = {}
# the number of layers
L = len(layers_dims)
for l in range(1, L):
parameters["W" + str(l)] = np.zeros((layers_dims[l], layers_dims[l - 1]))
parameters["b" + str(l)] = np.zeros((layers_dims[l], 1))
return parameters | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_parameters_random(layers_dims):\n # set random seed\n np.random.seed(3)\n parameters = {}\n L = len(layers_dims)\n\n for l in range(1, L):\n parameters['W' + str(l)] = np.random.randn(layers_dims[l], layers_dims[l - 1]) * 10\n parameters['b' + str(l)] = np.zeros((layers_... | [
"0.66994137",
"0.6524211",
"0.6484232",
"0.6440478",
"0.64257056",
"0.63918364",
"0.6384597",
"0.63792133",
"0.6360458",
"0.63285124",
"0.6324615",
"0.6255973",
"0.61910826",
"0.61910826",
"0.61910826",
"0.61248976",
"0.609352",
"0.6068253",
"0.6025813",
"0.6024569",
"0.59612... | 0.80968946 | 0 |
Compute instance mean and variance. | def _compute_instance_moments(x):
return torch.mean(x, dim=(2, 3), keepdim=True), torch.var(x, dim=(2, 3), keepdim=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_calculate_nhpp_mean_variance_inst_mean(self):\n\n _mean_var = calculate_nhpp_mean_variance(46, 3000.0, 0.332, 0.616, 2)\n self.assertAlmostEqual(_mean_var, 489.07164965)",
"def get_mean_and_variance(self):\n self._set_statistics()\n return self.statistics_object.get_mean(), s... | [
"0.7042789",
"0.7030097",
"0.684569",
"0.6785732",
"0.6705467",
"0.65460956",
"0.6473726",
"0.6455855",
"0.64296347",
"0.6423424",
"0.64022136",
"0.63945234",
"0.6373781",
"0.6314979",
"0.6271918",
"0.6263915",
"0.62379485",
"0.6202545",
"0.61835915",
"0.6181711",
"0.6178875"... | 0.7274688 | 0 |
RadiationModel() returns a DataFrame of which the size depends on the input. The time resolution for the output is a quarter ("15T") by default but can be changed with the "TimeResolution" parameter. | def __init__(self, t0, t1, hours=("00:00", "23:45"),
forecast_zones="DK", norm=False, TimeResolution="15T"):
self.t0 = t0
self.t1 = t1
self.muni_input = forecast_zones
self.norm = norm
self.Time = TimeResolution
self.fc_zones = self._muni_interpr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_TTR(self) -> pd.DataFrame:\n\n # user options\n res = self.options.resolution\n dim = self.options.dimension\n\n # sample the corpus\n x_choices = (np.arange(res) + 1) / res\n TTR = [self.sample(x=x).as_datarow(dim) for x in x_choices]\n\n # save to sel... | [
"0.566602",
"0.55865186",
"0.55567604",
"0.55247164",
"0.5453741",
"0.54424953",
"0.5365442",
"0.5311694",
"0.5263339",
"0.52498996",
"0.5234416",
"0.52332824",
"0.52237743",
"0.52104026",
"0.5177271",
"0.515588",
"0.5075149",
"0.50734264",
"0.5069924",
"0.5063935",
"0.506119... | 0.0 | -1 |
Returns the total number of documents, DELETED OR UNDELETED, in this reader. | def doc_count_all(self):
return self.index.collection.count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_number_of_documents(self):\n return self.total_number_of_documents",
"def doc_count(self):\n\t\treturn self.index.collection.count()",
"def count_deleted(self):\n count = 0\n for _, e in self.contents.items():\n count = count + e.count_deleted()\n return cou... | [
"0.7694914",
"0.7510874",
"0.7456718",
"0.74369824",
"0.7400394",
"0.7376454",
"0.7318653",
"0.70306486",
"0.6979551",
"0.69476104",
"0.6910956",
"0.68551785",
"0.6845533",
"0.67889684",
"0.67852783",
"0.67809534",
"0.675962",
"0.6714335",
"0.6646297",
"0.66243535",
"0.661896... | 0.7317203 | 7 |
Returns the total number of UNDELETED documents in this reader. | def doc_count(self):
return self.index.collection.count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_deleted(self):\n count = 0\n for _, e in self.contents.items():\n count = count + e.count_deleted()\n return count",
"def count_deleted(self): # EntryList.count_deleted\n count=0\n for name, e in self.contents.iteritems():\n count = co... | [
"0.774052",
"0.7685259",
"0.7200083",
"0.71623373",
"0.6974863",
"0.69508916",
"0.68825483",
"0.6874336",
"0.67723584",
"0.65331846",
"0.6532005",
"0.64764756",
"0.64342594",
"0.6419995",
"0.64097446",
"0.639157",
"0.63764316",
"0.6351271",
"0.63395876",
"0.62947416",
"0.6248... | 0.65769726 | 9 |
This method is used to convert a given pd.Series object into a list | def series_to_list(series: pd.Series) -> List:
list_cols = []
for item in series:
list_cols.append(item)
return list_cols | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_list(self):\n return SeriesDefault.register(pandas.Series.to_list)(self)",
"def _to_list(series: Union[TimeSeries, Sequence[TimeSeries]]) -> Sequence[TimeSeries]:\n\n return [series] if not isinstance(series, Sequence) else series",
"def to_real_series(self, data: pd.Series) -> pd.Series:\n ... | [
"0.8163235",
"0.8084659",
"0.67696327",
"0.6688192",
"0.6478346",
"0.6332372",
"0.63315487",
"0.63113815",
"0.6291304",
"0.6289916",
"0.6243208",
"0.6221836",
"0.62096226",
"0.6204572",
"0.6184458",
"0.6167135",
"0.6163509",
"0.61454004",
"0.61151385",
"0.6111333",
"0.608589"... | 0.80512226 | 2 |
Fetches a block from IOTA with an address. Since IOTA does not support exactly blocks, what is fetched is all the transactions of an address which are then sorted based on their timestamps and then concatenated in one block. | def fetch(self, address: str, log: Logger) -> Block:
def get_transactions(address: str) -> Iterable['Transaction']:
adapter = self._iota_api.adapter
return find_transaction_objects(adapter, addresses=[address])
def get_signature_string(t: 'Transaction') -> str:
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fetch(self, address: str, latest: bool = False) -> None:\n try:\n # Fetch block from the ledger\n self._address_index[address] = self._connector.fetch(address,\n self._logger)\n # Add block to the registry\... | [
"0.63075423",
"0.6130317",
"0.60563076",
"0.59326637",
"0.5903281",
"0.590054",
"0.5893151",
"0.5886603",
"0.58753556",
"0.5863715",
"0.57891095",
"0.57841134",
"0.57321405",
"0.57314",
"0.5723248",
"0.5698044",
"0.56945467",
"0.56176645",
"0.55606705",
"0.5559356",
"0.550265... | 0.7177153 | 0 |
Set a Qvalue for a given (observation, action) pair | def __setitem__(self, key: tuple, value: float):
s, a = key
if not isinstance(s, self.observation_space) or not isinstance(a, self.action_space):
raise KeyError
self.store.setdefault(s, dict())[a] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_action_value(self, state, action, value):\n self.value_function[to_table_index(state, action)] = value",
"def update_qvals(self, state, action, reward):\n self.qvals[(state, action)] = 0",
"def Q(self, observation, action):\n return self[observation, action]",
"def updateQValu... | [
"0.7207835",
"0.7086363",
"0.7083719",
"0.70424414",
"0.6665662",
"0.65934515",
"0.64996874",
"0.64944345",
"0.6423975",
"0.6421755",
"0.6347077",
"0.63399047",
"0.633607",
"0.6334427",
"0.63263094",
"0.6285045",
"0.6201128",
"0.6188193",
"0.6188193",
"0.6188193",
"0.6188193"... | 0.5894809 | 47 |
Read an image into a numpy array given the path of a H5 file. | def read_image_from_h5(h5_path, *args, **kwargs):
# TODO: Implement the method
h5_pathRd = h5.File(h5_path, "a")
image = h5_pathRd["data"]["image"]
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(path: Union[Path, str]) -> np.ndarray:\n return _reader.imread(str(path))",
"def read_data(path):\n with h5py.File(path, 'r') as hf:\n data = np.array(hf.get('data'))\n return data",
"def load_h5_file(file_path):\n # load\n fr = h5py.File(file_path, 'r')\n a_group_key = list(fr.... | [
"0.7554185",
"0.75005555",
"0.73265314",
"0.73265314",
"0.72788644",
"0.7277284",
"0.72648257",
"0.72648257",
"0.7202138",
"0.71711314",
"0.7156384",
"0.7148705",
"0.713533",
"0.71084225",
"0.7078591",
"0.701594",
"0.69675314",
"0.6962734",
"0.69086313",
"0.6829945",
"0.67954... | 0.74092174 | 2 |
Returns the hostname and record type of the record. | def extract_query(pkt):
request = DNSRecord.parse(pkt)
# Extract the hostname
qname = request.q.qname
hostname = str(qname)
# Remove tailing period (artifact of the dnslib)
if hostname[-1] == '.':
hostname = hostname[:-1]
# Record type
qtype = QTYPE.get(request.q.qtype)
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRecord(self, rr):\n\t\tif rr.type == 1: return {'type': 'a', 'ipv4': socket.inet_ntoa(rr.rdata), 'hostname': rr.name}\n\t\telif rr.type == 28: return {'type': 'aaaa', 'ipv6': socket.inet_ntop(socket.AF_INET6, rr.rdata), 'hostname': rr.name}\n\t\telif rr.type == 5: return {'type': 'cname', 'hostname': rr.nam... | [
"0.7288703",
"0.638681",
"0.6237808",
"0.6174709",
"0.59828585",
"0.5811655",
"0.5811644",
"0.5750304",
"0.5713665",
"0.56564605",
"0.56298727",
"0.5611728",
"0.5604755",
"0.5574632",
"0.5544346",
"0.552044",
"0.551721",
"0.54946756",
"0.54894084",
"0.54869735",
"0.54860216",... | 0.57737625 | 7 |
Area of the shape. | def area(self) -> float:
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n return self._ned_shape.area",
"def area(self):\n return self.length*self.length",
"def area(self):\n area = self.__size * self.__size\n return area",
"def area(self):\n area = self.__size * self.__size\n return(area)",
"def area(self):\n ar... | [
"0.859661",
"0.8539494",
"0.8486993",
"0.84419984",
"0.8439382",
"0.8387308",
"0.83254606",
"0.8314752",
"0.8312584",
"0.8241274",
"0.8237015",
"0.8232725",
"0.821546",
"0.821546",
"0.821546",
"0.8212535",
"0.8212535",
"0.8206858",
"0.8191822",
"0.8187152",
"0.8187152",
"0.... | 0.853149 | 2 |
Check if the point is inside the shape. Support semantics like `if point in shape` | def __contains__(self, point: Point2D) -> bool:
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isInside(point_x, point_y, area_left, area_top, area_width, area_height):\n return (area_left <= point_x < area_left + area_width) and (area_top <= point_y < area_top + area_height)",
"def point_in_poly(x_point: float, y_point: float) -> bool:\n\n # Semi-F47 extended states all devices should be able t... | [
"0.7572516",
"0.75540507",
"0.7464582",
"0.7464582",
"0.74356055",
"0.74341583",
"0.73613477",
"0.73446983",
"0.732574",
"0.732574",
"0.72910684",
"0.72736067",
"0.721901",
"0.7183408",
"0.7174966",
"0.7172073",
"0.7092216",
"0.7086525",
"0.7081146",
"0.7063076",
"0.70347816"... | 0.6834352 | 40 |
Implementation for Gaussian blur to reduce noise and detail in the image | def blur_gaussian(channel, ksize=3):
return cv2.GaussianBlur(channel, (ksize, ksize), 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_blur(self,img):\n return cv2.GaussianBlur(img, (self.kernel_size, self.kernel_size), 0)",
"def __gaussian_blur(self, img, kernel_size=3):\n return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)",
"def reblur(inp_img):\n\n img = np.array(inp_img)\n kernel_deviation = 1.5\n... | [
"0.81383604",
"0.81237864",
"0.7887736",
"0.7797448",
"0.77877295",
"0.7773531",
"0.77326",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0.77160615",
"0... | 0.6984415 | 54 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# Get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
while True:
city = input('Would you like to see data for Chicago, New York City or Washington?')
if city.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.6670955",
"0.65355206",
"0.64598334",
"0.6373697",
"0.63487226",
"0.6310236",
"0.6287051",
"0.6259993",
"0.62314963",
"0.62125754",
"0.62053525",
"0.61813915",
"0.6171331",
"0.6169096",
"0.61588687",
"0.6158631",
"0.6153347",
"0.6144922",
"0.6131542",
"0.6105515",
"0.61029... | 0.0 | -1 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month='all', day='all'):
df = pd.read_csv(CITY_DATA[city.lower()]).rename(columns={'Unnamed: 0': 'Trip Id'})
cols = df.columns
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['Month'] = df['Start Time'].dt.month
df['Day of Week'] = df['Start Time'].dt.dayofweek
df['St... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8108889",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7956163",
"0.7947432",
"0.79463065",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.7889219",
"0.788254... | 0.8045821 | 2 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# display the most common month
aux = df[['Month','Start Time']].groupby('Month').count()['Start Time']
month_max = aux.idxmax()
month_max_cnt = aux.max()
print("Most common month was... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.8023522",
"0.802221",
"0.7914353",
"0.7826378",
"0.7821697",
"0.78140223",
"0.7765606",
"0.7739828",
"0.7735833",
"0.7733764",
"0.7686237",
"0.76675326",
"0.7651101",
"0.7644171",
"0.7639292",
"0.7636152",
"0.76248395",
"0.76227194",
"0.7611663",
"0.7599656",
"0.75825727",... | 0.7194641 | 71 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# display most commonly used start station
aux = df[['Start Station','Start Time']].groupby('Start Station').count()['Start Time']
station_max = aux.idxmax()
station_max_cnt = aux.max... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815998",
"0.7661799",
"0.755378",
"0.74918276",
"0.74751854",
"0.7446441",
"0.7429881",
"0.74239737",
"0.7417978",
"0.74006975",
"0.73876286",
"0.7385986",
"0.7365314",
"0.73597723",
"0.7356932",
"0.7355265",
"0.7352331",
"0.7351879",
"0.73507756",
"0.734247",
"0.734072",... | 0.0 | -1 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# display total travel time
val = df['Trip Duration'].sum()/3600
print("Total trip duration was {:.2f} hours".format(val))
# display mean travel time
val = df['Trip Duration'].mean()/60
pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.8144002",
"0.8025936",
"0.80051756",
"0.7950414",
"0.7938244",
"0.7932019",
"0.7927543",
"0.79160506",
"0.7915316",
"0.79089457",
"0.79064983",
"0.7901538",
"0.7892409",
"0.7890379",
"0.7887529",
"0.78859615",
"0.78849727",
"0.7883412",
"0.78750104",
"0.7869431",
"0.786734... | 0.78604645 | 25 |
Creates a new nest operator. The set of keys is initially empty. If the map or entries operator is invoked before any key functions are registered, the nest operator simply returns the input array. | def __init__(self):
self._keys = []
self._sortKeys = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree():\n return defaultdict(tree)",
"def auto_nest(func):\n def wrapper(tensors, *args, **kwargs):\n return tf.nest.map_structure(\n lambda x: func(x, *args, **kwargs), tensors)\n return wrapper",
"def _tree():\n return collections.defaultdict(_tree)",
"def __create_nested_structure(ne... | [
"0.50510037",
"0.5038567",
"0.4854392",
"0.48375788",
"0.47468472",
"0.4714622",
"0.4705582",
"0.47014457",
"0.46549824",
"0.4628407",
"0.46255538",
"0.46242553",
"0.45791712",
"0.45502764",
"0.4549578",
"0.44959244",
"0.4480521",
"0.44716427",
"0.44619203",
"0.44552702",
"0.... | 0.0 | -1 |
Given a full Learner and Team population, where each Team points to two unique Learners, randomly add existing Learners to each Team until that Team reaches its full complement. | def fillTeamsInPopulation(self):
for team in self.team_pop:
while len(team.learners) < team.max_size:
learners = [l for l in self.learner_pop if l not in team.learners]
if len(learners) == 0:
break
else:
learner ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializeTeam(self):\n\n # Create two new Learners with different atomic actions\n a1 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n while a1 == a2:\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n\n l1 = Learner(action ... | [
"0.6198892",
"0.60099727",
"0.5909377",
"0.5602736",
"0.5578461",
"0.5570028",
"0.55162257",
"0.54663473",
"0.54535234",
"0.5446338",
"0.5419894",
"0.5384661",
"0.53839433",
"0.537948",
"0.53772473",
"0.53582704",
"0.53372985",
"0.53203225",
"0.5301221",
"0.5300238",
"0.52959... | 0.71697813 | 0 |
We use heapq class to implement Heaps in Python. By default Min Heap is implemented by this class. But we multiply each value by 1 so that we can use it as MaxHeap. | def addNum(self, num: int) -> None:
small, large = self.heaps
# push to small first by default
heapq.heappush(large, -heapq.heappushpop(small, -num))
# keep size even (let len(small) >= len(large))
if len(large) > len(small):
val = heapq.heappop(larg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.max_heap = [] # to contain left smaller half, or + 1\n self.min_heap = [] # to contain right bigger half",
"def __init__(self):\n # max_heap stores smaller half\n # min_heap stores larger half\n self.heaps = ([], [])",
"def min_heap(self): \n \n ... | [
"0.76983464",
"0.7662596",
"0.74752456",
"0.7363196",
"0.7337437",
"0.7319882",
"0.72922516",
"0.72666025",
"0.7229037",
"0.7225333",
"0.72153676",
"0.7207476",
"0.7174666",
"0.71282834",
"0.704995",
"0.70068634",
"0.7000654",
"0.6952775",
"0.68923765",
"0.6872462",
"0.684775... | 0.0 | -1 |
Method to delete the failing tests from the schema.yml. | def delete_failed_tests_from_schema(
self, path_file: Path, model_name: str, tests_to_delete: Dict[str, List[str]]
):
content = open_yaml(
path_file,
preserve_yaml_order=self._sugar_config.config.get("preserve_yaml_order", False),
)
for model in content["model... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n with app.app_context():\n db = app.db.get_db()\n cur = db.cursor()\n with app.open_resource('sql/drop_tests.sql', mode='r') as f:\n cur.execute(f.read())\n db.commit()\n cur.close()\n db.close()",
"def t... | [
"0.7157708",
"0.6840837",
"0.6840837",
"0.6744383",
"0.67398924",
"0.6644065",
"0.663067",
"0.6602651",
"0.66019326",
"0.65678084",
"0.65678084",
"0.65678084",
"0.65678084",
"0.6532619",
"0.65185887",
"0.6497793",
"0.6494446",
"0.6491216",
"0.64835113",
"0.648288",
"0.6480997... | 0.7389425 | 0 |
Return the other player, for a player PLAYER numbered 0 or 1. >>> other(0) 1 >>> other(1) 0 | def other(player):
return 1 - player | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def otherPlayer(cls, player):\n return 0 if player == 1 else 1",
"def other_player(cls, player):\n return 0 if player == 1 else 1",
"def other_player(self, player):\n if player == self.__opponent:\n return self.__pid\n else:\n return self.__opponent",
"def __... | [
"0.81847143",
"0.81327176",
"0.79256344",
"0.7875795",
"0.7709813",
"0.7093842",
"0.68455774",
"0.6804346",
"0.66201985",
"0.66201985",
"0.6579255",
"0.6476013",
"0.64561236",
"0.64236355",
"0.6390737",
"0.63760537",
"0.6363144",
"0.6363144",
"0.6335515",
"0.62314063",
"0.619... | 0.780577 | 5 |
Applies the logistic function to x, elementwise. | def sigmoid(X):
return 1 / (1 + np.exp(-X)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logistic(self,w,Xi):\n # print(w.T)\n # print(Xi)\n a = np.dot(w.T,Xi)\n return 1/(1+np.exp(-a))",
"def logistic(self, X, w):\n g = 1 / (1 + np.exp(-X.dot(w)))\n return g",
"def forward(self, x):\n\n embeds = self.dvector(x)\n logits = self.linear(emb... | [
"0.7002704",
"0.6978957",
"0.6883872",
"0.68210745",
"0.6803985",
"0.6706345",
"0.66907454",
"0.6664395",
"0.6663363",
"0.66488755",
"0.664373",
"0.660833",
"0.6597647",
"0.6596353",
"0.6534404",
"0.64707106",
"0.64558506",
"0.64442515",
"0.64267933",
"0.6374905",
"0.6363094"... | 0.0 | -1 |
Set up each webpage with a header and navigation bar. | def setup_page(
self, html_page, links, label=None, title=None, approximant=None,
background_colour=None, histogram_download=False
):
html_file = webpage.open_html(
web_dir=self.webdir, base_url=self.base_url, html_page=html_page,
label=label
)
html_fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_webpages(self):\n if self.add_to_existing:\n self.add_existing_data()\n self.make_home_pages()\n self.make_1d_histogram_pages()\n self.make_corner_pages()\n self.make_config_pages()\n if self.make_comparison:\n self.make_comparison_pages(... | [
"0.6627888",
"0.6465586",
"0.62752324",
"0.6114537",
"0.6103888",
"0.606285",
"0.60445887",
"0.6036751",
"0.60337174",
"0.6021009",
"0.5930741",
"0.5924869",
"0.5913862",
"0.58483374",
"0.5833003",
"0.58251595",
"0.57794666",
"0.57769567",
"0.57743686",
"0.5753638",
"0.575228... | 0.6815308 | 0 |
Make a navbar for the homepage | def make_navbar_for_homepage(self):
links = [
"home", ["Result Pages", self._result_page_links()], "Version"
]
if len(self.samples) > 1:
links[1][1] += ["Comparison"]
if self.publication:
links.insert(2, "Publication")
if self.gwdata is not Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_nav():\n return render_template('home.html')",
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def index():\n return render_template(\n 'index.html',\n nav=nav,\n title='Home Page',\n year=datetime... | [
"0.736893",
"0.67783135",
"0.6750848",
"0.66524625",
"0.6623326",
"0.6588633",
"0.6580005",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.6562279",
"0.653496",
"0.6521001",
"0.6503073",
"0.64983183",
... | 0.71998024 | 1 |
Make a navbar for the result page homepage | def make_navbar_for_result_page(self):
links = {
i: ["1d Histograms", [{"Custom": i}, {"All": i}]] for i in self.labels
}
for num, label in enumerate(self.labels):
for j in self.categorize_parameters(self.samples[label].keys()):
j = [j[0], [{k: label} for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_navbar_for_homepage(self):\n links = [\n \"home\", [\"Result Pages\", self._result_page_links()], \"Version\"\n ]\n if len(self.samples) > 1:\n links[1][1] += [\"Comparison\"]\n if self.publication:\n links.insert(2, \"Publication\")\n if... | [
"0.80170983",
"0.7169193",
"0.6690814",
"0.6587678",
"0.6552421",
"0.6529632",
"0.65201473",
"0.65188295",
"0.64830226",
"0.6469217",
"0.64192796",
"0.64133656",
"0.6382045",
"0.6367651",
"0.63470757",
"0.63470757",
"0.63470757",
"0.63470757",
"0.63470757",
"0.63470757",
"0.6... | 0.6568194 | 4 |
The ``.git`` directory for the current project. | def git_directory(delegator):
return delegator("git rev-parse --git-dir") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGitPath() -> osp:\n current_dir = osp.dirname(osp.realpath(__file__))\n git_dir = osp.dirname(osp.dirname(current_dir))\n return git_dir",
"def get_git_dir(tree):\n\n return os.path.join(tree, \".git\")",
"def git_dir():\n return subprocess.check_output([\"git\", \"rev-parse\", \"--git-di... | [
"0.83023816",
"0.8015751",
"0.7522234",
"0.74142706",
"0.70690876",
"0.7059461",
"0.70178574",
"0.6930033",
"0.68814874",
"0.6830864",
"0.67350674",
"0.6637658",
"0.64931214",
"0.64922035",
"0.6490604",
"0.64626306",
"0.646249",
"0.64517623",
"0.6420175",
"0.63963944",
"0.638... | 0.66105205 | 12 |
Creates a model, given the type of model and the output method. Adds the output layer with activation corresponding to the output type after the constructed model. This allows for easy switching between binary and multiclass classification, and prevents us from having to implement two types of each model. The model is ... | def create_model(model_type: str, input_size: Tuple[int, ...], output='binary', summary=True) -> keras.Model:
if model_type in MODELS:
inputs, outputs = MODELS[model_type](input_size)
else:
raise ValueError(f'Model type "{model_type}" not supported')
if output == 'binary':
activatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_model(input_dim, hidden_neurons, output_dim):\n\tmodel = Sequential([\n \tDense(hidden_neurons, input_dim=input_dim),\n Activation('relu'),\n Dropout(0.2),\n Dense(hidden_neurons),\n Activation('relu'),\n Dropout(0.2),\n Dense(output_dim, activation='softmax')... | [
"0.6704527",
"0.66973925",
"0.66615975",
"0.66041964",
"0.6572064",
"0.6570199",
"0.6549063",
"0.647823",
"0.6476947",
"0.6459976",
"0.6454561",
"0.6407263",
"0.64054805",
"0.638561",
"0.63830036",
"0.63781667",
"0.63442785",
"0.6344052",
"0.6315975",
"0.6313631",
"0.63134235... | 0.71340376 | 0 |
The function ``is_admin`` detects whether the calling process is running with administrator/superuser privileges. It works crossplatform on either Windows NT systems or Unixbased systems. | def is_admin():
if os.name == 'nt':
try:
# Only Windows users with admin privileges can read
# the C:\windows\temp directory.
os.listdir(os.sep.join([os.environ.get('SystemRoot','C:\\windows'),'temp']))
except:
return False
else:
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin():\n if platform_is(WINDOWS):\n return windll.shell32.IsUserAnAdmin()\n return os.getuid() == 0",
"def is_admin():\n # type: () -> bool\n current_os_name = os.name\n\n # Works with XP SP2 +\n if current_os_name == \"nt\":\n try:\n return IsUserAnAdmin()\n ... | [
"0.8821815",
"0.8732962",
"0.8634657",
"0.80681646",
"0.78383905",
"0.7656703",
"0.75744766",
"0.7562517",
"0.75570256",
"0.74586576",
"0.74525267",
"0.74387234",
"0.74240386",
"0.74240386",
"0.74135554",
"0.73537236",
"0.7341056",
"0.73286927",
"0.7305158",
"0.7260963",
"0.7... | 0.79539204 | 4 |
Set `password_hash` only when `password` is not set. | def _create(cls, model_class, *args, **kwargs):
assert 'password' in kwargs
assert 'passwd_hash' in kwargs
if kwargs.get('password'):
kwargs.pop('passwd_hash')
return super()._create(model_class, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_password_hash(self, password):\n salt = bcrypt.gensalt()\n self.password_hash = bcrypt.hashpw(password.encode(), salt)",
"def hash_password(self, password):\n self.password_hash = generate_password_hash(password)",
"def set_password(self, password):\n self.password = self.ha... | [
"0.7201298",
"0.7091728",
"0.70867187",
"0.6961345",
"0.69605434",
"0.69136447",
"0.6894837",
"0.6894837",
"0.68855447",
"0.6867788",
"0.68643236",
"0.6862712",
"0.68401206",
"0.68401206",
"0.68401206",
"0.68401206",
"0.67581147",
"0.6730123",
"0.6710391",
"0.6706543",
"0.668... | 0.0 | -1 |
If the input URL contains a port number, strip it out | def rewrite_url(line):
url_list = line.split(' ')
old_url = url_list[0]
new_url = '\n'
# http://192.168.1.13/biedronka_logo.jpg 192.168.1.100/192.168.1.100 - GET myip=- myport=3128
if old_url.endswith('jpg') or old_url.endswith('.jpeg'):
filename = str(uuid.uuid4())+".jpg"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_empty_port():\n assert (normalize_url(\"http://www.example.com:/\") ==\n \"http://www.example.com/\")",
"def test_remove_default_port():\n assert (normalize_url(\"http://www.example.com:80/bar.html\") ==\n \"http://www.example.com/bar.html\")\n assert (normalize_url... | [
"0.7776715",
"0.7397051",
"0.6689824",
"0.6589313",
"0.650951",
"0.650275",
"0.6461937",
"0.6428155",
"0.64266",
"0.6361706",
"0.6282323",
"0.62341475",
"0.61968756",
"0.6188919",
"0.6155203",
"0.6127684",
"0.61132604",
"0.60064256",
"0.59795815",
"0.5977992",
"0.5977227",
... | 0.0 | -1 |
Transformer blocks which includes multihead attention layer and mlp block | def __init__(self, num_heads, D, hidden_layers, dropout=0.1, norm_eps=1e-12):
super(TransformerBlock, self).__init__()
# Attention
self.attention = MultiHeadAttention(
num_heads=num_heads, key_dim=D, dropout=dropout
)
self.norm_attention = LayerNormalization(epsilon=n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_model_multihead_attention_multiscaleCNN4_covermore(self,\n dim_attention,headnum,\n embedding_vec,\n load_weights=False, weight_dir=None,\n nb_filter... | [
"0.6663586",
"0.6597379",
"0.64268494",
"0.6360674",
"0.6338788",
"0.6257444",
"0.6235589",
"0.6209039",
"0.60610014",
"0.59759337",
"0.59740186",
"0.59430027",
"0.590821",
"0.5900392",
"0.58956826",
"0.5895034",
"0.58770245",
"0.58639365",
"0.5794944",
"0.5788988",
"0.576384... | 0.6992421 | 0 |
Commit the current local SQLAlchemy session (created with L{db_session_localize} on this widget) and remove/close the session, making the global session visible to this widget and descendant widgets again. You might want to do self.db_session.expire() after this to make any changes to your local session visible in the ... | def db_session_commit_and_globalize(self):
self.db_session.commit()
self.session.worm_localized.remove(self.db_session)
del self.db_session
# FIXME: Update all nested localized sessions.
self.db_session.expire_all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_session_rollback_and_globalize(self):\n self.db_session.rollback()\n self.session.worm_localized.remove(self.db_session)\n del self.db_session",
"def save_before_close(self):\n if self.db_window:\n self.db_window.destroy()\n self.destroy()",
"def commit(self... | [
"0.67239785",
"0.66214174",
"0.64808667",
"0.64619935",
"0.63480055",
"0.6337384",
"0.6296969",
"0.6253922",
"0.6190622",
"0.612898",
"0.6086176",
"0.6084393",
"0.6043479",
"0.598818",
"0.59869117",
"0.5958185",
"0.59485453",
"0.5934197",
"0.5917074",
"0.5917074",
"0.5917074"... | 0.78256214 | 0 |
Rollback the current local SQLAlchemy session (created with L{db_session_localize} on this widget) and remove/close the session, making the global session visible to this widget and descendant widgets again. | def db_session_rollback_and_globalize(self):
self.db_session.rollback()
self.session.worm_localized.remove(self.db_session)
del self.db_session | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_session_commit_and_globalize(self):\n self.db_session.commit()\n self.session.worm_localized.remove(self.db_session)\n del self.db_session\n # FIXME: Update all nested localized sessions.\n self.db_session.expire_all()",
"def _close(self):\n if self.__session is n... | [
"0.69830817",
"0.6831465",
"0.6580956",
"0.63987786",
"0.63065374",
"0.6255354",
"0.6255354",
"0.6255354",
"0.62003577",
"0.619857",
"0.61350036",
"0.60096955",
"0.6001342",
"0.5989135",
"0.59747803",
"0.59709346",
"0.59528714",
"0.5927543",
"0.5882605",
"0.58783174",
"0.5874... | 0.78382546 | 0 |
Context manager for a temporary directory. This is similar to tempfile.TemporaryDirectory in python>=3.2. | def _temporary_directory():
name = tempfile.mkdtemp()
try:
yield name
finally:
shutil.rmtree(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_temp_dir():\n directory = tempfile.mkdtemp()\n try:\n yield directory\n finally:\n shutil.rmtree(directory)",
"def tempdir():\n\n class ctx(object):\n\n def __enter__(self):\n self.prevdir = os.getcwd()\n self.tempdir = tempfile.mkdtemp()\n ... | [
"0.8151143",
"0.80606616",
"0.79753256",
"0.79536724",
"0.79371685",
"0.79356587",
"0.79355663",
"0.7912876",
"0.78649515",
"0.78183824",
"0.7785393",
"0.7777123",
"0.77747816",
"0.7705706",
"0.7695398",
"0.7673213",
"0.7660842",
"0.76580966",
"0.7650998",
"0.7628625",
"0.761... | 0.8148666 | 1 |
Create a SageMaker ``TensorFlowModel`` object that can be deployed to an ``Endpoint``. | def create_model(self, model_server_workers=None, role=None,
vpc_config_override=VPC_CONFIG_DEFAULT, endpoint_type=None):
role = role or self.role
if endpoint_type == 'tensorflow-serving' or self._script_mode_enabled():
return self._create_tfs_model(role=role, vpc_confi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self) -> tf.keras.models.Model:\n raise NotImplementedError()",
"def _make_model(self):\n self._model = tf.estimator.Estimator(model_fn=self.model_fn,\n model_dir=self.model_dir,\n config=self._config... | [
"0.6819635",
"0.65104693",
"0.6498425",
"0.64926046",
"0.64838105",
"0.6425016",
"0.63994265",
"0.63273954",
"0.63156533",
"0.6306389",
"0.61792016",
"0.6173705",
"0.6173564",
"0.61605144",
"0.6146582",
"0.6115818",
"0.607953",
"0.6077646",
"0.60186505",
"0.6012362",
"0.59610... | 0.7037425 | 0 |
Returns True if row and col are valid values | def valid_input(self, row, col):
return ((row, col) not in self.marks and
row <= WIDTH and row > 0 and
col in COL_MAP) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid(self,row,col) -> bool:\n if(row >=0 and col>=0 and row<self.row and col<self.col and self.array[row][col]==-1 ):\n return True\n return False",
"def is_valid(self):\n if self.get_row() != -1 and self.get_column() != -1:\n return True\n else:\n ... | [
"0.8091675",
"0.80864257",
"0.7924023",
"0.78902096",
"0.7659951",
"0.75877786",
"0.7548906",
"0.75047547",
"0.7499336",
"0.74562085",
"0.74394834",
"0.7436682",
"0.7368682",
"0.7337169",
"0.73290545",
"0.73265445",
"0.7304924",
"0.7300693",
"0.7293138",
"0.7280832",
"0.72412... | 0.8213445 | 0 |
Returns true if a tie exists on this board | def tie_exists(self):
return len(self.marks) == 9 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_tie(board):\n return 0 not in board[0]",
"def game_tie(self):\n\n shape = self.board.shape\n if np.count_nonzero(self.board) == (shape[0] * shape[1]):\n # The board is full\n player = 0\n return True\n else:\n return False",
"def _is... | [
"0.7543741",
"0.74421966",
"0.7174385",
"0.7158319",
"0.70751244",
"0.6951705",
"0.6935137",
"0.6933638",
"0.68399227",
"0.6839235",
"0.67778605",
"0.66985226",
"0.6692007",
"0.6671597",
"0.6668072",
"0.66296566",
"0.6591076",
"0.655537",
"0.65299284",
"0.6523104",
"0.6508229... | 0.75141263 | 1 |
poll_git.filter_dict Utility method to remove all keys from a dict except those in the key set | def _filter_dict(src_dict, key_set):
for k in set(src_dict.keys()) - key_set:
src_dict.pop(k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cleanse_dict(original):\n return {k: v for k, v in original.items() if \"_pass\" not in k}",
"def _cleanse_dict(original):\n return dict((k, v) for k, v in original.items() if \"_pass\" not in k)",
"def clean_dict(dictionary):\n return {k: v for k, v in dictionary.items() if v}",
"def clean_dic... | [
"0.7563569",
"0.7440057",
"0.7419116",
"0.7418322",
"0.740843",
"0.73695225",
"0.72462183",
"0.72018117",
"0.71871424",
"0.7120856",
"0.7070811",
"0.70674783",
"0.70619494",
"0.70096827",
"0.69330645",
"0.69295365",
"0.6927854",
"0.6914809",
"0.69089794",
"0.6890785",
"0.6881... | 0.81835246 | 0 |
Converts the education experience to a single int representing the minimum qualifications held. This is one higher than the EducationLevel values (0 = no education, 1 = certification, etc.) | def min_edu_level(self) -> int:
if len(self._history_edus) == 0:
return 0
# add one since allocating 0 for 'none'
return int(max([e.education_lvl for e in self._history_edus])) + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_experience(self) -> int:\n return self._base_experience",
"def min_weight(self):\n return self.experiences.min_weight",
"def scoreEducation(self, employee_ed, name):\n\n university = self.university\n schools = [school for school in name if school != \"\"]\n rank = [... | [
"0.6091574",
"0.60766613",
"0.5663413",
"0.5663034",
"0.5594252",
"0.5542864",
"0.5542864",
"0.54906315",
"0.5470742",
"0.54238975",
"0.5421171",
"0.53634584",
"0.5359417",
"0.5359417",
"0.5327927",
"0.5322198",
"0.53167486",
"0.5293654",
"0.5291187",
"0.5285667",
"0.5284425"... | 0.7296643 | 0 |
A string to represent the age of this post. | def age(self) -> str:
tdelta = dt.now() - self.created_timestamp
if tdelta.days >= 548: # enough to round it up to 2 years
return f'about {tdelta.days/365:.0f} years'
elif tdelta.days >= 345: # enough to round it up to 1 year (so it doesn't report '12 months')
return f'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def age(self):\n\n years, months, days = calculate_age(self.birthdate)\n if years:\n return \"%d year%s old\" % (years, \"s\" if years > 1 else \"\")\n elif months:\n return \"%d month%s old\" % (months, \"s\" if months > 1 else \"\")\n else:\n return \"... | [
"0.82187986",
"0.77554965",
"0.7717731",
"0.7594224",
"0.7593773",
"0.7579443",
"0.75256914",
"0.7522066",
"0.7522066",
"0.7522066",
"0.75171536",
"0.7515912",
"0.74829715",
"0.74518067",
"0.74498564",
"0.7447325",
"0.7446756",
"0.73713535",
"0.7241897",
"0.7241897",
"0.71139... | 0.8177297 | 1 |
Return the index of the blank square in a given state | def find_blank_square(self, state):
return state.index(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_empty_space(self, state):\r\n for i in range(3):\r\n for j in range(3):\r\n if state[i][j] == 0:\r\n return (i, j)",
"def _state_index(state):\n delta_y, delta_x, bird_lmh, pipe_lmh, is_flapping = state\n actions, height, width, _, _, _ =... | [
"0.7701521",
"0.72728777",
"0.66417044",
"0.6527599",
"0.6459278",
"0.64067525",
"0.63600284",
"0.6277902",
"0.6268305",
"0.62539375",
"0.6250342",
"0.6234354",
"0.62124133",
"0.6211223",
"0.61981434",
"0.61808527",
"0.6180443",
"0.61688066",
"0.6149172",
"0.61204535",
"0.610... | 0.8688786 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.