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 |
|---|---|---|---|---|---|---|
View function for home page of site. | def index(request):
#context = RequestContext(request)
category_list = Keyword.objects.all().count()
context_dict = {'categories': category_list}
# Generate counts of some of the main objects
num_books = Book.objects.all().count()
num_keywords = Keyword.objects.all().count()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def home(request):\r\n return render(request, 'home.html')",
"def homepage(request):\n\treturn render(request, 'core/homepage.html')",
"def homepage(req... | [
"0.8493426",
"0.84268916",
"0.83415145",
"0.83306193",
"0.82976943",
"0.8295291",
"0.8276345",
"0.82545686",
"0.82155704",
"0.8132563",
"0.81246215",
"0.81224865",
"0.8121264",
"0.81049734",
"0.8098485",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0... | 0.0 | -1 |
Return an argparse.Namespace populated with commandline args. | def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('-e', '--env', default='production',
help='Environment to check: integration, staging, production.')
parser.add_argument('-l', '--log_type', default='govuk_assets',
help='Which logs to ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_args(self, args=None, namespace=None):\n # This will call our parse_known_args below, so don't use setup_logging.\n namespace = argparse.ArgumentParser.parse_args(\n self, args=args, namespace=namespace)\n return namespace",
"def parse() -> argparse.Namespace:\n parse... | [
"0.7443497",
"0.7115812",
"0.69915414",
"0.69227624",
"0.6858888",
"0.6854832",
"0.68530047",
"0.68056965",
"0.67993045",
"0.6797189",
"0.67931736",
"0.67706084",
"0.6739368",
"0.66685873",
"0.6666356",
"0.66181177",
"0.65704334",
"0.6560804",
"0.65576804",
"0.6546076",
"0.65... | 0.0 | -1 |
Returns a sample from the latent distribution. | def sample_latent(self, x):
latent_dist = self.encoder(x)
latent_sample = self.reparameterize(*latent_dist)
return latent_sample | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_from_latent_dist(self, latent_dist, num_particles):\n return latent_dist.sample((num_particles,))",
"def latent_sample(self, mu, logvar):\n\n # the reparameterization trick\n std = logvar.mul(0.5).exp_()\n eps = torch.empty_like(std).normal_()\n return eps.mul(std).a... | [
"0.763293",
"0.7500387",
"0.7482738",
"0.7463196",
"0.72070825",
"0.71234363",
"0.70615244",
"0.702605",
"0.6950538",
"0.6918983",
"0.6805106",
"0.6786428",
"0.6733934",
"0.66662365",
"0.66662365",
"0.66662365",
"0.66662365",
"0.66662365",
"0.66555613",
"0.66555613",
"0.66459... | 0.8105079 | 0 |
Apply the eliminate strategy to a Sudoku puzzle The eliminate strategy says that if a box has a value assigned, then none of the peers of that box can have the same value. | def eliminate(values):
# TODO: Copy your code from the classroom to complete this function
for box,value in values.items():
#print (box,value)
if len(values[box]) == 1:
for peer in peers[box]:
if value in values[peer]:
values[peer] = values[peer].r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_puzzle(values):\n # TODO: Copy your code from the classroom and modify it to complete this function\n stalled = False\n while not stalled:\n # Check how many boxes have a determined value\n solved_values_before = len([box for box in values.keys() if len(values[box]) == 1])\n\n ... | [
"0.7113186",
"0.69285506",
"0.68381935",
"0.674554",
"0.67242247",
"0.6683853",
"0.6627115",
"0.6591953",
"0.65869564",
"0.644053",
"0.6395532",
"0.6312864",
"0.6244127",
"0.6229971",
"0.62063974",
"0.6196636",
"0.6173033",
"0.6096948",
"0.60952747",
"0.6065118",
"0.6017561",... | 0.56778806 | 46 |
Compute the cross generalized product of a x b, assuming that both fall into the w=1 hyperplane | def cross(a,b):
return [ a[1]*b[2] - a[2]*b[1],
a[2]*b[0] - a[0]*b[2],
a[0]*b[1] - a[1]*b[0],
1.0 ] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross(a, b):\n #return np.cross(a,b)\n\n return vector(a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0])",
"def cross_product(a, b):\n return (a[1]*b[2] - a[2]*b[0],\n a[2]*b[0] - a[0]*b[2],\n a[0]*b[1] - a[1]... | [
"0.7781757",
"0.7769356",
"0.7618885",
"0.7450098",
"0.74042857",
"0.7312032",
"0.7284011",
"0.72580504",
"0.7202887",
"0.7162842",
"0.699895",
"0.6939122",
"0.691171",
"0.6867125",
"0.68409973",
"0.6820777",
"0.6820173",
"0.6735716",
"0.6726079",
"0.6686691",
"0.668388",
"... | 0.7594905 | 3 |
3 vector ``a`` dot ``b`` | def dot(a,b):
return a[0]*b[0]+a[1]*b[1]+a[2]*b[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot(a, b):\n\n if len(a) != len(b):\n raise Exception(\"Input vectors must be of same length, not %d and %d\" % (len(a), len(b)))\n\n return float(sum([a[i] * b[i] for i in range(len(a))]))",
"def dot(a, b):\n return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]",
"def vecDot(a, b):\n re... | [
"0.85504246",
"0.8518371",
"0.8390621",
"0.81569344",
"0.8134731",
"0.80812556",
"0.8069943",
"0.79253095",
"0.7889016",
"0.7869812",
"0.78256196",
"0.7812701",
"0.77985966",
"0.779138",
"0.7770342",
"0.7762624",
"0.77584946",
"0.7736852",
"0.77351236",
"0.773444",
"0.7715075... | 0.8531209 | 1 |
4 vect dot product | def dot4(a,b):
return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot_product(v,w):\n return v[0] * w[0] + v[1] * w[1]",
"def dot_vectors(u, v):\n return u[0] * v[0] + u[1] * v[1] + u[2] * v[2]",
"def dot_product(vec_1:tuple, vec_2:tuple)->float:\n return vec_1[0] * vec_2[0] + vec_1[1] * vec_2[1]",
"def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y... | [
"0.7319568",
"0.7312534",
"0.7305484",
"0.72395074",
"0.72389656",
"0.7236532",
"0.71749246",
"0.71721345",
"0.7139549",
"0.7070456",
"0.7067735",
"0.7058254",
"0.7031897",
"0.7012487",
"0.70033956",
"0.6996373",
"0.69874394",
"0.6975707",
"0.692703",
"0.69262916",
"0.6921388... | 0.7954915 | 0 |
Point creation from point or scalars | def point(x=False,y=False,z=False,w=False):
if ispoint(x):
return deepcopy(x)
r = [0,0,0,1]
if isgoodnum(x):
r[0]=x
if isgoodnum(y):
r[1]=y
if isgoodnum(z):
r[2]=z
if isgoodnum(w):
r[3]=w
if r[3] > 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createFromPoint(cls, point, **kwargs):\n return cls(point.x, point.y, **kwargs)",
"def create_point(x_crd, y_crd):\n\n Point = namedtuple(\"Point\", \"x_crd y_crd\")\n return Point(x_crd, y_crd)",
"def point(cls): # No range because it's unknown at this time.\r\n def factory(i, name):\... | [
"0.74409354",
"0.71744204",
"0.71545947",
"0.7038778",
"0.7038778",
"0.69801426",
"0.6927782",
"0.66147345",
"0.6612779",
"0.66008186",
"0.65793395",
"0.65712434",
"0.6520769",
"0.6483556",
"0.6431624",
"0.63237184",
"0.6312141",
"0.6270511",
"0.62432456",
"0.62365323",
"0.62... | 0.5914086 | 41 |
compute 3D bounding box of point, which is 2 epsilon on a side. Note, this guarantees that two points that are wtihin epsilon of eachother will be within each other's bbox | def pointbbox(x):
ee = point(epsilon,epsilon,epsilon)
return [sub(x,ee),add(x,ee)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_in_boundingbox(solid, pnt, tolerance=1e-5):\n bbox = Bnd_Box()\n bbox.SetGap(tolerance)\n brepbndlib_Add(solid, bbox)\n return not bbox.IsOut(pnt)",
"def bounding_box(points):\n x, y, z = zip(*points)\n min_x = min(x)\n max_x = max(x)\n min_y = min(y)\n max_y = max(y)\n mi... | [
"0.6535787",
"0.6354298",
"0.63204396",
"0.6280185",
"0.62511194",
"0.62422615",
"0.62405956",
"0.6215135",
"0.6201556",
"0.616639",
"0.61623824",
"0.6146558",
"0.6119636",
"0.6115911",
"0.60995966",
"0.6096933",
"0.60764766",
"0.60586566",
"0.6058626",
"0.60147166",
"0.60105... | 0.6825214 | 0 |
Return the scalar length of figure x. | def length(x):
if ispoint(x):
# return pointlength(x):
return 0.0
elif isline(x):
return linelength(x)
elif isarc(x):
return arclength(x)
elif ispoly(x):
return polylength(x)
elif isgeomlist(x):
l = 0.0
for g in x:
l += length(g)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pointlength(x):\n return 0.0",
"def width(self):\n return self.x.max() - self.x.min()",
"def length(self):\n return len(self.x)",
"def vec_len(x):\r\n \r\n length = math.sqrt(x[0]**2 + x[1]**2)\r\n return length",
"def get_length(self):\n return math.sqrt(self.x**2 + se... | [
"0.7217307",
"0.7159165",
"0.7018",
"0.69435537",
"0.69221693",
"0.6916993",
"0.6822735",
"0.67670625",
"0.674197",
"0.6737974",
"0.67180204",
"0.6661482",
"0.66479915",
"0.66434",
"0.6641439",
"0.66020775",
"0.6584414",
"0.656284",
"0.6558763",
"0.6533366",
"0.6512442",
"0... | 0.659413 | 16 |
Check if model parameters are allocated on the GPU. | def is_cuda(self):
return next(self.parameters()).is_cuda | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_cuda(model):\n\treturn next(model.parameters()).is_cuda",
"def is_gpu_available():\n ret = get_gpu_count() > 0\n if _HAS_PADDLE:\n import paddle\n if ret is True and not paddle.is_compiled_with_cuda():\n logger.warning(\"Found non-empty CUDA_VISIBLE_DEVICES. \\\n ... | [
"0.7035844",
"0.67039204",
"0.6659393",
"0.65733784",
"0.6548726",
"0.6418005",
"0.6284684",
"0.61922556",
"0.6084889",
"0.60580724",
"0.60226715",
"0.60047615",
"0.59713936",
"0.5916576",
"0.5914285",
"0.5895965",
"0.588647",
"0.58627695",
"0.584468",
"0.58226997",
"0.579909... | 0.64029634 | 8 |
is_writable(object, content_type) > boolean Return whether this writer can write the specified object serialized according to the MIME content type. | def is_writable(self, object, content_type):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_writable_file(obj):\n try:\n obj.write(\"\")\n except(AttributeError, OSError, IOError):\n return False\n else:\n return True",
"def is_writable(self):\n raise NotImplementedError()",
"def is_writable(schema_obj):\n\n if isinstance(schema_obj, schema.Field):\n # ... | [
"0.72136736",
"0.7112116",
"0.7097934",
"0.6773591",
"0.6709747",
"0.6673223",
"0.65156037",
"0.64066255",
"0.6333642",
"0.63209593",
"0.62092805",
"0.61462426",
"0.6076606",
"0.58778083",
"0.58414876",
"0.58109945",
"0.571904",
"0.57167816",
"0.5700768",
"0.5697282",
"0.5590... | 0.87054765 | 0 |
Converts `parsed_time` to a datetime object. | def _time_to_date(parsed_time):
if not parsed_time:
return parsed_time
return datetime.fromtimestamp(calendar.timegm(parsed_time), tz=timezone.utc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_to_datetime(time):\n split_time = time.split(':')\n hour = int(split_time[0])\n minutes = int(split_time[1])\n now = dt.datetime.now()\n time_as_datetime = dt.datetime(now.year, now.month, now.day,\n hour=hour, minute=minutes)\n\n # Need to change the da... | [
"0.64130354",
"0.63340354",
"0.6331689",
"0.6286792",
"0.62509006",
"0.6176121",
"0.6174799",
"0.6156896",
"0.6118578",
"0.61165",
"0.6086338",
"0.5977252",
"0.59611464",
"0.5927652",
"0.5869239",
"0.5849842",
"0.5776376",
"0.5770897",
"0.5746229",
"0.57253295",
"0.57238656",... | 0.8162323 | 0 |
Corrects dates potentially from the future. | def _normalize_date(date):
if not date:
return None
if date.tzinfo:
date = date.replace(tzinfo=None) - date.tzinfo.utcoffset(date)
return min(date, datetime.utcnow()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_date_entry_returns_correct_outOfBounds_if_future(self):\n date_string = \"3018-01-21\"\n date_format = settings.DATE_FORMATS['iso 8601']\n\n error_text = \"dates in the future are not permitted\"\n\n result = self.menu.validate_date_entry(date_string, date_format)\n\n ... | [
"0.67007244",
"0.65752447",
"0.634985",
"0.61623573",
"0.6146663",
"0.61287034",
"0.6087605",
"0.608539",
"0.607972",
"0.6020683",
"0.6010806",
"0.59975517",
"0.59913725",
"0.5913431",
"0.58847654",
"0.5880367",
"0.5850784",
"0.57288617",
"0.57236654",
"0.5714489",
"0.5704053... | 0.5393957 | 52 |
Define learning rate update scheduler. | def lr_scheduler(self, lr_init, global_step):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_learning_rate(self):\r\n self.scheduler.step(self.clock.epoch)",
"def update_learning_rate(self):\n for scheduler in self.schedulers:\n if self.opt.lr_policy == 'plateau':\n scheduler.step(self.metric)\n else:\n scheduler.step()\n\n ... | [
"0.7963858",
"0.77578026",
"0.75703096",
"0.7444173",
"0.7389931",
"0.72665566",
"0.7263322",
"0.72375524",
"0.7200921",
"0.71721905",
"0.70632005",
"0.7018395",
"0.7012715",
"0.69404644",
"0.69335186",
"0.6913178",
"0.6880206",
"0.68732023",
"0.68502975",
"0.68266404",
"0.68... | 0.734191 | 5 |
Update the `change_x` and `change_y` properties using a vector. Normally, sprites' intended movement is set using the `change_x` and `change_y` properties. This method updates `change_x` and `change_y` based on an (x, y) vector whose magnitude is scaled to the sprite's speed. This is helpful when you have an | def set_course(self, vector):
vx, vy = scale(vector, self.speed)
self.change_x = vx
self.change_y = vy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changespeed(self, x, y):\n self.change_x += x\n self.change_y += 200",
"def changespeed(self, x, y):\n self.change_x += x\n self.change_y += y",
"def changespeed(self, x, y):\n self.change_x += x\n self.change_y += y",
"def changespeed(self, x, y):\n self.... | [
"0.72199756",
"0.72143126",
"0.72143126",
"0.72143126",
"0.68627197",
"0.6717241",
"0.6644019",
"0.66122127",
"0.6604217",
"0.6604217",
"0.6555888",
"0.6550177",
"0.6529392",
"0.64523286",
"0.6444069",
"0.64423865",
"0.64423865",
"0.64330053",
"0.6411574",
"0.63882256",
"0.63... | 0.62574273 | 31 |
Set the sprite's `change_x` and `change_y` to zero. | def stop(self):
self.change_x = 0
self.change_y = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self._x = 0\n self._y = 0",
"def reset(self):\n self.x_pos1 = 0\n self.x_pos2 = self.x_pos1 + self.width\n self.y_pos = self.offset_y\n self.velocity = self.origin_velocity",
"def reset(self):\n self.x_pos = -self.width\n self.y_pos = s... | [
"0.69810736",
"0.6774382",
"0.67249686",
"0.66218376",
"0.6497525",
"0.6472125",
"0.6420883",
"0.63824487",
"0.63539696",
"0.63500476",
"0.6349558",
"0.6340924",
"0.6247932",
"0.61952996",
"0.6157246",
"0.6157246",
"0.6157246",
"0.6157246",
"0.6057038",
"0.604043",
"0.6031217... | 0.6853248 | 1 |
apply `func` to every item, and collect the result. | def map(self, func):
return _(map(func, self._)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_(func, some_list):\n \n result = []\n \n for arg in some_list:\n result.append(func(arg))\n \n return result",
"def map(self, func: Callable[[T], V]) -> 'List[V]':\n return [func(v) for v in self.array]",
"def process_list(_func, iterator, *args, **kwargs):\n retu... | [
"0.67064786",
"0.66957474",
"0.6676593",
"0.66411436",
"0.657438",
"0.65635514",
"0.63724416",
"0.63312733",
"0.6323714",
"0.63086337",
"0.6250355",
"0.618989",
"0.6171773",
"0.6169816",
"0.61682683",
"0.6137597",
"0.61330724",
"0.6097141",
"0.6045037",
"0.60281897",
"0.60259... | 0.59346986 | 25 |
leftfold the self._ by `func` with initial value set to `init` | def reduce(self, func, init=None):
return _(reduce(func, self._, init) if init else reduce(func, self._)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foldl(func, start, itr):\n return _foldl(func, start, iter(itr))",
"def fold(iterable, func, base):\n acc = base\n for element in iterable:\n acc = func(acc, element)\n return acc",
"def reduce_right(self, func, init=None):\n return self.reverse().reduce(func, init)",
"def foldr... | [
"0.6317266",
"0.6044533",
"0.5847977",
"0.57651484",
"0.571364",
"0.57092494",
"0.56221",
"0.54851633",
"0.54799354",
"0.5473303",
"0.54528415",
"0.5292809",
"0.5205884",
"0.5150864",
"0.51215047",
"0.50888157",
"0.5062803",
"0.50566816",
"0.5041427",
"0.5012389",
"0.4985053"... | 0.67031395 | 0 |
rightfold the self._ by `func` with initial value set to `init` | def reduce_right(self, func, init=None):
return self.reverse().reduce(func, init) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce(self, func, init=None):\n return _(reduce(func, self._, init) if init else reduce(func, self._))",
"def foldr(func, start, itr):\n return _foldr(func, start, iter(itr))",
"def unfold(func, seed):\n try:\n elem = func(seed)\n while elem is not None:\n seed, x = e... | [
"0.69876534",
"0.5961646",
"0.56888425",
"0.56607085",
"0.551489",
"0.54971963",
"0.5441101",
"0.5390668",
"0.53208953",
"0.53167593",
"0.52640796",
"0.523796",
"0.522511",
"0.522048",
"0.5211309",
"0.5135804",
"0.5017804",
"0.5010653",
"0.49780267",
"0.49590963",
"0.49308324... | 0.7246964 | 0 |
get the min item using a key function `fn` | def min(self, fn=lambda x: x):
return _(min(*self._, key=fn)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min(self, key=lambda _: _):\n return min(self, key=key)",
"def getMin(listOfVCFs, compareFun, numMins = 1):\n # \"\"\"Returns the numMin keys with smallest values in the list\"\"\"\n return min(listOfVCFs, key = compareFun)",
"def min(*args, **kwargs):\n key = kwargs.get(\"key\", lambda x: ... | [
"0.79542047",
"0.70083785",
"0.6882546",
"0.6803885",
"0.67753047",
"0.6761948",
"0.6761948",
"0.6666372",
"0.6570796",
"0.6508797",
"0.63379115",
"0.6334637",
"0.63106126",
"0.62835866",
"0.6233954",
"0.6233205",
"0.6231206",
"0.62003374",
"0.6178467",
"0.61648",
"0.6109572"... | 0.78798866 | 1 |
return all but first n items. n deafult is 1. | def rest(self, n=1):
return _(self._[n:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop(iterable, n, islice=islice):\n return islice(iterable, n, None)",
"def take(iterable, n):\n return list(itertools.islice(iterable, n))",
"def drop(n, seq):\n return itertools.islice(seq, n, None)",
"def drop(iterable, n):\n counter = 0\n for element in iterable:\n if counter < ... | [
"0.7701511",
"0.73919606",
"0.7351583",
"0.73452836",
"0.72743267",
"0.72743267",
"0.7250926",
"0.72451603",
"0.72451603",
"0.71940464",
"0.71694416",
"0.7099013",
"0.69721884",
"0.6837333",
"0.6832611",
"0.68197954",
"0.6817167",
"0.6715548",
"0.66675466",
"0.6575521",
"0.65... | 0.6566812 | 22 |
Uses a binary search to determine the index at which the value should be inserted into the list in order to maintain the list's sorted order the return index will be as large as possible. see the examples. | def sorted_index(self, item):
return _(_sorted_index(self._, item)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search(lst, key):\n lst.sort()\n low = 0\n high = len(lst) - 1\n while low <= high:\n mid = low + (high - low) //2\n if lst[mid] == key:\n return mid\n if lst[mid] < key:\n low = mid + 1\n else:\n hihg = mid - 1\n return -low - ... | [
"0.7234414",
"0.7178396",
"0.7126716",
"0.7113498",
"0.710619",
"0.705802",
"0.7020701",
"0.6939585",
"0.692894",
"0.68992275",
"0.6885669",
"0.6847501",
"0.68418384",
"0.6831532",
"0.6823288",
"0.6703282",
"0.6699355",
"0.6694996",
"0.6673862",
"0.66634715",
"0.66606885",
... | 0.0 | -1 |
list of lists containing two items. if self._ is dict then it will be keyvalue tuple. | def pairs(self):
return self.items() if self.is_a(dict) else self.chunks(2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items(self):\r\n return [(k, self[k]) for k in self]",
"def items(self):\n return [ (x, self[x]) for x in self ]",
"def items(self) -> tuple[tuple[Any, Any], ...]: # type: ignore\n return tuple(zip(self.keys(), self.values()))",
"def items(self):\r\n L = []\r\n for key,... | [
"0.74698246",
"0.73609763",
"0.7204701",
"0.7184429",
"0.7184429",
"0.7170297",
"0.7133238",
"0.69358766",
"0.6889742",
"0.6888532",
"0.68438",
"0.68438",
"0.6799072",
"0.6772477",
"0.67690206",
"0.6767019",
"0.67582715",
"0.6712153",
"0.66809005",
"0.66809005",
"0.6663738",
... | 0.61867034 | 48 |
get a new dict by filtering out keys from self._ | def omit(self, *keys):
return _({k: self[k] for k in self._ if k not in keys}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __filter(self, obj):\n filtered_keys = ['file_path', \"Data\", \"raw_block_data\", \"Reserved1\", \"raw\"]\n if isinstance(obj, list):\n return dict([t for t in obj if t[0] not in filtered_keys])\n elif isinstance(obj, dict):\n return {k: self.__filter(v) for k, v in ... | [
"0.70537007",
"0.698108",
"0.6776572",
"0.67714417",
"0.6609516",
"0.65673584",
"0.65516824",
"0.64717597",
"0.6458294",
"0.6449654",
"0.63842654",
"0.63655484",
"0.63415843",
"0.63197875",
"0.63019836",
"0.6262461",
"0.619912",
"0.6163807",
"0.6156054",
"0.6153872",
"0.61469... | 0.68541175 | 2 |
check if the number is even | def even(self):
return self._ % 2 == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_even(number):\n return (number%2)==0",
"def is_even(number):\n return number % 2 == 0",
"def is_even(num):\n return num % 2 == 0",
"def is_even(number: int) -> bool:\n return number % 2 == 0",
"def is_even(number):\n if ((number%2) == 0):\n return True\n else:\n retur... | [
"0.9044682",
"0.8953251",
"0.89411163",
"0.89273983",
"0.8896811",
"0.8878678",
"0.88478565",
"0.88364774",
"0.8812797",
"0.8729424",
"0.85860205",
"0.8536478",
"0.85233545",
"0.8441365",
"0.8415158",
"0.841257",
"0.8368453",
"0.83481276",
"0.82515913",
"0.82229394",
"0.82070... | 0.77848625 | 36 |
check if the number is odd. | def odd(self):
return not self.even() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd(number):\r\n return number % 2 != 0",
"def is_odd(number):\n return (number%2)==1",
"def is_odd(number: int) -> bool:\n return number % 2 != 0",
"def is_odd(x):\n return x % 2 != 0",
"def is_odd(n):\n if n % 2:\n return True\n else:\n return False",
"def is_odd(... | [
"0.91239274",
"0.90233827",
"0.9010909",
"0.8676036",
"0.8651456",
"0.84850687",
"0.8480497",
"0.8466093",
"0.84444046",
"0.8402817",
"0.8284561",
"0.82418215",
"0.8237344",
"0.818709",
"0.8172283",
"0.8168336",
"0.8159251",
"0.8084061",
"0.7976461",
"0.79348963",
"0.79037803... | 0.75473017 | 34 |
Returns the canonical accelerator name. | def canonicalize_accelerator_name(accelerator: str) -> str:
# TPU names are always lowercase.
if accelerator.lower().startswith('tpu-'):
return accelerator.lower()
# Common case: do not read the catalog files.
mapping = {name.lower(): name for name in _ACCELERATORS}
if accelerator.lower() i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accelerator_string():\n if is_mac():\n return \"Command\"\n else:\n return \"Ctrl\"",
"def accelerator_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"accelerator_id\")",
"def accelerator_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"accelerator_i... | [
"0.7141921",
"0.67246884",
"0.67246884",
"0.65416247",
"0.6481238",
"0.635599",
"0.635599",
"0.618503",
"0.61305064",
"0.6098627",
"0.6052083",
"0.5950856",
"0.5928464",
"0.5913853",
"0.59015733",
"0.58457077",
"0.58374697",
"0.5836619",
"0.5832053",
"0.5818554",
"0.5807542",... | 0.79009324 | 0 |
Check we have a public ip address | def public_ip():
found_public_ip = False
try:
metadata = get_instance_metadata()
for key, value in metadata.items():
LOG.info("{0}: {1}".format(key, value))
if metadata['public-ipv4'] is not None:
try:
socket.inet_aton(metadata['public-ipv4'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_public_ip(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"use_public_ip\")",
"def find_available_public_ip(self):\n raise NotImplementedError",
"def is_valid_ip(ip):\n ...",
"def __lookup_public_ip(self):\n\n response = requests.get('https://api.ipify.org?fo... | [
"0.7754687",
"0.7584841",
"0.7528389",
"0.7526265",
"0.7320912",
"0.73131496",
"0.7284921",
"0.72054183",
"0.71376836",
"0.7128714",
"0.708552",
"0.7072471",
"0.70522326",
"0.70368385",
"0.7031245",
"0.69999033",
"0.69971776",
"0.6990239",
"0.69789124",
"0.6973825",
"0.695925... | 0.827444 | 0 |
Finds all the odd degree vertices in graph | def _get_odd_degree_vertices(graph):
odd_degree_vertices = set()
for index, row in enumerate(graph):
if len(np.nonzero(row)[0]) % 2 != 0:
odd_degree_vertices.add(index)
return odd_degree_vertices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_odd_vertices(adj_dict):\n return [i for i in adj_dict.keys() if len(adj_dict[i]) % 2]",
"def find_odd_neighbor(graph, candidate, vertices):\n out = []\n for c in candidate:\n if np.mod(len(set(graph.neighbor(c)) ^ vertices), 2) == 1:\n out.append(c)\n return out",
"def fin... | [
"0.7689515",
"0.6993228",
"0.6682944",
"0.6523113",
"0.64734",
"0.64040375",
"0.6349915",
"0.6312714",
"0.6229429",
"0.6186725",
"0.6128781",
"0.6124727",
"0.6106614",
"0.60978574",
"0.608154",
"0.6060013",
"0.60547775",
"0.6034889",
"0.59700304",
"0.595321",
"0.5928284",
"... | 0.8670936 | 1 |
Get the learning rate for a given epoch. Note that this uses the LipschitzLR policy, so the epoch number doesn't actually matter. | def _lr_schedule(self, epoch: int):
penultimate_activ_func = K.function([self.model.layers[0].input], [self.model.layers[-2].output])
Kz = 0.
for i in range((len(self.x_train) - 1) // self.bs + 1):
start_i = i * self.bs
end_i = start_i + self.bs
xb = self.x_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learning_rate(epoch):\n self.lr = self.lr / 1.00000001\n return self.lr",
"def learning_rate(epoch):\n return alpha / (1 + decay_rate * epoch)",
"def learning_rate(epoch):\n return alpha / (1 + decay_rate * epoch)",
"def __learning_rate(self, lr0, epoch):\n \n ... | [
"0.84617525",
"0.82243884",
"0.82243884",
"0.80980533",
"0.7709461",
"0.7532248",
"0.74800146",
"0.7420223",
"0.7365421",
"0.73182833",
"0.7307398",
"0.7302014",
"0.7291769",
"0.7291769",
"0.7291769",
"0.7291769",
"0.72633696",
"0.7252848",
"0.725215",
"0.7195715",
"0.7191501... | 0.67102796 | 34 |
Create and save a User with the given email and password. | def create_user(self, email, password, **extra_fields):
if not email:
raise ValueError(_('The Email must be set'))
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save()
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.set_password(password)\n user.save(using=self._db)\n return user",
"def... | [
"0.85445017",
"0.8511888",
"0.850827",
"0.85025996",
"0.8502548",
"0.84896004",
"0.84896004",
"0.84888655",
"0.84888655",
"0.84888655",
"0.8486028",
"0.84772795",
"0.84767693",
"0.8475504",
"0.8475504",
"0.8475504",
"0.8475504",
"0.8475504",
"0.8475504",
"0.8475504",
"0.84755... | 0.84570897 | 22 |
Initialize a Sphere object. | def __init__(self, n=65, radius=1, port_distance_from_surface=.07):
super(SilicaSphere, self).__init__()
particle = mb.load('O=[Si]=O', smiles=True)
particle.name = 'Silica'
particle.add(mb.Port(anchor=particle[1]), label='out')
# Generate 65 points on the surface of a unit sphe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createSphere( position=(0,0,0), radius=1, colour=(0.6,0.6,0.6), samplesY = 20, samplesXZ = 20 ):\r\n return createEllipsoid( position, (radius,radius,radius), colour, samplesY, samplesXZ )",
"def test_sphere_init():\n Sphere(5)",
"def __init__(self,SO,d_dimp,rd_dimp,N_e,N_a):\n self.sphere = S... | [
"0.7074449",
"0.7070917",
"0.6801158",
"0.6777688",
"0.67146844",
"0.6679839",
"0.65584123",
"0.65274596",
"0.65274596",
"0.6449195",
"0.64282715",
"0.63870364",
"0.6337408",
"0.6333842",
"0.63134474",
"0.62698895",
"0.6204761",
"0.619875",
"0.6179071",
"0.61301124",
"0.61205... | 0.63088113 | 15 |
Return the brightness of this light between 0..255. | def brightness(self):
return self._brightness | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def brightness(self) -> float:\n # http://alienryderflex.com/hsp.html\n r, g, b = self.r, self.g, self.b\n return sqrt(0.299*r**2 + 0.587*g**2 + 0.114*b**2)/255",
"def brightness(self):\n return brightness_from_percentage(self._brightness_pct)",
"def brightness(self):\n retur... | [
"0.86106795",
"0.85797876",
"0.84444",
"0.837146",
"0.83107203",
"0.81361365",
"0.81177837",
"0.78746456",
"0.78518254",
"0.78518254",
"0.7823478",
"0.77862597",
"0.7754381",
"0.77270913",
"0.769415",
"0.75714487",
"0.75458485",
"0.7526449",
"0.7523753",
"0.7504014",
"0.74457... | 0.8387642 | 6 |
Return true if light is on. | def is_on(self):
request = requests.get(self._resource+"/state", timeout=10)
try:
if int(float(request.text)) > 0:
self._state = True
else:
self._state = False
except:
self._state = None
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def light_is_on(self):\r\n return self._light == \"ON\"",
"def light_is_on(self):\n return self._light == \"ON\"",
"def is_on(self):\n return self._light_on",
"def is_light(self) -> bool:\n return ATTRIBUTE.Light.value in self.type_data.attributes",
"def is_light(self) -> bool:\... | [
"0.9035416",
"0.89275813",
"0.86664206",
"0.8008696",
"0.8008696",
"0.78880787",
"0.7866302",
"0.7610281",
"0.7565963",
"0.7415077",
"0.7345493",
"0.7335999",
"0.73116577",
"0.7303292",
"0.72991306",
"0.7243393",
"0.71792775",
"0.71722543",
"0.7157757",
"0.7157757",
"0.715775... | 0.0 | -1 |
Turn the light off. | def turn_off(self, **kwargs):
request = requests.post(self._resource, data="0", timeout=10)
if (request.status_code == 200) or (request.status_code == 201):
self._state = False
else:
_LOGGER.error("Can't turn off %s. Is resource/endpoint offline?",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light",
"def lightning_turnoff(self):\n self.turnOff()",
"def set_light_off(self):\n self._light = \"OFF\"",
"def turn_off(self, **kwargs):\n self._light.set_color(0, 0, 0, 0)",
"def set_light_off(self):\r\n ... | [
"0.9158525",
"0.88893706",
"0.88740003",
"0.8852116",
"0.8842971",
"0.87965184",
"0.864986",
"0.85981315",
"0.85843927",
"0.85641575",
"0.8526551",
"0.8403609",
"0.83990663",
"0.8292084",
"0.8271316",
"0.82411224",
"0.81950665",
"0.8189084",
"0.8162265",
"0.8066985",
"0.80102... | 0.0 | -1 |
Check to see whether or not this Account is a member of a list of Groups. | def has_groups(self, resolvables, all=True):
total_checks = 0
for group in resolvables:
if self.has_group(group):
total_checks += 1
if not all:
return True
return True if all and total_checks == len(resolvables) else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_in_group(user, group_name):\n return user.groups.filter(name__exact=group_name).exists()",
"def is_in_group(self, group):\n return group in self.get_all_groups()",
"def is_group(self, group_name):\n\n return group_name in self._group",
"def user_in_group(user, *group_names):\n\treturn boo... | [
"0.68917906",
"0.67864627",
"0.67457235",
"0.67310065",
"0.67156535",
"0.670736",
"0.6704473",
"0.6661034",
"0.66532177",
"0.6640184",
"0.6632986",
"0.66006",
"0.6580356",
"0.6525978",
"0.63369054",
"0.633593",
"0.6331595",
"0.63157886",
"0.63111275",
"0.62684673",
"0.6267412... | 0.6078281 | 39 |
Remove this Account from the specified Group. | def remove_group(self, resolvable):
group = self._resolve_group(resolvable)
for membership in self.group_memberships:
if membership.group.href == group.href:
membership.delete()
return
raise StormpathError({
'developerMessage': 'This user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_group(self, org, contact, group):\n pass",
"def delete_group(self, group):\n raise NotImplementedError('delete_group')",
"def remove_from_group(self, group):\n\n if self.in_group(group):\n self.secondary_groups.remove(group)\n return self",... | [
"0.7001001",
"0.6963882",
"0.69261235",
"0.6655901",
"0.65744185",
"0.6558673",
"0.6529276",
"0.64068115",
"0.6391318",
"0.63866955",
"0.63547575",
"0.6347564",
"0.6340707",
"0.6331727",
"0.6329144",
"0.6323397",
"0.63206124",
"0.62450665",
"0.6191298",
"0.6183577",
"0.615082... | 0.6285145 | 17 |
Remove this Account from the specified Groups. | def remove_groups(self, resolvables):
memberships = [membership for membership in self.group_memberships]
for g in [self._resolve_group(group) for group in resolvables]:
done = False
for membership in memberships:
if membership.group.href == g.href:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_from_groups(self, username, groups):\n pass",
"def remove_accounts(self):\n current_creds = self._accounts.copy()\n for creds in current_creds:\n self.remove_account(current_creds[creds].credentials.token,\n current_creds[creds].credentials.u... | [
"0.7131122",
"0.6211978",
"0.6096747",
"0.59927213",
"0.59406334",
"0.5862089",
"0.5761963",
"0.57058656",
"0.5687555",
"0.56605244",
"0.56303865",
"0.5617083",
"0.55281025",
"0.5502936",
"0.54808134",
"0.53569514",
"0.53486884",
"0.53478575",
"0.53005046",
"0.52964145",
"0.5... | 0.57640827 | 6 |
__init__ method to specify the attributes of a User object | def __init__(self, credentials_name,credentials_user_name,fname, lname,email, credentials_site, credentials_password):
self.credentials_name = credentials_name
self.credentials_user_name = credentials_user_name
self.fname = fname
self.lname = lname
self.email = email
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, user):\n\n if isinstance(user, dict):\n # Every user must have these values\n self.id = user['id']\n self.name = user['first_name']\n\n # These are optional\n self.username = user.get('username', None)\n self.last_name = us... | [
"0.8139694",
"0.7742269",
"0.7632221",
"0.7514317",
"0.7479648",
"0.74781466",
"0.73859185",
"0.7297833",
"0.7205707",
"0.71704376",
"0.71656185",
"0.7125136",
"0.7099701",
"0.70803595",
"0.7033167",
"0.7031077",
"0.702701",
"0.70164716",
"0.695493",
"0.6912947",
"0.6865634",... | 0.0 | -1 |
Gets a secret from the DynamoDB secrets vault. | def test_get_secret_from_vault(key, environment, stage, namespace, table, nkey,
boto3_resource, boto3_client, monkeypatch):
# Call to the DynamoDB client to retrieve the encrypted secret
monkeypatch.setattr("boto3.resource", boto3_resource)
monkeypatch.setattr("boto3.client", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_secret(secret):\n if isinstance(secret, AwsSecret):\n result = aws_cli([\n 'secretsmanager',\n '--region', secret.region,\n 'get-secret-value',\n '--secret-id', secret.arn\n ])\n\n \"\"\"\n Result will be of the form:\n {\n... | [
"0.75081635",
"0.7418677",
"0.7403105",
"0.71719915",
"0.7112281",
"0.6981018",
"0.6963023",
"0.69508934",
"0.6941142",
"0.6921383",
"0.6920858",
"0.6851192",
"0.68134636",
"0.68008757",
"0.6780388",
"0.67319816",
"0.66990674",
"0.663176",
"0.66122556",
"0.6586976",
"0.650927... | 0.68288445 | 12 |
Get a state value from DynamoDB. | def test_get_state(boto3_resource, monkeypatch, key, environment, layer,
stage, shard_id, namespace, table, consistent, nkey):
monkeypatch.setattr("boto3.resource", boto3_resource)
lambdautils.utils.get_state(key, environment=environment, layer=layer,
stage=sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\n return self.val... | [
"0.75622314",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.7417428",
"0.73832",
"0.68980134",
"0.68980134",
"0.6708277",
"0.6682277",
"0.6624591",
"0.65897566",
"0.6578076",
... | 0.5727469 | 54 |
Tests sending events to a Kinesis stream. | def test_send_to_kinesis_stream(search_events, boto3_client, monkeypatch):
monkeypatch.setattr("boto3.client", boto3_client)
lambdautils.utils.send_to_kinesis_stream(search_events, "dummy_stream")
boto3_client("kinesis").put_records.call_count == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_send_to_delivery_stream(search_events, boto3_client, monkeypatch):\n monkeypatch.setattr(\"boto3.client\", boto3_client)\n lambdautils.utils.send_to_delivery_stream(search_events, \"dummy_stream\")\n boto3_client(\"firehose\").put_record_batch.call_count == 1",
"def test_kinesis_producer(sdc_bu... | [
"0.73958737",
"0.65939516",
"0.6562662",
"0.63289183",
"0.62678695",
"0.62392575",
"0.6180703",
"0.6127866",
"0.6088465",
"0.60832953",
"0.6060568",
"0.6050372",
"0.59838164",
"0.59591836",
"0.5934428",
"0.5880064",
"0.5880064",
"0.5869971",
"0.585581",
"0.5839014",
"0.583443... | 0.8220413 | 0 |
Tests sending events to a Firehose delivery stream. | def test_send_to_delivery_stream(search_events, boto3_client, monkeypatch):
monkeypatch.setattr("boto3.client", boto3_client)
lambdautils.utils.send_to_delivery_stream(search_events, "dummy_stream")
boto3_client("firehose").put_record_batch.call_count == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_firehose_destination_to_s3(sdc_builder, sdc_executor, aws):\n s3_client = aws.s3\n firehose_client = aws.firehose\n\n # setup test static\n s3_bucket = aws.s3_bucket_name\n stream_name = aws.firehose_stream_name\n # json formatted string\n random_raw_str = '{{\"text\":\"{0}\"}}'.forma... | [
"0.6836899",
"0.6728501",
"0.6404267",
"0.629082",
"0.6271923",
"0.60981536",
"0.60865474",
"0.6059993",
"0.6058122",
"0.6046713",
"0.60003126",
"0.5948927",
"0.59198534",
"0.58658206",
"0.5850441",
"0.5811043",
"0.57739997",
"0.57500505",
"0.57340044",
"0.5723268",
"0.572290... | 0.80097747 | 0 |
returns a list of rules that are bound to this URI register. these may inherited, and have inheriting subrules that will need ot be accessed | def find_matching_rules(self, requested_uri):
rulesfound = []
for rule in RewriteRule.objects.filter(register=self) :
(matched,nestedrule) = rule.match_inheritance( requested_uri)
if matched :
rulechain = (rule,) + nestedrule.get_subrules() + (nestedrule,)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rules(self):\n rules = []\n for item in self.name:\n rules.append(item)\n return rules",
"def get_rules(self):\n # TODO: Implement\n self.traverse2(self.tree, [])\n return self.rules",
"def get_rules(cls):\n raise NotImplementedError()",
"de... | [
"0.7360198",
"0.72860944",
"0.7256938",
"0.72413635",
"0.7137854",
"0.70234334",
"0.6808077",
"0.67854154",
"0.6758962",
"0.66615343",
"0.65582335",
"0.6415378",
"0.6415378",
"0.64038676",
"0.6396085",
"0.6372609",
"0.63706386",
"0.63706386",
"0.63315487",
"0.62492275",
"0.62... | 0.8033008 | 0 |
An accessor function for the elapsed time of a word_time. | def elapsed_time(word_time):
return word_time[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_time(word, elapsed_time):\n return [word, elapsed_time]",
"def get_time_elapsed(self):\n return self.__time_elapsed",
"def elapsed_time(self):\n return self.__elapsed_time",
"def get_elapsed_time(self):\n\n return datetime.timedelta(seconds=int(time.time() - self.start_time))... | [
"0.7250786",
"0.7186347",
"0.70401293",
"0.6793212",
"0.67556137",
"0.6743557",
"0.66025287",
"0.6541595",
"0.6531728",
"0.64950126",
"0.64903915",
"0.6461789",
"0.6454673",
"0.63680804",
"0.6341702",
"0.63032204",
"0.6265737",
"0.6247675",
"0.6235996",
"0.62313354",
"0.62289... | 0.86056423 | 0 |
Handles the shooting action of the spaceships when they press the shoot key. | def handle_bullets_fired(context: GameContext, event: pygame.event.Event) -> None:
if event.type == pygame.KEYDOWN:
if event.key == LEFT_SHOOT and len(context.left_bullets) < MAX_ACTIVE_BULLETS:
context.left_bullets.append(
Bullet(shooter=context.left_spaceship, color=YELLOW))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shoot(self):\n if self.gun_interface:\n self.gun_interface.prepare_fire()",
"def shoot(self):\n shots = Shooting(self.rect.centerx, self.rect.bottom)\n # Adding the shots to sprite lists created\n all_sprites_list.add(shots)\n shooting_list.add(shots)",
"def sh... | [
"0.6830748",
"0.6812363",
"0.6758362",
"0.66564107",
"0.6645007",
"0.6570809",
"0.6567969",
"0.649499",
"0.6492216",
"0.6487243",
"0.6471834",
"0.64095825",
"0.63718605",
"0.63663113",
"0.6332932",
"0.63117796",
"0.6265336",
"0.6215359",
"0.61728483",
"0.6169206",
"0.6132534"... | 0.60222256 | 31 |
Handles the damage dealt when a bullet hits an spaceship. | def handle_bullet_hit(context: GameContext, event: pygame.event.Event) -> None:
if event.type == RIGHT_HIT:
context.right_spaceship.health -= event.damage
BULLET_HIT_SOUND.play()
if context.right_spaceship.is_dead():
pygame.event.post(pygame.event.Event(
WIN, winn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def charactersShotDamageHandler(screen):\n for bullet in Laser.List:\n\n bullet.x += bullet.velx\n bullet.y += bullet.vely\n\n screen.blit(bullet.img, (bullet.x, bullet.y))\n\n if bullet.offscreen(screen):\n Laser.List.remove(bullet)\n ... | [
"0.6829159",
"0.6538542",
"0.65336555",
"0.6457117",
"0.6429845",
"0.6426174",
"0.6416543",
"0.6402615",
"0.6362282",
"0.6327024",
"0.629774",
"0.62884146",
"0.6266172",
"0.6229707",
"0.6226663",
"0.62094706",
"0.61427563",
"0.61045724",
"0.6027305",
"0.59923446",
"0.598325",... | 0.7441827 | 0 |
Handles the movement and collisions of the bullets. | def handle_bullets_movement(context: GameContext) -> None:
for bullet in context.left_bullets:
bullet.body.x += BULLET_VEL
if bullet.is_hitting(context.right_spaceship):
pygame.event.post(pygame.event.Event(
RIGHT_HIT, damage=bullet.damage))
context.left_bulle... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_bullet(self):\n\n # update position of old bullets\n self.bullets.update()\n\n # Get rid of bullets that are off screen\n for bullet in self.bullets.copy():\n if bullet.rect.left >= self.screen_width:\n self.bullets.remove(bullet)\n\n # see i... | [
"0.7582959",
"0.7395327",
"0.7346885",
"0.7328024",
"0.7273234",
"0.7217157",
"0.7195903",
"0.71874547",
"0.7179212",
"0.71546996",
"0.71267796",
"0.70750415",
"0.7062781",
"0.70018387",
"0.6998345",
"0.69911355",
"0.698905",
"0.69789064",
"0.69079584",
"0.6862696",
"0.686066... | 0.77643746 | 0 |
Run when entity about to be added to hass. | async def async_added_to_hass(self) -> None:
if not (last_state := await self.async_get_last_state()):
return
self._attr_is_on = last_state.state == STATE_ON
if self._attr_is_on:
evt.async_call_later(self.hass, OFF_DELAY, self.off_delay_listener) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_added_to_hass(self):\n self.hass.data[DOMAIN].add_entity_id(self.entity_id)\n self.hass.data[DOMAIN].add_sensor(self)",
"async def async_added_to_hass(self):\n await super().async_added_to_hass()\n self.coordinator.entities.append(self)",
"async def async_added_to_ha... | [
"0.76435804",
"0.75078416",
"0.729544",
"0.72007114",
"0.71249294",
"0.6637344",
"0.6637344",
"0.6609217",
"0.6587545",
"0.6568664",
"0.6558652",
"0.65439403",
"0.6542437",
"0.6523167",
"0.6480334",
"0.6472043",
"0.6433679",
"0.64238393",
"0.6418894",
"0.6390242",
"0.6389016"... | 0.0 | -1 |
Turn off camera siren. | async def async_turn_off(self, **kwargs: Any) -> None:
try:
result = await self.hass.async_add_executor_job(
self.coordinator.ezviz_client.sound_alarm, self._serial, 1
)
except (HTTPError, PyEzvizError) as err:
raise HomeAssistantError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_camera_off():\n # Do command\n consoleOutput = exec_console_command(constants.cameraOff + constants.getExitStatus)\n\n if \"2\" in consoleOutput:\n raise IOError(constants.cameraOffScriptNotFound)\n\n # Parse output\n feedbackOutput = constants.cameraSwitchedOff\n\n return feedbac... | [
"0.7496608",
"0.74059844",
"0.7404746",
"0.7309104",
"0.71862817",
"0.711986",
"0.65938026",
"0.6571407",
"0.6570841",
"0.65678394",
"0.64931613",
"0.6480135",
"0.64612347",
"0.6455518",
"0.6445569",
"0.6444959",
"0.64316237",
"0.64021134",
"0.6389612",
"0.6381899",
"0.636304... | 0.0 | -1 |
Populates a Sudoku box with missing numbers. TODO safeguard against user feeding a puzzle with dupes in a box, row, or col. | def populate_box(box):
missing = []
[missing.append(z) for z in range(16) if z not in np.reshape(box, 16)]
for i in range(4):
for j in range(4):
if box[i, j] == 16:
box[i, j] = missing.pop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solveSudoku(board):\n # represents all numbers in a specific row, col, box\n # format: if (5,9) is in rows, that means row 5 contains digit 9\n\t\t# format: if (3, 2) is in cols, that means col 3 contains digit 2\n\t\t# format: if (0,2,8) is in boxes, that means box (0,2) contains 8\n\t\t# cellsT... | [
"0.6834966",
"0.654431",
"0.61932665",
"0.613928",
"0.6120546",
"0.61044496",
"0.5935123",
"0.5908947",
"0.5906849",
"0.5890432",
"0.58584404",
"0.5849396",
"0.5848208",
"0.58263344",
"0.5823368",
"0.58130866",
"0.5791542",
"0.578596",
"0.5776167",
"0.5768304",
"0.57636744",
... | 0.72917163 | 0 |
Return True if a roll has at least an amount of 'black' equal to resistance. 'black' was chosen arbitrarily. | def _success(self, roll, resistance):
hits = roll.count('black')
if 'Wild White' in self.special_powers:
hits += roll.count('white')
return hits >= resistance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def red_has_won(self):\n return not any([self.squares[p].is_red() for p in self.squares \\\n if self.squares[p]])",
"def black_has_won(self):\n return not any([self.squares[p].is_black() for p in self.squares \\\n if self.squares[p]])",
"d... | [
"0.6463261",
"0.60419405",
"0.5954305",
"0.59287566",
"0.5915348",
"0.57937604",
"0.5682572",
"0.5672669",
"0.56553185",
"0.56458694",
"0.5614182",
"0.5559539",
"0.5549654",
"0.5534451",
"0.5528087",
"0.5501214",
"0.54762465",
"0.54754704",
"0.5457948",
"0.5456126",
"0.544067... | 0.7735157 | 0 |
Retrieves communication connection parameters from environment variables | def validate_endpoint(cmd, namespace):
n = namespace
if not n.endpoint:
n.endpoint = get_config_value(cmd, 'communication', 'endpoint', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getParamsFromEnv(self):\r\n self.port = os.getenv('PGPORT', self.port)\r\n self.host = os.getenv('PGHOST', self.host)\r\n self.database = os.getenv('PGDATABASE', self.database)\r\n self.user = os.getenv('PGUSER', self.user)\r\n self.password = os.getenv('PGPASSWORD', self.pas... | [
"0.71315414",
"0.6984379",
"0.68156654",
"0.63937074",
"0.6306903",
"0.625447",
"0.62280285",
"0.6207392",
"0.6190396",
"0.6159994",
"0.6157785",
"0.5986137",
"0.5973659",
"0.5934997",
"0.59213203",
"0.5900448",
"0.5887794",
"0.5880929",
"0.5880929",
"0.5874544",
"0.5785258",... | 0.0 | -1 |
Retrieves communication connection parameters from environment variables | def validate_access_token(cmd, namespace):
n = namespace
if not n.access_token:
n.access_token = get_config_value(cmd, 'communication', 'access_token', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getParamsFromEnv(self):\r\n self.port = os.getenv('PGPORT', self.port)\r\n self.host = os.getenv('PGHOST', self.host)\r\n self.database = os.getenv('PGDATABASE', self.database)\r\n self.user = os.getenv('PGUSER', self.user)\r\n self.password = os.getenv('PGPASSWORD', self.pas... | [
"0.7132804",
"0.69858855",
"0.68159443",
"0.63932514",
"0.6308155",
"0.62568074",
"0.6230579",
"0.62070477",
"0.6191876",
"0.6160925",
"0.6159276",
"0.5987351",
"0.59742486",
"0.5936744",
"0.59231603",
"0.5900399",
"0.5889401",
"0.5882519",
"0.5882519",
"0.58768386",
"0.57867... | 0.0 | -1 |
Maps an observation to discrete state index for both position and velocity | def obs_to_index(obs, env_low, env_dx):
a = math.floor((obs[0] - env_low[0])/env_dx[0])
b = math.floor((obs[1] - env_low[1])/env_dx[1])
return a, b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self, observation):\n values = make_discrete(\n observation,\n self.__environment.observation_space,\n CartPoleEnvironment.intervals,\n )\n\n velocity_state = 0\n if observation[1] > 0:\n velocity_state = 1\n elif observation[1] < 0:\n velocity_state = 2\n\n ... | [
"0.67786074",
"0.6537952",
"0.63523203",
"0.5935677",
"0.5906151",
"0.5898781",
"0.58889306",
"0.58823013",
"0.5773632",
"0.5754219",
"0.57272106",
"0.5696519",
"0.5659486",
"0.5658497",
"0.5656951",
"0.5622493",
"0.5599197",
"0.5592899",
"0.5579516",
"0.55647415",
"0.5559073... | 0.55422634 | 21 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,), detail=False):
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:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)",
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua... | [
"0.83305424",
"0.8285189",
"0.82385355",
"0.82303274",
"0.822045",
"0.8186781",
"0.8185327",
"0.8175578",
"0.81719494",
"0.81705135",
"0.8167001",
"0.8164987",
"0.816426",
"0.81626654",
"0.81626654",
"0.81626654",
"0.81626654",
"0.81626654",
"0.81626654",
"0.81626654",
"0.816... | 0.0 | -1 |
The masked 2D grid used by the dataset in the modelfit. | def grid(self) -> aa.Grid2D:
return self.analysis.dataset.grid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mask_grid(self):\n xg, yg = self._build_grid()\n mask = self._build_mask(xg, yg)\n mask = mask.reshape(xg.shape)\n\n return xg, yg, mask",
"def real_space_mask(self) -> aa.Mask2D:\r\n return self.max_log_likelihood_fit.dataset.real_space_mask",
"def mask(self):\n ... | [
"0.75573176",
"0.7230357",
"0.7174881",
"0.6918848",
"0.6745583",
"0.64837116",
"0.63407534",
"0.6321653",
"0.6321337",
"0.62902534",
"0.6283323",
"0.62347174",
"0.619163",
"0.61883813",
"0.61809033",
"0.6148085",
"0.6140789",
"0.61034673",
"0.60924304",
"0.6067866",
"0.60167... | 0.7292168 | 1 |
Returns the average of the array. Uses floatingpoint division. | def avg(arr):
return sum(arr) / float(len(arr)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_average(array):\n result = 0\n for item in array:\n result += float(item)\n final_result = result/len(array)\n return final_result",
"def get_average(array):\n total = sum(array)\n count = len(array)\n average = total / count\n return average",
"def mean(arr) -> flo... | [
"0.83349454",
"0.82899994",
"0.8212963",
"0.7766178",
"0.7680095",
"0.7622747",
"0.7522209",
"0.7502235",
"0.7483243",
"0.73657703",
"0.7359074",
"0.7359074",
"0.7349715",
"0.7339887",
"0.7313043",
"0.72779435",
"0.7270407",
"0.718516",
"0.7185139",
"0.7168243",
"0.7163157",
... | 0.8386555 | 0 |
Does a POST request to /emailvalidate. | def email_validate(self,
email,
fix_typos=False):
# Prepare query URL
_url_path = '/email-validate'
_query_builder = Configuration.get_base_uri()
_query_builder += _url_path
_query_url = APIHelper.clean_url(_query_builder)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n data = EmailAddressValidationSchema().load(request.json)\n email_lowercase = data[\"email\"].lower()\n verification_token = data[\"verificationToken\"]\n UserRegistrationService.validate_email_address_verification_token(email_lowercase, verification_token)",
"def val... | [
"0.79815966",
"0.71081567",
"0.6944144",
"0.67577386",
"0.6743851",
"0.6674706",
"0.6674706",
"0.6559279",
"0.6500751",
"0.6457878",
"0.6451997",
"0.6451997",
"0.6375501",
"0.63622296",
"0.6332028",
"0.6308513",
"0.63042706",
"0.6275062",
"0.62735856",
"0.6272149",
"0.6206531... | 0.72253996 | 1 |
Does a POST request to /phonevalidate. Parse, validate and get location information about a phone number. | def phone_validate(self,
number,
country_code=None,
ip=None):
# Prepare query URL
_url_path = '/phone-validate'
_query_builder = Configuration.get_base_uri()
_query_builder += _url_path
_query_url = AP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validatephone(self, send_to):\n\n self.send_to = send_to.lstrip('+')\n self.params = {\n 'api_key': self.phone_validate_api_key,\n 'phone' : self.send_to\n }\n response = requests.get(self.phone_validate_api_url,params=self.p... | [
"0.63570565",
"0.63082945",
"0.6155318",
"0.61548567",
"0.6143602",
"0.59452236",
"0.5901058",
"0.58651334",
"0.58563143",
"0.58556294",
"0.58481556",
"0.58451223",
"0.5824831",
"0.5799924",
"0.5730809",
"0.5727636",
"0.5727636",
"0.5703088",
"0.56898946",
"0.56744343",
"0.56... | 0.7256053 | 0 |
Returns project's root working directory (entire path). Returns string Path to project's root directory. | def get_root_working_directory():
# Get current working directory
cwd = os.getcwd()
# Remove all children directories
rd = os.path.join(cwd.split('stochastic-travel-demand-modelling/', 1)[0])
# Make sure directory ends with project's name
if not rd.endswith('stochastic-travel-demand-modelling'):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_root() -> Path:\n return PROJECT_ROOT",
"def getProjectRootDir():\n return ROOT_DIR",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() -> Path:\n return Pa... | [
"0.8592724",
"0.8327607",
"0.8312195",
"0.8312195",
"0.8312195",
"0.8312195",
"0.82783514",
"0.81768227",
"0.8132063",
"0.80996436",
"0.8094401",
"0.8082749",
"0.8082749",
"0.79929626",
"0.79292774",
"0.7872894",
"0.7850325",
"0.7772306",
"0.77514374",
"0.7743649",
"0.7720207... | 0.74264586 | 31 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(VideoImage, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.unique_key is None:
self.unique_key = 0
if self.gps_week is None:
self.gps_week = 0
if se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.7794478",
"0.77204376",
"0.77204376",
"0.76865023",
"0.7625996",
"0.7563802",
"0.74399596",
"0.74173665",
"0.73513013",
"0.73086345",
"0.72797984",
"0.7237519",
"0.7227004",
"0.7224259",
"0.7224259",
"0.7218872",
"0.72119284",
"0.72119284",
"0.72119284",
"0.72119284",
"0.7... | 0.6446751 | 99 |
Returns a Location object containing the latitude/longitude `north` and `east` (floating point) meters from the specified `original_location`, and optionally `alt` meters above the `original_location`. The returned Location has the same and `is_relative` value as `original_location`. The function is useful when you wan... | def get_location_meters(original_location, north, east, alt=0):
# Radius of "spherical" earth
earth_radius = 6378137.0
# Coordinate offsets in radians
lat = north / earth_radius
lon = east / (earth_radius * math.cos(original_location.lat * math.pi/180))
# New position in decimal degrees
new... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_location_metres(original_location, dNorth, dEast):\n earth_radius = 6378137.0 # Radius of \"spherical\" earth\n # Coordinate offsets in radians\n dLat = dNorth / earth_radius\n dLon = dEast / (earth_radius * math.cos(math.pi * original_location.lat / 180))\n\n # New position in decimal degr... | [
"0.7680507",
"0.7649459",
"0.7581445",
"0.7438943",
"0.74093175",
"0.7401367",
"0.65779614",
"0.5313725",
"0.52788293",
"0.5222334",
"0.5222334",
"0.51701635",
"0.51588756",
"0.51348907",
"0.5121284",
"0.5094413",
"0.50760937",
"0.50320166",
"0.50320166",
"0.5016322",
"0.5014... | 0.77961797 | 0 |
Returns the ground distance in meters between two Location objects. This method is an approximation, and will not be accurate over large distances and close to the | def get_distance_meters(location1, location2):
dlat = location2.lat - location1.lat
dlong = location2.lon - location1.lon
return math.sqrt((dlat*dlat) + (dlong*dlong)) * 1.113195e5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance_meters(aLocation1, aLocation2):\n dlat = aLocation2.lat - aLocation1.lat\n dlong = aLocation2.lon - aLocation1.lon\n return math.sqrt((dlat*dlat) + (dlong*dlong)) * 1.113195e5",
"def get_distance_metres(aLocation1, aLocation2):\n dlat = aLocation2.lat - aLocation1.lat\n dlong = aL... | [
"0.7167165",
"0.7079099",
"0.7079099",
"0.7079099",
"0.7079099",
"0.7079099",
"0.70474285",
"0.7044118",
"0.7008921",
"0.68730134",
"0.66396636",
"0.6567191",
"0.6462758",
"0.6425752",
"0.63876534",
"0.63308275",
"0.63308275",
"0.625272",
"0.625088",
"0.62275505",
"0.6202599"... | 0.7054187 | 6 |
Test that the `sparse_distance_matrix` method returns the same thing in the redistributed KDTree and on the actual scipy one. | def test_sparse_distance_matrix(coordinates, max_dist, p):
original_tree = scipyKDTree(coordinates)
redis_tree = redisKDTree(coordinates)
original_output = original_tree.sparse_distance_matrix(original_tree, max_dist, p)
redis_output = redis_tree.sparse_distance_matrix(redis_tree, max_dist, p)
ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_sparse(self):\n x, x_rand, s = self.create_testdata()\n task = mmRDTR()\n #check that a dense array x is passed thru unchanged\n check = task.check_sparse(x)\n self.assertEqual(np.all(check==x),True)\n #check that a sparse matrix s is converted to a numpy ar... | [
"0.7023899",
"0.6719681",
"0.6599601",
"0.6436412",
"0.6433746",
"0.62209845",
"0.612098",
"0.6057461",
"0.6046778",
"0.6001348",
"0.5944586",
"0.59415406",
"0.5885322",
"0.58597505",
"0.58593243",
"0.5845917",
"0.58370626",
"0.58323026",
"0.58223087",
"0.58198905",
"0.581543... | 0.80030465 | 0 |
Gets string from datetime object. In UTC Time. | def get_mdal_datetime_to_string(date_object):
return date_object.strftime('%Y-%m-%d %H:%M:%S') + ' UTC' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_utc_from_datetime(datetime_obj, fmt=\"%Y-%m-%d %H:%M:%S\"):\n return time.strftime(fmt, time.gmtime(time.mktime(datetime_obj.timetuple())))",
"def datetime_to_str(obj: \"datetime\") -> str:\n if obj.tzinfo is not None and obj.tzinfo.utcoffset(obj) is not None:\n # aware time; translate to UT... | [
"0.73960054",
"0.738016",
"0.72528803",
"0.7245231",
"0.724145",
"0.7235136",
"0.7189752",
"0.7062306",
"0.7053631",
"0.7003563",
"0.6973802",
"0.6955501",
"0.68832535",
"0.6881237",
"0.68115944",
"0.6805447",
"0.6805447",
"0.6805447",
"0.6796045",
"0.67717963",
"0.6767804",
... | 0.7586225 | 0 |
Concatinates all thermal data zone data into one big dataframe. Will sort by index. Get rid of all zone_temperature columns. | def concat_zone_data(thermal_data):
concat_data = pd.concat(thermal_data.values()).sort_index()
filter_columns = ["zone_temperature" not in col for col in concat_data.columns]
return concat_data[concat_data.columns[filter_columns]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_full_temp(df_temperature):\n df_interp_full = build_missing(df_temperature)\n df_full = pd.concat([df_interp_full, df_temperature], ignore_index=True)\n df_full = df_full.sort_values(by=['datetime'])\n return df_full",
"def prepare_for_influxdb(df):\n df = df.drop(columns=\"landkreis\", ... | [
"0.67080474",
"0.5877774",
"0.57785916",
"0.57717144",
"0.56823885",
"0.5676393",
"0.5662394",
"0.55926794",
"0.5579588",
"0.5494668",
"0.5440085",
"0.5387524",
"0.5377144",
"0.53647923",
"0.5359446",
"0.535154",
"0.534595",
"0.53407085",
"0.53315556",
"0.53063667",
"0.529673... | 0.81880385 | 0 |
Generates each ngram from a sequence. As on the whiteboard, the sequence is padded with special symbols so every event has the proper context. | def extract_ngrams(self, sequence):
sequence = self.prefix + sequence + self.suffix
for i, event in enumerate(sequence[self.n:], self.n):
yield event, sequence[i-self.n: i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ngrams(seq, n):\n return",
"def everygrams(seq):\n for n in range(1, len(seq) + 1):\n for ng in nltk.util.ngrams(seq, n):\n yield ng",
"def ngrams(n, target):\n chars = collections.deque()\n while True:\n chars.append((yield))\n if len(chars) == n... | [
"0.70220107",
"0.67713094",
"0.6717845",
"0.66013354",
"0.65804136",
"0.64680845",
"0.6348618",
"0.63359",
"0.6330116",
"0.630219",
"0.62617964",
"0.62508935",
"0.6246824",
"0.6193201",
"0.6190689",
"0.6171698",
"0.61618155",
"0.6154644",
"0.6154279",
"0.61264557",
"0.6116867... | 0.76493615 | 0 |
Create a binary search tree. | def bst_empty():
from bbst import Bst
return Bst() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_binary_search_tree(self):\n root = self.get_root()\n bst = BinarySearchTree(root)\n\n for patient in self.dataset:\n bst.insert_node(patient)\n\n return bst",
"def construct_tree():\n root = TreeNode(5)\n root.left = TreeNode(3)\n root.right = TreeNode(8)\n ... | [
"0.760747",
"0.734949",
"0.72915184",
"0.7232463",
"0.72318155",
"0.71516824",
"0.7026545",
"0.69894946",
"0.6938572",
"0.69171786",
"0.68835646",
"0.6879449",
"0.6789941",
"0.6787757",
"0.6750924",
"0.6746733",
"0.668539",
"0.66823655",
"0.6680597",
"0.6665809",
"0.6643068",... | 0.0 | -1 |
r"""Create a binary search tree 5 numbers. 5 / \ 2 6 / \ \ 1 3 7 | def bst_balanced():
from bbst import Bst
return Bst([5, 6, 2, 3, 1, 7]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build():\n # root = TreeNode(5)\n # root.left = TreeNode(2)\n # root.right = TreeNode(7)\n # return root\n\n \"\"\"\n 5\n / \\\n 2 6\n / \\\n 1 3\n [5,2,1,3,6]\n \"\"\"\n _5 = TreeNode(5)\n _2 = TreeNode(2)\n _6 = TreeN... | [
"0.7478297",
"0.7296461",
"0.69578207",
"0.6955442",
"0.69475204",
"0.68356323",
"0.68255305",
"0.6804919",
"0.6768944",
"0.667888",
"0.6631164",
"0.6588557",
"0.6585884",
"0.6563305",
"0.6550456",
"0.6549018",
"0.6520075",
"0.6466318",
"0.64642066",
"0.6463543",
"0.6446722",... | 0.0 | -1 |
r"""Create a binary search tree 5 numbers. 6 / \ 5 8 / / \ 2 7 9 | def bst_right_balance():
from bbst import Bst
return Bst([5, 8, 6, 9, 2, 7]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build():\n # root = TreeNode(5)\n # root.left = TreeNode(2)\n # root.right = TreeNode(7)\n # return root\n\n \"\"\"\n 5\n / \\\n 2 6\n / \\\n 1 3\n [5,2,1,3,6]\n \"\"\"\n _5 = TreeNode(5)\n _2 = TreeNode(2)\n _6 = TreeN... | [
"0.7508102",
"0.7388292",
"0.7065875",
"0.6982955",
"0.6982262",
"0.6975616",
"0.6961125",
"0.6900942",
"0.6788537",
"0.67634875",
"0.6716761",
"0.67118734",
"0.66720515",
"0.6601973",
"0.6563353",
"0.6562807",
"0.6550962",
"0.65054137",
"0.64960486",
"0.6493271",
"0.64817923... | 0.0 | -1 |
Return 0 on empty tree. | def test_depth_returns_zero_on_empty_tree(bst_empty):
assert bst_empty.depth() == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_tree(height_one_tree):\n assert height_one_tree.root.val is 0",
"def size(self) -> int:\n if self.root is None: # If tree is empty\n return 0\n\n return self.size_helper(self.root)",
"def __len__(self):\n return self.tree.filled_size()",
"def root_ind... | [
"0.7409048",
"0.7219481",
"0.7176118",
"0.7148872",
"0.7122267",
"0.7093614",
"0.7003308",
"0.6989346",
"0.6942608",
"0.6936339",
"0.6919273",
"0.69147694",
"0.6913444",
"0.68903935",
"0.68643457",
"0.6818482",
"0.67871666",
"0.6748771",
"0.6734934",
"0.67220837",
"0.67141914... | 0.7284261 | 1 |
Tree balanced right returns 1. | def test_balance_left_tree(bst_all_to_left):
assert bst_all_to_left.balance() == -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_depth_returns_correct_value_right_balanced_tree(bst_right_balance):\n assert bst_right_balance.depth() == 3",
"def _right(node):\n return 2 * node + 2",
"def recursive(node):\n if not node:\n return -1\n\n h_left = recursive(node.left)\n if h_left < -1:\n return h_left\n \n h_right = r... | [
"0.7153389",
"0.70516586",
"0.6953326",
"0.69010335",
"0.6750387",
"0.6708068",
"0.66908234",
"0.6675071",
"0.66586083",
"0.66586083",
"0.6606943",
"0.6581615",
"0.6581615",
"0.6581513",
"0.6580226",
"0.652384",
"0.64854455",
"0.6458268",
"0.64536995",
"0.6423518",
"0.6418781... | 0.0 | -1 |
Tree balanced right returns 0. | def test_balance_balanced_tree(bst_balanced):
assert bst_balanced.balance() == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance(self):\n if self.val is None:\n return 0\n return self.left.depth() - self.right.depth()",
"def test_depth_returns_correct_value_right_balanced_tree(bst_right_balance):\n assert bst_right_balance.depth() == 3",
"def _get_right_height(self):\n if self.right is None:\n ... | [
"0.73298436",
"0.7154279",
"0.7105206",
"0.7024582",
"0.697647",
"0.6908066",
"0.68003285",
"0.6707597",
"0.6648786",
"0.6594518",
"0.6556658",
"0.6556658",
"0.6520672",
"0.6509241",
"0.6498207",
"0.6475158",
"0.64529175",
"0.64521086",
"0.64521086",
"0.644718",
"0.6439641",
... | 0.0 | -1 |
Tree balanced right returns 0. | def test_balance_empty_tree(bst_empty):
assert bst_empty.balance() == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance(self):\n if self.val is None:\n return 0\n return self.left.depth() - self.right.depth()",
"def test_depth_returns_correct_value_right_balanced_tree(bst_right_balance):\n assert bst_right_balance.depth() == 3",
"def _get_right_height(self):\n if self.right is None:\n ... | [
"0.73298436",
"0.7154279",
"0.7105206",
"0.7024582",
"0.697647",
"0.6908066",
"0.68003285",
"0.6707597",
"0.6648786",
"0.6594518",
"0.6556658",
"0.6556658",
"0.6520672",
"0.6509241",
"0.6498207",
"0.6475158",
"0.64529175",
"0.64521086",
"0.64521086",
"0.644718",
"0.6439641",
... | 0.0 | -1 |
Delete returns none on empty tree. Tree remains. | def test_delete_empty_bst(bst_empty):
assert bst_empty.delete() is None
assert bst_empty._root is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_node_empty_returns_none(bst_empty):\n assert bst_empty.delete(5) is None",
"def delete(self):\n if self.left is None or self.right is None:\n if self is self.parent.left:\n self.parent.left = self.left or self.right\n if self.parent.left is not N... | [
"0.76282203",
"0.7422466",
"0.7371376",
"0.7371376",
"0.7307012",
"0.72331923",
"0.71977055",
"0.71851134",
"0.7150815",
"0.7150099",
"0.7040827",
"0.7023488",
"0.70232224",
"0.7021793",
"0.7002285",
"0.70008034",
"0.69909143",
"0.6988557",
"0.69447464",
"0.6937728",
"0.69374... | 0.73124784 | 4 |
Test delete on empty tree with value not in tree. | def test_delete_empty_bst_value_not_in_tree(bst_empty):
assert bst_empty.delete(5) is None
assert bst_empty._root is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_node_empty_returns_none(bst_empty):\n assert bst_empty.delete(5) is None",
"def test_delete_left_tree_single_child(bst_all_to_left):\n bst_all_to_left.delete(4)\n assert bst_all_to_left.search(3).val == 3\n assert bst_all_to_left.search(4) is None",
"def test_deletion_no_child(basic... | [
"0.77489096",
"0.7599642",
"0.7582181",
"0.75293005",
"0.7495544",
"0.74936074",
"0.72178745",
"0.70879745",
"0.70583344",
"0.70416665",
"0.7018589",
"0.6984134",
"0.69797534",
"0.6972672",
"0.69686717",
"0.6905891",
"0.6880399",
"0.68580616",
"0.68499476",
"0.68328255",
"0.6... | 0.8150073 | 0 |
Test four node with deletion requireing left rotation. | def test_four_nodes_needs_left_rotation(three_del):
three_del.insert(40)
three_del.delete(10)
assert tuple(three_del.in_order()) == (20, 30, 40)
assert tuple(three_del.breadth_first()) == (30, 20, 40) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_four_nodes_needs_right_left_rotation(three_del):\n three_del.insert(25)\n three_del.delete(10)\n assert tuple(three_del.in_order()) == (20, 25, 30)\n assert tuple(three_del.breadth_first()) == (25, 20, 30)",
"def test_four_nodes_needs_left_right_rotation(three_del):\n three_del.insert(15)... | [
"0.8040648",
"0.8032714",
"0.7799203",
"0.6961463",
"0.6776534",
"0.6462687",
"0.64182127",
"0.6365497",
"0.63579774",
"0.6340384",
"0.6306984",
"0.62662494",
"0.62516254",
"0.62261117",
"0.6099811",
"0.605788",
"0.6054583",
"0.59273565",
"0.58718014",
"0.5861333",
"0.5835034... | 0.81075567 | 0 |
Test delete leaf, branch needs right rotation. | def test_delele_requires_right_branch_rotation(comp):
comp.delete(12)
assert tuple(comp.in_order()) == (4, 6, 7, 8, 9, 10, 11, 13, 14, 15)
assert tuple(comp.breadth_first()) == (11, 8, 14, 6, 10, 13, 15, 4, 7, 9) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_left_leaf_no_rotation(bst_balanced):\n bst_balanced.delete(1)\n assert tuple(bst_balanced.in_order()) == (2, 3, 5, 6, 7)\n assert tuple(bst_balanced.breadth_first()) == (5, 2, 6, 3, 7)",
"def test_delete_right_leaf_no_rotation(bst_balanced):\n bst_balanced.delete(7)\n assert tuple(... | [
"0.78283525",
"0.7744716",
"0.7675529",
"0.76136214",
"0.7489766",
"0.74228394",
"0.7407677",
"0.7403079",
"0.73589516",
"0.73018104",
"0.72987247",
"0.7284646",
"0.72755444",
"0.7262102",
"0.7234282",
"0.7228832",
"0.71202856",
"0.70601445",
"0.7056773",
"0.70374805",
"0.703... | 0.67506516 | 32 |
Delete left node leaves tree in order. | def test_delete_three_node_tree_02(three):
three.delete(1)
assert three._root.val == 2
assert three._root.right.val == 3
assert three._root.left is None
assert tuple(three.in_order()) == (2, 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_left(self):\n temp = self._leftchild\n self._leftchild.set_parent(None)\n self.set_leftchild(None)\n return temp",
"def leftdelalllistitems(self):\n self._leftlist.delete()",
"def delete_leaves(self):\n if not (self.left or self.right):\n return T... | [
"0.7693669",
"0.7157385",
"0.7143875",
"0.6997507",
"0.6988747",
"0.68209314",
"0.66341317",
"0.65905005",
"0.64867073",
"0.64798003",
"0.64762044",
"0.6475913",
"0.6441044",
"0.6397768",
"0.63756317",
"0.63524693",
"0.6341043",
"0.6332914",
"0.6327042",
"0.63221246",
"0.6322... | 0.61168426 | 35 |
Test three nodes rotate right. | def test_right_rotation_three_node_tree_including_root():
from bbst import Bst
tree = Bst([5, 4, 3])
assert tuple(tree.in_order()) == (3, 4, 5)
assert tuple(tree.breadth_first()) == (4, 3, 5)
assert tuple(tree.pre_order()) == (4, 3, 5)
assert tuple(tree.post_order()) == (3, 5, 4)
assert tree... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_four_nodes_needs_right_rotation(three_del):\n three_del.insert(5)\n three_del.delete(30)\n assert tuple(three_del.in_order()) == (5, 10, 20)\n assert tuple(three_del.breadth_first()) == (10, 5, 20)",
"def test_four_nodes_needs_right_left_rotation(three_del):\n three_del.insert(25)\n th... | [
"0.7244612",
"0.71747845",
"0.715655",
"0.70550424",
"0.7051016",
"0.6737464",
"0.67204314",
"0.6670491",
"0.66553575",
"0.6648834",
"0.6565768",
"0.65567756",
"0.65288675",
"0.65283906",
"0.65100634",
"0.64838284",
"0.6454327",
"0.6409956",
"0.63997763",
"0.6393975",
"0.6302... | 0.68062484 | 5 |
Test three nodes rotate right. | def test_left_rotation_three_node_tree_including_root():
from bbst import Bst
tree = Bst([3, 4, 5])
assert tuple(tree.in_order()) == (3, 4, 5)
assert tuple(tree.breadth_first()) == (4, 3, 5)
assert tuple(tree.pre_order()) == (4, 3, 5)
assert tuple(tree.post_order()) == (3, 5, 4)
assert tree.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_four_nodes_needs_right_rotation(three_del):\n three_del.insert(5)\n three_del.delete(30)\n assert tuple(three_del.in_order()) == (5, 10, 20)\n assert tuple(three_del.breadth_first()) == (10, 5, 20)",
"def test_four_nodes_needs_right_left_rotation(three_del):\n three_del.insert(25)\n th... | [
"0.7244612",
"0.71747845",
"0.715655",
"0.70550424",
"0.7051016",
"0.68062484",
"0.6737464",
"0.67204314",
"0.6670491",
"0.66553575",
"0.6648834",
"0.6565768",
"0.65567756",
"0.65288675",
"0.65283906",
"0.65100634",
"0.64838284",
"0.6454327",
"0.6409956",
"0.63997763",
"0.639... | 0.5971625 | 39 |
Test four nodes rotate left, no root change. | def test_left_rotation_four_node_tree():
from bbst import Bst
tree = Bst([1, 2, 3, 4, 5])
assert tuple(tree.in_order()) == (1, 2, 3, 4, 5)
assert tuple(tree.breadth_first()) == (2, 1, 4, 3, 5)
assert tuple(tree.pre_order()) == (2, 1, 4, 3, 5)
assert tuple(tree.post_order()) == (1, 3, 5, 4, 2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_left(self):\n if self.change_valid(dr=-1):\n self.rotate = (self.rotate-1)%4",
"def test_right_rotation_four_node_tree():\n from bbst import Bst\n tree = Bst([5, 4, 3, 2, 1])\n assert tuple(tree.in_order()) == (1, 2, 3, 4, 5)\n assert tuple(tree.breadth_first()) == (4, 2,... | [
"0.7145199",
"0.70359665",
"0.70339715",
"0.6938236",
"0.68493",
"0.6826053",
"0.6809888",
"0.680813",
"0.6793656",
"0.6779276",
"0.6777485",
"0.6682943",
"0.6650619",
"0.6646005",
"0.6593867",
"0.6590856",
"0.6572811",
"0.6501921",
"0.64969486",
"0.64854395",
"0.6469805",
... | 0.7629938 | 0 |
Test three nodes rotate right, no root change. | def test_right_left__rotation_five_node_tree():
from bbst import Bst
tree = Bst([1, 2, 5, 3, 4])
assert tuple(tree.in_order()) == (1, 2, 3, 4, 5)
assert tuple(tree.breadth_first()) == (2, 1, 4, 3, 5)
assert tuple(tree.pre_order()) == (2, 1, 4, 3, 5)
assert tuple(tree.post_order()) == (1, 3, 5, 4... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_right_rotation_three_node_tree_including_root():\n from bbst import Bst\n tree = Bst([5, 4, 3])\n assert tuple(tree.in_order()) == (3, 4, 5)\n assert tuple(tree.breadth_first()) == (4, 3, 5)\n assert tuple(tree.pre_order()) == (4, 3, 5)\n assert tuple(tree.post_order()) == (3, 5, 4)\n ... | [
"0.7481119",
"0.7387212",
"0.7352123",
"0.7339656",
"0.7086651",
"0.69661427",
"0.6846909",
"0.6752607",
"0.66977465",
"0.6643228",
"0.663239",
"0.66291463",
"0.66097504",
"0.6489198",
"0.64807373",
"0.6469176",
"0.64473814",
"0.64301956",
"0.6417827",
"0.641129",
"0.6377458"... | 0.6560525 | 13 |
Test three nodes rotate right, no root change. | def testt_left_right_rotation_five_node_tree():
from bbst import Bst
tree = Bst([4, 5, 1, 3, 2])
assert tuple(tree.in_order()) == (1, 2, 3, 4, 5)
assert tuple(tree.breadth_first()) == (4, 2, 5, 1, 3)
assert tuple(tree.pre_order()) == (4, 2, 1, 3, 5)
assert tuple(tree.post_order()) == (1, 3, 2, 5... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_right_rotation_three_node_tree_including_root():\n from bbst import Bst\n tree = Bst([5, 4, 3])\n assert tuple(tree.in_order()) == (3, 4, 5)\n assert tuple(tree.breadth_first()) == (4, 3, 5)\n assert tuple(tree.pre_order()) == (4, 3, 5)\n assert tuple(tree.post_order()) == (3, 5, 4)\n ... | [
"0.7481119",
"0.7387212",
"0.7352123",
"0.7339656",
"0.7086651",
"0.69661427",
"0.6846909",
"0.6752607",
"0.66977465",
"0.6643228",
"0.663239",
"0.66291463",
"0.66097504",
"0.6560525",
"0.6489198",
"0.64807373",
"0.64473814",
"0.64301956",
"0.6417827",
"0.641129",
"0.6377458"... | 0.6469176 | 16 |
Split the last dimension into (num_heads, depth). Transpose the result such that the shape is (batch_size, num_heads, seq_len, depth). | def split_heads(self, x, batch_size): # noqa
x = tf.reshape(x, (batch_size, -1, self.num_heads, self.depth))
return tf.transpose(x, perm=[0, 2, 1, 3]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_heads(x, batch_size, num_heads, depth):\n x = tf.reshape(x, (batch_size, -1, num_heads, depth))\n return tf.transpose(x, perm=[0, 2, 1, 3])",
"def _split_heads(x, num_heads):\n\tshape_lst = bert_utils.get_shape_list(x)\n\tdepth = shape_lst[-1]\n\tbatch = shape_lst[0]\n\tseq = shap... | [
"0.7869922",
"0.75504696",
"0.7479287",
"0.7333889",
"0.72919595",
"0.72733986",
"0.72733986",
"0.72733986",
"0.72733986",
"0.72733986",
"0.72733986",
"0.72733986",
"0.6984665",
"0.6591452",
"0.6591452",
"0.65532863",
"0.6539169",
"0.6334736",
"0.62884897",
"0.605777",
"0.597... | 0.7195931 | 12 |
Apply the layer to the input tensors. | def call(self, inputs):
# Collect input tensors
seq_len = tf.shape(inputs["time"])[1]
tensors = []
if self.use_pitch_embedding:
tensors.append(self.pitch_embedding(inputs["pitch"]))
else:
tensors.append(
tf.expand_dims(tf.cast(inputs["pitch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, input: torch.Tensor) ->torch.Tensor:\n layer_outputs: List[torch.Tensor]\n if self._layers is None:\n layer_outputs = input\n if not isinstance(layer_outputs, (list, tuple)):\n layer_outputs = [layer_outputs]\n else:\n layer_out... | [
"0.6753409",
"0.671783",
"0.6637566",
"0.65469384",
"0.6509586",
"0.6460174",
"0.6414193",
"0.6413204",
"0.6387469",
"0.63157153",
"0.62916076",
"0.62581027",
"0.62526387",
"0.6244991",
"0.62192446",
"0.6164613",
"0.61617565",
"0.61295956",
"0.61281586",
"0.61254865",
"0.6118... | 0.0 | -1 |
Happy path for make_dataset.py | def test_make_dataset_happy_path(self):
# User story: user runs src.make_dataset() on the current directory
# and gets a fully functional dataset
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autogen_dataset_dir():\n return TabularDataset.autogen('tests/data/dummy_tabular',\n seed=42,\n sep=',')",
"def dir_dataset():\n return TabularDataset.from_path('tests/data/dummy_tabular', sep=',')",
"def dataset_path(dataset, work_dir... | [
"0.7420449",
"0.6976186",
"0.6889295",
"0.68462455",
"0.67821646",
"0.67315966",
"0.6537164",
"0.65354943",
"0.6491808",
"0.64149296",
"0.6412347",
"0.6406602",
"0.6401823",
"0.63989455",
"0.6319784",
"0.6312762",
"0.629519",
"0.6288799",
"0.6285458",
"0.6280564",
"0.6256131"... | 0.7803285 | 0 |
cuts `l` into slices of len `size` stepping `step` | def get_cuts(l, step, size):
ncuts= (len(l)-size)/step + 1
cuts= [None]*ncuts
for i in xrange(ncuts):
cuts[i]= l[i*step:i*step+size]
if ncuts*step < len(l):
cuts.append(l[ncuts*step:])
return cuts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice_list(input, size):\n input_size = len(input)\n slice_size = input_size // size\n remain = input_size % size\n result = []\n iterator = iter(input)\n for i in range(size):\n result.append([])\n for j in range(slice_size):\n result[i].append(next(iterator))\n ... | [
"0.7050704",
"0.6925007",
"0.68266094",
"0.67659515",
"0.661363",
"0.6553607",
"0.6539174",
"0.6448047",
"0.6438924",
"0.6436389",
"0.6367698",
"0.6352644",
"0.6310227",
"0.6268214",
"0.62623787",
"0.6255275",
"0.624303",
"0.6236319",
"0.6230932",
"0.62224394",
"0.62143505",
... | 0.7883205 | 0 |
add an edge between two nodes. | def add_edge(self, from_node: int, to_node: int, distance=INT_MAX) -> None:
self._add_node(from_node)
self._add_node(to_node)
self.edges.setdefault(from_node, set()).add(to_node)
self.distances[from_node, to_node] = distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, node1: Node, node2: Node):\n self.__add_edge(node1, node2)\n self.__add_edge(node2, node1)",
"def add_edge(self, v1, v2):\n pass # TODO",
"def add_edge(self, vertex1, vertex2):\n\n vertex1.add_outgoing_node(vertex2)\n vertex2.add_incoming_node(vertex1)",
... | [
"0.850532",
"0.84804124",
"0.8397903",
"0.83130187",
"0.8079192",
"0.80647314",
"0.8008219",
"0.79976374",
"0.7907179",
"0.7829602",
"0.78275335",
"0.7804633",
"0.7785613",
"0.7708164",
"0.77036977",
"0.7690177",
"0.76886755",
"0.7687877",
"0.7647581",
"0.76408356",
"0.762789... | 0.0 | -1 |
add a twosided edge between two nodes. | def add_two_sided_edge(self, from_node: int, to_node: int, distance=INT_MAX) -> None:
self.add_edge(from_node, to_node, distance)
self.add_edge(to_node, from_node, distance) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, v1, v2):\n pass # TODO",
"def add_edge(self, node1: Node, node2: Node):\n self.__add_edge(node1, node2)\n self.__add_edge(node2, node1)",
"def add_bidirectional_edges( self, node1, node2, distance):\n n1, n2 = self.__create_node(node1.lower(), node2.lower())\n\n ... | [
"0.7712034",
"0.7644719",
"0.7324977",
"0.7303081",
"0.72882795",
"0.7206781",
"0.7194396",
"0.71911335",
"0.7170179",
"0.7133722",
"0.7121482",
"0.70431334",
"0.7038399",
"0.7031622",
"0.7028593",
"0.7007308",
"0.6995227",
"0.6988022",
"0.6861676",
"0.686097",
"0.6848671",
... | 0.7281836 | 5 |
Creates and saves a User with the given email, username and password. | def _create_user(self, email, password, **extra_fields):
if not email:
raise ValueError("The given email must be set")
try:
with transaction.atomic():
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password,username, **extra_fields):\r\n if not email:\r\n raise ValueError('The given email must be set')\r\n if not username:\r\n raise ValueError('The given username must be set')\r\n email = self.normalize_email(email)\r\n user = se... | [
"0.8635751",
"0.8481309",
"0.8441386",
"0.84209526",
"0.8409523",
"0.84030384",
"0.8398564",
"0.8384188",
"0.83548737",
"0.8316477",
"0.83082694",
"0.8279697",
"0.8262201",
"0.8221194",
"0.8216966",
"0.8194955",
"0.819365",
"0.8185923",
"0.8171971",
"0.8171934",
"0.8151684",
... | 0.0 | -1 |
Linear learning rate schedule. | def linear_schedule(initial_value: float) -> Callable[[float], float]:
def func(progress_remaining: float) -> float:
"""
Progress will decrease from 1 (beginning) to 0.
:param progress_remaining:
:return: current learning rate
"""
return progress_remaining * initial_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lr_schedule(epoch, current_lr):\n lr = current_lr\n if epoch == 23: lr *= 0.5\n elif epoch == 21: lr *= 1e-1\n elif epoch == 16: lr *= 1e-1\n elif epoch == 11: lr *= 1e-1\n return lr",
"def lr_schedule(epoch,lr):\r\n learning_rate = lr\r\n if epoch > 10:\r\n learning_rate *= 0.1\r\n ... | [
"0.7515678",
"0.74983704",
"0.7439236",
"0.73950636",
"0.738104",
"0.738104",
"0.738104",
"0.738104",
"0.7322055",
"0.7321421",
"0.73177594",
"0.73156947",
"0.7314144",
"0.7278899",
"0.7255392",
"0.7233378",
"0.7226824",
"0.7200598",
"0.71579033",
"0.7129427",
"0.7113383",
... | 0.7180287 | 19 |
Fetches and renders current user's settings. | def Render(self, unused_args, token=None):
user_settings = self.GetUserSettings(token)
return api_value_renderers.RenderValue(user_settings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settings(self):\r\n url = '{0}/userSettings'.format(self.get_url())\r\n return http.Request('GET', url), parsers.parse_json",
"def settings_page():\n log.info(\":WEB:/settings\")\n if \"username\" in session.keys():\n if \"logged-in\" in session.keys():\n if session[\"lo... | [
"0.74022007",
"0.7045857",
"0.68842953",
"0.6755608",
"0.6609588",
"0.6597063",
"0.6593824",
"0.6521557",
"0.6464156",
"0.64420015",
"0.64092535",
"0.6402261",
"0.6367778",
"0.6353381",
"0.6338036",
"0.6266399",
"0.6199469",
"0.6041284",
"0.6000738",
"0.59952396",
"0.59899896... | 0.63118166 | 15 |
test that a lecture cannot be created in the past. | def test_create_invalid_datetime_lecture(lecture_class, course, invalid_datetime):
with pytest.raises(ValueError, match="Lecture cannot be in the past"):
lecture_class.create_lecture(course, invalid_datetime) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_now_datetime_lecture(lecture_class, course, now_datetime):\n with pytest.raises(ValueError, match=\"Lecture cannot be in the past\"):\n lecture_class.create_lecture(course, now_datetime)",
"def test_past_question(self):\n past_question = create_question(question_text='Past questi... | [
"0.7544665",
"0.6509047",
"0.64896345",
"0.64292526",
"0.6408504",
"0.6404732",
"0.6401584",
"0.64001626",
"0.6392187",
"0.63879454",
"0.63704324",
"0.6361234",
"0.63390964",
"0.63249385",
"0.6240659",
"0.6228316",
"0.62196296",
"0.62100077",
"0.6157148",
"0.61525375",
"0.614... | 0.7573576 | 0 |
Test that a lecture cannot be created at the current moment in time. | def test_create_now_datetime_lecture(lecture_class, course, now_datetime):
with pytest.raises(ValueError, match="Lecture cannot be in the past"):
lecture_class.create_lecture(course, now_datetime) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_invalid_datetime_lecture(lecture_class, course, invalid_datetime):\n with pytest.raises(ValueError, match=\"Lecture cannot be in the past\"):\n lecture_class.create_lecture(course, invalid_datetime)",
"def test_create_lecture(lecture_class, course, valid_datetime):\n id = lecture_cla... | [
"0.79380757",
"0.6977447",
"0.6825488",
"0.6693055",
"0.6653233",
"0.66129386",
"0.6552553",
"0.64851046",
"0.646237",
"0.6459529",
"0.6412418",
"0.63940257",
"0.63937587",
"0.6390616",
"0.6385989",
"0.6379848",
"0.63737106",
"0.63716674",
"0.63582814",
"0.6334948",
"0.633044... | 0.7904244 | 1 |
Test that a lecture can be deleted. | def test_delete_lecture(lecture_class, course, valid_datetime):
id = lecture_class.create_lecture(course, valid_datetime)
assert id != None
assert lecture_class.delete_lecture() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete(self):\r\n course = CourseFactory.create(org='edX', course='999')\r\n with self.assertRaises(ValueError):\r\n tabs.primitive_delete(course, 0)\r\n with self.assertRaises(ValueError):\r\n tabs.primitive_delete(course, 1)\r\n with self.assertRaises(In... | [
"0.7639081",
"0.7383968",
"0.7313929",
"0.73011756",
"0.7272008",
"0.71114296",
"0.7109574",
"0.71086",
"0.7088084",
"0.70518875",
"0.7011428",
"0.6959127",
"0.6919809",
"0.69194907",
"0.69169915",
"0.69087046",
"0.6906628",
"0.68767464",
"0.6864632",
"0.6841791",
"0.6838008"... | 0.8308579 | 0 |
Return file as DF | def get_file_df(filepath):
dd = [json.loads(f) for f in open(filepath).readlines()]
return pd.DataFrame(dd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(fname: str) -> pd.DataFrame:\n raw_data = (\n pd.read_hdf(fname).to_frame().reset_index(level=[0, 1]).loc[ANALYSIS_DATE]\n )\n raw_data[\"date\"] = raw_data.index\n return raw_data",
"def load_file_to_dataframe(self, file_path: str) -> pd.DataFrame:\n r... | [
"0.70271915",
"0.6970548",
"0.6853013",
"0.68487674",
"0.68137926",
"0.6758491",
"0.67458373",
"0.67317843",
"0.6666918",
"0.65768003",
"0.6562063",
"0.6557112",
"0.6557112",
"0.6557112",
"0.6555574",
"0.65099967",
"0.65044075",
"0.6485939",
"0.6472121",
"0.64531744",
"0.6433... | 0.7255091 | 0 |
This method loads a GPX file into a Pandas DataFrame. Columns names are translated to sweat terminology (e.g. "heart_rate" > "heartrate"). | def read_gpx(fpath, resample: bool = False, interpolate: bool = False) -> pd.DataFrame:
tree = ET.parse(Path(fpath))
root = tree.getroot()
trk = root.find("default:trk", NAMESPACES)
trkseg = trk.find("default:trkseg", NAMESPACES)
records = []
for trackpoint in trkseg.findall("default:trkpt", NA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_gpx(self):\n\n # Parsing XML file\n elements = parse(self.source)\n points = []\n for element in elements.iter():\n if element.tag.find(\"trkpt\") == -1:\n continue\n\n latitude = element.attrib.get(\"lat\", None)\n longitude = e... | [
"0.6410894",
"0.6370713",
"0.6301176",
"0.6237741",
"0.61660844",
"0.60442615",
"0.60002863",
"0.5969312",
"0.59268826",
"0.5852782",
"0.581373",
"0.57794213",
"0.5762868",
"0.5688254",
"0.5687821",
"0.56598574",
"0.5650581",
"0.56299937",
"0.5618135",
"0.56141293",
"0.561219... | 0.66943026 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.