query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Creates a label colormap used in PASCAL VOC segmentation benchmark. Returns A colormap for visualizing segmentation results. | def create_pascal_label_colormap(num_classes=21):
def bit_get(val, idx):
"""
Gets the bit value.
Parameters
----------
val: int or numpy int array
Input value.
idx:
Which bit of the input val.
Returns
-------
The "idx"-t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_label_colormap():\n colormap = np.array([\n [128, 64, 128],\n [244, 35, 232],\n [ 70, 70, 70],\n [102, 102, 156],\n [190, 153, 153],\n [153, 153, 153],\n [250, 170, 30],\n [220, 220, 0],\n [107, 142, 35],\n [152, 251, 152],... | [
"0.8371343",
"0.72954524",
"0.7129402",
"0.7120766",
"0.7120766",
"0.71196634",
"0.71113145",
"0.70651746",
"0.70651746",
"0.6849834",
"0.6723233",
"0.6723233",
"0.66840845",
"0.66840845",
"0.66831684",
"0.6637538",
"0.64252156",
"0.63807845",
"0.63168275",
"0.62440175",
"0.6... | 0.6896598 | 9 |
Gets the bit value. | def bit_get(val, idx):
return (val >> idx) & 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBit(self,i):\n return self.boolVals[i]",
"def get_bit(self):\n try:\n current_byte = self.contents[self.current_bit_position >> 3]\n except IndexError:\n raise EmptyStreamError(f\"Attempting read at bit position {self.current_bit_position} \"\n ... | [
"0.7660222",
"0.76436466",
"0.7623698",
"0.73997563",
"0.736371",
"0.72016805",
"0.71770066",
"0.7171173",
"0.71067333",
"0.70789784",
"0.70352",
"0.7029353",
"0.70293",
"0.6998789",
"0.68690395",
"0.6852962",
"0.6816802",
"0.67196685",
"0.6667597",
"0.66084266",
"0.6577516",... | 0.73543143 | 5 |
Generate a random color name (string) | def _rand_color(self):
return self._rand_elem(COLOR_NAMES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_color():\n r = lambda: random.randint(0, 255)\n color = ('%02X%02X%02X' % (r(), r(), r()))\n return color",
"def getrandomcolor(self) -> str:\n return self.tab10[random.randint(0, len(self.tab10)-1)]",
"def generateColor(text):\n random.seed(text)\n return ('#%06X' % random.ran... | [
"0.79987806",
"0.7786565",
"0.75885475",
"0.75320965",
"0.74076486",
"0.73553854",
"0.7335833",
"0.7316281",
"0.7240394",
"0.72199",
"0.7218885",
"0.71967876",
"0.7173117",
"0.708695",
"0.70380276",
"0.6991115",
"0.6942665",
"0.6911017",
"0.6905815",
"0.69028956",
"0.6855608"... | 0.7503278 | 4 |
Transform a length1 Variable or Tensor to scalar. Suppose tx is a torch Tensor with shape tx.size() = torch.Size([1]), then npx = tx.cpu().numpy() has shape (1,), not 1. | def to_scalar(vt):
if isinstance(vt, Variable):
return vt.data.cpu().numpy()[0]
if torch.is_tensor(vt):
return vt.cpu().numpy()[0]
raise TypeError('Input should be a variable or tensor') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tensor2scalar(x):\n if isinstance(x, float):\n return x\n return x.cpu().detach().item()",
"def scalar(val: torch.Tensor):\n return val.item()",
"def to_scalar(vt):\n if isinstance(vt, Variable):\n return vt.data.cpu().numpy().flatten()[0]\n if torch.is_tensor(vt):\n return vt.cpu()... | [
"0.71861416",
"0.70074224",
"0.6975095",
"0.6552168",
"0.6501481",
"0.6420787",
"0.63840985",
"0.6335328",
"0.6235296",
"0.61965",
"0.6170892",
"0.61136335",
"0.6018982",
"0.601414",
"0.59351593",
"0.5935049",
"0.59052634",
"0.5888919",
"0.58878505",
"0.5885977",
"0.58684844"... | 0.70033467 | 2 |
Get the max column width in a `Worksheet` column. | def get_column_width(worksheet: Worksheet, column: int) -> Optional[int]:
strings = getattr(worksheet, '_ts_all_strings', None)
if strings is None:
strings = worksheet._ts_all_strings = sorted(
worksheet.str_table.string_table,
key=worksheet.str_table.string_table.__getitem__)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excel_max_col(self, sheet_name):\n return self.wb[sheet_name].max_column",
"def max_width_col(table, col_idx):\n return max(len(row[col_idx]) for row in table)",
"def max_col(self):\n return self.screen.getmaxyx()[1]",
"def get_column_width(self, index):\n return self.colwid[i... | [
"0.7521142",
"0.7510542",
"0.7009785",
"0.69534314",
"0.67698085",
"0.66685605",
"0.6668467",
"0.66195625",
"0.65575737",
"0.6552253",
"0.6489405",
"0.64654773",
"0.6451523",
"0.6375112",
"0.63489753",
"0.6307389",
"0.62916064",
"0.6285491",
"0.62225217",
"0.6219399",
"0.6203... | 0.7598595 | 0 |
Inits the colour san and any comment of the ply | def __init__(self, colour, san, nags=[], comment="", variations=[]):
self.colour = colour
self.san = san
self.nags = self.nodes_to_nags(nags)
self.comment = comment
self.variations = variations | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.red = 0\n self.black = 0",
"def __init__(self):\n self.colors = (\n 'BLACK', 'RED', 'GREEN', 'YELLOW',\n 'BLUE', 'MAGENTA', 'CYAN', 'WHITE'\n )\n\n self.disable_color = True\n\n if sys.stdout.isatty():\n self.di... | [
"0.61455804",
"0.60723376",
"0.6018521",
"0.6007782",
"0.6004217",
"0.5998522",
"0.5998522",
"0.599362",
"0.59719056",
"0.5970706",
"0.5970706",
"0.5970706",
"0.59613603",
"0.5949006",
"0.59257257",
"0.59200835",
"0.5850054",
"0.5850054",
"0.5850054",
"0.5850054",
"0.5850054"... | 0.639621 | 0 |
returns an image of same shape as data but with zero where there are false mask values | def get_sub_image(data, mask, mask_false_value=False):
# TODO: ask about error handling!!! Also this method might be useless!
assert data.shape == mask.shape
return np.where(mask, mask_false_value, data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mask(shape):\n return np.zeros(shape).astype(bool)",
"def zeros_like(data):\n return _make.zeros_like(data)",
"def rb_erosion(image,size,origin=-1):\n return cv2.erode(image.astype(uint8), brick(size))\n # output = zeros(image.shape,'f')\n # filters.uniform_filter(image,size,output=ou... | [
"0.6812456",
"0.6532914",
"0.64393103",
"0.64352137",
"0.6391473",
"0.6346276",
"0.6332731",
"0.6319373",
"0.6315237",
"0.630499",
"0.62711406",
"0.626246",
"0.62139374",
"0.6193369",
"0.61910397",
"0.6179891",
"0.61689097",
"0.61538535",
"0.6134241",
"0.6120186",
"0.6093556"... | 0.652114 | 2 |
Lists the qos given a tenant_id and qos_id. | def get_qos(tenant_id, qos_id):
LOG.debug("get_qos() called")
session = db.get_session()
try:
return (session.query(network_models_v2.QoS).
filter_by(tenant_id=tenant_id).
filter_by(qos_id=qos_id).one())
except exc.NoResultFound:
raise c_exc.QosNotFound(qo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_qos(self, qos_id):\n url = \"qos-specs/%s\" % qos_id\n resp, body = self.get(url)\n body = json.loads(body)\n self.validate_response(schema.show_qos, resp, body)\n return rest_client.ResponseBody(resp, body)",
"def list_qos(self):\n url = 'qos-specs'\n re... | [
"0.7581823",
"0.69052064",
"0.69043237",
"0.66892624",
"0.6669575",
"0.6562861",
"0.64035887",
"0.5966863",
"0.59558743",
"0.59502834",
"0.5846988",
"0.5820116",
"0.56879693",
"0.5587535",
"0.55622625",
"0.55401415",
"0.5497485",
"0.54749566",
"0.54670936",
"0.5430894",
"0.54... | 0.73914516 | 1 |
Adds a qos to tenant association. | def add_qos(tenant_id, qos_name, qos_desc):
LOG.debug("add_qos() called")
session = db.get_session()
try:
qos = (session.query(network_models_v2.QoS).
filter_by(tenant_id=tenant_id).
filter_by(qos_name=qos_name).one())
raise c_exc.QosNameAlreadyExists(qos_name=q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_qos(self, qos):\n \n qos_id = qos[\"ovsdb:qos-entries\"][0][\"qos-id\"]\n self.qos_dict[qos_id] = qos",
"def associate_qos(self, qos_id, vol_type_id):\n url = \"qos-specs/%s/associate\" % qos_id\n url += \"?vol_type_id=%s\" % vol_type_id\n resp, body = self.get(u... | [
"0.76679295",
"0.6903344",
"0.6661703",
"0.6486012",
"0.636095",
"0.62336963",
"0.59865934",
"0.59587973",
"0.5945562",
"0.59273165",
"0.5915752",
"0.5861309",
"0.5839892",
"0.57792497",
"0.5756636",
"0.57531077",
"0.5751835",
"0.57466877",
"0.5723024",
"0.57029676",
"0.56681... | 0.6661759 | 2 |
Updates a qos to tenant association. | def update_qos(tenant_id, qos_id, new_qos_name=None):
session = db.get_session()
try:
qos = (session.query(network_models_v2.QoS).
filter_by(tenant_id=tenant_id).
filter_by(qos_id=qos_id).one())
if new_qos_name:
qos["qos_name"] = new_qos_name
ses... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_qos(self, arg, qos):\n\n if isinstance(arg, (list, tuple)):\n for job_id in arg:\n self.change_qos(job_id, qos)\n\n elif isinstance(arg, int):\n cmd = 'update job {} QOS={}'.format(arg, qos)\n self.scontrol(cmd)\n\n elif str(arg).lower... | [
"0.6175666",
"0.6121091",
"0.6115384",
"0.60210353",
"0.59004664",
"0.58427036",
"0.5790823",
"0.57454324",
"0.5560308",
"0.547326",
"0.54158705",
"0.5392609",
"0.52221525",
"0.51610255",
"0.5153999",
"0.51252204",
"0.50820154",
"0.5081609",
"0.5064825",
"0.5059684",
"0.50291... | 0.6552799 | 0 |
Get an existing Pipeline resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name, id, opts=None, arn=None, artifact_store=None, name=None, role_arn=None, stages=None, tags=None):
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
__props__ = dict()
__props__["arn"] = arn
__props__["artifact_store"] = artifact_store
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None,\n arn: Optional[pulumi.Input[str]] = None,\n auth_mode: Optional[pulumi.Input[str]] = None,\n default_s3_location: Optional[pulumi.Input[str]] = None,\n ... | [
"0.6305254",
"0.61387646",
"0.56281024",
"0.5586482",
"0.55844057",
"0.55741394",
"0.551912",
"0.55107915",
"0.5498641",
"0.5496618",
"0.54916704",
"0.54544765",
"0.54535544",
"0.5427976",
"0.5392241",
"0.53568965",
"0.53271633",
"0.5322272",
"0.53044796",
"0.5270195",
"0.526... | 0.6562569 | 0 |
Rotates the given 3d point cloud 90 degrees around the x axis | def rotate_3dcloud(cloud):
theta = np.radians(90)
c, s = np.cos(theta), np.sin(theta)
Rx = np.array(((1,0,0),(0, c, -s), (0, s, c)))
return cloud.dot(Rx.T) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_point_cloud(data):\n rotated_data = np.zeros(data.shape, dtype=np.float32)\n for k in xrange(data.shape[0]):\n rotation_angle = np.random.uniform() * 2 * np.pi\n cosval = np.cos(rotation_angle)\n sinval = np.sin(rotation_angle)\n rotation_matrix ... | [
"0.6988909",
"0.6859488",
"0.6859488",
"0.65736806",
"0.6572166",
"0.65294546",
"0.6521064",
"0.6520874",
"0.64929926",
"0.64891005",
"0.64838374",
"0.6478546",
"0.6478546",
"0.6478546",
"0.6465489",
"0.64528424",
"0.64390886",
"0.6427741",
"0.6421523",
"0.6421523",
"0.642152... | 0.6628356 | 3 |
Create a Pandas dataframe with a column 'file' for the path to a file and a column 'hash' with the corresponding hash identifier. | def create_table(folder: str, ext: str = None, pre: bool = False) -> pd.DataFrame:
folder = format_path(folder)
input_files = filelist(folder, ext=ext)
if pre is True:
input_files = preselect(input_files)
summary_df = pd.DataFrame(columns=['file', 'hash'])
summary_df['file'] = input_files... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_file_dataframe():\n \n row_names_link = [\"NA\"] * MAX_NUM_OF_FILES\n row_names_name = [\"NA\"] * MAX_NUM_OF_FILES\n row_names_down = [\"NA\"] * MAX_NUM_OF_FILES\n \n for i in range(MAX_NUM_OF_FILES):\n row_names_link[i] = \"link_\" + str(i + 1)\n row_names_name[i] = \"name... | [
"0.6847703",
"0.6580882",
"0.61827743",
"0.61161786",
"0.5830665",
"0.55097944",
"0.5502549",
"0.5456555",
"0.54528195",
"0.54449123",
"0.54145837",
"0.5407093",
"0.53744996",
"0.5346042",
"0.53375924",
"0.5331756",
"0.5331626",
"0.5316205",
"0.5297161",
"0.5281166",
"0.52734... | 0.69450814 | 0 |
Save a Pandas dataframe as a csv file. | def save_csv(csv_path: str, duplicates: pd.DataFrame) -> None:
csv_file = os.path.join(csv_path, 'duplicates.csv')
duplicates.to_csv(csv_file, index=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_dataframe(dataframe, filename):\n with open(filename, \"w\", encoding=\"utf8\") as outfile: \n dataframe.to_csv(outfile, sep=\",\")",
"def save_df(data_frame, file_path):\r\n data_frame.to_csv(file_path)\r\n return None",
"def save(df, save_preprocessed_dataframe_path, name):\n\n df... | [
"0.84590364",
"0.845661",
"0.80258167",
"0.7936627",
"0.78414655",
"0.7782067",
"0.77090317",
"0.7700652",
"0.7698997",
"0.7671506",
"0.76549876",
"0.7622764",
"0.760874",
"0.7559522",
"0.7543665",
"0.7543623",
"0.7522902",
"0.7515388",
"0.7513179",
"0.7495856",
"0.73869336",... | 0.70139176 | 43 |
Get Centroid position and bbox of the arrow from the passed frame. | def track(self, frame):
mask = self.get_arrow_mask(frame)
label = skimage.measure.label(mask)
props = skimage.measure.regionprops(label)
arrow = max(props, key=lambda prop: prop.area)
yc, xc = arrow.centroid
self.position_list.append((xc, yc))
y0, x0, y1, x1 = ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_bounding_box(self, frame, bounding_offset):\n\n # Try to find board if the boundingbox is not set\n center, ellipse, mask = self.board.detect(frame)\n\n # Should not be None\n if center is None:\n print(\"skipping frame\")\n return None\n if ellipse... | [
"0.65665007",
"0.64398456",
"0.6312674",
"0.624233",
"0.6002025",
"0.5979414",
"0.597255",
"0.59622365",
"0.5958608",
"0.595108",
"0.59473926",
"0.5869504",
"0.5827211",
"0.5808636",
"0.58039224",
"0.57288116",
"0.5724164",
"0.56998104",
"0.56894743",
"0.5684186",
"0.5680054"... | 0.65241843 | 1 |
Convert a Tensor to numpy image. | def convert_image_np(inp):
inp = inp.numpy().transpose((1, 2, 0))
inp = (inp*255).astype(np.uint8)
return inp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_tensor_to_numpy_img(tensor_img):\n\n img = tensor_img.to('cpu').clone().detach()\n img = img.numpy().squeeze(0)\n img = img.transpose(1, 2, 0)\n img = img * np.array((0.229, 0.224, 0.225)) + np.array((0.485, 0.456, 0.406))\n img = img.clip(0, 1)\n return img",
"def tensor_to_image(i... | [
"0.7923916",
"0.75331163",
"0.7380131",
"0.73709023",
"0.7288476",
"0.7271192",
"0.7246783",
"0.7202921",
"0.6994109",
"0.69590163",
"0.69450575",
"0.693309",
"0.69328296",
"0.68642205",
"0.6773001",
"0.65329295",
"0.6524601",
"0.64803165",
"0.6468088",
"0.64457154",
"0.64424... | 0.6585984 | 15 |
Merge two deep dicts nondestructively. Uses a stack to avoid maximum recursion depth exceptions. base the dict to merge into upd the content to merge inplace change base if True, otherwise deepcopy base the merged dict (base if inplace else a merged deepcopy) | def dict_merge(base, upd, inplace=False):
assert quacks_like_dict(base), quacks_like_dict(upd)
dst = base if inplace else deepcopy(base)
stack = [(dst, upd)]
while stack:
current_dst, current_src = stack.pop()
for key in current_src:
if key not in current_dst:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_merge(a, b):\n assert quacks_like_dict(a), quacks_like_dict(b)\n dst = a.copy()\n\n stack = [(dst, b)]\n while stack:\n current_dst, current_src = stack.pop()\n for key in current_src:\n if key not in current_dst:\n current_dst[key] = current_src[key]\n ... | [
"0.7371871",
"0.7318391",
"0.71878237",
"0.6993153",
"0.6970671",
"0.6918322",
"0.6883084",
"0.6863656",
"0.68599135",
"0.68251836",
"0.6817568",
"0.6792345",
"0.6772972",
"0.6769716",
"0.6745883",
"0.6727938",
"0.6691694",
"0.6664593",
"0.66587853",
"0.6653672",
"0.66496587"... | 0.7791856 | 0 |
Returns standard ION representation of a global timestamp. It is defined as a str representing an integer number, the millis in UNIX epoch | def get_ion_ts():
return str(current_time_millis()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_timestamp():\n return str(int(time.time()))",
"def __timestamp():\n today = time.time()\n return struct.pack(b'=L', int(today))",
"def _timestamp():\n moment = time.time()\n moment_us = repr(moment).split(\".\")[1]\n return time.strftime(\"%Y-%m-%d-%H-%M-%S-{}\".format(moment_us)... | [
"0.78894067",
"0.7457427",
"0.7408313",
"0.7392758",
"0.7392219",
"0.73362887",
"0.7290596",
"0.7282857",
"0.72792107",
"0.7228847",
"0.7207158",
"0.718562",
"0.7181414",
"0.7170238",
"0.71603805",
"0.71603805",
"0.71252406",
"0.71214956",
"0.70965195",
"0.7067296",
"0.702363... | 0.78545314 | 1 |
Returns a datatime instance in either local time or GMT time based on the given ION timestamp ts ION timestamp (str with millis in epoch) local_time if True, returns local time (default), otherwise GMT datetime instance | def get_datetime(ts, local_time=True):
tsf = float(ts) / 1000
timev = time.localtime(tsf) if local_time else time.gmtime(tsf)
dt = datetime.datetime.fromtimestamp(time.mktime(timev))
return dt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UTCtimestampTolocal(ts, local_tz):\n t_utc = dt.datetime.fromtimestamp(ts,tz=pytz.timezone(\"UTC\"))\n t_local = t_utc.astimezone(local_tz)\n return t_local",
"def timestampfromlocal(local):\n return local.timestamp()",
"def aware_local_from_timestamp(timestamp):\n return datetime.fromti... | [
"0.65604126",
"0.64219886",
"0.6173313",
"0.6058731",
"0.60378045",
"0.601892",
"0.59705204",
"0.59258825",
"0.5863314",
"0.5854993",
"0.57953864",
"0.5745442",
"0.56473917",
"0.5637418",
"0.56247044",
"0.5580136",
"0.5525696",
"0.5515893",
"0.5512142",
"0.53866893",
"0.53562... | 0.7573783 | 0 |
Returns a string with date and time representation from an ION timestamp ts ION timestamp (str with millis in epoch) show_millis If True, appends the milli seconds local_time if True, returns local time (default), otherwise GMT str with ION standard date and time representation | def get_datetime_str(ts, show_millis=False, local_time=True):
dt = get_datetime(ts, local_time)
dts = str(dt)
if show_millis:
dts += "." + ts[-3:]
return dts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamp():\n my_date_object = datetime.utcnow()\n my_date_string = my_date_object.strftime('%d-%m-%Y %H:%M:%S')\n return my_date_string",
"def get_ion_ts():\n return str(current_time_millis())",
"def _get_timestamp() -> str:\n\n dt = timezone(\"UTC\").localize(datetime.utcnow()).strfti... | [
"0.634518",
"0.63072026",
"0.6263306",
"0.623856",
"0.6204276",
"0.6168413",
"0.61587757",
"0.61571795",
"0.6135762",
"0.6124623",
"0.6078285",
"0.60761523",
"0.60649204",
"0.6045621",
"0.6045621",
"0.60408926",
"0.60345703",
"0.6026348",
"0.60098404",
"0.5986088",
"0.5845086... | 0.7348694 | 0 |
Returns all subclasses that have no further subclasses, for the given class | def getleafsubclasses(cls):
scls = itersubclasses(cls)
return [s for s in scls if not s.__subclasses__()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_subclasses(python_class):\n python_class.__subclasses__()\n\n subclasses = set()\n check_these = [python_class]\n\n while check_these:\n parent = check_these.pop()\n for child in parent.__subclasses__():\n if child not in subclasses:\n subclasses.add(... | [
"0.75766647",
"0.7500465",
"0.7500465",
"0.75004375",
"0.7275418",
"0.72545564",
"0.7155931",
"0.707242",
"0.70386314",
"0.70339954",
"0.7019465",
"0.7015464",
"0.69866544",
"0.6960531",
"0.6862481",
"0.6859642",
"0.68474334",
"0.68047214",
"0.67582136",
"0.6756596",
"0.67411... | 0.8076825 | 0 |
Initializes Mailer class with the email account credentials and recipient information | def __init__(self, user, password, _recipients, templatedir='templates'):
self.user = user
self.password = password
self.recipient = _recipients if type (_recipients) is list else [_recipients]
self.server = 'smtp.gmail.com'
self.port = 587
if os.path.isdir(templatedir)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, mailhost, username, password, fromaddr, toaddrs, subject):\r\n logging.handlers.SMTPHandler.__init__(self, mailhost, fromaddr, toaddrs, subject)\r\n self.username = username\r\n self.password = password",
"def __init__(self, *args, **kwargs):\n super().__init__(*arg... | [
"0.7384663",
"0.7037052",
"0.6990069",
"0.6833254",
"0.67692137",
"0.67580754",
"0.6697198",
"0.6651598",
"0.6643156",
"0.655713",
"0.6537559",
"0.6518616",
"0.6473443",
"0.6387266",
"0.636401",
"0.6324007",
"0.6317948",
"0.6307721",
"0.6245826",
"0.6222716",
"0.6181867",
"... | 0.73935467 | 0 |
Equality with different type | def test_equal_with_different_type():
assert_false(Vector(1.0) == 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_equal_same_type(self, other):\n return True",
"def __eq__(self, other):\r\n\t\treturn (self.type == other.type and self.value == other.value)",
"def __eq__(self, other):\n\n return self.type == other.type and self.value == other.value",
"def __eq__(self, other):\r\n\r\n return t... | [
"0.7852633",
"0.77951753",
"0.77177143",
"0.77074623",
"0.7703581",
"0.746359",
"0.74566114",
"0.74249566",
"0.73746264",
"0.7339633",
"0.7285347",
"0.7277359",
"0.7203298",
"0.7194574",
"0.7171086",
"0.71593046",
"0.71366084",
"0.7127086",
"0.70912284",
"0.7076218",
"0.70716... | 0.6891199 | 83 |
Dot product of two vectors | def test_dot():
assert_equal(dot(Vector(3.0, 2.0), Vector(2.0, -1.0)), 4.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y))",
"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 dotproduct(vec1, v... | [
"0.8688895",
"0.86587024",
"0.86350816",
"0.8631175",
"0.861646",
"0.8581014",
"0.8580933",
"0.8529882",
"0.8509719",
"0.8441795",
"0.8423987",
"0.84158",
"0.84066904",
"0.84055364",
"0.8401772",
"0.8383433",
"0.835288",
"0.834979",
"0.83385503",
"0.8335736",
"0.825806",
"0... | 0.72647065 | 78 |
Cross product of two vectors | def test_cross():
assert_equal(cross(Vector(1, 0, 0), Vector(0, 1, 0)), Vector(0, 0, 1))
assert_equal(cross(Vector(1, 3, 2), Vector(-1, 1, 0)), Vector(-2, -2, 4)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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] - a[1] * b[0]]",
"def cross_product(v1, v2):\n return cg3d_vector.CG3dVector(\n v1[1] * v2[2] - v2[1] * v1[2],\n v1[2] * v2[0] - v2[2] * v1[0],\n v1[0] * v2[1] - v2... | [
"0.84413624",
"0.83118844",
"0.8216175",
"0.8093725",
"0.8064643",
"0.799129",
"0.7918299",
"0.789285",
"0.7865209",
"0.78616273",
"0.7831348",
"0.78068763",
"0.7749392",
"0.77108514",
"0.7671456",
"0.7617378",
"0.751008",
"0.74876124",
"0.7477015",
"0.72882897",
"0.7271123",... | 0.7147474 | 22 |
Dot multiply vectors of different sizes | def test_dot_different_sizes():
dot(Vector(1.0), Vector(2.0, 3.0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y))",
"def vec_dot(v1,v2):\r\n \r\n return np.dot(v1,v2)",
"def dot_vectors(u, v):\n return u[0] * v[0] + u[1] * v[1] + u[2] * v[2]",
"def dotproduct(vec1, vec2):\n import operator\n return sum(map(operator.mul, vec1, vec2))",
"def ... | [
"0.8152717",
"0.80416536",
"0.7960907",
"0.7951767",
"0.7882876",
"0.7858175",
"0.78225684",
"0.77345407",
"0.7731231",
"0.7728193",
"0.76553446",
"0.7628323",
"0.76004446",
"0.759744",
"0.75751984",
"0.75567514",
"0.75200075",
"0.75078756",
"0.74696136",
"0.7438956",
"0.7438... | 0.79848766 | 2 |
Returns the environment.muse section of the landscape configuration or None. | def environment_muse(self) -> dict:
return self._environment_muse | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environment(self):\r\n return self.mcas[0].get_environment()",
"def env(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:\n return pulumi.get(self, \"env\")",
"def get_current_profile_extent(request):\n\n # Get the path of the yaml\n path = local_profile_directory_path... | [
"0.59781986",
"0.55586517",
"0.53833765",
"0.5346253",
"0.5324262",
"0.52005893",
"0.51779133",
"0.5158542",
"0.5130403",
"0.51116496",
"0.5106515",
"0.51041687",
"0.51000446",
"0.50623345",
"0.49795467",
"0.49782184",
"0.49754784",
"0.49736145",
"0.49619412",
"0.49569994",
"... | 0.6648855 | 0 |
Returns a boolean indicating if the landscape contains upnp devices. | def has_upnp_devices(self) -> bool:
return self._has_upnp_devices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_home(self):\n return bool([\n device for device in self.devices\n if device.is_home and device.is_phone\n ])",
"def available(self) -> bool:\n if self._avm_wrapper.devices[self._mac].wan_access is None:\n return False\n return super().available"... | [
"0.59324116",
"0.58147484",
"0.5706958",
"0.5594201",
"0.55695426",
"0.55402786",
"0.5522446",
"0.5468499",
"0.54653525",
"0.5430056",
"0.54087704",
"0.5387172",
"0.5361747",
"0.5361559",
"0.53540444",
"0.5345028",
"0.5341719",
"0.5339771",
"0.53366345",
"0.5309829",
"0.52951... | 0.7247105 | 0 |
Returns the list of device configurations from the landscape. This will | def get_device_configs(self) -> List[dict]:
device_config_list = self._internal_get_device_configs()
return device_config_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _internal_get_device_configs(self) -> List[dict]:\n\n device_config_list = []\n\n self.landscape_lock.acquire()\n try:\n pod_info = self._landscape_info[\"pod\"]\n for dev_config_info in pod_info[\"devices\"]:\n if \"skip\" in dev_config_info and dev_co... | [
"0.7526751",
"0.67574996",
"0.65783674",
"0.60727847",
"0.6045593",
"0.5849141",
"0.58141524",
"0.57985526",
"0.5751021",
"0.5729486",
"0.56721574",
"0.56657636",
"0.5659087",
"0.56452674",
"0.5644081",
"0.56112856",
"0.55938596",
"0.5593033",
"0.557351",
"0.5530513",
"0.5505... | 0.66185087 | 2 |
Creates and returns a list of devices that are found to correspond to the match criteria provided. If a 'count' parameter is passed then the number of devices returned is limited to count devices. | def list_devices_by_match(self, match_type, *match_params, count=None) -> List[LandscapeDevice]:
matching_devices = []
device_list = self.get_devices()
for dev in device_list:
if dev.match_using_params(match_type, *match_params):
matching_devices.append(dev)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_available_devices_by_match(self, match_type, *match_params, count=None) -> List[LandscapeDevice]:\n matching_devices = []\n device_list = self.list_available_devices()\n\n for dev in device_list:\n if dev.match_using_params(match_type, *match_params):\n match... | [
"0.6925827",
"0.6863699",
"0.64958715",
"0.6330233",
"0.6143849",
"0.6124236",
"0.6038158",
"0.60300946",
"0.58948445",
"0.5881054",
"0.58646935",
"0.5860529",
"0.58603466",
"0.58545065",
"0.5818669",
"0.58179855",
"0.57488114",
"0.5746134",
"0.5703334",
"0.56888694",
"0.5685... | 0.70539224 | 0 |
returns the average energy vector | def ex1_get(alpha,beta,pace,delta):
filename = seed+"/ex_sim_a"+str(alpha)+"_p"+str(pace)+"_d"+str(delta)+".tmp"
# get the avg_energy vector
avg_energy = [0]*(T+1)
file = open(filename,'r')
for _ in range(K):
file.readline() # the first line contains T
for t in range(T+1):
e_t = float(file.readline().s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_mean(self):\n return self._get_conditional_negative_energy()",
"def compute_energy(self):\n energy = 0.5 * self.masses * np.sum(self.velocities * self.velocities, axis=1)\n avg_energy = np.mean(energy) # average kinetic energy of all particles\n return avg_energy",
"def en... | [
"0.7660614",
"0.76469445",
"0.7587964",
"0.7261214",
"0.72512436",
"0.71023947",
"0.7101984",
"0.709022",
"0.7041264",
"0.702773",
"0.6978445",
"0.6936997",
"0.69261336",
"0.6899432",
"0.68606806",
"0.68448985",
"0.67899376",
"0.6782148",
"0.6777283",
"0.67763686",
"0.6739625... | 0.6323033 | 80 |
Display an area chart. This is just syntaxsugar around st.altair_chart. The main difference is this command uses the data's own column and indices to figure out the chart's spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. If st.area_chart does not guess the dat... | def area_chart(
self,
data: "Data" = None,
*,
x: Union[str, None] = None,
y: Union[str, Sequence[str], None] = None,
color: Union[str, Color, None] = None,
width: int = 0,
height: int = 0,
use_container_width: bool = True,
) -> "DeltaGenerator"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(\n self,\n x: Hashable | None = None,\n y: Hashable | None = None,\n stacked: bool = True,\n **kwargs,\n ) -> PlotAccessor:\n return self(kind=\"area\", x=x, y=y, stacked=stacked, **kwargs)",
"def test_area_defaults():\n cdata = json.loads(CliRunner().invo... | [
"0.7082768",
"0.65933675",
"0.65834683",
"0.63872176",
"0.616848",
"0.6065817",
"0.59570754",
"0.59183365",
"0.5823251",
"0.58119357",
"0.5607745",
"0.5544416",
"0.5539116",
"0.5516259",
"0.5461747",
"0.5404892",
"0.53965837",
"0.5383624",
"0.5343653",
"0.5338503",
"0.5315496... | 0.7511302 | 0 |
Display a scatterplot chart. This is syntaxsugar around st.altair_chart. The main difference is this command uses the data's own column and indices to figure out the chart's spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. If st.scatter_chart does not guess the... | def scatter_chart(
self,
data: "Data" = None,
*,
x: Union[str, None] = None,
y: Union[str, Sequence[str], None] = None,
color: Union[str, Color, None] = None,
size: Union[str, float, int, None] = None,
width: int = 0,
height: int = 0,
use_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def altair_scatter(dataset: pd.DataFrame, x_selection: str, y_selection: str, color_selection: str) -> alt.Chart:\n\n # use set to handle edge case of duplicated axes or 'Date' selection\n tooltip = list(set(['Date', x_selection, y_selection, color_selection]))\n if color_selection == '<select>':\n ... | [
"0.71507263",
"0.70589083",
"0.68820024",
"0.6671382",
"0.6566429",
"0.6446729",
"0.6439431",
"0.63568234",
"0.6349332",
"0.6227603",
"0.62023634",
"0.6175102",
"0.6152018",
"0.6145859",
"0.6132285",
"0.61067045",
"0.61009264",
"0.60829085",
"0.60644",
"0.60444605",
"0.601287... | 0.69022197 | 2 |
Display a chart using the Altair library. | def altair_chart(
self,
altair_chart: "Chart",
use_container_width: bool = False,
theme: Union[None, Literal["streamlit"]] = "streamlit",
) -> "DeltaGenerator":
if _use_arrow():
return self.dg._arrow_altair_chart(altair_chart, use_container_width, theme)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toAltair(self) -> str:\t\t\n\t\tfrom lux.vizLib.altair.AltairRenderer import AltairRenderer\n\t\trenderer = AltairRenderer(outputType=\"Altair\")\n\t\tself.vis= renderer.createVis(self)\n\t\treturn self.vis",
"def plot_altair(\n self, x_domain: Vector2d = None, y_domain: Vector2d = None\n ) -> alt.... | [
"0.6415593",
"0.62744915",
"0.6256426",
"0.61921513",
"0.61800224",
"0.6134258",
"0.5910274",
"0.59041786",
"0.5893433",
"0.58333194",
"0.5774706",
"0.5688453",
"0.561152",
"0.55896866",
"0.5554131",
"0.55285376",
"0.5448559",
"0.5429293",
"0.5388663",
"0.5380446",
"0.5368429... | 0.62174 | 3 |
Returns all the subclasses of the given class | def get_all_subclasses(the_class, check_meta_abstract=True, top=True):
kids = the_class.__subclasses__()
result = set(kids).union(
[s for c in kids for s in get_all_subclasses(c, check_meta_abstract, False)])
if top:
if check_meta_abstract:
non_abstract_result = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_subclasses(python_class):\n python_class.__subclasses__()\n\n subclasses = set()\n check_these = [python_class]\n\n while check_these:\n parent = check_these.pop()\n for child in parent.__subclasses__():\n if child not in subclasses:\n subclasses.add(... | [
"0.79390645",
"0.7898456",
"0.77453536",
"0.77143735",
"0.76546067",
"0.765048",
"0.7593779",
"0.7516751",
"0.74423623",
"0.7393576",
"0.7326372",
"0.72998166",
"0.72998166",
"0.725576",
"0.72450024",
"0.7228968",
"0.72143084",
"0.7202816",
"0.7182957",
"0.71803474",
"0.71764... | 0.7240745 | 15 |
Given a full file path on the hard drive return a relative path to the data directory ie /full/path/to/data/my/file | def build_relative_path(full_path, prefix='/', split_on='/data/'):
splits = full_path.split(split_on)
return os.path.join(prefix, split_on, splits[-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataPath(relative):\n return os.path.join(_dataDir, relative)",
"def get_file_path(filename, path='Data/'):\n path= os.path.abspath(os.path.dirname(path))\n return os.path.join(path, filename)",
"def get_path(data_path):\n\treturn os.path.dirname(os.path.realpath(__file__)) + os.sep + data_path",
... | [
"0.7832095",
"0.76195097",
"0.74634725",
"0.7323675",
"0.73166716",
"0.72268856",
"0.71764684",
"0.7128338",
"0.71103364",
"0.7070811",
"0.6985736",
"0.69848865",
"0.68775505",
"0.68281037",
"0.6809121",
"0.6755845",
"0.67545",
"0.6750643",
"0.67453665",
"0.6738185",
"0.67069... | 0.7022735 | 10 |
A single block for ResNet v2, with inception structure | def inception_block_v2(self, inputs, block_params, training,
projection_shortcut, half_layer=None, no_prenorm=False):
shortcut = inputs
if not no_prenorm:
inputs = self.batch_norm_act(inputs, training)
# The projection shortcut should come after the first batch norm and ReLU
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inception_resnet_block(x, scale, block_type, block_idx, activation='relu'):\n if block_type == 'block35':\n branch_0 = conv2d_bn(x, 32, 1)\n branch_1 = conv2d_bn(x, 32, 1)\n branch_1 = conv2d_bn(branch_1, 32, 3)\n branch_2 = conv2d_bn(x, 32, 1)\n branch_2 = conv2d_bn(branch_2, 48, 3)\n branc... | [
"0.70338273",
"0.67023027",
"0.6470891",
"0.6415284",
"0.6396173",
"0.6379284",
"0.6297588",
"0.6265968",
"0.6227656",
"0.62236434",
"0.6216902",
"0.620383",
"0.61624235",
"0.6140817",
"0.6094253",
"0.6005656",
"0.59982353",
"0.59922117",
"0.5976582",
"0.5972811",
"0.59701836... | 0.627368 | 7 |
Feedforward upto layer 'upto'. If 'upto' is not passed, this works as the standard forward function in PyTorch. | def _forward(self, x, X, upto=None):
if upto is not None: # cannot use 'if upto' here since it is 0-indexed
# and layer0 is the first layer
assert 0<=upto<=self._layer_counter
counter = upto + 1
else: counter = self._layer_counter
y_previous, Y_previous = x, X
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x_in):\r\n # x_out = torch.zeros_like(x_in)\r\n\r\n for layer in self.layers: #Call forward function of each layer in order\r\n x_out = layer.forward(x_in)\r\n # print(\"Forward pass Seq: \", layer, x_in, x_out)\r\n x_in = x_out ... | [
"0.6902619",
"0.6571247",
"0.65539545",
"0.655188",
"0.65398526",
"0.65056264",
"0.6449982",
"0.6438037",
"0.636464",
"0.6320265",
"0.6292199",
"0.6250237",
"0.6246885",
"0.6246879",
"0.6246879",
"0.6236945",
"0.6230823",
"0.6230275",
"0.6215639",
"0.62069774",
"0.61824054",
... | 0.71362674 | 0 |
Feedforward upto layer 'upto' in volatile mode. Use for inference. See | def _forward_volatile(self, x, X, upto=None):
x.volatile = True
return self._forward(x, X, upto) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, observation: Tensor) -> Tensor:\n pass",
"def _fuse_back(self):\n with tf.variable_scope('fusion'):\n #self.fuse_p_encodes, _ = rnn('lstm', self.match_p_encodes, self.p_length,\n # self.hidden_size, layer_num=1)\n self.f... | [
"0.60368043",
"0.600728",
"0.59997463",
"0.5982935",
"0.58912665",
"0.5810705",
"0.5798738",
"0.5781117",
"0.5707858",
"0.5695147",
"0.5658959",
"0.5604582",
"0.5598461",
"0.5596364",
"0.55574805",
"0.5552797",
"0.5543089",
"0.5535469",
"0.55267316",
"0.55255175",
"0.5513776"... | 0.5926029 | 4 |
This method aims to split train array into train array and val array. | def split_train_val(self, train_docs_array, train_labels_array):
val_docs_array = train_docs_array[:7600] # len of test.csv is 7600
val_labels_array = train_labels_array[:7600]
train_docs_array = train_docs_array[7600:]
train_labels_array = train_labels_array[7600:]
return tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_val_split(self):\n idx = np.arange(self.num_data)\n np.random.shuffle(idx)\n val_num = int(self.ratio * self.num_data)\n dev_num = int(self.dev_ratio * self.num_data)\n self.num_train = self.num_data - val_num\n\n self.val_data = self.data[idx[:val_num]]\n ... | [
"0.7756852",
"0.71884453",
"0.71252763",
"0.70841926",
"0.70319784",
"0.6964175",
"0.68817157",
"0.6774583",
"0.67707324",
"0.6746481",
"0.67065394",
"0.6686195",
"0.66679657",
"0.6651874",
"0.66366446",
"0.6578289",
"0.6578289",
"0.6555046",
"0.65174425",
"0.64987975",
"0.64... | 0.8271099 | 0 |
Calculate the distance between asteroid_1 and asteroid_2 (Pythagorean theorem). | def calculate_distance(asteroid_1: Asteroid, asteroid_2: Asteroid) -> float:
dy = asteroid_2.y - asteroid_1.y
dx = asteroid_2.x - asteroid_1.x
return math.sqrt(dy * dy + dx * dx) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_angle(asteroid_1: Asteroid, asteroid_2: Asteroid) -> float:\n dy = asteroid_2.y - asteroid_1.y\n dx = asteroid_2.x - asteroid_1.x\n return math.atan2(dy, dx) * 180.0 / math.pi",
"def calculate_distance(atom1,atom2): #dot string to show when you go into the help doc of this function\n x_... | [
"0.7030926",
"0.69522965",
"0.6843009",
"0.67852646",
"0.67721796",
"0.6762501",
"0.67552006",
"0.6741944",
"0.67308104",
"0.6729038",
"0.6727312",
"0.67190367",
"0.6715936",
"0.67065495",
"0.6669334",
"0.666397",
"0.6662535",
"0.6651546",
"0.6649383",
"0.6647903",
"0.6641508... | 0.8495939 | 0 |
Returns a dictionary with the abinit variables. | def structure_to_abivars(self):
types_of_specie = self.types_of_specie
natom = self.num_sites
znucl_type = [specie.number for specie in types_of_specie]
# znucl_atoms = self.atomic_numbers
typat = numpy.zeros(natom, numpy.int)
for (atm_idx, site) in enumerate(self):
typat[atm_idx] = t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variables_declared (self) :\r\n\t\treturn {}",
"def variables(self) -> OrderedDict:\n return OrderedDict({'a': self.a, 'b': self.b, 'c': self.c})",
"def set_vars():\n return dict()",
"def dictOfRandomVariables(self):\n return dict()",
"def getInitParams(self):\n paramDict = Boos... | [
"0.66561687",
"0.66187584",
"0.6564198",
"0.65137863",
"0.64970803",
"0.6493973",
"0.64735377",
"0.6420498",
"0.64122444",
"0.64089346",
"0.6371754",
"0.6367232",
"0.6250228",
"0.6217111",
"0.620657",
"0.6197839",
"0.6191349",
"0.6177113",
"0.616655",
"0.61246306",
"0.6124630... | 0.0 | -1 |
This method is used for unpickling the object. It takes a dictionary of saved state of object and restores the object to that state. | def __setstate__(self, state: typing.Dict) -> None:
# print("[INFO] Set state called!")
fitted = state['fitted_pipe']
del state['fitted_pipe']
structure = state['pipeline']
state['pipeline'] = Pipeline.from_json_structure(structure)
run = Runtime(state['pipeline'], st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self, serialized: bytes) -> None:\n loaded_state = pickle.loads(serialized)\n self.__dict__.update(loaded_state.__dict__)",
"def restore(self):\n self.abstract_obj.restore()",
"def restore_after_serialize(self):\n self.on_deserialize()",
"def restore(self, obj):\n ... | [
"0.766889",
"0.72199327",
"0.70207036",
"0.6989697",
"0.6874713",
"0.6671277",
"0.65949976",
"0.6577151",
"0.6576557",
"0.64628685",
"0.645548",
"0.6370465",
"0.63238204",
"0.6308298",
"0.6308298",
"0.6308298",
"0.62814313",
"0.6261581",
"0.6234738",
"0.62065405",
"0.6202803"... | 0.0 | -1 |
Binding information is provided, subnets on segments. Update to subnet on different segment fails. | def test_port_update_with_fixed_ips_fail_if_host_not_on_segment(self):
network, segments, subnets = self._create_test_segments_with_subnets(2)
# Setup host mappings
self._setup_host_mappings([(segments[0]['segment']['id'], 'fakehost')])
# Create a port and validate immediate ip allocat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_subnet_update(self, resource_id, resource_dict):\n pass",
"def update(self, oid, name=None, network_id=None, tenant_id=None, \n gateway_ip=None, cidr=None, allocation_pools=None, \n enable_dhcp=None, host_routes=None, dns_nameservers=None):\n data = {\n ... | [
"0.65200055",
"0.639751",
"0.62897927",
"0.62334126",
"0.61188185",
"0.60520905",
"0.5948046",
"0.582398",
"0.58226216",
"0.5808104",
"0.5781673",
"0.5758251",
"0.5648543",
"0.5644478",
"0.56273913",
"0.56151056",
"0.56106764",
"0.5585514",
"0.5576019",
"0.5531402",
"0.548065... | 0.49248797 | 54 |
Initialize the change handler set. Use a set to avoid duplicate change handler | def _initChangeHandlers(self, handlers):
if hasattr(self, "_changeHandlerSet") :
return
if isinstance(handlers, BaseChangeHandler):
self._changeHandlerSet = set([handlers])
elif hasattr(handlers, '__iter__'):
self._changeHandlerSet = set(
[h fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self):\n # Setup the callbacks.\n self.selectstate.on_change(\n \"value\",\n self.callback_selectstate)",
"def __init__(self, on_change):\n self._observed_paths = {}\n self._observed_watches = {}\n self._watch_dog_observed_paths = {}\n sel... | [
"0.5881474",
"0.5871115",
"0.58293456",
"0.57882136",
"0.57472223",
"0.5725899",
"0.56255716",
"0.559775",
"0.555969",
"0.5559071",
"0.5543176",
"0.5495069",
"0.54867136",
"0.5475566",
"0.5474835",
"0.5473563",
"0.54693365",
"0.5454845",
"0.5442295",
"0.5441224",
"0.54062635"... | 0.8266457 | 0 |
Create a JobConfig with spec and resource_references. | def _create_job_config(
self,
experiment_id: str,
params: Optional[dict],
pipeline_package_path: Optional[str],
pipeline_id: Optional[str],
version_id: Optional[str],
enable_caching: Optional[bool],
):
class JobConfig:
def __init__(self, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_config_job(self,\n resource_uri,\n cim_creation_class_name,\n cim_name,\n target,\n cim_system_creation_class_name='DCIM_ComputerSystem',\n cim_system_nam... | [
"0.62561446",
"0.60430896",
"0.60400945",
"0.58935916",
"0.58864635",
"0.5875684",
"0.5871379",
"0.584013",
"0.5820678",
"0.57929623",
"0.5637575",
"0.56269974",
"0.5624368",
"0.5599166",
"0.559184",
"0.5577394",
"0.5541287",
"0.5509366",
"0.5450939",
"0.5420695",
"0.53842145... | 0.66846776 | 0 |
Convert date string to datetime object | def convert_time(cls, time_str):
if cls.date_ignore_pattern:
time_str = re.sub(cls.date_ignore_pattern, '', time_str)
return datetime.strptime(time_str, cls.date_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_datetime(date_str: str) -> datetime:\n return dateutil.parser.parse(date_str)",
"def str_to_datetime(datestr):\n\n from dateutil import parser\n from datetime import datetime\n\n date = parser.parse(datestr)\n return date",
"def to_datetime(date_string):\n return dt.strptime(date_st... | [
"0.7930714",
"0.79228985",
"0.78461456",
"0.7823007",
"0.7765306",
"0.7758197",
"0.77210593",
"0.77157897",
"0.7672485",
"0.76312476",
"0.7558715",
"0.7558625",
"0.7526571",
"0.7488091",
"0.74646574",
"0.74374604",
"0.74374604",
"0.74314743",
"0.7428123",
"0.74275655",
"0.740... | 0.0 | -1 |
Initialises the min heap as an array. | def __init__(self):
self.heap = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, start_heap=None):\n self.heap = DynamicArray()\n\n # populate MinHeap with initial values\n if start_heap:\n for node in start_heap:\n self.add(node)",
"def __init__(self):\n self.min_heap = []\n self.max_heap = []",
"def __init__(... | [
"0.76369536",
"0.7323436",
"0.72954553",
"0.729079",
"0.72667074",
"0.7228895",
"0.7206584",
"0.7176344",
"0.71421194",
"0.70766425",
"0.7057281",
"0.6986395",
"0.6966209",
"0.6964436",
"0.69635946",
"0.69197536",
"0.68995535",
"0.6877638",
"0.67646736",
"0.6728533",
"0.67219... | 0.67627436 | 20 |
Gets the index position of the left child of the current index. | def get_left_child_index(self, parent):
return 2*parent+1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_left_child_index(self):\n return (2 * self.index) + 1",
"def left_child(self, index):\n return 2 * index + 1",
"def left_child(self, index):\n return 2 * index",
"def left(self, index):\n try:\n if index == self.root_index():\n index = self.adjace... | [
"0.8948201",
"0.87412655",
"0.8534088",
"0.8160279",
"0.810036",
"0.8038489",
"0.7976176",
"0.79241633",
"0.79241633",
"0.7815993",
"0.75838304",
"0.7577498",
"0.7282006",
"0.7258321",
"0.7238516",
"0.7231464",
"0.71018",
"0.70900136",
"0.7086588",
"0.707997",
"0.707997",
"... | 0.82569045 | 3 |
Gets the index position of the right child of the current index. | def get_right_child_index(self, parent):
return 2*parent+2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_right_child_index(self):\n return (2 * self.index) + 2",
"def right_child(self, index):\n return 2 * index + 1",
"def right_child(self, index):\n return 2 * index + 2",
"def rightChild(self, pos):\n return (2 * pos) + 1",
"def rightChild(self, pos):\n retu... | [
"0.9011021",
"0.8633151",
"0.8531423",
"0.8370852",
"0.8370852",
"0.8289925",
"0.8150738",
"0.7946013",
"0.78447604",
"0.78244996",
"0.7785491",
"0.75587386",
"0.7493096",
"0.7460555",
"0.7340458",
"0.7312867",
"0.73039967",
"0.7069105",
"0.695821",
"0.6938523",
"0.68731093",... | 0.82620025 | 6 |
If the current index has a left child. | def has_left_child(self, index):
return self.get_left_child_index(index) < len(self.heap) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _has_left(self, index):\r\n return self._left(index) < len(self)",
"def _has_left(self, j):\n return self._left(j) < len(self._data)",
"def left_child(self, index):\n return 2 * index + 1",
"def is_left_child(self):\n if self.parent == None:\n return False\n\n ... | [
"0.82198906",
"0.7681524",
"0.7608825",
"0.75832427",
"0.7568282",
"0.7563968",
"0.75505817",
"0.7518649",
"0.745438",
"0.74216944",
"0.73891354",
"0.726554",
"0.7235292",
"0.72010857",
"0.71941555",
"0.71941555",
"0.7136589",
"0.7058717",
"0.6949695",
"0.6926167",
"0.6903647... | 0.7903126 | 1 |
Gets the value of the left child. | def get_left_child(self, index):
return self.heap[self.get_left_child_index(index)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leftchild(self):\n return self._leftchild",
"def getLeft(self):\n return self.left",
"def get_left(self):\n return self.left",
"def get_left(self):\n return self.__left",
"def left(self):\n\t\treturn self._left",
"def GetValueLeft(self, *args, **kwargs):\n pass"... | [
"0.82867664",
"0.7928124",
"0.7870172",
"0.76868725",
"0.75270224",
"0.74952865",
"0.7486788",
"0.7465546",
"0.7465546",
"0.73644143",
"0.73644143",
"0.73478836",
"0.7292628",
"0.7270574",
"0.7240877",
"0.72162706",
"0.7190722",
"0.71337694",
"0.7131057",
"0.7091651",
"0.6968... | 0.6959868 | 21 |
Gets the value of the right child. | def get_right_child(self, index):
return self.heap[self.get_right_child_index(index)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rightchild(self):\n return self._rightchild",
"def get_right(self):\n return self.right",
"def getRight(self):\n return self.right",
"def get_right(self):\n return self.__right",
"def value(self):\n return self.get_attribute(\"value\", str(self.children))",
"def... | [
"0.79575384",
"0.73748654",
"0.7258782",
"0.7207577",
"0.7147142",
"0.70688105",
"0.7059984",
"0.69855195",
"0.69855195",
"0.69697416",
"0.6956057",
"0.6910828",
"0.6910828",
"0.6909001",
"0.686987",
"0.68502927",
"0.6820349",
"0.6797401",
"0.67868674",
"0.6718048",
"0.670523... | 0.6828688 | 16 |
Gets the value of the parent. | def get_parent(self, index):
return self.heap[self.get_parent_index(index)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n return self.get_attribute(\"value\", str(self.children))",
"def getValue(self):\n return -self.child.getValue()",
"def return_to_parent_value():\n print (\"\\nReturning to parent value...\\n\")",
"def get_value(self):\n return self.value",
"def get_value(self)... | [
"0.77470577",
"0.73996675",
"0.70814437",
"0.69659644",
"0.69659644",
"0.69659644",
"0.69570625",
"0.69506264",
"0.69232136",
"0.6918087",
"0.6918087",
"0.68862516",
"0.68736166",
"0.68736166",
"0.68736166",
"0.68730634",
"0.68553233",
"0.6842884",
"0.6842326",
"0.6829715",
"... | 0.0 | -1 |
Returns the root i.e the min element of the array. | def peek(self):
assert len(self.heap) > 0, "ERROR: Heap is empty."
return self.heap[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min(self):\n return self._min(self.root)",
"def find_smallest(self):\n return self._find_smallest(self.root)",
"def peek_min(self):\n if self.root:\n return self.root.min().value\n raise ValueError(\"cannot perform peek_min on an empty tree\")",
"def min(self):\n ... | [
"0.7874096",
"0.7663163",
"0.75349027",
"0.74688077",
"0.7465135",
"0.740487",
"0.73814034",
"0.73388565",
"0.7302015",
"0.72936517",
"0.72936517",
"0.72763884",
"0.725718",
"0.7246762",
"0.72260815",
"0.7226078",
"0.72094166",
"0.7185127",
"0.71662915",
"0.71125805",
"0.7110... | 0.0 | -1 |
Adds an element to the end of the heap and then fixes the heap. | def add(self, value):
self.heap.append(value)
self.heapify_up() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, element):\n self.heap.append(element)\n # sift up the element append before\n self.sift_up(self.size() - 1)",
"def insert(self, element):\n if self.size >= self.maxsize:\n return\n self.size += 1\n self.heap[self.size] = element\n... | [
"0.79778886",
"0.7553869",
"0.74997747",
"0.7496256",
"0.74767005",
"0.7456915",
"0.7406283",
"0.7398262",
"0.72955495",
"0.72785217",
"0.72715855",
"0.70750034",
"0.70655006",
"0.7040195",
"0.702266",
"0.7005854",
"0.6992324",
"0.69768435",
"0.6920414",
"0.69048434",
"0.6895... | 0.66528386 | 38 |
Start with the last element and walk up the heap and swap in case the elements are out of order. | def heapify_up(self):
index = len(self.heap) - 1
while self.has_parent(index) and self.get_parent(index) > self.heap[index]:
self.swap_values(self.get_parent_index(index), index)
index = self.get_parent_index(index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heapify_down(self):\n index = 0\n while self.has_left_child(index):\n smaller_child_index = self.get_left_child_index(index)\n if self.has_right_child(index) and self.get_right_child(index) < self.get_left_child(index):\n smaller_child_index = self.get_right_c... | [
"0.77082103",
"0.7632198",
"0.7577516",
"0.7530355",
"0.74858934",
"0.73966324",
"0.7302574",
"0.7293591",
"0.72646886",
"0.7246478",
"0.7233589",
"0.7206389",
"0.7189972",
"0.7127015",
"0.7119611",
"0.7118349",
"0.7113132",
"0.70920616",
"0.70861673",
"0.7083656",
"0.7077719... | 0.733915 | 6 |
Returns an ordered list of joints which have animation channels | def get_animated_joints(self):
if self.animated_joints is not None:
for joint in self.animated_joints:
yield joint
else:
for name, node in self.node_names.items():
if "channels" in node.keys() and len(node["channels"]) > 0:
yiel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_frame_joints(self, frame):\n joints = frame[(self.POS_SIZE + self.ROT_SIZE):].copy()\n return joints",
"def get_joints(joint_listener): \n if LOCAL_TEST: # dummy\n return np.array([-0.5596, 0.5123, 0.5575, -1.6929, 0.2937, 1.6097, -1.237, 0.04, 0.04])\n else:\n joints = joi... | [
"0.65674084",
"0.5863098",
"0.58055115",
"0.5773283",
"0.5733203",
"0.57276505",
"0.56302696",
"0.56042594",
"0.5569908",
"0.5542186",
"0.54934955",
"0.5430374",
"0.53899354",
"0.5359265",
"0.52538407",
"0.5252124",
"0.5250862",
"0.5229304",
"0.5221193",
"0.5169468",
"0.51278... | 0.7621449 | 0 |
Initialize predictor layers of the head. | def _init_predictor(self):
self.conv_cls_prev = self._init_branch(
conv_channels=self.cls_branch,
conv_strides=(1, ) * len(self.cls_branch))
self.conv_cls = nn.Conv2d(self.cls_branch[-1], self.cls_out_channels,
1)
# init regression head
... | {
"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 _init_layers(self) -> None:\n self.self_attn = MultiheadAttention(**self.self_attn_cfg)\n self.cross_attn = MultiheadAttention(**self.cross_attn_cfg)\n self.... | [
"0.74005747",
"0.7128113",
"0.7097725",
"0.66451305",
"0.66024977",
"0.65445304",
"0.6448508",
"0.63685393",
"0.63507307",
"0.6345113",
"0.6297267",
"0.62768024",
"0.62672603",
"0.62551504",
"0.62361294",
"0.6223856",
"0.62094337",
"0.62059826",
"0.6200887",
"0.6178777",
"0.6... | 0.6794499 | 3 |
Initialize layers of the head. | def _init_layers(self):
self._init_predictor()
if self.use_edge_fusion:
self._init_edge_module() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_layers(self) -> None:\n self.self_attn = MultiheadAttention(**self.self_attn_cfg)\n self.cross_attn = MultiheadAttention(**self.cross_attn_cfg)\n self.embed_dims = self.self_attn.embed_dims\n self.ffn = FFN(**self.ffn_cfg)\n norms_list = [\n build_norm_layer(... | [
"0.73801965",
"0.7378758",
"0.70826614",
"0.70083666",
"0.68058515",
"0.6793121",
"0.6747672",
"0.67046845",
"0.6699219",
"0.6565106",
"0.6552534",
"0.6548868",
"0.6536724",
"0.6533556",
"0.65013635",
"0.64803135",
"0.6478405",
"0.6438143",
"0.6429889",
"0.6428964",
"0.640128... | 0.7565452 | 0 |
Forward features from the upstream network. | def forward(self, feats: List[Tensor], batch_img_metas: List[dict]):
mlvl_batch_img_metas = [batch_img_metas for i in range(len(feats))]
return multi_apply(self.forward_single, feats, mlvl_batch_img_metas) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_train(self, *args, **kwargs):\n pass",
"def forward(self, X, training=False):\n pass",
"def forward(self, features=None):\n\n assert (features is None) == (self.in_features is None), \\\n \"Layer has not been properly configured to take in features!\"\n\n in_d... | [
"0.69998914",
"0.67290515",
"0.671595",
"0.6710372",
"0.66852725",
"0.6682484",
"0.6649977",
"0.6626594",
"0.660322",
"0.65913093",
"0.6573614",
"0.6568412",
"0.6568412",
"0.65524113",
"0.6550743",
"0.65131605",
"0.6505302",
"0.6499309",
"0.6492958",
"0.6483335",
"0.64765483"... | 0.0 | -1 |
Forward features of a single scale level. | def forward_single(self, x: Tensor, batch_img_metas: List[dict]):
img_h, img_w = batch_img_metas[0]['pad_shape'][:2]
batch_size, _, feat_h, feat_w = x.shape
downsample_ratio = img_h / feat_h
for conv_cls_prev_layer in self.conv_cls_prev:
cls_feat = conv_cls_prev_layer(x)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_forward(self, x):\n raise NotImplementedError",
"def forward(self, x):\n x = self.features(x)\n return x",
"def forward_features(self, x):\n x_size = (x.shape[2], x.shape[3])\n x = self.patch_embed(x)\n if self.ape:\n x = x + self.absolute_pos_em... | [
"0.7507718",
"0.70580316",
"0.6831061",
"0.6580248",
"0.65654314",
"0.6526338",
"0.64446896",
"0.6356364",
"0.6326204",
"0.62937754",
"0.62895703",
"0.62686944",
"0.62652",
"0.62571406",
"0.6247619",
"0.6238785",
"0.62334955",
"0.62334955",
"0.62243533",
"0.62243533",
"0.6210... | 0.0 | -1 |
Test of quantized conv3d whose stride is bigger than kernel. | def test_qconv_3d(self, name, conv, tensor):
with torch.no_grad():
model = torch.ao.quantization.QuantWrapper(conv)
model.qconfig = torch.ao.quantization.get_default_qconfig("fbgemm")
torch.ao.quantization.prepare(model, inplace=True)
# Calibration
mod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_pool3d(input, kernel_size, stride=1, padding=0, ceil_mode=False):\n return _pool('MAX', utils._triple, **locals())",
"def test_conv2d(\n dtype,\n shape,\n out_channels,\n kernel_size,\n pad,\n stride,\n qnn_per_channel,\n):\n np.random.seed(0)\n\n dilation = (1, 1)\n grou... | [
"0.5666321",
"0.5656654",
"0.56472075",
"0.5618702",
"0.56081617",
"0.5596541",
"0.55769694",
"0.5552911",
"0.55222505",
"0.55222505",
"0.5509066",
"0.5498436",
"0.5494873",
"0.549459",
"0.5487287",
"0.54639226",
"0.54639226",
"0.54639226",
"0.54639226",
"0.54639226",
"0.5463... | 0.5364637 | 79 |
Return a string representation of the field type. This should return a string summary suitable for human consumption. | def __str__(self):
return str(self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_type(self):\n return \"\"",
"def typeString(self):\n return Parameter.string_dict[self._field.type]",
"def _type_str(self):\n try:\n record_name = RECORD_TYPES[self.type]\n return '{0} record'.format(record_name)\n except KeyError:\n return... | [
"0.79661125",
"0.74855477",
"0.74838156",
"0.7454353",
"0.7408825",
"0.7331011",
"0.72898734",
"0.7265324",
"0.726467",
"0.71772826",
"0.71726555",
"0.69893074",
"0.6940092",
"0.69090796",
"0.6876074",
"0.6850533",
"0.6845983",
"0.67900616",
"0.67900616",
"0.67900616",
"0.678... | 0.0 | -1 |
Return a string representation of the field type. | def __str__(self):
return gettext('One of %s') % self._get_choices_str() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_type(self):\n return \"\"",
"def typeString(self):\n return Parameter.string_dict[self._field.type]",
"def type_as_string(self):\n return self.properties.get('TypeAsString', None)",
"def type(self):\n return self._field.type",
"def getTypeString(self):\n return ... | [
"0.8030206",
"0.7904023",
"0.75580126",
"0.75550663",
"0.75305605",
"0.74934256",
"0.7469422",
"0.7416512",
"0.7365571",
"0.71603066",
"0.71030045",
"0.70713246",
"0.7063964",
"0.6920155",
"0.6870598",
"0.6869264",
"0.6869264",
"0.6869264",
"0.6865707",
"0.68656194",
"0.68491... | 0.0 | -1 |
Return a string representation of the field type. | def __str__(self):
if self.item_info:
item_type = self.item_info['type'](self.item_info)
return gettext('List of %s') % item_type
else:
return gettext('List') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_type(self):\n return \"\"",
"def typeString(self):\n return Parameter.string_dict[self._field.type]",
"def type_as_string(self):\n return self.properties.get('TypeAsString', None)",
"def type(self):\n return self._field.type",
"def getTypeString(self):\n return ... | [
"0.8030206",
"0.7904023",
"0.75580126",
"0.75550663",
"0.75305605",
"0.74934256",
"0.7469422",
"0.7416512",
"0.7365571",
"0.71603066",
"0.71030045",
"0.70713246",
"0.7063964",
"0.6920155",
"0.6870598",
"0.6869264",
"0.6869264",
"0.6869264",
"0.6865707",
"0.68656194",
"0.68491... | 0.0 | -1 |
Return a string representation of the field type. | def __str__(self):
return self.resource.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_type(self):\n return \"\"",
"def typeString(self):\n return Parameter.string_dict[self._field.type]",
"def type_as_string(self):\n return self.properties.get('TypeAsString', None)",
"def type(self):\n return self._field.type",
"def getTypeString(self):\n return ... | [
"0.8030206",
"0.7904023",
"0.75580126",
"0.75550663",
"0.75305605",
"0.74934256",
"0.7469422",
"0.7416512",
"0.7365571",
"0.71603066",
"0.71030045",
"0.70713246",
"0.7063964",
"0.6920155",
"0.6870598",
"0.6869264",
"0.6869264",
"0.6869264",
"0.6865707",
"0.68656194",
"0.68491... | 0.0 | -1 |
Return a string representation of the field type. | def __str__(self):
return gettext('List of %s') % self.resource.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_type(self):\n return \"\"",
"def typeString(self):\n return Parameter.string_dict[self._field.type]",
"def type_as_string(self):\n return self.properties.get('TypeAsString', None)",
"def type(self):\n return self._field.type",
"def getTypeString(self):\n return ... | [
"0.8030206",
"0.7904023",
"0.75580126",
"0.75550663",
"0.75305605",
"0.74934256",
"0.7469422",
"0.7416512",
"0.7365571",
"0.71603066",
"0.71030045",
"0.70713246",
"0.7063964",
"0.6920155",
"0.6870598",
"0.6869264",
"0.6869264",
"0.6869264",
"0.6865707",
"0.68656194",
"0.68491... | 0.0 | -1 |
Returns "proper" utf8 bytestring that should work as expected in Py3. In Py2 it's just gonna be a string because that's all that's needed. | def polite_bytes(a_string):
if is_py3():
try:
return bytes(a_string, 'utf-8')
except TypeError:
return a_string
return a_string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_utf8_bytes(v: Union[str, bytes]) -> bytes:\n if isinstance(v, str):\n v = v.encode(\"utf-8\")\n return v",
"def _encode_to_utf8(s):\n return s.encode('utf-8')",
"def to_bytes(string):\n assert isinstance(string, basestring)\n if sys.version_info[0] >= 3:\n if isinstance(... | [
"0.74226063",
"0.7335992",
"0.73334837",
"0.72967774",
"0.7267488",
"0.7261671",
"0.72390926",
"0.7187718",
"0.7162",
"0.71588904",
"0.7080986",
"0.70787746",
"0.7066213",
"0.70643765",
"0.7064243",
"0.70505166",
"0.7040282",
"0.7036327",
"0.70357966",
"0.7031672",
"0.7014782... | 0.7372888 | 1 |
Returns deserialized object from json string. Checks __custom_key_type__ in object's keys to choose appropriate type. | def decode_typed_json(json_value: str) -> tp.Any:
def type_check(dct: tp.Dict[tp.Any, tp.Any]) -> tp.Any:
val: tp.Any = dct.get("__custom_key_type__")
if val is not None:
dct.pop("__custom_key_type__")
if val == "int":
dct = {int(key): val for key, val in dct.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _json_to_obj(cls, serialized_str):\n json_dict = json.loads(serialized_str)\n if 'metadata' in json_dict.keys():\n metadata_dict = json_dict['metadata']\n return Metadata(metadata_dict)",
"def DeserializeJson(self, json_string, object_to_serialize):\n\n\n object_to_... | [
"0.66604674",
"0.64233714",
"0.63827646",
"0.6374764",
"0.6276657",
"0.62685084",
"0.61749315",
"0.6130702",
"0.6104741",
"0.60607105",
"0.6032036",
"0.6016991",
"0.6009984",
"0.6006332",
"0.59988225",
"0.5998612",
"0.5966077",
"0.5917982",
"0.59018284",
"0.59018284",
"0.5901... | 0.73699856 | 0 |
set attendee_dob to none if it has not passed value | def create(self, vals):
if not vals.get("attendee_dob"):
vals.update(attendee_dob=None)
return super(Attendee, self).create(vals) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_birthday(self, year, month, day):\n self.birthday = datetime.date(year, month, day)",
"def date_of_birth(self, value: str) -> None:\n self._date_of_birth = datetime.strptime(value, '%Y-%m-%d')",
"def _fill_date(self):\n if not self.date['year']:\n self.date['year'] = sel... | [
"0.61143327",
"0.6099918",
"0.60346496",
"0.5922572",
"0.58660996",
"0.58660996",
"0.57722753",
"0.5769564",
"0.5744518",
"0.572332",
"0.5703696",
"0.5691944",
"0.5647945",
"0.5615717",
"0.5541811",
"0.5457154",
"0.5432146",
"0.5416512",
"0.5347184",
"0.5306672",
"0.5286353",... | 0.7035845 | 0 |
Returns a face that's been aligned on the zaxis. The face is defined by the coordinates in the landmarks. | def align_and_extract_face(self, image, landmarks, output_size=(150,150), desired_left_eye_relative_position=(0.55, 0.55)):
# get the key landmark features
lp, eye_center, facebox = landmarks['left-eye-center-pos'], landmarks['eye-center-pos'], landmarks['face-box']
# calculating the center bo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aligned_face(self):\n return self.aligned[\"face\"]",
"def get_landmarks(self, image): # from https://www.paulvangent.com/2016/08/05/emotion-recognition-using-facial-landmarks/\n # Ask the detector to find the bounding boxes of each face. The 1 in the\n # second argument indicates that w... | [
"0.62676036",
"0.60988194",
"0.59568006",
"0.5932224",
"0.5835605",
"0.5833613",
"0.5830624",
"0.58236897",
"0.5808907",
"0.57835263",
"0.5745574",
"0.5705943",
"0.57038516",
"0.5672395",
"0.55525005",
"0.55497175",
"0.552406",
"0.5500061",
"0.549559",
"0.5486997",
"0.5468005... | 0.54983926 | 18 |
Creates and saves a User with the given username, email and password. | def create_user(self, username, email, password=None):
if not email:
raise ValueError('Users must have an email address')
user = self.model(
username=username,
email=self.normalize_email(email),
)
user.set_password(password)
user.save(using=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password,username, **extra_fields):\r\n if not email:\r\n raise ValueError('The given email must be set')\r\n if not username:\r\n raise ValueError('The given username must be set')\r\n email = self.normalize_email(email)\r\n user = se... | [
"0.86018157",
"0.84706366",
"0.8462776",
"0.8417308",
"0.8413365",
"0.839183",
"0.8346418",
"0.83453476",
"0.8314481",
"0.8306914",
"0.8288764",
"0.827679",
"0.8270353",
"0.82577944",
"0.8213095",
"0.81978804",
"0.8175898",
"0.81719273",
"0.8164025",
"0.8162915",
"0.8138058",... | 0.80698454 | 28 |
Creates and saves a superuser with the given username, email and password. | def create_superuser(self, username, email, password):
user = self.create_user(
username,
email,
password=password,
)
user.is_admin = True
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_superuser(username, email, password):\n if username and email and password:\n user, created = User.objects.get_or_create(pk=defaults.USERWARE_SUPERUSER_ID)\n if user:\n user.username = username\n user.email = email\n user.set_password(password)\n ... | [
"0.83966196",
"0.82777953",
"0.8263329",
"0.81833094",
"0.81760895",
"0.81711185",
"0.81337005",
"0.8122679",
"0.81198525",
"0.8119165",
"0.81154525",
"0.81089586",
"0.8083815",
"0.8056806",
"0.80374634",
"0.8026917",
"0.80079323",
"0.79766345",
"0.7973099",
"0.7967584",
"0.7... | 0.8098656 | 12 |
Getter method for instance_id, mapped from YANG variable /brocade_xstp_ext_rpc/get_stp_mst_detail/output/msti/instance_id (uint32) | def _get_instance_id(self):
return self.__instance_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_id(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(se... | [
"0.63520867",
"0.63520867",
"0.63520867",
"0.6311185",
"0.6311185",
"0.6311185",
"0.6254042",
"0.6254042",
"0.6254042",
"0.62035793",
"0.61607665",
"0.61607665",
"0.61607665",
"0.61607665",
"0.6143082",
"0.61306065",
"0.6103794",
"0.6103794",
"0.6103794",
"0.6103794",
"0.6103... | 0.5820573 | 28 |
A complete binary tree data structure represented as an array. Every parent node's value is less than or equal to their child node's values. If no argument is given, the constructor creates a new empty min heap. If an argument is provided, the constructor will alter (heapify) the collection to ensure that the min heap ... | def __init__(self, collection: Optional[list]=None):
if isinstance(collection, list):
super().__init__(collection=[])
# If a valid collection is provided,
# construct the min heap with the collection
for value in collection:
self.insert(value)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __build(self) -> None:\n parent_idx = 0\n left_idx = 1\n right_idx = 2\n length = len(self._array)\n\n # While the bottom/end of the min heap has not been reached\n while left_idx < length or right_idx < length:\n\n # initialize the child_idx to the child wi... | [
"0.70357347",
"0.67362547",
"0.65779084",
"0.649961",
"0.64686674",
"0.6457577",
"0.6445057",
"0.63903946",
"0.6366498",
"0.63661385",
"0.6364642",
"0.63633776",
"0.6360914",
"0.63537306",
"0.63269526",
"0.630807",
"0.63019174",
"0.62940514",
"0.62830925",
"0.6246909",
"0.618... | 0.6555866 | 3 |
This renders the home.html on | def home():
return render_template("home.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n\n return render_template('home_page.html')",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def home():\n r... | [
"0.8944153",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.88916105",
"0.8888877",
"0.885456",
"0.88507354",
... | 0.8879826 | 19 |
VGG 16layer model (configuration "D") | def vgg16(pretrained=False, **kwargs):
model = VGG(make_layers(cfg['D']), **kwargs)
if pretrained:
model_dict = paddle.load('./pre_model/vgg16.paddle')
model.set_state_dict(model_dict)
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vgg16(pretrained=False, **kwargs):\n if pretrained:\n kwargs['init_weights'] = False\n model = VGG(make_layers(cfg['D']), **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['vgg16']), strict=False)\n return model",
"def build_cnn_vgg16(num_classes):\n\n... | [
"0.7896579",
"0.761893",
"0.7582476",
"0.74899364",
"0.74295044",
"0.7400541",
"0.73811644",
"0.7257291",
"0.7233009",
"0.7170191",
"0.71655226",
"0.7116012",
"0.710491",
"0.71014565",
"0.7095213",
"0.705962",
"0.703168",
"0.7015972",
"0.7006458",
"0.6923585",
"0.6902139",
... | 0.7813053 | 1 |
Create a new template and return the ID. | def create_template(name, event_id):
# Check that the template does not exist
exists = QueryRunsheet.get_template_by_name(name, event_id)
if exists:
raise Exception("A template with that name exists for the event")
sql = """
insert into runsheet_template (name, e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_template(self, **kwargs):\n _template = self.get_template(name=kwargs[\"name\"])\n if _template:\n raise ValueError(f\"Template already used: {kwargs['name']}\")\n\n if \"compute_id\" not in kwargs:\n kwargs[\"compute_id\"] = \"local\"\n\n response = sel... | [
"0.74299717",
"0.7393033",
"0.7143282",
"0.71082556",
"0.70142287",
"0.6747401",
"0.6691572",
"0.64780784",
"0.64627206",
"0.64113736",
"0.6248576",
"0.6225962",
"0.62209386",
"0.6208098",
"0.62034285",
"0.6120013",
"0.61168915",
"0.60969794",
"0.6076492",
"0.60454446",
"0.60... | 0.75538856 | 0 |
Returns a list of all four priors. See Section 3.4. | def all_priors(
p,
qu,
var,
name=""):
# Means of quantile differences
qu_diff_m = np.array([qu[0], qu[1] - qu[0], qu[2] - qu[1]])
# Means and variances of quantile differences
qu_diff_mv = np.transpose(np.array([qu_diff_m, var]))
# Parameters for quanti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def priors(self):\n\n return self._priors",
"def getPrimes(start, end):\n # This list will contain every 4-digit prime numbers\n primes = []\n\n for i in range(start, end):\n if isPrime(i):\n primes.append(i)\n return primes",
"def prime_divisors(n):\r\n\treturn list(set(fa... | [
"0.7346301",
"0.7052287",
"0.6350234",
"0.62430334",
"0.62308836",
"0.6194996",
"0.61730295",
"0.6162081",
"0.61296695",
"0.6062364",
"0.60496825",
"0.6015395",
"0.59999204",
"0.5995015",
"0.5987637",
"0.5977561",
"0.59704393",
"0.59551364",
"0.59346867",
"0.59145975",
"0.590... | 0.0 | -1 |
calculate the transform probability from density | def cal_prob(density_df, adv_intcpt, adv_slope, dis_intcpt, dis_slope):
def p_adv(density):
prob = adv_intcpt+adv_slope*density
return prob
def p_dis(density):
prob = dis_intcpt+(dis_slope)*density
return prob
density_df['PROB'] = density_df[['Density', 'st0']].apply(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gc_prob_density(r):\n return np.exp(_interp_ln_dens(r))",
"def test_probability_density(self):\n # Setup\n copula = GaussianMultivariate(GaussianUnivariate)\n copula.fit(self.data)\n X = np.array([2000., 200., 0.])\n expected_result = 0.032245296420409846\n\n # Ru... | [
"0.6668645",
"0.6632313",
"0.6604763",
"0.6547502",
"0.6525668",
"0.6466166",
"0.64416224",
"0.64201796",
"0.63968396",
"0.6292091",
"0.6256422",
"0.62472284",
"0.62435526",
"0.62361515",
"0.6199664",
"0.6145877",
"0.61432993",
"0.61091757",
"0.61091757",
"0.61047316",
"0.607... | 0.56977224 | 87 |
Represents a collection of worksheets associated with the workbook. Readonly. | def worksheets(self):
return self.properties.get('worksheets',
WorkbookWorksheetCollection(self.context,
ResourcePath("worksheets", self.resource_path))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spreadsheets(self):\r\n return resource.Spreadsheets(self)",
"def get_worksheets(self) -> list or None:\n if self.connected:\n cursor = self.workbook.cursor()\n if cursor:\n worksheet_names = []\n for table in cursor.tables():\n ... | [
"0.7037911",
"0.66948557",
"0.6445054",
"0.6317662",
"0.6316715",
"0.6210471",
"0.57445204",
"0.5659169",
"0.5579575",
"0.55347747",
"0.5477783",
"0.5458732",
"0.5437223",
"0.5344449",
"0.5150555",
"0.5149315",
"0.5134713",
"0.51071453",
"0.50524867",
"0.50493467",
"0.4955158... | 0.76754093 | 0 |
Takes month as parameter returns first date of the in_month months. | def get_first_date(in_month=1):
from_date = (today-relativedelta(months=in_month)).replace(day=1)
return from_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_month(date):\n return date.month",
"def month(self, month: str):\n return get_from_list(self.months, \"month\", month)",
"def start_month(d):\n return date(d.year, d.month, 1)",
"def get_month(self, indate):\n return indate.strftime(\"%B\") + \"-\" + indate.strftime(\"%Y\")",
"... | [
"0.76118416",
"0.7434227",
"0.7398153",
"0.7390573",
"0.7184189",
"0.7184189",
"0.717545",
"0.7164542",
"0.7098121",
"0.70717156",
"0.70714176",
"0.7017819",
"0.69781256",
"0.6968835",
"0.68800116",
"0.68220633",
"0.67527246",
"0.67527246",
"0.6726894",
"0.6663032",
"0.658611... | 0.809558 | 0 |
Configures the learning rate. | def __configure_learning_rate(self, num_samples_per_epoch, global_step):
decay_steps = int(num_samples_per_epoch / self.batch_size *
self.num_epochs_per_decay)
if self.learning_rate_decay_type == 'exponential':
return tf.train.exponent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)",
"def adjust_lr(self):\n learning_rate = self.params.base_lr * (1 - float(self.epoch) / self.params.num_epoch) ** self.params.power\n for param_group in self.opt.param_groups:\n param_group['lr'] = learning_rat... | [
"0.78593874",
"0.75907296",
"0.742758",
"0.7406107",
"0.739691",
"0.7320627",
"0.7320627",
"0.72974896",
"0.7253351",
"0.7229305",
"0.721023",
"0.72072744",
"0.71990186",
"0.71936136",
"0.7180078",
"0.7170698",
"0.7169669",
"0.7165654",
"0.71405464",
"0.71101654",
"0.71101654... | 0.0 | -1 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# TO DO: get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
# Get the names of the cities
city = ''
while city not in CITY_DATA.keys():
print("\nPlease enter... | {
"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.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.59841925 | 32 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
print("\nLoading data ...")
df = pd.read_csv(CITY_DATA[city])
# Convert the Start Time column to datetime for time period comparison
# then further create new columns for month and day of week based on that
df['Start Time'] = pd.to_datetime(df['Start Time'])
... | {
"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.8045821",
"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.78930074",
"0.7889219",
"0.788254... | 0.7900715 | 18 |
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()
# TO DO: display the most common month
# the mode() method is used to find the most common month
months = ['january','february','march','april','may','june']
common_month = df['month'].mo... | {
"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.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.708049 | 85 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# TO DO: display total travel time
# We're using the sum() method to get the total trip duration
total_trip_duration = df['Trip Duration'].sum()
# get the duration in the mm:ss format
# then us... | {
"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.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.7603003 | 88 |
Return True if n is a power of two. | def is_power_of_two(n):
if n < 0:
return False
else:
return n & (n - 1) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isPowerOfTwo(self, n: int) -> bool:\n if n <= 0:\n return False\n return bin(n).count('1') == 1",
"def is_power_of_two(n):\n if n <= 0:\n return False\n else:\n return n & (n - 1) == 0",
"def is_power_of_two(n: Union[int, float]):\n\n if n > 1:\n if n ... | [
"0.9018986",
"0.88537836",
"0.86676097",
"0.84409565",
"0.8168425",
"0.81002796",
"0.81002796",
"0.79719347",
"0.78607",
"0.7523444",
"0.75003964",
"0.74941194",
"0.7263389",
"0.7162678",
"0.7140002",
"0.70655465",
"0.70607436",
"0.69604325",
"0.6865322",
"0.6846204",
"0.6841... | 0.8857611 | 1 |
Calculates the sigmoid for x | def sigmoid_activation(x):
return 1.0 / (1 + np.exp(-x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n\treturn 1 / (1 + m.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + math.exp(-x))",
"def sigmoid(x):\n\n return 1 / (1 + math.exp(-x))",
"def sigmoid(x):\n\n return 1 / (1 + math.exp(-x... | [
"0.90683085",
"0.90683085",
"0.9061349",
"0.90310293",
"0.90255064",
"0.90255064",
"0.9018758",
"0.9016657",
"0.90118366",
"0.9001736",
"0.89798224",
"0.8972255",
"0.8955409",
"0.8943365",
"0.89376867",
"0.8930079",
"0.8930079",
"0.8930079",
"0.8930079",
"0.8930079",
"0.89300... | 0.84464604 | 52 |
Initialize a data set and load both training and test data DO NOT MODIFY THIS FUNCTION | def __init__(self, data_set):
self.name = data_set
# The training and test labels
self.labels = {'train': None, 'test': None}
# The training and test examples
self.examples = {'train': None, 'test': None}
# Load all the data for this data set
for data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(self):\n\n self._load_train_data()\n self._load_test_data()",
"def prepare_data(self):\n try:\n self.train_dataset = self.datasets['train']\n self.val_dataset = self.datasets['val']\n try:\n self.test_dataset = self.datasets['test... | [
"0.7671639",
"0.7642905",
"0.7551185",
"0.752678",
"0.7497357",
"0.7443911",
"0.7357239",
"0.7353174",
"0.7323596",
"0.72700185",
"0.7269416",
"0.7247759",
"0.7233153",
"0.72317135",
"0.72145814",
"0.7150233",
"0.71412224",
"0.71301144",
"0.7061545",
"0.7059428",
"0.70547694"... | 0.7453984 | 5 |
Computes the average error between the true labels (y_true) and the predicted labels (y_pred) Returns the error = (1/n) sum(y_true != y_pred) | def compute_error(y_true, y_pred):
length = len(y_true)
error_cnt = 0
for i in range (length):
if y_true[i] != y_pred[i]:
error_cnt = error_cnt+1
error = (1/length) * error_cnt
return error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_error(y_true, y_pred):\r\n\r\n # INSERT YOUR CODE HERE\r\n \r\n n = len(y_true)\r\n err = [y_true[i] != y_pred[i] for i in range(n)]\r\n return sum(err) / n\r\n \r\n raise Exception('Function not yet implemented!')",
"def error(y_pred, y_true):\n m = len(y_true) # number of sa... | [
"0.82036215",
"0.8156075",
"0.79500735",
"0.79412025",
"0.78387094",
"0.78210425",
"0.7691307",
"0.76818055",
"0.76228875",
"0.7598012",
"0.75840014",
"0.75840014",
"0.75674915",
"0.75334865",
"0.75271785",
"0.7524689",
"0.74667907",
"0.7443789",
"0.7434548",
"0.7405347",
"0.... | 0.8154134 | 2 |
Returns table data rowfirst indexed. Each column is a Dict with header as key | def rows_coldict(self) -> List[Dict]:
return self._rows_coldict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head(table: dict[str, list[str]], rows: int) -> dict[str, list[str]]:\n result: dict[str, list[str]] = {}\n for key in table:\n result[key] = table[key][:rows]\n return result",
"def head(self, rows, as_list=False):\n indexes = self.index[: int(rows)]\n return self.get_table(ind... | [
"0.68659216",
"0.6757493",
"0.6626195",
"0.63636774",
"0.63095903",
"0.6185374",
"0.60969436",
"0.6070012",
"0.60606587",
"0.5981324",
"0.59643376",
"0.5928643",
"0.59000313",
"0.58230686",
"0.5817167",
"0.58052534",
"0.5802641",
"0.5715958",
"0.5706676",
"0.5684248",
"0.5681... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum(axis=0) # only difference | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.70117974 | 76 |
Add a vertex to the graph. | def add_vertex(self, vertex_id):
# just add new dict entry
self.vertices[vertex_id] = set()
pass # TODO | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex):\n if isinstance(vertex, Vertex):\n self.vertices.append(vertex)\n return\n raise TypeError('Is not vertex instance!')",
"def add_vertex(self, vertex_name: n):\n new_verte... | [
"0.87015903",
"0.84329987",
"0.8422056",
"0.840923",
"0.83646226",
"0.8317027",
"0.825337",
"0.808519",
"0.8081489",
"0.8038682",
"0.8035422",
"0.78834563",
"0.78711975",
"0.7838118",
"0.7838118",
"0.77608305",
"0.7757061",
"0.77158874",
"0.7711681",
"0.76663774",
"0.76616603... | 0.72508645 | 40 |
Add a directed edge to the graph. | def add_edge(self, v1, v2):
pass # TODO
# both vertices have to exist to make connection(e.g. directed edge)
if v1 in self.vertices and v2 in self.vertices:
# print(f' type(vertices) is {type(self.vertices)}')
self.vertices[v1].add(v2) # using set .add() method to append
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n src = edge.get_source()\n dest = edge.get_destination()\n #weightEdge = WeightedEdge(src, dest, edge.get_total_distance(), edge.get_outdoor_distance())\n if not (src in self.edges and dest in self.edges):\n raise ValueError('Node not in graph')\n ... | [
"0.78169996",
"0.77789694",
"0.7618847",
"0.761851",
"0.75694674",
"0.7547367",
"0.7483565",
"0.7437083",
"0.74284625",
"0.7422367",
"0.741715",
"0.7337182",
"0.73281914",
"0.7266331",
"0.7227267",
"0.7212267",
"0.71977764",
"0.7194343",
"0.71735585",
"0.7168542",
"0.7152955"... | 0.0 | -1 |
Get all neighbors (edges) of a vertex. | def get_neighbors(self, vertex_id):
pass # TODO
if vertex_id in self.vertices:
# print(f' self.vertices[vertex_id] >> {self.vertices[vertex_id]} ')
return self.vertices[vertex_id]
else:
# print(f' ERROR: vertex {vertex.id} does not exist')
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbors_in(self, vertex):\n return list(self.neighbor_in_iterator(vertex))",
"def neighbors_out(self, vertex):\n return list(self.neighbor_out_iterator(vertex))",
"def get_neighbours(self, vertex):\n output = []\n \n if vertex in self.adjacency_list:\n for ne... | [
"0.8146008",
"0.78266084",
"0.78112674",
"0.7634123",
"0.76183206",
"0.7559868",
"0.7391218",
"0.73596346",
"0.73310196",
"0.729323",
"0.729323",
"0.729323",
"0.729323",
"0.729323",
"0.729323",
"0.7279731",
"0.71649474",
"0.7128683",
"0.7083494",
"0.7077735",
"0.7033856",
"... | 0.66344154 | 39 |
r"""Call the list operations method over HTTP. | def __call__(
self,
request: operations_pb2.ListOperationsRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.ListOperationsResponse:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list(self, **kwargs):\n\n return self._make_request(**kwargs)",
"def index():\n return make_json_response(ENDPOINT_LIST)",
"def list(self):\n return self.request(\"GET\")",
"def list(self, request):\n\n a_viewset = [\n 'Uses action (list, create, reteieve, update, part... | [
"0.750394",
"0.72345656",
"0.71966034",
"0.6960108",
"0.6957731",
"0.68971574",
"0.68971574",
"0.68971574",
"0.68971574",
"0.68971574",
"0.6850885",
"0.6850885",
"0.6829171",
"0.68089885",
"0.677977",
"0.67791873",
"0.67576295",
"0.67576295",
"0.67576295",
"0.67576295",
"0.67... | 0.0 | -1 |
Global airflow variable configuration for tests. This configuration is written to the airflow database, and as such is shared between all tests. Individual tests should never use Variable.set, as the state crosses test boundaries. See mock_airflow_variables. | def configure_airflow_variables():
from airflow.bin.cli import import_helper
for path in glob(os.path.join(airflow_variables_dir, '*.json')):
import_helper(path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_global_config_persistence():\n gc = GlobalConfig()\n\n # Track old one\n old_analytics_opt_in = gc.analytics_opt_in\n\n # Toggle it\n gc.analytics_opt_in = not old_analytics_opt_in\n\n # Initialize new config\n gc = GlobalConfig()\n\n # It still should be equal to the old value, as... | [
"0.635674",
"0.6111685",
"0.60833323",
"0.6010066",
"0.59071386",
"0.58810616",
"0.58162194",
"0.5714247",
"0.57067895",
"0.5618533",
"0.5607227",
"0.5606189",
"0.55961037",
"0.55409366",
"0.5519098",
"0.55055666",
"0.54954404",
"0.54898",
"0.547822",
"0.54736257",
"0.5471978... | 0.6797551 | 0 |
Fixture for creating a spark context. | def spark():
quiet_log4j()
builder = (
SparkSession.builder
.master("local[2]")
.appName("pytest-pyspark-local-testing")
# By default spark will shuffle to 200 partitions, which is
# way too many for our small test cases. This cuts execution
# time of the tests ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spark_context(request):\n spark = SparkSession.builder.master(\"local[1]\").appName(\"pytest-test\").getOrCreate()\n request.addfinalizer(lambda: spark.stop())\n\n quiet_py4j()\n return spark",
"def spark():\n return SparkSession.builder.master(\"local\").appName(\"tests\").getOrCreate()",
"... | [
"0.7423192",
"0.6821139",
"0.67771465",
"0.6681303",
"0.6625494",
"0.6275944",
"0.62481785",
"0.6209018",
"0.60507584",
"0.60401237",
"0.6033249",
"0.601733",
"0.5978928",
"0.59754175",
"0.590043",
"0.58996296",
"0.58895284",
"0.5871942",
"0.58645046",
"0.5859318",
"0.5853072... | 0.70610136 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.