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 |
|---|---|---|---|---|---|---|
The area of a circle is defined as $\pi r^2$. Estimate $\pi$ to 3 decimal places using a Monte Carlo method. | def coding_problem_14():
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_of_circle(radius):\n return math.pi * radius ** 2",
"def area_circle(radius):\n return np.pi*radius**2",
"def circleArea(radius):\n return math.pi * radius * radius",
"def area_circle(radius):\n area = math.pi * radius ** 2\n print(\"Area =\", area)",
"def areaOfCircle(r):\n area... | [
"0.8444615",
"0.8421605",
"0.83678246",
"0.8325463",
"0.82900566",
"0.8210355",
"0.81356305",
"0.8005022",
"0.7893233",
"0.7878503",
"0.7830844",
"0.7810936",
"0.7809454",
"0.77659464",
"0.7730499",
"0.7599209",
"0.7538799",
"0.7492429",
"0.7396838",
"0.7386778",
"0.73216534"... | 0.0 | -1 |
Return train and val generators that give data in batches, and data label names. | def get_data_gen():
# define preprocessing pipeline
train_transforms = [
partial(color_jitter, brightness=0.4, contrast=0.4, saturation=0.4),
partial(meanstd, mean=mean, std=std),
partial(random_crop, new_size=CROP_DIM, padding=4),
partial(horizontal_flip, f=0.5),
]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_generator():\n\n def batch_generator(mode=\"train\", batch_size=100):\n \"\"\"Generator for the data batches.\n \n Args:\n mode (str): Mode in ['train', 'val'] that decides which data set the generator\n samples from (default: 'train').\n ba... | [
"0.7133349",
"0.68724006",
"0.68083316",
"0.6768527",
"0.6765292",
"0.6708259",
"0.6681251",
"0.6672894",
"0.66462463",
"0.6613605",
"0.6613014",
"0.6563158",
"0.64950037",
"0.6493395",
"0.64880073",
"0.647702",
"0.6460102",
"0.6440122",
"0.6427183",
"0.6426157",
"0.6338851",... | 0.6852173 | 2 |
Does the circle of this person overlap that of other? | def overlaps(self, other):
return np.hypot(*(self.r - other.r)) < self.radius + other.radius | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_if_circles_overlap(x, y, r, a, b, t):\n if math.hypot(x - a, y - b) <= (r + t):\n return True\n return False",
"def rect_circle_overlap(circle,rect):\n temp = False\n for i in range(rect.corner.x ,(rect.corner.x + rect.length)):\n for j in range(rect.corner.y ,(rec... | [
"0.7504036",
"0.72654635",
"0.7249882",
"0.717157",
"0.70691174",
"0.70532495",
"0.6970523",
"0.69541955",
"0.6952926",
"0.6942691",
"0.68817043",
"0.6809695",
"0.6697229",
"0.66942316",
"0.6688559",
"0.66755474",
"0.66710883",
"0.6629567",
"0.66232187",
"0.66149795",
"0.6611... | 0.76160544 | 0 |
The constructor for User model. | def __init__(self, first_name: str, last_name: str, raw_password: str):
self.first_name = first_name
self.last_name = last_name
self.password_hash = self.get_hash_password(raw_password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, user):\n self.user_model = user\n self.username = user.key.id()",
"def __init__(self, name: str, last_name: str, gov_id: str,\n email: str, company: str, password:str,\n is_admin: bool=False) -> \"User\":\n self.name = name\n self.last_... | [
"0.7543909",
"0.7451694",
"0.7415139",
"0.7267786",
"0.72533363",
"0.72195375",
"0.7213958",
"0.6972844",
"0.6865481",
"0.68615544",
"0.68378127",
"0.68242246",
"0.68067306",
"0.6723334",
"0.6708085",
"0.6679189",
"0.66713244",
"0.66597724",
"0.66469514",
"0.6632712",
"0.6631... | 0.0 | -1 |
Generating a hashed string from the raw_password. | def get_hash_password(self, raw_password: str):
assert(str is not None, 'The raw_password cannot be None.')
return generate_password_hash(self.password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_hash(raw_password):\n salt = \"This_Is_A_Very_Bad_But_Fake_Hash_Function\"\n pw_hash = salt + raw_password\n return pw_hash",
"def generate_password_hash(raw_password):\n # Encode password in byte literals\n password = raw_password.encode('utf-8')\n\n # Hash password using bcrypt\n... | [
"0.81279814",
"0.81160676",
"0.749383",
"0.7395973",
"0.72857404",
"0.7248073",
"0.7194683",
"0.7099634",
"0.7059287",
"0.7057905",
"0.70163023",
"0.70117456",
"0.70117456",
"0.7001551",
"0.6998763",
"0.698407",
"0.6977546",
"0.69727844",
"0.69470936",
"0.6937569",
"0.6928370... | 0.8381517 | 0 |
Create a convolution block which is a convolution layer followed by activation | def conv_block(num_kernels, kernel_shape, stride_shape,input_layer, layer_num):
conv = layers.Conv2D(num_kernels,
kernel_shape,
padding='valid',
activation='relu',
strides=strid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _conv_block(inputs, filters, kernel, strides):\n channel_axis = 1 if K.image_data_format() == 'channels_first' else -1\n\n x = Conv2D(filters, kernel, padding='same', strides=strides)(inputs)\n x = InstanceNormalization(axis=channel_axis)(x)\n return Activation(relu6)(x)",
"def _conv_block(inputs... | [
"0.7843055",
"0.7825449",
"0.78167945",
"0.7682783",
"0.7618862",
"0.75749",
"0.7483327",
"0.7478464",
"0.7467231",
"0.74463356",
"0.74236774",
"0.7338656",
"0.73341244",
"0.72628784",
"0.7252296",
"0.7239228",
"0.716052",
"0.716052",
"0.7131664",
"0.71285844",
"0.712169",
... | 0.70159566 | 30 |
Generate a random string of specified length ahd nucleotides sampled from the specified alphabet | def generate_nucleotide_sequence(seq_length, alphabet="AGCT"):
if not alphabet:
alphabet = "AGCT"
return "".join([ random.choice(alphabet) for i in range(seq_length) ]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_random_string():\n letters = string.ascii_letters\n return ''.join(random.choice(letters) for i in range(70))",
"def random_string(length):\n amino_acids = set(ascii_uppercase).difference(set(['B','O','J','U','X','Z']))\n return ''.join(choice(list(amino_acids)) for i in range(length))",... | [
"0.72776234",
"0.72617495",
"0.713852",
"0.7055625",
"0.70255107",
"0.6981934",
"0.69623893",
"0.6953072",
"0.6953072",
"0.695281",
"0.6947344",
"0.691706",
"0.690912",
"0.6904352",
"0.6887848",
"0.68779224",
"0.68768203",
"0.6874446",
"0.68720144",
"0.68690336",
"0.6858208",... | 0.74425733 | 0 |
Wrapper for checking if something exists in the settings or not. Return the default otherwise | def get_django_setting_or_default(setting_name, default):
if hasattr(settings, setting_name) and getattr(settings, setting_name):
return getattr(settings, setting_name)
else:
return default | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_config(value, default=False, place=config):\n return place[value] if (value in place and place[value]) else default",
"def get_if_exists(self, item_name, default_value=None):\n\t\tif self.has_option(item_name):\n\t\t\treturn self.get(item_name)\n\t\treturn default_value",
"def test_get_setting_wit... | [
"0.6842639",
"0.676464",
"0.67345685",
"0.6716579",
"0.6673151",
"0.6623738",
"0.6598821",
"0.65087867",
"0.65051776",
"0.64671373",
"0.6377017",
"0.63",
"0.6284165",
"0.62665313",
"0.62598586",
"0.62554204",
"0.62370634",
"0.6214041",
"0.61464214",
"0.6126894",
"0.61162627",... | 0.7200509 | 0 |
For constructing a Jacobian. This is the change in the total current through the membrane | def dIdV(self, system_state=None):
V_m = self.membrane.phi(system_state)
h = self.h(system_state)
m = self.m(system_state)
invalues = self.membrane.inside.get_val_dict(system_state)
outvalues = self.membrane.outside.get_val_dict(system_state)
dIdV = [ gmax*species.z*(V_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jacobianF(self):\n\n jacob = np.eye(len(self.x))\n jacob[0][1] = 1\n jacob[2][0] = self.x[4] + self.x[6] * self.x[0] + self.x[8] * (self.x[0] ** 2) / 2\n jacob[2][4] = self.x[0]\n jacob[2][6] = (self.x[0] ** 2) / 2\n jacob[2][8] = (self.x[0] ** 3) / 6\n jacob[3]... | [
"0.80064213",
"0.78675115",
"0.76251334",
"0.76014525",
"0.7496929",
"0.7278031",
"0.7198658",
"0.71227306",
"0.7026088",
"0.70084965",
"0.69522935",
"0.69456315",
"0.68816394",
"0.6863831",
"0.6843681",
"0.682983",
"0.68208843",
"0.6777606",
"0.67560595",
"0.6714403",
"0.669... | 0.0 | -1 |
Send colorWipe animation with the specified color and delay r red byte g green byte b blue byte delay delay to wait between LED | def colorWipe(self, r, g, b, delay):
payload = bytearray([ 0x0b, r, g, b, delay ])
return self._send(payload) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colorWipe(self, color, wait_ms=50):\n\t\tfor i in range(self.s.strip.numPixels()):\n\t\t\tself.s.strip.setPixelColor(i, color)\n\t\t\tself.s.strip.show()\n\t\t\ttime.sleep(wait_ms/1000.0)",
"def colorWipe(self, color, wait_ms=50):\n for i in range(self.strip.numPixels()):\n self.strip.setPi... | [
"0.7370352",
"0.73589313",
"0.7327861",
"0.7183936",
"0.7176652",
"0.7176652",
"0.7176652",
"0.7176652",
"0.7176652",
"0.7155539",
"0.7091171",
"0.6694534",
"0.6512605",
"0.6350694",
"0.6335596",
"0.63083905",
"0.62511533",
"0.62477106",
"0.6233805",
"0.6233805",
"0.6233805",... | 0.81491286 | 0 |
Get disc usage This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True | def get_disc_usage(self, **kwargs):
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.__get_disc_usage_with_http_info(**kwargs)
else:
(data) = self.__get_disc_usage_with_http_info(**kwargs)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_disc_usage_with_http_info(self, **kwargs):\r\n\r\n all_params = ['storage_name']\r\n all_params.append('async_req')\r\n all_params.append('_return_http_data_only')\r\n all_params.append('_preload_content')\r\n all_params.append('_request_timeout')\r\n\r\n params ... | [
"0.76123786",
"0.6680539",
"0.66526246",
"0.58453846",
"0.5536747",
"0.55272025",
"0.5314973",
"0.5251787",
"0.52050704",
"0.5180958",
"0.5140939",
"0.5099805",
"0.50948614",
"0.50421",
"0.5037837",
"0.5035608",
"0.49978378",
"0.49736527",
"0.49409792",
"0.49128744",
"0.48888... | 0.7585449 | 1 |
Get disc usage This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True | def __get_disc_usage_with_http_info(self, **kwargs):
all_params = ['storage_name']
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_disc_usage(self, **kwargs):\r\n kwargs['_return_http_data_only'] = True\r\n if kwargs.get('async_req'):\r\n return self.__get_disc_usage_with_http_info(**kwargs)\r\n else:\r\n (data) = self.__get_disc_usage_with_http_info(**kwargs)\r\n return data",
"... | [
"0.7584236",
"0.6680213",
"0.6653044",
"0.58456516",
"0.5534648",
"0.55276525",
"0.5314092",
"0.5250102",
"0.52064425",
"0.5178529",
"0.5140202",
"0.5101104",
"0.50953877",
"0.50408316",
"0.5037384",
"0.50358146",
"0.49995384",
"0.4972875",
"0.4939933",
"0.49122",
"0.48880213... | 0.76123613 | 0 |
Convert an input data row into a numpy vector. | def get_np_vec(data_row):
tokens = data_row.strip().split('\t')
pmc = tokens[1]
# Use round() to avoid exact match
vec = [round(float(x), 3) for x in tokens[-300:]]
# Convert Python list to NumPy array, which is expected by get_paper_knn()
np_vec = np.array(vec).reshape(1, -1)
return (pm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_vector(self, obj):\n if isinstance(obj, np.ndarray):\n return obj\n elif isinstance(obj, basestring):\n return self.row_named(obj)\n elif is_iterable(obj):\n return self.vector_from_terms(obj)\n else:\n raise TypeError(\n ... | [
"0.7138178",
"0.7001051",
"0.6858514",
"0.6768937",
"0.66206294",
"0.660904",
"0.65386057",
"0.6434331",
"0.6362427",
"0.63546854",
"0.63546854",
"0.63440204",
"0.63437235",
"0.63103175",
"0.6283274",
"0.62759423",
"0.6272533",
"0.6244294",
"0.6200415",
"0.61569005",
"0.61441... | 0.6700572 | 4 |
Turns an ndarray created by a meshgrid back into a 1D array | def demeshgrid(arr):
dim = len(arr.shape)
for i in range(dim):
Slice1 = [0]*dim
Slice2 = [1]*dim
Slice1[i] = slice(None)
Slice2[i] = slice(None)
if (arr[tuple(Slice1)] == arr[tuple(Slice2)]).all():
return arr[tuple(Slice1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flattengrid(grid):\n return np.vstack([g.flatten() for g in grid]).T",
"def create_grid(r):\n grid = np.meshgrid(*r)\n grid = [grid[i].flatten() for i in range(len(r))]\n grid = np.array(grid).T\n return grid",
"def convert_array_to_2d(grid):\n grid_2d = []\n for row in range(MAP_SIZE)... | [
"0.65268284",
"0.6101796",
"0.594389",
"0.5931659",
"0.5925256",
"0.59027404",
"0.5864861",
"0.5854036",
"0.58375835",
"0.5834828",
"0.5813354",
"0.58099735",
"0.5809388",
"0.5809388",
"0.57932967",
"0.5685833",
"0.56774724",
"0.5666553",
"0.56383705",
"0.56321657",
"0.562713... | 0.601624 | 2 |
3x3 convolution with padding | def conv3x3(in_planes, out_planes, stride=1, groups=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, groups=groups, bias=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv3x3(in_planes, out_planes, stride=1, padding=1, groups=1, dilation=1, zero_init=False):\n conv = nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=padding, groups=groups, bias=False, dilation=dilation)\n if zero_init:\n conv.weight.data.zero_()\n return conv",
"def co... | [
"0.73706514",
"0.7335249",
"0.7216377",
"0.72037584",
"0.72037584",
"0.7199952",
"0.7192902",
"0.7183875",
"0.7178802",
"0.7172082",
"0.71645725",
"0.71645725",
"0.716185",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",... | 0.0 | -1 |
Constructs a ResNet50 model. | def resnet50(pretrained=True, **kwargs):
model = ResNet(Bottleneck, [3, 4, 6, 3], **kwargs)
if pretrained:
print('using own pre-trained model')
model.load_state_dict(torch.load('models/{}.pth'.format(modelName)))
model.eval()
print('download finished')
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet50(self):\n\n base_model = ResNet50(weights=self.weights, include_top=self.include_top,\n pooling=self.pooling)\n x = base_model.layers[-1]\n out = Dense(units=self.num_classes, activation=self.activation, name='output',\n use_bias=True... | [
"0.78577375",
"0.7818183",
"0.7473913",
"0.7473913",
"0.74538076",
"0.7446541",
"0.7446541",
"0.7446541",
"0.74296004",
"0.7385123",
"0.7385123",
"0.7385123",
"0.7378058",
"0.7371368",
"0.7314428",
"0.73017883",
"0.72765946",
"0.7252975",
"0.7215502",
"0.7213279",
"0.7125597"... | 0.7092856 | 22 |
Turn a raw HTML review into a string of cleaned up words. | def clean_review(review):
# Remove HTML
review_text = BeautifulSoup(review, 'html.parser').get_text()
# Remove non-letters
review_text = re.sub('[^a-zA-Z]', ' ', review_text)
# Convert words to lower case and split them
words = review_text.lower().split()
# Return a string of words separa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_review(review: str) -> str:\n review = re.sub(\"(&#39;)+\", \"'\", review)\n review = re.sub(\"(<br>)+\", \" \", review)\n review = re.sub(\"\\xa0\", \"\", review)\n review = review.lower()\n return review",
"def clean_web_text(rawWebText):\n # replace html... | [
"0.72103006",
"0.71785486",
"0.6955544",
"0.66851956",
"0.666188",
"0.6640968",
"0.65969515",
"0.656474",
"0.65566653",
"0.6541912",
"0.6538927",
"0.65319484",
"0.64619696",
"0.6439614",
"0.6409721",
"0.6409141",
"0.6378007",
"0.6326617",
"0.6322812",
"0.6315445",
"0.6296389"... | 0.7637557 | 0 |
This function returns a Pyramid WSGI application. In our case, this is only used for tests. | def main(global_config, **settings):
config = Configurator(settings=settings)
return config.make_wsgi_app() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wsgi_app():\n return bottle.default_app()",
"def app():\n _app = create_app('testing')\n\n return _app",
"def app():\n return create_app()",
"def app():\n app = server.app\n return app",
"def app_request():\n _app = create_app('testing')\n\n return _app",
"def get_internal_wsg... | [
"0.7956633",
"0.7660178",
"0.75891054",
"0.75311226",
"0.75234365",
"0.74993247",
"0.74054617",
"0.73988855",
"0.73652667",
"0.7324382",
"0.732262",
"0.7319883",
"0.73049575",
"0.7295622",
"0.72781855",
"0.725345",
"0.72514224",
"0.72138757",
"0.72128123",
"0.7187927",
"0.717... | 0.71263075 | 24 |
Return swivel axis. Points from side midpoint to top side top corner. | def swivel_axis(self, side, depth_offset=0, lateral_offset=0):
side_mid = self.side_middle_pt(side)
if side == "left":
axis_end = self.corners[0]
elif side == "right":
axis_end = self.corners[1]
axis = axis_end - side_mid
pt_on_line = side_mid
pt_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axis(self):\n if self:\n return (self.start_offset + self.stop_offset) / 2",
"def axis(self):\n return self._axis",
"def axis(self):\n return self._axis",
"def vaxis(self):\n return self._position[0] + self._svgheader.extent()[0]/2",
"def getLeftY(self):\r\n return... | [
"0.67550266",
"0.6320466",
"0.6320466",
"0.6258131",
"0.61319256",
"0.60736865",
"0.6022813",
"0.5985699",
"0.5966474",
"0.5948874",
"0.5905173",
"0.5839286",
"0.58279705",
"0.58193",
"0.58104956",
"0.58101165",
"0.58061314",
"0.579891",
"0.57653517",
"0.5754129",
"0.5717567"... | 0.6473191 | 1 |
Return tilt axis, including optional offsets. Choose positive rotation to tilt display upwards. | def tilt_axis(self, side="left", depth_offset=0, vertical_offset=0):
side_mid = self.side_middle_pt(side)
if side == "left":
axis = side_mid - self.center
elif side == "right":
axis = self.center - side_mid
pt_on_line = side_mid
pt_on_line[1] += vertical_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axial_tilt(self):\n if self.tilt is None:\n self.tilt = int(\n (self.axis ** 0.2) * about(self.earth_axial_tilt, 0.4)\n ) % 360\n return self.tilt",
"def _tilt(self, tilt=DEFAULT_TILT):\n # Center in logarithmic scale\n c = DEFAULT_F_MIN * np.s... | [
"0.65539926",
"0.6466094",
"0.6370399",
"0.630227",
"0.6302223",
"0.5790168",
"0.5747037",
"0.57077277",
"0.5666",
"0.56486857",
"0.5572455",
"0.54757357",
"0.54664755",
"0.544356",
"0.5399542",
"0.5326602",
"0.52691454",
"0.52557963",
"0.52360487",
"0.5175332",
"0.51540107",... | 0.70596975 | 0 |
Return the normal vector of the rectangle placed at the center. Take length 1 and points to z direction. | def normal(self):
normal = np.array(
[
self.center[0],
self.center[1],
self.center[2]-1,
self.center[3],
]
)
return normal | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(self, surface_point):\n return (surface_point - self.center).normalized()",
"def GetNormal(self) -> Vector:\n ...",
"def surfaceNormal(self, sfPoint):\n return (sfPoint.subVector(self.center)).normalizeVector()",
"def normal_at(self, point):\n return (point - self.cente... | [
"0.74864423",
"0.74556035",
"0.73693466",
"0.73302364",
"0.7295959",
"0.72542137",
"0.719704",
"0.71530074",
"0.7146664",
"0.71286774",
"0.7039137",
"0.6972274",
"0.6935189",
"0.6921019",
"0.682357",
"0.680966",
"0.67966884",
"0.6781008",
"0.6737465",
"0.6732932",
"0.67295724... | 0.80064446 | 0 |
Only subunit will rotate to move, not the entire unit | def revertmove(self):
self.new_angle = self.angle
self.moverotate = False # will not rotate to move
self.revert = True
newangle = self.setrotate()
for subunit in self.subunit_sprite:
subunit.new_angle = newangle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_subunit_target(self, target=\"rotate\", resetpath=False):\n if target == \"rotate\": # rotate unit before moving\n unit_topleft = pygame.Vector2(self.base_pos[0] - self.base_width_box, # get the top left corner of sprite to generate subunit position\n ... | [
"0.68667483",
"0.66542804",
"0.6293545",
"0.62833",
"0.6249918",
"0.62233067",
"0.6213692",
"0.61725706",
"0.6140073",
"0.61106044",
"0.6102683",
"0.6013231",
"0.6013155",
"0.6007055",
"0.59930414",
"0.59824306",
"0.59291357",
"0.59036016",
"0.5826345",
"0.5822189",
"0.581913... | 0.67502564 | 1 |
pulls the region from the aws config file | def get_region(self):
file1 = self.home_dir + '/.aws/config'
lines = [line.rstrip('\n') for line in open(file1)]
for each in lines:
if 'region' in each:
line = each.split()
region = line[2]
logger.info('using region ' + region)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region(self):\n return self.config.get(\"aws\", \"aws_region_name\", fallback=\"us-east-1\")",
"def get_cloud_region():\n return get_setup_file_contents().get('region')",
"def get_region():\n if bb.aws.region is None:\n __init_region()\n log.debug('Return region: %s', bb.aws.region)\... | [
"0.7518045",
"0.74540454",
"0.73421526",
"0.6947595",
"0.6747246",
"0.6612189",
"0.65955544",
"0.6548131",
"0.6535957",
"0.65194035",
"0.6482296",
"0.63870543",
"0.6293738",
"0.6293738",
"0.6293738",
"0.6293738",
"0.6278929",
"0.6278929",
"0.6278929",
"0.6278929",
"0.6278929"... | 0.8649407 | 0 |
Check user is trying to edit their own profile. | def has_object_permission(self, request, view, obj):
if request.method in permissions.SAFE_METHODS:
return True
return obj.id == request.user.id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_edit_user(request):\n return _EDIT_USER_EPPN in request.session",
"def test_auth_user_have_access_to_profile_edit(self):\n self.assertEqual(self.response.status_code, 200)",
"def test_no_profile_to_edit(self):\n self.client.force_login(self.user)\n\n response = self.client.get(r... | [
"0.74102867",
"0.73587835",
"0.72118115",
"0.7211096",
"0.71150285",
"0.71110284",
"0.7061463",
"0.70219576",
"0.70213044",
"0.7016309",
"0.70036376",
"0.69230103",
"0.6905491",
"0.6882643",
"0.6836896",
"0.679881",
"0.6785099",
"0.6770943",
"0.6763607",
"0.67589223",
"0.6755... | 0.0 | -1 |
Adds error to context with optional message. | def add_error(self, code, message=None):
self.errors[code] = message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(self, message: str, context: Dict):\n logger = self.get_logger()\n logger.error(message, extra=context)",
"def _add_error(self, error: ValidationError) -> None:\n\n if self.errors is None:\n self.errors = Errors()\n\n message = error.args[0]\n self.errors.a... | [
"0.72641546",
"0.6980854",
"0.69472873",
"0.6843933",
"0.68056905",
"0.66995466",
"0.66837555",
"0.6647495",
"0.64769757",
"0.6469454",
"0.646835",
"0.6460343",
"0.63834804",
"0.6369637",
"0.6334235",
"0.6295643",
"0.6291705",
"0.62893695",
"0.6280306",
"0.6280306",
"0.628030... | 0.6723106 | 5 |
Return the number of measurements in the time series. | def n_measurements(self):
return len(self._d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_values(self):\n # type: () -> float\n return self._count",
"def size(self):\n n = 0\n for spectra in self.data:\n n += spectra.flux.size\n return n",
"def series_len(self):\n #print \"self.datalen\\n\",self.datalen\n return self.datalen",
"d... | [
"0.70172215",
"0.6961804",
"0.6880685",
"0.6869061",
"0.6744403",
"0.6732015",
"0.6693618",
"0.65468574",
"0.6509349",
"0.6509349",
"0.6509349",
"0.6508743",
"0.640838",
"0.63829696",
"0.6373691",
"0.63710976",
"0.63710976",
"0.6370746",
"0.6365956",
"0.63650703",
"0.6351591"... | 0.73267156 | 0 |
Should this return the length of time in seconds that the time series spans, or the number of measurements in the time series? For now, it's the number of measurements. | def __len__(self):
return self.n_measurements() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_length_ms(self):\n # If list empty or single element:\n if len(self._traj) < 2:\n return 0;\n\n else:\n time_length = self._traj[-1].time_ms - self._traj[0].time_ms;\n\n if time_length < 0:\n print('WARNING: Trajectory: time length is neg... | [
"0.72407514",
"0.7204414",
"0.69094855",
"0.684956",
"0.6768016",
"0.6662046",
"0.66358733",
"0.6575834",
"0.65692085",
"0.65539694",
"0.6518863",
"0.65094095",
"0.64921796",
"0.6451227",
"0.6449689",
"0.6442639",
"0.63881785",
"0.6379324",
"0.6370948",
"0.6354749",
"0.635361... | 0.668945 | 5 |
Iterate over groups of `n` consecutive measurement points in the time series, optionally only the groups where the starting value of the time series matches `value`. | def iterintervals(self, n=2):
# tee the original iterator into n identical iterators
streams = tee(iter(self), n)
# advance the "cursor" on each iterator by an increasing
# offset
for stream_index, stream in enumerate(streams):
for i in range(stream_index):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups(iterable, n, step):\n itlist = tee(iterable, n)\n onestepit = izip(*(starmap(drop, enumerate(itlist))))\n return take_every(step, onestepit)",
"def group_consecutives(vals, step=1):\n run = []\n result = [run]\n expect = None\n for v in vals:\n if (v == expect) or (expect i... | [
"0.62668794",
"0.55861336",
"0.5524358",
"0.54752725",
"0.5439465",
"0.54082894",
"0.53726405",
"0.5315775",
"0.52947545",
"0.5285714",
"0.5284521",
"0.52182066",
"0.51942617",
"0.51704055",
"0.5162255",
"0.51407385",
"0.51387334",
"0.5132307",
"0.51283896",
"0.51283896",
"0.... | 0.46583936 | 98 |
This function uses a priority queue to efficiently yield the (time, value_list) tuples that occur from merging together many time series. | def _iter_merge(timeseries_list):
# cast to list since this is getting iterated over several
# times (causes problem if timeseries_list is a generator)
timeseries_list = list(timeseries_list)
# Create iterators for each timeseries and then add the first
# item from each iterator... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def union(\n postings_lists: List[Iterable[CaptionIndex.Posting]],\n use_time: bool = True\n ) -> List[CaptionIndex.Posting]:\n\n def get_priority(p) -> Tuple[Number, Number]:\n return (p.start, p.idx) if use_time else (p.idx, p.start)\n\n postings_lists_with_prior... | [
"0.5602045",
"0.5587701",
"0.555857",
"0.5523651",
"0.54985124",
"0.5281342",
"0.52434945",
"0.5164913",
"0.5147687",
"0.51336926",
"0.51046216",
"0.5056488",
"0.50505286",
"0.502012",
"0.494466",
"0.4925558",
"0.49023232",
"0.48928195",
"0.48895004",
"0.48803774",
"0.4867227... | 0.7029977 | 0 |
Return True if > than treshold value (or >= threshold value if inclusive=True). | def threshold(self, value, inclusive=False):
if inclusive:
def function(x, y): return True if x >= y else False
else:
def function(x, y): return True if x > y else False
return self.operation(value, function) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_difference_under_threshold(val1, val2, threshold):\n\n\treturn abs(val1 - val2) < threshold",
"def check_threshold_Poisson(x, y, threshold):\n # deal with the infinity special cases separately - nothing should ever be below the -inf curve or above the +inf one:\n if threshold > 6: return Tru... | [
"0.7020902",
"0.6872193",
"0.68616146",
"0.68486744",
"0.6761881",
"0.6701969",
"0.6625692",
"0.6621975",
"0.6519473",
"0.6491781",
"0.6412196",
"0.6408688",
"0.6380867",
"0.6369634",
"0.6349333",
"0.62038535",
"0.6190611",
"0.6174434",
"0.61629844",
"0.61473614",
"0.6146001"... | 0.7792134 | 0 |
Takes a mesh and return its group names and a list of lists, one list per vertex. aligning the each vert list with the group names, each list contains float value for the weight. These 2 lists can be modified and then used with list2MeshWeight to apply the changes. | def BPyMesh_meshWeight2List(vgroup, me):
# Clear the vert group.
groupNames = [g.name for g in vgroup]
len_groupNames = len(groupNames)
if not len_groupNames:
# no verts? return a vert aligned empty list
#return [[] for i in range(len(me.vertices))], []
return [], []
else:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_mesh_groups(\n mesh: Mesh,\n selected_elements: np.ndarray,\n vertex_id_dtype: np.dtype) -> Tuple[List[MeshElementGroup], np.ndarray]:\n\n # {{{ find filtered_group_elements\n\n group_elem_starts = [\n np.searchsorted(selected_elements, base_element_nr)\n for ba... | [
"0.610094",
"0.576832",
"0.57650137",
"0.55066407",
"0.547462",
"0.5441324",
"0.538347",
"0.5325514",
"0.529864",
"0.52506393",
"0.51920134",
"0.51356894",
"0.513384",
"0.5089945",
"0.5088459",
"0.50853837",
"0.5075402",
"0.50699234",
"0.50599104",
"0.50490844",
"0.50279355",... | 0.79543144 | 0 |
Updates state for `toggle autoupdates` context menu item. | def update_cmenu_item_toggle(self, torrents_to_update):
states = []
for torrent_id in self.get_selected_torrents():
state = torrent_id in torrents_to_update
states.append(state)
if states.count(True) >= states.count(False):
self.cmenu_item_toggle.set_label(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_cmenu_item_toggle_activate(self, widget):\n enable = False\n if widget.get_label() == self.CONTEXT_UPDATE_CHOICES[True]:\n enable = True\n widget.set_label(self.CONTEXT_UPDATE_CHOICES[not enable])\n for torrent_id in self.get_selected_torrents():\n client.up... | [
"0.66862166",
"0.65633464",
"0.6430941",
"0.6063986",
"0.5994603",
"0.58682954",
"0.58220243",
"0.5775352",
"0.568976",
"0.55567086",
"0.5530437",
"0.5516849",
"0.5478373",
"0.5469399",
"0.5441129",
"0.5399359",
"0.5369504",
"0.53428143",
"0.53380513",
"0.53325945",
"0.530908... | 0.6155317 | 3 |
Checks if the given catalog has a logbook for a job. | def __contains__(self, job):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_job(self, job_name) -> bool:\n self.log.info(\"Checking if job already exists: %s\", job_name)\n\n try:\n self.conn.get_job(JobName=job_name)\n return True\n except self.conn.exceptions.EntityNotFoundException:\n return False",
"def job_exists(self, p... | [
"0.5535955",
"0.5494091",
"0.5225379",
"0.50290865",
"0.50031465",
"0.49692872",
"0.49045354",
"0.48376393",
"0.48282212",
"0.48012704",
"0.479196",
"0.47682634",
"0.4738047",
"0.47355062",
"0.47296533",
"0.47216943",
"0.47196937",
"0.47026727",
"0.46857795",
"0.4674944",
"0.... | 0.43002823 | 100 |
Create and append a new text block (shortcut). | def TextBlock(self, *args, **kwargs):
tb = TextBlock(*args, **kwargs)
self.append(tb)
return tb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addTextBlock(text, options = None):\n if options is None:\n options = BlocksFactory.__DEFAULT_OPTIONS\n BlocksFactory.addBlock(\"TextBlock\", options)\n BlocksFactory.setData(\"text\", text)\n\n return BlocksFactory",
"def add_text(self, text):\n tk.Label(self.fr... | [
"0.70613647",
"0.6749358",
"0.6729895",
"0.66891015",
"0.665438",
"0.64168113",
"0.63847727",
"0.63176906",
"0.63090247",
"0.63061714",
"0.6279489",
"0.62544006",
"0.62502575",
"0.62279433",
"0.62261105",
"0.62200314",
"0.6218292",
"0.61628586",
"0.61507976",
"0.6120969",
"0.... | 0.7380163 | 0 |
Create and append a Paragraph to this TextBlock. A CR is automatically inserted after the Paragraph. To avoid this behavior, create the Paragraph and append it to the TextBlock in a separate call. | def Paragraph(self, *args, **kwargs):
p = Paragraph(*args, **kwargs)
self.append(p)
self.append(CR())
return p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddParagraph(*args, **kwargs):\n return _richtext.RichTextCtrl_AddParagraph(*args, **kwargs)",
"def AddParagraph(*args, **kwargs):\n return _richtext.RichTextParagraphLayoutBox_AddParagraph(*args, **kwargs)",
"def _append_to_paragraph(self, content):\n if self.paragraph is not None:\n ... | [
"0.7919813",
"0.7684803",
"0.74253607",
"0.74162644",
"0.70566624",
"0.6891299",
"0.68559414",
"0.6584655",
"0.65666234",
"0.65596575",
"0.6545326",
"0.6521366",
"0.6517715",
"0.6441505",
"0.63991755",
"0.63752997",
"0.6237477",
"0.6179077",
"0.61408365",
"0.59603906",
"0.588... | 0.83195364 | 0 |
Return only "active" (i.e. published) questions. | def active(self):
return self.filter(status__exact=self.model.ACTIVE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_active(self):\n question = factories.Question(is_active=True)\n factories.Question(is_active=False)\n self.assertEqual(list(models.Question.objects.active()), [question])",
"def active(self):\n return self.filter(active=True)",
"def active(self):\n return self.filter... | [
"0.70421934",
"0.65282714",
"0.65282714",
"0.65282714",
"0.6446878",
"0.6401196",
"0.6401196",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.6388831",
"0.63511264",
"0.63511264... | 0.63670564 | 19 |
Turn a duration in seconds into a human readable string | def duration(s):
m, s = divmod(s, 60)
h, m = divmod(m, 60)
d, h = divmod(h, 24)
parts = []
if d:
parts.append('%dd' % d)
if h:
parts.append('%dh' % h)
if m:
parts.append('%dm' % m)
if s:
parts.append('%ds' % s)
return ' '.join(parts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration_humanize(duration):\n hours = duration // 60\n minutes = duration % 60\n return f'{hours}h {minutes}min'",
"def duration(value: bytes) -> str:\n\n seconds = int(value)\n\n if seconds == 1:\n return f\"{seconds} second\"\n\n if 60 < seconds <= 90:\n ... | [
"0.80868894",
"0.78684264",
"0.7864514",
"0.7860095",
"0.77652806",
"0.77180666",
"0.7672669",
"0.76617384",
"0.76001483",
"0.7588576",
"0.75479007",
"0.75290745",
"0.7529068",
"0.7515182",
"0.7509064",
"0.7491689",
"0.74907106",
"0.74736494",
"0.74270564",
"0.7422449",
"0.74... | 0.7690858 | 6 |
Turn a duration in seconds into a shorter human readable string | def shortduration(s):
return ' '.join(duration(s).split()[:2]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration_humanize(duration):\n hours = duration // 60\n minutes = duration % 60\n return f'{hours}h {minutes}min'",
"def pretty_duration(seconds):\n ms = int((seconds or 0) * 1000)\n out = ''\n for name, nms in periods:\n if ms >= nms:\n val, ms = divmod(ms, nms)\n ... | [
"0.8189498",
"0.7849678",
"0.7839605",
"0.77631485",
"0.77043915",
"0.76931024",
"0.768064",
"0.7670526",
"0.76409763",
"0.76232296",
"0.7603788",
"0.75933665",
"0.7591754",
"0.7553469",
"0.752117",
"0.7509792",
"0.7458194",
"0.7432813",
"0.7403779",
"0.7392098",
"0.73789334"... | 0.8064858 | 1 |
Check if is logged | def test_login(self):
self.assertTrue(self.login) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_logged(self):\n raise NotImplementedError()",
"def is_logged(self, session):\n if 'username' in session:\n return True\n print('False')\n return False",
"def is_logged(self):\n\n return self.__class__._logged",
"def is_logged(self):\n\n result = sel... | [
"0.8179406",
"0.77684534",
"0.7582776",
"0.71835077",
"0.7133736",
"0.7096793",
"0.7092757",
"0.6979239",
"0.6978218",
"0.6954446",
"0.6839962",
"0.6791395",
"0.6789908",
"0.6780859",
"0.6733155",
"0.6729386",
"0.6728452",
"0.6712638",
"0.66908824",
"0.6682016",
"0.6649523",
... | 0.0 | -1 |
Initialize the basic LSTM cell | def __init__(self, num_units, forget_bias=1.0, activation=tf.tanh, layer_norm=False):
self._num_units = num_units
self._forget_bias = forget_bias
self._activation = activation
self._layer_norm = layer_norm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, n_hidden, scope='SimpleLSTM', lstm_activation=tanh, initializer=None):\n self.cell = BasicLSTMCell(n_hidden, forget_bias=1.0, activation=lstm_activation)\n self.scope = scope\n self.lstm_activation = lstm_activation\n self.initializer = initializer",
"def __init__(s... | [
"0.76037407",
"0.7204271",
"0.71418935",
"0.71318066",
"0.70089394",
"0.6899984",
"0.6834639",
"0.6801664",
"0.6744594",
"0.6660286",
"0.66540784",
"0.6567444",
"0.65647155",
"0.65566844",
"0.65563977",
"0.6500976",
"0.6472985",
"0.6458893",
"0.64242494",
"0.64229584",
"0.641... | 0.0 | -1 |
Return the value of the state (computed in __init__). | def getValue(self, state):
return self.values[state] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self):\n return self.__state",
"def get_value(self):\n return self.__state",
"def value(self, state):\r\n raise NotImplementedError",
"def value(self, state):\r\n raise NotImplementedError",
"def value(self, state):\n raise NotImplementedError",
"def value... | [
"0.8413014",
"0.8413014",
"0.8322541",
"0.8322541",
"0.83004",
"0.83004",
"0.82500297",
"0.80264217",
"0.802584",
"0.802151",
"0.79571116",
"0.79308134",
"0.79308134",
"0.79308134",
"0.790441",
"0.78325194",
"0.7743595",
"0.772862",
"0.7708989",
"0.76752216",
"0.7649296",
"... | 0.7734854 | 29 |
Convert a 32bit unsigned number into a hex string. | def uint32ToHexString(number):
bottom = number & 0xFFFF
top = (number >> 16) & 0xFFFF
hexString = "%4.0X%4.0X" %(top, bottom)
return hexString | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def u32_to_hex8le(val: int) -> str:\n return uint_to_hex_le(val, 32)",
"def sint_to_hex(val):\n return str(hex((val + (1 << 32)) % (1 << 32)))",
"def uint_to_hex_le(value: int, width: int) -> str:\n return ''.join(\"%02x\" % ((value >> b) & 0xff) for b in range(0, align_up(width, 8), 8))",
"def hex_st... | [
"0.7527901",
"0.7093584",
"0.70082563",
"0.70041555",
"0.6972358",
"0.6905779",
"0.68700755",
"0.68610734",
"0.6815685",
"0.673066",
"0.6614669",
"0.6575328",
"0.65446174",
"0.65143836",
"0.6474778",
"0.63642716",
"0.63610256",
"0.63579416",
"0.63579416",
"0.63453674",
"0.633... | 0.8136829 | 0 |
calc GradCAM of each target layer. | def _get_gcam(
self: GradCAM,
target_layer: str,
inter_shape: Tuple[int]
) -> torch.Tensor:
# weight of each output channel in target layer
# weight of each output channel is the average of its gradient.
weight = F.adaptive_avg_pool2d(self.grad_cache[target_layer], 1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_gcam(self, img, node, target_index=1):\n\n # Get model and forward pass\n probs, ids = self.gcam.forward(img, node)\n\n for i in range(target_index):\n # Grad-CAM\n self.gcam.backward(ids=ids[:, [i]])\n regions = self.gcam.generate(target_layer='module.... | [
"0.73285645",
"0.7025061",
"0.70101964",
"0.6988135",
"0.65799683",
"0.6405481",
"0.6372013",
"0.61593723",
"0.6153729",
"0.6081417",
"0.60480183",
"0.6040301",
"0.60385555",
"0.586056",
"0.57486653",
"0.57451475",
"0.5439371",
"0.5429155",
"0.5374696",
"0.53556377",
"0.53542... | 0.6903083 | 4 |
Checks that arg has elements of the right dtype. | def check_array(self, arg, t):
if not isinstance(arg, np.ndarray):
raise MyiaInputTypeError('Expected ndarray')
if arg.dtype != dtype.type_to_np_dtype(t):
raise MyiaInputTypeError('Wrong dtype')
return arg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_ndarray(data):\n if data.__class__ is not np.ndarray:\n raise TypeError(\"Argument of type numpy.ndarray expected\")",
"def _check_input(data):\n T = len(data)\n data = np.array(data)\n dim = data[0].size if not np.isscalar(data[0]) else 1\n return data, T, dim",
"def check_... | [
"0.71195066",
"0.69713706",
"0.6886858",
"0.6777899",
"0.67488676",
"0.6673882",
"0.6524822",
"0.6510956",
"0.6448363",
"0.63996994",
"0.6372803",
"0.6363821",
"0.6355716",
"0.63438636",
"0.6320797",
"0.62875295",
"0.62794626",
"0.6255435",
"0.6248054",
"0.62279785",
"0.62221... | 0.7795066 | 0 |
Test that when no terms are given, no articles are returned. | def test_search_no_terms(self):
self.assertEqual([ ], search.collect([ ])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_context(self):\n data = self._assertGetRecommendations({'context': '', 'lang': 'en'})\n self.assertFalse(data['terms'] and data['results'])",
"def test_terms_undefined(self):\n with pytest.raises(qml.operation.TermsUndefinedError):\n op.terms()",
"def test_get_inv... | [
"0.70040464",
"0.68942106",
"0.6586319",
"0.64377797",
"0.61795515",
"0.61677355",
"0.61458045",
"0.6072981",
"0.6033973",
"0.6019291",
"0.6017644",
"0.58369523",
"0.57966834",
"0.57797265",
"0.5745026",
"0.5729583",
"0.57180446",
"0.5702156",
"0.56967074",
"0.56941324",
"0.5... | 0.70010185 | 1 |
Test that when searching for an unknown term, no results are returned. | def test_search_unknown_term(self):
random_string = ''.join(random.choice(string.ascii_lowercase + string.digits) for i in range(32))
self.assertFalse(len(search.collect(random_string))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_no_results(self):\n\n with self.client as c:\n resp = c.post(\"/search\", json={\"term\": \"asdfasdfasdfasdf\", \"media\": \"music\",\n \"entity\": \"song\", \"country\": \"US\", \"limit\": 10, \"lang\": \"en\"})\n data = resp.j... | [
"0.7249825",
"0.7195312",
"0.7181548",
"0.71655065",
"0.71239775",
"0.7115932",
"0.7025825",
"0.6900726",
"0.68654656",
"0.6829413",
"0.67754287",
"0.67617166",
"0.6674376",
"0.66385895",
"0.6630148",
"0.6627713",
"0.66130424",
"0.6586497",
"0.65439063",
"0.6539122",
"0.64972... | 0.77659905 | 0 |
Hub height of the turbines; currently assumed to be the same | def hub_height(self) -> float:
return self.turbines[0].hub_height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height():\n return (_toph + _both) / _scale",
"def height(self) -> torch.Tensor:\n return self.ymax - self.ymin",
"def height(self):\n return 80",
"def height(self):\n return 80",
"def get_height(self) -> Number:\n return (self.right_bottom[1] - self.left_top[1])",
... | [
"0.731045",
"0.67121094",
"0.66953826",
"0.66953826",
"0.6636391",
"0.65250456",
"0.65207547",
"0.65207547",
"0.6490693",
"0.6472958",
"0.6408361",
"0.6408361",
"0.6408361",
"0.6393282",
"0.63523024",
"0.6318826",
"0.6256155",
"0.62512445",
"0.62497175",
"0.6236379",
"0.62010... | 0.8300176 | 0 |
Test the post method with invalid payload. | async def test_authors_endpoint_post_invalid_payload(
async_client: AsyncTestClient, base_url: str
) -> None:
response = await async_client.post(f"{base_url}/authors", json={"foo": "bar"})
assert response.status_code == 422
if base_url == API_PYDANTIC_BASE_URL:
assert response.json() == {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_without_parameter(self):\n response = requests.post(\n self.endpoint, json=self.test_value)\n assert response.status_code == status.bad_request, response.text",
"def test_body_handles_request_with_invalid_post(self, sqs_queue_post):\n request = RequestFactory().post(... | [
"0.7950059",
"0.78009087",
"0.77032596",
"0.76753956",
"0.76586556",
"0.75814754",
"0.75626564",
"0.75536495",
"0.75139844",
"0.7478306",
"0.7478306",
"0.7473138",
"0.74697316",
"0.74426764",
"0.7431829",
"0.7418408",
"0.74149245",
"0.7396365",
"0.73622364",
"0.7354742",
"0.7... | 0.0 | -1 |
Return a random BST and a node in it. | def random_bst_and_node(nodes=6,seed=None):
T,x,y = random_bst_and_node_pair(nodes=nodes,seed=seed,distinct=False)
return T,x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_bst(nodes=6,seed=None):\n if seed == None:\n R = random\n else:\n R = random.Random(seed)\n x = R.randrange(nodes)\n T = BST()\n keys = []\n for _ in range(nodes):\n keys.append(x)\n x += 1 + R.randrange(4 + nodes//10)\n R.shuffle(keys)\n for k in keys... | [
"0.7571088",
"0.69211686",
"0.6797017",
"0.66505647",
"0.660267",
"0.65601957",
"0.6385252",
"0.636375",
"0.63297087",
"0.631506",
"0.6313716",
"0.6236526",
"0.6183414",
"0.6154135",
"0.6116365",
"0.61126435",
"0.61104155",
"0.6060853",
"0.60421765",
"0.6014854",
"0.5939537",... | 0.71267176 | 1 |
Return a list of node `x` and all its descendants | def all_descendants(x):
if x == None:
return
L=[x]
if x.left:
L += all_descendants(x.left)
if x.right:
L += all_descendants(x.right)
return L | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child_nodes(node):\r\n return list(iter_child_nodes(node))",
"def descendants(G, x):\n return set(nx.dfs_preorder_nodes(G, x)) - {x}",
"def getNodeDescendantList(self, node):\n return list(node.descendantGen())",
"def get_nodes(self):\n return list(self.nodes.__iter__())",
"def ... | [
"0.7314688",
"0.71952486",
"0.67766255",
"0.6560415",
"0.64934677",
"0.6433259",
"0.6403544",
"0.6377302",
"0.6325965",
"0.62842727",
"0.6283311",
"0.62808686",
"0.62683266",
"0.6256285",
"0.62410575",
"0.6224691",
"0.62144214",
"0.6213318",
"0.621129",
"0.62101555",
"0.61744... | 0.77290916 | 0 |
Make a deep copy of this panel instance. Returns a new Panel instance. | def copy(self):
return Panel( self.material, self.data, wavelengths=self.get_wavelengths() ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self) -> Widget:\n\n return deepcopy(self)",
"def clone(self):\n return deepcopy(self)",
"def deepcopy(self):\n return self.clone()",
"def __deepcopy__(self):\n return self",
"def clone(self):\n return _copy.deepcopy(self)",
"def clone(self):\n return co... | [
"0.7214779",
"0.7117549",
"0.71108496",
"0.7109455",
"0.7079166",
"0.70559233",
"0.70559233",
"0.7000912",
"0.69789195",
"0.6905558",
"0.6860694",
"0.6860694",
"0.6860694",
"0.68579996",
"0.6848404",
"0.6845788",
"0.68453866",
"0.6834257",
"0.6815441",
"0.68109554",
"0.678863... | 0.7987602 | 0 |
Get the normal vector of this panel by assuming its outline is square (prior to projection onto the camera). | def get_normal(self, cam):
# get corners of panel and convert to rays
corners = np.array([self.outline.vertices[i, :] for i in range(4)])
if cam.is_panoramic():
ray1 = pix_to_ray_pano(corners[0, 0], corners[0, 1], cam.fov, cam.step, cam.dims)
ray2 = pix_to_ray_pano(corn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(self):\n normal = np.array(\n [\n self.center[0],\n self.center[1],\n self.center[2]-1,\n self.center[3],\n ]\n )\n return normal",
"def norm(self):\n return _almathswig.Pose2D_norm(self)",
... | [
"0.75014544",
"0.72147727",
"0.71446663",
"0.70306396",
"0.70262885",
"0.7013204",
"0.69549453",
"0.68852425",
"0.68449205",
"0.6843432",
"0.6837066",
"0.6815318",
"0.68132997",
"0.67939496",
"0.6779223",
"0.6769793",
"0.67489785",
"0.672289",
"0.66918105",
"0.66686064",
"0.6... | 0.65287054 | 23 |
Get the wavelengths for which this ELC has been calculated. | def get_wavelengths(self):
return self.wav | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wavelengths(self):\n fspsDir = os.environ['SPS_HOME'] # environment variable for FSPS\n # print fspsDir\n if self.specType == \"basel\":\n lambdaPath = os.path.join(\n fspsDir, \"SPECTRA\", \"BaSeL3.1\", \"basel.lambda\")\n elif self.specType == \"miles\":... | [
"0.788445",
"0.74928194",
"0.7489678",
"0.7488711",
"0.6959445",
"0.67556024",
"0.6646474",
"0.65899634",
"0.64893466",
"0.6478196",
"0.6448215",
"0.63320476",
"0.6327718",
"0.6317287",
"0.618249",
"0.618249",
"0.61652",
"0.61416733",
"0.609387",
"0.60759974",
"0.59847623",
... | 0.7685185 | 1 |
Closes the database again at the end of the request. | def close_db(error):
if hasattr(g, 'sqlite_db'):
g.sqlite_db.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _end_db(self):\n database.close()",
"def end_connection(self):\n self.db.close()",
"def close_db(self):\n self.con.close()",
"def _close():\n if _database:\n _database.close()",
"def close(self):\n self.db_connection.close()",
"def close(self):\n self.db.c... | [
"0.84597117",
"0.8063647",
"0.80243427",
"0.799994",
"0.7965991",
"0.7959317",
"0.7959317",
"0.793528",
"0.79080456",
"0.7837638",
"0.78289086",
"0.78139913",
"0.7760883",
"0.77436775",
"0.76676434",
"0.7636659",
"0.75463897",
"0.7546091",
"0.7543379",
"0.75397",
"0.7526698",... | 0.0 | -1 |
Convert enum element to string. | def __str__(self):
if self in (Ethnicity.Asian, Ethnicity.Indian, Ethnicity.Caucasian):
# pylint: disable=E1101
return self.name.lower()
return "african_american" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_enum(val: Union[Enum, str]) -> str:\n return val.value",
"def enum_name(self, key, value):\n if not self.value_type(key):\n return str(value)\n \n options = self.value(key).options\n return options[value]",
"def __repr__(self):\n res = super(En... | [
"0.7148124",
"0.6860236",
"0.6633846",
"0.63141227",
"0.6167947",
"0.61349446",
"0.6096943",
"0.6082757",
"0.6042544",
"0.5998012",
"0.5906121",
"0.58846724",
"0.5854666",
"0.5805476",
"0.5785894",
"0.57790697",
"0.5777974",
"0.5716577",
"0.57041967",
"0.57041967",
"0.5696522... | 0.0 | -1 |
Get asian ethnicity value. | def asian(self) -> float:
return self._coreEstimation.asian | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_ethnicity_coding(self):\n self.ethnicity_system = 'http://hl7.org/fhir/v3/Ethnicity'\n df = pd.read_html(self.ethnicity_system)[2]\n df.columns = df.iloc[0,:]\n df = df[df.Level=='1']\n df = df.iloc[0:,1:3]\n self.ethnicity_description = random.choice(df.Display.t... | [
"0.7255585",
"0.7255585",
"0.67815244",
"0.67815244",
"0.58069223",
"0.5768871",
"0.5454215",
"0.54184633",
"0.5414245",
"0.5342788",
"0.52836514",
"0.52734923",
"0.52525896",
"0.5200611",
"0.51637036",
"0.515631",
"0.5137561",
"0.5137561",
"0.5119273",
"0.5119273",
"0.511647... | 0.51981264 | 14 |
Get predominate ethnicity (ethnicity with max score value). | def predominateEmotion(self) -> Ethnicity:
return Ethnicity.fromCoreEmotion(self._coreEstimation.getPredominantEthnicity()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def personal_best(self):\n return max(self.scores)",
"def predicted_confidence(self):\n sorted_clips = sorted(self.clips, key=lambda x: x.classifier_best_score)\n best_guess = sorted_clips[-1].classifier_best_score\n return best_guess",
"def get_best(self):\n return max(self.... | [
"0.6290126",
"0.59096473",
"0.58683515",
"0.5848649",
"0.5785346",
"0.57639873",
"0.5758272",
"0.57508236",
"0.5731987",
"0.5714391",
"0.56723946",
"0.5669343",
"0.56580067",
"0.5610121",
"0.5584949",
"0.5563564",
"0.5536507",
"0.55049473",
"0.54943585",
"0.54921323",
"0.5482... | 0.667816 | 0 |
Create our function to check if a token has been blacklisted. In this simple case, we will just store the tokens jti (unique identifier) in redis whenever we create a new token (with the revoked status being 'false'). This function will return the revoked status of a token. If a token doesn't exist in this store, we do... | def check_if_token_is_revoked(decrypted_token):
user_ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
jti = decrypted_token['jti']
entry = redis_store.get('access_jti:' + user_ip + jti)
entry_refresh = redis_store.get('refresh_jti:' + user_ip + jti)
# print(str(entry) + ' ' + str(jti)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_check_blacklist(decrypted_token):\n jti = decrypted_token[\"jti\"]\n return RevokedTokenModel.is_jti_blacklisted(jti)",
"def is_blacklisted(token):\n try:\n cur = conn.cursor()\n cur.execute(\n \"SELECT * FROM blacklist_tokens WHERE token = %s;\",\n ... | [
"0.70677704",
"0.6659287",
"0.6294042",
"0.6095297",
"0.6083637",
"0.606278",
"0.5978123",
"0.5937945",
"0.5875358",
"0.58668077",
"0.583856",
"0.5811641",
"0.58062583",
"0.5803653",
"0.5785171",
"0.57527184",
"0.5702121",
"0.56868535",
"0.5653345",
"0.56456286",
"0.56303155"... | 0.6987731 | 1 |
Creates a sample of different parameter combinations from all possible combinations within the passed parameter ranges. | def sample_discrete(parameter_ranges):
def make_tuple(v):
if isinstance(v, tuple):
return v
else:
return (v,)
param_ranges_values = [make_tuple(v) for k, v in parameter_ranges.items()]
param_combinations = list(itertools.product(*param_ranges_values))
param_samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(parameter_ranges, n, digits=None):\n\n parameter_ranges = dict(parameter_ranges)\n for k, v in parameter_ranges.items():\n if isinstance(v, tuple):\n p_range = np.linspace(v[0], v[1], n)\n if all([isinstance(pv, int) for pv in v[:2]]):\n p_range = [int(r... | [
"0.77469456",
"0.6644224",
"0.6614407",
"0.65824765",
"0.65824765",
"0.65824765",
"0.65824765",
"0.65824765",
"0.65824765",
"0.65824765",
"0.65199167",
"0.6507753",
"0.6480997",
"0.64312446",
"0.64141893",
"0.6397101",
"0.6363507",
"0.6343929",
"0.6332297",
"0.6326657",
"0.63... | 0.79772073 | 0 |
Returns the string representation of the model | def to_str(self):
return pprint.pformat(self.to_dict()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _repr_model_(self):\n return str(self)",
"def __str__(self):\n\n return str(self.model)",
"def get_model_string(self):\n raise NotImplementedError()",
"def __str__(self):\n return self.model",
"def serialize_model(self):\n return dill.dumps(self.model)",
"def __str_... | [
"0.86030954",
"0.85091114",
"0.8235956",
"0.80497414",
"0.80114347",
"0.793421",
"0.78784716",
"0.77902746",
"0.7789831",
"0.77466464",
"0.7629886",
"0.7608351",
"0.7582489",
"0.7515188",
"0.75065583",
"0.7504687",
"0.74877244",
"0.744343",
"0.74351317",
"0.74271595",
"0.7407... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n return not self == other",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other):\n return self.__dict__ != other.__dict__",
"def __eq__(self, other):\n return not self.__ne__(other)",
... | [
"0.8410411",
"0.8391477",
"0.8172175",
"0.81410587",
"0.80920255",
"0.8088807",
"0.80676955"
] | 0.0 | -1 |
Inputs the missing values in both training and test sets. | def input_missing_values(X_train: pd.DataFrame, X_test: pd.DataFrame) -> tuple:
ctx = context.load_context("../wind-power-forecasting")
cols_to_interpol = ctx.params.get("cols_to_interpol")
X_train_raw = ctx.catalog.load("X_train_raw")
cols_train = X_train_raw.columns[3:]
cols_test = X_train_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_missing_value_train_data(self, missing_rate = 0.30):\n n_samples, n_features = self.train_data.shape\n n_missing_samples = int(n_samples * missing_rate) #samples missing in each col \n missing_samples = np.zeros(n_samples, dtype=bool) \n missing_samples[: n_mi... | [
"0.6870553",
"0.6642674",
"0.662422",
"0.65739894",
"0.64720356",
"0.6335701",
"0.6207816",
"0.6181945",
"0.61126584",
"0.6111812",
"0.6050738",
"0.6010709",
"0.59997827",
"0.5995294",
"0.59931874",
"0.59658355",
"0.59611326",
"0.591497",
"0.5902013",
"0.58927894",
"0.5883987... | 0.71755886 | 0 |
Get the anchor's index. This must return an ``int``. Subclasses may override this method. | def _get_index(self):
glyph = self.glyph
if glyph is None:
return None
return glyph.anchors.index(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anchor_atom_index(self) -> int:\n lattice = self.structure.lattice\n all_coords = self.structure.frac_coords\n dist_set = lattice.get_all_distances(self.defect_center, all_coords)[0]\n return int(np.argmax(dist_set))",
"def index(self) -> int:\n return self._index",
"def ... | [
"0.75251055",
"0.73108447",
"0.73108447",
"0.73108447",
"0.7224182",
"0.7039579",
"0.7022747",
"0.6922026",
"0.6900296",
"0.68999535",
"0.6762886",
"0.67576057",
"0.67435664",
"0.6736467",
"0.6736467",
"0.6736467",
"0.6650438",
"0.6647845",
"0.66119224",
"0.6611092",
"0.65283... | 0.8025858 | 0 |
Returns True if the KEM algorithm is enabled, False otherwise. | def is_KEM_enabled(alg_name):
try:
kem = liboqs.OQS_KEM_new(ct.create_string_buffer(alg_name.encode()))
if(kem.contents):
liboqs.OQS_KEM_free(kem)
return True
except ValueError:
pass
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_enabled_KEM_mechanisms():\n return _enabled_KEMs",
"def enabled(self):\n return self.has_config(self.key_switch)",
"def enable_pkce(self) -> bool:\n return pulumi.get(self, \"enable_pkce\")",
"def get_is_estimate_enabled(self):\n return self.is_estimate_enabled",
"def print_... | [
"0.65951294",
"0.6403001",
"0.6338768",
"0.62004495",
"0.61247116",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
"0.600475",
... | 0.7661685 | 0 |
Returns True if the signature algorithm is enabled, False otherwise. | def is_sig_enabled(alg_name):
try:
sig = liboqs.OQS_SIG_new(ct.create_string_buffer(alg_name.encode()))
if(sig.contents):
liboqs.OQS_SIG_free(sig)
return True
except ValueError:
pass
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def support_digital_signature(self) -> bool:\n return self._support_digital_signature",
"def is_signing(self):\n return self.signing_algorithm_info is not None",
"def has_signatures(self) -> bool:\n # TODO\n return False",
"def needsSigning(self):\r\n return (\r\n ... | [
"0.7604705",
"0.71454555",
"0.6698152",
"0.65366876",
"0.6450858",
"0.6424242",
"0.6419804",
"0.6397507",
"0.63928884",
"0.63836586",
"0.62762797",
"0.62489223",
"0.60319096",
"0.59663147",
"0.58272177",
"0.57987523",
"0.57525676",
"0.57525676",
"0.57525676",
"0.57525676",
"0... | 0.6931186 | 2 |
Return string self username. | def __str__(self):
return self.username | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username(self) -> str:\n return self._username",
"def username(self) -> str:\n return self._username",
"def get_username(self):\n return self.username",
"def username(self) -> str:\n return pulumi.get(self, \"username\")",
"def username(self) -> str:\n return pulumi.g... | [
"0.8836901",
"0.8836901",
"0.8813036",
"0.8781945",
"0.8781945",
"0.8781945",
"0.8781945",
"0.8781945",
"0.8781945",
"0.8781945",
"0.8781945",
"0.8747039",
"0.87326694",
"0.86675864",
"0.86401266",
"0.85704446",
"0.85704446",
"0.8539993",
"0.8539993",
"0.8539993",
"0.8539993"... | 0.79156107 | 81 |
Adds the target user as a follower of the given viewpoint owned by the source user. Accumulates the size of all viewpoints that are merged. Creates notifications for the merged viewpoint. Sets a checkpoint containing follower and accounting information to be used if a restart occurs. | def _MergeOneViewpoint(self, viewpoint_id):
# Skip default and system viewpoints.
viewpoint = yield gen.Task(Viewpoint.Query, self._client, viewpoint_id, None)
if viewpoint.IsDefault() or viewpoint.IsSystem():
return
# Lock the viewpoint while querying and modifying to the viewpoint.
vp_lock ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NotifyMergeViewpoint(cls, client, viewpoint_id, existing_followers, target_follower,\r\n source_user_id, act_dict, timestamp):\r\n activity_func = NotificationManager._CreateActivityFunc(act_dict,\r\n Activity.CreateMergeAccounts,... | [
"0.7094665",
"0.6830304",
"0.6307537",
"0.6289766",
"0.6220632",
"0.620495",
"0.62028795",
"0.61746466",
"0.6104164",
"0.60841376",
"0.6039214",
"0.60122025",
"0.5985372",
"0.5922841",
"0.58983743",
"0.588777",
"0.58600974",
"0.5850811",
"0.5835373",
"0.58315504",
"0.5815633"... | 0.6792163 | 2 |
Returns active nodes and their attributes sorted by energy. | def sorted_nodes(self, descending=False):
active = [n_d for n_d in self.nodes(data=True) if n_d[1]['active']]
return sorted(active, key=lambda x: (
x[1]['energy'], x[0]), reverse=descending) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorted_nodes(self, attribute = 'energy', rev = False, nodes = None):\n if nodes is None:\n nodes = self.nodes\n return sorted(nodes, key = lambda x: self.nodes[x][attribute], reverse = rev)",
"def _getExpNodes(self):\n\t\tif len(self._sample['nodes']['open']) > 0:\n\t\t\t# Clustering... | [
"0.6995431",
"0.6043625",
"0.6043625",
"0.5981057",
"0.59048045",
"0.5721532",
"0.56711864",
"0.5621298",
"0.5621219",
"0.56115055",
"0.5591172",
"0.5589607",
"0.5585216",
"0.55743784",
"0.5562153",
"0.5550505",
"0.5533725",
"0.55327386",
"0.55038375",
"0.54766935",
"0.547499... | 0.7871805 | 0 |
Landscape coarsegraining base on energy barriers. Every structure gets assigned to an energetically better or equal macrostate. If a structure gets a assigned to itself, well then it represents the macrostate | def coarse_grain(self, dG_min=None):
merged_nodes = dict()
merged_to = dict()
if dG_min is None:
dG_min = self._dG_min
assert dG_min is not None
# sort by energy (high to low)
for ni, data in sorted(self.nodes(data=True),
key=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_m10_15_4000000():\r\n \"\"\"State 0,2: [BEST] [Preset] Map middle gimmick door_Relief_SubState\"\"\"\r\n assert event_m10_15_x148(z15=10152700, z16=10152705, flag2=115010020)\r\n \"\"\"State 1: Finish\"\"\"\r\n EndMachine()\r\n Quit()",
"def getStateMatrices(self, state): \n def g... | [
"0.54211384",
"0.5378607",
"0.5358354",
"0.5298941",
"0.5293432",
"0.52759844",
"0.527194",
"0.52440643",
"0.5243214",
"0.52030236",
"0.5198229",
"0.5156573",
"0.514935",
"0.5147866",
"0.5145235",
"0.51386917",
"0.51369053",
"0.5135519",
"0.5135223",
"0.51077926",
"0.51016694... | 0.0 | -1 |
Get the days that the vacuuming schedule should run. | def active_days(self) -> list:
on_days = []
for toggle in self.properties['schedule_switches']:
state = self.get_state(toggle, attribute='all')
if state['state'] == 'on':
on_days.append(state['attributes']['friendly_name'])
return on_days | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def days(self):\n days = list(self.schedule.keys())\n days.sort(key=DAYS_SORT.get)\n return days",
"def _getDays(self):\n week = [datetime.now()]\n dayDelta = timedelta(1)\n\n d_of_w = week[0].isoweekday()%7\n days = [(week[0].day,d_of_w+1)]\n self.month=se... | [
"0.7436441",
"0.6838408",
"0.6771178",
"0.6754328",
"0.6754328",
"0.666352",
"0.66126186",
"0.66016114",
"0.65261376",
"0.6396264",
"0.63912255",
"0.6387952",
"0.6156947",
"0.6093453",
"0.60882723",
"0.60606265",
"0.604407",
"0.60162866",
"0.6003232",
"0.5990758",
"0.5988765"... | 0.60908663 | 14 |
Define a property to get the bin state. | def bin_state(self) -> Enum:
return self.BinStates(self.get_state(self.entity_ids['bin_state'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\r\n return self.state",
"def get(self):\n\t\treturn self.state",
"def getDMXbin(self):\n return self.getter(lambda x: x.getDMXbin())",
"def state(self):\n if self._isbinary:\n return STATE_ON if self.is_on else STATE_OFF\n\n return self._def[ATTR_VALUE_FN... | [
"0.6123206",
"0.6118159",
"0.60530156",
"0.59950554",
"0.5958323",
"0.595266",
"0.588203",
"0.5841711",
"0.5839525",
"0.57864213",
"0.5782994",
"0.5749523",
"0.57384926",
"0.5715999",
"0.56819564",
"0.5663182",
"0.56595457",
"0.56591916",
"0.56533515",
"0.56533515",
"0.564878... | 0.66513294 | 0 |
Use the group of parsers to parse the records specify by date range, and return the parsing result. | def parseByDateRange(self, bdate, edate, parsers = []):
data = self.rec_m.date_range(bdate, edate)
return self.parseByRecords(data, parsers) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self, response):\n self.form_response = response\n\n # self.log(\"headers: %s\" % (response.headers,))\n range_start = self.date_range_start\n range_end = self.date_range_end\n search_span = self.search_span\n \n # Set initial search range dates\n s... | [
"0.6291318",
"0.61814237",
"0.6017875",
"0.57443434",
"0.5730976",
"0.57010347",
"0.56181425",
"0.5563536",
"0.5561201",
"0.55090517",
"0.5486022",
"0.5399779",
"0.53855425",
"0.536782",
"0.5320093",
"0.5246264",
"0.52305084",
"0.5224193",
"0.5222032",
"0.52057314",
"0.519978... | 0.71312803 | 0 |
tests project data i.e. accounts, subnets in project | def _test_project_data(self):
LOG.info("Checking presence of accounts and subnets in created project")
project_data = get_project(self.project_name)
project_str = json.dumps(project_data)
assert NTNX_ACCOUNT_1_UUID in project_str
assert NTNX_ACCOUNT_1_SUBNET_1_UUID in project_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_networking_project_netadp_list(self):\n pass",
"def test_all_projects(self):\n pass",
"def test_iam_project_list(self):\n pass",
"def test_projects_read(self):\n pass",
"def test_iam_project_billing_list(self):\n pass",
"def test_portfolio_subaccounts_get(self)... | [
"0.69201285",
"0.68132234",
"0.67403",
"0.6729288",
"0.6699541",
"0.66924375",
"0.66813064",
"0.6679088",
"0.6668057",
"0.6662657",
"0.66336125",
"0.6624754",
"0.6546679",
"0.6490782",
"0.64281446",
"0.63277",
"0.6325481",
"0.63227636",
"0.6215698",
"0.6213258",
"0.62085927",... | 0.8086559 | 0 |
Get the `tf.estimator.Estimator` defined by this builder. | def get_estimator(self, config=None):
return tf.estimator.Estimator(
self.build_estimator, self.model_dir, config=config) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getEstimator(self) -> Estimator:\n return self.getOrDefault(self.estimator)",
"def estimator(self):\n if self._estimator is None:\n self.load_estimator()\n return self._estimator",
"def get_estimator(hparams):\n def _train_op_fn(loss):\n \"\"\"Defines train op used in ra... | [
"0.8382522",
"0.7966316",
"0.7373348",
"0.72991574",
"0.7224157",
"0.6885237",
"0.6853254",
"0.67377377",
"0.6677574",
"0.658677",
"0.65652806",
"0.62466943",
"0.6207586",
"0.61958414",
"0.5989896",
"0.59816533",
"0.5925263",
"0.58709836",
"0.5797324",
"0.57285607",
"0.565640... | 0.81656843 | 1 |
Returns True if inside a current app session. | def in_session(self):
return HOU_IMPORTED or self.remote_connection | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_session(self):\n return bool(self.user)",
"def logged_in(self):\n return self._session_key is not None",
"def logged_in(self):\n return self.auth.get_user_by_session() is not None",
"def logged_in(self):\n return self.auth.get_user_by_session() is not None or users.get_current_... | [
"0.7467565",
"0.734612",
"0.72821796",
"0.7133159",
"0.70807844",
"0.70040405",
"0.6954018",
"0.6935837",
"0.6879317",
"0.6879317",
"0.68680936",
"0.68198127",
"0.68168175",
"0.67315656",
"0.67229784",
"0.66842973",
"0.6655748",
"0.6646222",
"0.664352",
"0.6639511",
"0.659753... | 0.0 | -1 |
Returns the name of the application. | def name(self):
return "houdini" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_name(self):\n return self._app_name",
"def appname(self) -> str:\n return self._appname",
"def get_app_name(self):\n if \"app\" in self.properties:\n return self.properties[\"app\"].display_name\n return None",
"def name(self):\n assert self.NAME, \"Inval... | [
"0.87439495",
"0.8742621",
"0.866181",
"0.8624232",
"0.86036634",
"0.86024654",
"0.84100884",
"0.82651204",
"0.824841",
"0.822835",
"0.82148",
"0.81541634",
"0.77943075",
"0.77785474",
"0.77160394",
"0.7690557",
"0.7680822",
"0.7650631",
"0.7633644",
"0.76259166",
"0.74681836... | 0.0 | -1 |
search n in array and return its index, if you find, return 1 | def binary_search(arr, n):
low = 0
high = len(arr) - 1
found = False
index = -1 # error condition
# integer overflow, int, float, double
while not found and low <= high:
# mid = (low + high) // 2
mid = low + ((high - low) // 2) # integer overflow cases for big numbers
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_search(a, s:int, x:int):\n for k in range(s):\n if a[k] == x:\n return k\n return -1",
"def nth_index(arr, item, n):\n return np.where(np.array(arr) == item)[0][n]",
"def _find(self, array, value):\n i = bisect.bisect_left(array, value)\n if i != len(array) an... | [
"0.7586091",
"0.74089175",
"0.73601454",
"0.7264007",
"0.7254226",
"0.7154035",
"0.71215653",
"0.71061844",
"0.7076174",
"0.70421183",
"0.69704115",
"0.6936228",
"0.69293255",
"0.69038737",
"0.6893532",
"0.6856859",
"0.6839258",
"0.6763568",
"0.6757409",
"0.67417675",
"0.6735... | 0.69589025 | 11 |
Pooling with a convolution of stride 2. | def convolution_pooling(prev_layer, n_filters, hype_space):
current_layer = keras.layers.convolutional.Conv1D(
filters=n_filters, kernel_size=3, strides=2,
padding='same', activation='linear',
kernel_regularizer=keras.regularizers.l2(
STARTING_L2_REG * hype_space['l2_weight_reg_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv2d_block(input, n_filters, kernel_size=3, stride=1, padding='valid', batch_norm=True, activation='relu'):\r\n x = Conv2D(filters=n_filters, kernel_size=kernel_size, strides=stride, kernel_initializer='he_normal',\r\n padding=padding, use_bias=not batch_norm)(input)\r\n if batch_norm:\r\... | [
"0.713064",
"0.6955843",
"0.6926887",
"0.6856198",
"0.6802863",
"0.6767965",
"0.67229104",
"0.6722598",
"0.6704806",
"0.6695074",
"0.665732",
"0.6637525",
"0.66179407",
"0.660475",
"0.65894973",
"0.65894973",
"0.65839714",
"0.6552081",
"0.65509486",
"0.65421283",
"0.65313464"... | 0.687684 | 3 |
Normalizes given site homepage address if address has no URL scheme, defines it as 'http', cuts the path and quers parts of URL and adds tracing slash if needed. site homepage address corresponding URL Returns normalized URL. | def _normalize_homepage_address(self, site_homepage_address):
# Split URL into parts
address_parts = urlparse.urlsplit(site_homepage_address,
allow_fragments = False)
scheme = address_parts.scheme
netloc = address_parts.netloc
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _construct_absolute_url(self, sublink):\n if sublink[:4] == \"http\":\n root = \"\"\n elif sublink[0] == \"/\":\n root = re.search(ROOT_DOMAIN_PATTERN, self.homepage_url).group(1)\n elif \"index\" in self.homepage_url:\n root = re.sub(r\"/index?[A-Za-z\\d]*... | [
"0.6499561",
"0.64182365",
"0.63810545",
"0.63809276",
"0.63511413",
"0.61768997",
"0.6172342",
"0.61670715",
"0.6161611",
"0.6142006",
"0.6106285",
"0.60694325",
"0.60045105",
"0.5976045",
"0.59558076",
"0.59036404",
"0.5895158",
"0.5826203",
"0.576839",
"0.57263505",
"0.563... | 0.8545122 | 0 |
Filters given parsing information of reference by its value. Discards parsing information if reference was discarded by _filter_reference method. reference_parsing_info ReferenceParsingInfo class or its subclass instance containing reference parsing information Returns back given instance if parsing information was not... | def _filter_reference_parsing_info(self, reference_parsing_info):
reference = reference_parsing_info.reference
if not self._filter_reference(reference):
return None
return reference_parsing_info | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_reference(self, reference):\n \n if self._allowed_domain not in reference:\n logging.info('Filtered offsite reference: %s' % reference)\n return None\n reference_parts = urlparse.urlsplit(reference)\n if '.' in reference_parts.path:\n if not ... | [
"0.6755873",
"0.5857061",
"0.515095",
"0.45612127",
"0.4336992",
"0.42781118",
"0.42341566",
"0.41687444",
"0.40915337",
"0.40611547",
"0.40343168",
"0.40007612",
"0.3984087",
"0.39663595",
"0.39296082",
"0.39189336",
"0.3913303",
"0.39093474",
"0.39035043",
"0.38942957",
"0.... | 0.85114634 | 0 |
Returns current crawling state of site spider. | def crawling_status(self):
return self._crawling_status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_state(self):\n return self.robot.get_current_state()",
"def site_get_current(self, request=None):\n return sites.by_host()",
"def get_state(self):\r\n return self.get_global_state()",
"def current_state(self):\n return self._current_state",
"def get_current_state(sel... | [
"0.62678176",
"0.59954613",
"0.5927505",
"0.59253126",
"0.5920313",
"0.5920313",
"0.5891911",
"0.5854614",
"0.5834806",
"0.581398",
"0.57866335",
"0.57521236",
"0.56916344",
"0.56885403",
"0.56873816",
"0.56550384",
"0.56550384",
"0.56550384",
"0.56550384",
"0.56325096",
"0.5... | 0.7264311 | 0 |
Downloads a blob from the bucket to local file | def download_csv_from_bucket(filename, destination_file_name, credentials=None):
# set_credentials(credentials)
bucket_name, filepath = split_gs_filename(filename)
storage_client = storage.Client.create_anonymous_client()
bucket = storage_client.bucket(bucket_name=bucket_name)
blob = bucket.blo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_blob(bucket_name, blob_filepath, local_filepath):\n storage_client = storage.Client()\n bucket = storage_client.get_bucket(bucket_name)\n blob = bucket.blob(blob_filepath)\n blob.download_to_filename(local_filepath)\n print(\n \"Blob {} downloaded to {}.\".format(\n bl... | [
"0.8382079",
"0.82967263",
"0.81547457",
"0.8109099",
"0.80729544",
"0.80715877",
"0.7973928",
"0.78780496",
"0.7847706",
"0.7847179",
"0.7766764",
"0.7754974",
"0.7679629",
"0.7657087",
"0.7474316",
"0.74383277",
"0.7357417",
"0.72018677",
"0.70135254",
"0.6941646",
"0.68863... | 0.678451 | 25 |
Load data from file either on Google Storage or locally into a DataFrame | def read_csv_data(filename, credentials=None, verbose=True, **kwargs):
# if on GS split bucket name from file location as first directory
if file_is_on_gs(filename):
df = read_csv_from_bucket(filename, credentials=credentials, verbose=verbose, **kwargs)
else:
if verbose:
prin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_loader(file_path):\n with open(file_path) as f:\n data_frame = pandas.read_csv(f)\n return data_frame",
"def __load_from_local_file(path):\n return pd.read_csv(path, infer_datetime_format=True)",
"def load_data(file_path):\n data = pd.read_csv(file_path)\n return data",
"def import... | [
"0.721296",
"0.6812426",
"0.67773414",
"0.67714",
"0.67122173",
"0.6701897",
"0.6671436",
"0.6606472",
"0.65713125",
"0.6562788",
"0.6556251",
"0.65218395",
"0.65184575",
"0.65124977",
"0.65033805",
"0.6503147",
"0.65028876",
"0.6449657",
"0.6441633",
"0.6438078",
"0.6429835"... | 0.60067004 | 72 |
Load data from file either on Google Storage or locally into a DataFrame | def write_csv_data(df, filename, credentials=None, verbose=True, **kwargs):
# if on GS split bucket name from file location as first directory
if file_is_on_gs(filename):
write_csv_to_bucket(df, filename, credentials=credentials, verbose=verbose, **kwargs)
else:
if verbose:
print... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_loader(file_path):\n with open(file_path) as f:\n data_frame = pandas.read_csv(f)\n return data_frame",
"def __load_from_local_file(path):\n return pd.read_csv(path, infer_datetime_format=True)",
"def load_data(file_path):\n data = pd.read_csv(file_path)\n return data",
"def import... | [
"0.7212764",
"0.6811892",
"0.67774254",
"0.67709863",
"0.67119616",
"0.6701435",
"0.6670961",
"0.6607168",
"0.6572425",
"0.6563109",
"0.65562594",
"0.6523237",
"0.65201503",
"0.65121114",
"0.6504767",
"0.650347",
"0.65022135",
"0.6449148",
"0.6441488",
"0.6437837",
"0.6430477... | 0.0 | -1 |
Test the functionality of Vec.as_tuple(). | def test_vec_as_tuple(frozen_thawed_vec: VecClass) -> None:
Vec = frozen_thawed_vec
for x, y, z in iter_vec(VALID_ZERONUMS):
# Check as_tuple() makes an equivalent tuple
orig = Vec(x, y, z)
with pytest.deprecated_call():
tup = orig.as_tuple()
assert isinstance(tup, tu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tuple_as_list(self):\n expected = [1, 2, 3]\n actual = lists.as_list((1, 2, 3))\n self.assertEqual(actual, expected)",
"def astuple(v):\n return to_tuple(v, reuse_instances=False, convert_sets=False)",
"def what_is_tuple():\n pass",
"def _is_tuple(v):\n return isinstanc... | [
"0.7091963",
"0.67456645",
"0.6714692",
"0.6468809",
"0.6452094",
"0.6322982",
"0.6222917",
"0.62128794",
"0.6153591",
"0.60429895",
"0.6014277",
"0.59404355",
"0.59404355",
"0.590927",
"0.58961755",
"0.5870985",
"0.586248",
"0.58516765",
"0.5847145",
"0.5845886",
"0.58239156... | 0.8004955 | 0 |
Test that nonfloats can be given to parse_vec_str(). | def test_parse_vec_passthrough(py_c_vec):
parse_vec_str = vec_mod.parse_vec_str
obj1, obj2, obj3 = object(), object(), object()
assert parse_vec_str('1 2 3', obj1, obj2, obj3) == (1, 2, 3)
assert parse_vec_str('fail', obj1, obj2, obj3) == (obj1, obj2, obj3)
assert parse_vec_str(range, obj1, obj2, ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_from_str_fails(py_c_vec, frozen_thawed_vec: VecClass) -> None:\n # Note - does not pass defaults through unchanged, they're converted to floats!\n parse_vec_str = vec_mod.parse_vec_str\n Vec = frozen_thawed_vec\n for val in VALID_ZERONUMS:\n assert val == parse_vec_str('', x=val)[0]\n ... | [
"0.7107485",
"0.6709336",
"0.651126",
"0.6456113",
"0.63985175",
"0.63983446",
"0.62682587",
"0.6096653",
"0.6045759",
"0.60120624",
"0.60068387",
"0.5988281",
"0.5988281",
"0.59696156",
"0.59676576",
"0.5963141",
"0.59557444",
"0.5934435",
"0.5933977",
"0.59315306",
"0.59294... | 0.60904443 | 8 |
Test the with_axes() constructor. | def test_with_axes(frozen_thawed_vec: VecClass) -> None:
Vec = frozen_thawed_vec
for axis, u, v in ['xyz', 'yxz', 'zxy']:
for num in VALID_ZERONUMS:
vec = Vec.with_axes(axis, num)
assert vec[axis] == num
# Other axes are zero.
assert vec[u] == 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__setup_pr_axes(basic_ax):\n _setup_pr_axes(basic_ax, \"dummy_title\")",
"def make_axes(axes=()):\n return Axes(axes=axes)",
"def axes_helper(axes):\n if axes is None:\n from matplotlib import pyplot\n return pyplot.gca()\n return axes",
"def test_post_faxes(self):\n ... | [
"0.7366354",
"0.6630334",
"0.65744764",
"0.62854475",
"0.6284711",
"0.6276184",
"0.61768687",
"0.60881937",
"0.60830957",
"0.60830957",
"0.6033166",
"0.5997243",
"0.5994043",
"0.59787893",
"0.59068495",
"0.59049624",
"0.5892923",
"0.58853745",
"0.5853896",
"0.5826092",
"0.581... | 0.6153237 | 7 |
Check that Vec() +/ Vec() does the correct thing. For +, , two Vectors apply the operations to all values. Dot and cross products do something different. | def test_vec_to_vec(frozen_thawed_vec: VecClass):
Vec = frozen_thawed_vec
mutable = Vec is vec_mod.Vec
operators = [
('+', op.add, op.iadd),
('-', op.sub, op.isub),
]
def test(x1, y1, z1, x2, y2, z2):
"""Check a Vec pair for addition and subtraction."""
vec1 = Vec(x1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(x1, y1, z1, x2, y2, z2):\n vec1 = Vec(x1, y1, z1)\n vec2 = Vec(x2, y2, z2)\n vec_tup_1 = pytest.deprecated_call(Vec_tuple, x1, y1, z1)\n vec_tup_2 = pytest.deprecated_call(Vec_tuple, x2, y2, z2)\n\n # These are direct methods, so no inheritence and iop to deal with.\n\n ... | [
"0.7101746",
"0.6967475",
"0.69533604",
"0.6949414",
"0.68747586",
"0.6622455",
"0.66003156",
"0.6588902",
"0.65579444",
"0.6539379",
"0.65393084",
"0.6533222",
"0.6525954",
"0.65226454",
"0.64646363",
"0.64589894",
"0.6429856",
"0.64183193",
"0.64175045",
"0.639262",
"0.6379... | 0.6789612 | 5 |
Check a Vec pair for addition and subtraction. | def test(x1, y1, z1, x2, y2, z2):
vec1 = Vec(x1, y1, z1)
vec2 = Vec(x2, y2, z2)
vec_tup_1 = pytest.deprecated_call(Vec_tuple, x1, y1, z1)
vec_tup_2 = pytest.deprecated_call(Vec_tuple, x2, y2, z2)
# These are direct methods, so no inheritence and iop to deal with.
# Comm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtract_vect(a, b):\n return (a[0] - b[0],\n a[1] - b[1],\n a[2] - b[2])",
"def test_unary_ops(frozen_thawed_vec: VecClass) -> None:\n Vec = frozen_thawed_vec\n for x, y, z in iter_vec(VALID_NUMS):\n assert_vec(-Vec(x, y, z), -x, -y, -z, type=Vec)\n assert_vec(+V... | [
"0.61233187",
"0.61176205",
"0.6103925",
"0.60736245",
"0.60343945",
"0.59241426",
"0.59135306",
"0.5861046",
"0.584906",
"0.57962894",
"0.5794619",
"0.5776375",
"0.5743443",
"0.574205",
"0.57351196",
"0.56867933",
"0.5683656",
"0.5669577",
"0.56602067",
"0.5649656",
"0.56420... | 0.606312 | 4 |
Verify the correct types are returned when using differing types. | def test_vec_to_vec_types(py_c_vec: PyCVec, op_func) -> None:
Vec = vec_mod.Vec
FrozenVec = vec_mod.FrozenVec
assert type(op_func(Vec(1, 2, 3), Vec(1, 2, 3))) is Vec
assert type(op_func(Vec(1, 2, 3), FrozenVec(1, 2, 3))) is Vec
assert type(op_func(FrozenVec(1, 2, 3), Vec(1, 2, 3))) is FrozenVec
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_types(self):\n \n self.assertIsInstance(self.netlist, str)\n self.assertIsInstance(self.waves, dict)\n \n pass",
"def check_types() -> None:\n python_code_quality.check_types(targets=_get_targets())",
"def test_types(self):\n values.Date.validate(date(2000,... | [
"0.71923226",
"0.71166724",
"0.7102889",
"0.70995045",
"0.70691276",
"0.6989278",
"0.6987411",
"0.69632703",
"0.69366366",
"0.68669426",
"0.67731845",
"0.6734963",
"0.6728533",
"0.67149895",
"0.67037857",
"0.6674092",
"0.666474",
"0.6650042",
"0.66187423",
"0.6609209",
"0.660... | 0.0 | -1 |
Test the Vec.axis() function. | def test_axis(frozen_thawed_vec) -> None:
Vec = frozen_thawed_vec
handler = pytest.raises(ValueError, match='not an on-axis vector')
for num in VALID_NUMS:
assert Vec(num, 0, 0).axis() == 'x', num
assert Vec(0, num, 0).axis() == 'y', num
assert Vec(0, 0, num).axis() == 'z', num
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_with_axes(frozen_thawed_vec: VecClass) -> None:\n Vec = frozen_thawed_vec\n for axis, u, v in ['xyz', 'yxz', 'zxy']:\n for num in VALID_ZERONUMS:\n vec = Vec.with_axes(axis, num)\n assert vec[axis] == num\n # Other axes are zero.\n assert vec[u] == ... | [
"0.68750197",
"0.6513011",
"0.601913",
"0.601913",
"0.59999",
"0.59283304",
"0.587763",
"0.58338064",
"0.5815352",
"0.5790607",
"0.5765428",
"0.564493",
"0.564493",
"0.56398916",
"0.55526185",
"0.54884285",
"0.5481711",
"0.54732955",
"0.54722416",
"0.5443413",
"0.54415363",
... | 0.79138 | 0 |
Test the functionality of Vec.bbox(). | def test_bbox(frozen_thawed_vec: VecClass) -> None:
Vec = frozen_thawed_vec
# No arguments
with raises_typeerror:
Vec.bbox()
# Non-iterable
with raises_typeerror:
Vec.bbox(None)
# Starting with non-vector.
with raises_typeerror:
Vec.bbox(None, Vec())
# Contain... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bbox() -> None:\n rand = Random(1234) # Ensure reproducibility.\n SIZE = 128.0\n # Build a set of points and keys.\n points = [\n (\n Vec(rand.uniform(-SIZE, SIZE), rand.uniform(-SIZE, SIZE), rand.uniform(-SIZE, SIZE)),\n Vec(rand.uniform(-SIZE, SIZE), rand.unifor... | [
"0.7684893",
"0.69912726",
"0.68856966",
"0.68691564",
"0.67973673",
"0.67703694",
"0.66383576",
"0.6491828",
"0.637949",
"0.6374677",
"0.6290289",
"0.6243139",
"0.6242027",
"0.6230889",
"0.6211995",
"0.6170375",
"0.6170375",
"0.61688805",
"0.61527723",
"0.61430156",
"0.61420... | 0.7539346 | 1 |
Test mixing types gives the right classes. | def test_cross_types(py_c_vec) -> None:
Vec = vec_mod.Vec
FrozenVec = vec_mod.FrozenVec
assert type(Vec(1, 2, 3).cross(Vec(1, 2, 3))) is Vec
assert type(Vec(1, 2, 3).cross(FrozenVec(1, 2, 3))) is Vec
assert type(FrozenVec(1, 2, 3).cross(Vec(1, 2, 3))) is FrozenVec
assert type(FrozenVec(1, 2, 3).... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_types(self):\n \n self.assertIsInstance(self.netlist, str)\n self.assertIsInstance(self.waves, dict)\n \n pass",
"def test_type(self):\n self.assertTrue(isinstance(self.second.villans, str))\n self.assertTrue(isinstance(self.second.heroes, str))\n ... | [
"0.70936906",
"0.704403",
"0.6920247",
"0.66799563",
"0.6635254",
"0.6619606",
"0.6582974",
"0.65548056",
"0.65244186",
"0.65028405",
"0.65017825",
"0.6495611",
"0.6481271",
"0.64520824",
"0.64372206",
"0.64114743",
"0.63891095",
"0.63440984",
"0.633515",
"0.6319758",
"0.6275... | 0.0 | -1 |
Get the configuration, skip on ConfigError. | def getConfig(confSection="root", **confArgs):
confFile = os.path.join(testdir, "data", "icat.cfg")
if not os.path.isfile(confFile):
pytest.skip("no test ICAT server configured")
try:
args = ["-c", confFile, "-s", confSection]
conf = icat.config.Config(**confArgs).getconfig(args)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self, **kwargs) -> Optional[Dict[str, Any]]:\n raise NotImplementedError",
"def get_configuration(obj, path):\n\n try:\n config = obj.get_resource(path)\n except (IndexError, AttributeError, TypeError, AssertionError, KeyError) as e:\n traceback.print_exc... | [
"0.6516318",
"0.6489059",
"0.6414558",
"0.64082205",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
"0.63979125",
... | 0.0 | -1 |
Rotation jitter should rotate image but preserve size. | def test_rotate_jitter():
transform = sumie.transforms.RotationJitter(1)
image = torch.randn(1, 3, 10, 10)
out = transform(image)
assert torch.all(out != image)
assert out.shape == image.shape | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(img, angle, resample=False, expand=False, center=None):\n \n return img.rotate(angle, resample, expand, center)",
"def rotations(src: MyImage) -> MyImage:\r\n result = MyImage((src.size[0]*2, src.size[1]*2), src.pointer) #creating an image twice the original size\r\n ... | [
"0.6567267",
"0.6442103",
"0.6270575",
"0.6270575",
"0.6270575",
"0.61846626",
"0.6146979",
"0.61141914",
"0.6103729",
"0.59996",
"0.5969123",
"0.59355855",
"0.5934893",
"0.59226984",
"0.59178615",
"0.5913591",
"0.59087324",
"0.589456",
"0.58678246",
"0.58656424",
"0.58640987... | 0.7442035 | 0 |
Filter the df for observations occurring at least min_obs times | def filter_min_obs(df, min_obs, obs_col='item_size_id'):
enough_obs_item_size_ids = df.groupby(obs_col).items_kept.sum() >= min_obs
enough_obs_item_size_ids = enough_obs_item_size_ids[enough_obs_item_size_ids]
enough_obs_item_size_ids = enough_obs_item_size_ids.index
return df[df[obs_col].isin(enough_ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_min_occurrences(self, **kwargs):\n self.x2 = kwargs.get('x2', self.x2)\n self.feature_headers2 = kwargs.get('feature_headers2', self.feature_headers2)\n self.min_occur = kwargs.get('min_occur', self.min_occur)\n\n feature_filter = (np.count_nonzero(x2, axis=0) >= min_occur)\n... | [
"0.5994878",
"0.5785835",
"0.56328285",
"0.5595253",
"0.5547559",
"0.5493459",
"0.5374937",
"0.53061116",
"0.5296625",
"0.5282809",
"0.5252652",
"0.52470225",
"0.52341175",
"0.52320176",
"0.5206862",
"0.51910275",
"0.5190457",
"0.51901436",
"0.51627064",
"0.51623255",
"0.5151... | 0.8320585 | 0 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actual.size(0)\n\n _, pred = y_pred.topk(maxk, 1, True, True)\n pred = pred.t()\n correct = pred.eq(y_actual.view(1, -1).expand_as(pred))\n\n res = []\n for k in topk:\n correct_k = correct[:k].view(-1).floa... | [
"0.8286288",
"0.82650673",
"0.8210967",
"0.82106775",
"0.81913805",
"0.8180691",
"0.81765115",
"0.81764203",
"0.8171627",
"0.81696045",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395... | 0.78481054 | 92 |
Returns mesh of document associations. | def _get_associations():
associations = collections.defaultdict(list)
for p in _get_cached_documents("cim.2.designing.Project"):
for e in p.required_experiments:
# associations["p:e"].append((p.meta.id, e.id))
associations["p:e"].append((p._ID, _CIM_CACHE[e.id]._ID))
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_associations(self):\n raise NotImplementedError(\n 'operation get_associations(...) not yet implemented')",
"def get_relations(self):\n return self.client.call('GET', 'contact_relation', {})",
"def associations(self, diagnostics=None, context=None):\n raise NotImplemente... | [
"0.6249399",
"0.5932522",
"0.57224333",
"0.5703603",
"0.5623316",
"0.55194265",
"0.54240394",
"0.5415486",
"0.5403468",
"0.52787703",
"0.5265176",
"0.5218615",
"0.52175313",
"0.5211161",
"0.5209788",
"0.519603",
"0.5182945",
"0.51682556",
"0.51548797",
"0.5134885",
"0.5120337... | 0.6010807 | 1 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def distance(actual: "Position", last: "Position") -> float:
# convert decimal degrees to radians
actual_longitude, actual_latitude, last_longitude, last_latitude = map(
radians,
[float(actual.lon), float(actual.lat), float(last.lon), float(last.lat)],
)
# havers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle_distance(latitudes1: float, longitudes1: float, latitudes2: float, longitudes2: float) -> float:\n dlat = math.radians(latitudes1 - latitudes2)\n dlon = math.radians(longitudes1 - longitudes2)\n alat = math.radians((latitudes1 + latitudes2) / 2)\n R = 3958.8\n x = dlon * math.cos(al... | [
"0.82643914",
"0.7904323",
"0.7651475",
"0.7636124",
"0.76001215",
"0.7544723",
"0.75346744",
"0.753415",
"0.7524895",
"0.74974763",
"0.7497021",
"0.74599123",
"0.7406315",
"0.7362742",
"0.735464",
"0.7324868",
"0.7324037",
"0.7297849",
"0.72678494",
"0.72661763",
"0.7218592"... | 0.0 | -1 |
Read and preprocess an image with data augmentation (random transform). | def read_for_training(p):
return read_cropped_image(p, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_preprocess(self, img):\n return crop_rescale(imread(img))# - self.pixel_means",
"def process_img(self, img: np.ndarray) -> np.ndarray:\n\n # there are damaged files in IAM dataset - just use black image instead\n if img is None:\n img = np.zeros(self.img_size[::-1])\n\n ... | [
"0.7044627",
"0.7034828",
"0.6861045",
"0.6848393",
"0.6845723",
"0.67995244",
"0.6675408",
"0.66702646",
"0.66541904",
"0.6622928",
"0.6616886",
"0.6564892",
"0.6562134",
"0.6523857",
"0.650934",
"0.65059614",
"0.64898556",
"0.6451827",
"0.6444947",
"0.6430255",
"0.64265704"... | 0.592098 | 90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.