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 |
|---|---|---|---|---|---|---|
substract two time units from eachother using only the seconds seconds will be converted to standard time units again since that is defined in __init__ | def __sub__(self, other):
return MyTime(0,0,self.to_seconds() - other.to_seconds()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _subtract_times(self, a, b):\n td = a - b\n return td.days * 24 * 60 + td.seconds // 60",
"def __sub__(self, *args, **kwargs):\n return _uhd_swig.time_spec_t___sub__(self, *args, **kwargs)",
"def subtractTimes(time1, time2):\n t1 = timedelta(hours=time1.hour, minutes=time1.minute, s... | [
"0.7609227",
"0.6840941",
"0.66100484",
"0.6502824",
"0.6401398",
"0.6379976",
"0.63569397",
"0.6316195",
"0.62796474",
"0.6259163",
"0.6191553",
"0.6178268",
"0.6173185",
"0.6152514",
"0.6108575",
"0.6065522",
"0.60627323",
"0.60016334",
"0.5995307",
"0.5982728",
"0.5968915"... | 0.7343501 | 1 |
Load configuration from yaml file. | def load_devices_names_file(self):
try:
with open(self._path, "r") as infile:
logger.debug("Loading devices names from <%s>", self._path)
self._devices_names = yaml.safe_load(infile) or {}
except yaml.YAMLError as error:
logger.error("In devices fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_yaml(cls, file=None):\n if file is None: file = f'{rcp.base_path}cfg.yml'\n try:\n with open(file, 'r') as f:\n config = yaml.load(f, Loader=yaml.FullLoader)\n cfg.__dict__ = config\n return cfg\n except FileNotFoundError:\n p... | [
"0.8179827",
"0.8017778",
"0.80106324",
"0.79977477",
"0.79616463",
"0.7912023",
"0.78959846",
"0.78686064",
"0.78511626",
"0.7841511",
"0.7832712",
"0.78167754",
"0.78072906",
"0.7794084",
"0.779144",
"0.77470595",
"0.7747034",
"0.7735434",
"0.76964366",
"0.767669",
"0.76688... | 0.0 | -1 |
Computes the retainment rate of a given function that takes a list and a n. Invokes compute_retained_ratio once for each value between `min_range` and `max_range`, storing the results in a 2D array. The first key is a given `n`, the inner dictionary is the result of invoking compute_retained_ratio on a curried version ... | def compute_parameterized_retained_ratio(f, min_n=1, max_n=100, **kwargs):
ratios = OrderedDict()
for n in range(min_n, max_n + 1):
ratios[n] = compute_retained_ratio(dropsort._curry(f, n), **kwargs)
return ratios | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_retained_ratio(f, *,\n min_size=10,\n max_size=100,\n iters=10000,\n shuffle=util.full_shuffle,\n ls_gen=lambda n: list(range(n))):\n retained = Counter()\n for size in range(min_size, max_size + 1):\n for _ in range(iters):\n ls = shuffle(ls_gen(size), .5) # TODO make this tun... | [
"0.6400169",
"0.5316378",
"0.50176907",
"0.4920259",
"0.49161065",
"0.47659487",
"0.47552636",
"0.47213432",
"0.4705907",
"0.47023025",
"0.46832505",
"0.46040916",
"0.45828983",
"0.45739385",
"0.45611027",
"0.45477706",
"0.45155326",
"0.4492996",
"0.4479096",
"0.44443065",
"0... | 0.77451766 | 0 |
Combine time and date and timezone | def _make_iso_time(time: datetime,
date: datetime,
time_zone: pytz.timezone) -> str:
time_combined = time.replace(year=date.year,
month=date.month,
day=date.day)
return time_zone.localize(time_combined).isofo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine(date, time, tzinfo):\n return tzinfo.localize(datetime.datetime.combine(date, time))",
"def apply_timezone_datetime(_local_tz: str, _time: datetime.time):\n return pytz.timezone(_local_tz).localize(\n datetime.datetime.combine(datetime.datetime.now().date(), _time)\n )",
"def timezo... | [
"0.80390775",
"0.67696124",
"0.6644239",
"0.65426004",
"0.6324212",
"0.6186051",
"0.6117546",
"0.59755343",
"0.5944956",
"0.5935439",
"0.59291196",
"0.58561325",
"0.58016276",
"0.56792164",
"0.56687415",
"0.56287205",
"0.5626102",
"0.56241924",
"0.56196356",
"0.56123173",
"0.... | 0.64488554 | 4 |
Parition the iterable from first to last such that all elements that satisfy pred are before all elements where pred is false. Returns one past the index of the last element where pred is true. Relative order of the elements is not preserved. | def partition(iterable, pred, first=0, last=None):
assert hasattr(iterable, '__getitem__')
last = last or len(iterable)
assert first <= last
while first != last:
# advance first
while pred(iterable[first]):
first += 1
if first == last:
return first... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partition(pred, iterable):\n stream = list(iterable)\n matched = list(itertools.takewhile(pred, stream))\n unmatched = list(itertools.dropwhile(pred, stream))\n return matched, unmatched",
"def partition(lst, pred):\n start = []\n append = start.append\n\n while lst:\n ... | [
"0.6653333",
"0.62750965",
"0.60788745",
"0.6073547",
"0.6068218",
"0.60504055",
"0.593691",
"0.58197707",
"0.5810037",
"0.57639676",
"0.5727689",
"0.5684145",
"0.56559706",
"0.5599281",
"0.5599281",
"0.5599281",
"0.5429319",
"0.5390464",
"0.5365841",
"0.536417",
"0.53410697"... | 0.707069 | 0 |
Find and return the minimum and maximum element in an iterable range. | def minmax_element(iterable, first=0, last=None, key=None):
assert hasattr(iterable, '__getitem__')
iterable = iterable if first == 0 and last is None else iterable[first:last]
if key is None:
return min(iterable), max(iterable)
else:
return min(iterable, key=key), max(iterable, key=key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range(x):\n try:\n return (min(min(y) for y in x), max(max(y) for y in x))\n except ValueError:\n return (None, None)",
"def minmax(xs):\n min_val = None\n max_val = None\n for x in xs:\n if min_val is None or x < min_val:\n min_val = x\n if max_val is No... | [
"0.7852435",
"0.74743265",
"0.74586254",
"0.74137986",
"0.7318053",
"0.7231252",
"0.72259164",
"0.72171664",
"0.71919966",
"0.7162416",
"0.71586597",
"0.7143243",
"0.71270925",
"0.7066641",
"0.7040819",
"0.7025757",
"0.7002557",
"0.6973054",
"0.69020236",
"0.688721",
"0.68668... | 0.7682018 | 1 |
Get the day and time | def create(service, user, email):
day,year,month,hour,minutes = 0,0,0,0,0
while day < 1 or day > 31 or month < 1 or month > 12 or year < 1:
dateinput = input("Enter date (day/month/year): ") .strip()
if "/" in dateinput:
date = dateinput.split('/')
if len(date) != 3 or ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time(self):\r\n\t\tactual_time = '{}, {} de {} del {} ({}:{} {} (UTC))'\r\n\t\tda_taim = actual_time.format(self.wday, self.day, self.mon,\r\n\t\t\t\t\t\t\t\t\t self.year, self.hour, self.min,\r\n\t\t\t\t\t\t\t\t\t self.day_or_night)\r\n\t\treturn da_taim",
"def time_of_day(self):\n return self.ti... | [
"0.73437434",
"0.70954156",
"0.7011319",
"0.6930026",
"0.6862294",
"0.6833743",
"0.6817395",
"0.68117034",
"0.67775583",
"0.6750826",
"0.6652038",
"0.6625347",
"0.6625347",
"0.6625347",
"0.66150385",
"0.6612631",
"0.6564505",
"0.65492547",
"0.6528791",
"0.6497159",
"0.6471448... | 0.0 | -1 |
Patch load_yaml with a dictionary of yaml files. | def patch_yaml_files(files_dict, endswith=True):
# match using endswith, start search with longest string
matchlist = sorted(list(files_dict.keys()), key=len) if endswith else []
def mock_open_f(fname, **_):
"""Mock open() in the yaml module, used by load_yaml."""
# Return the mocked file o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(yml_files, debug = False):\n\n dc = {}\n\n if type(yml_files) == dict:\n dc = yml_files\n elif type(yml_files) == str:\n with open(yml_files, \"r\") as f:\n dc = yaml.load(f)\n elif type(yml_files) == list or type(yml_files) == tuple:\n for yml_file in yml_files:\n ... | [
"0.72198427",
"0.64734876",
"0.64331627",
"0.64302367",
"0.6345241",
"0.6304661",
"0.63003",
"0.6234311",
"0.6189285",
"0.61823887",
"0.6181173",
"0.61780536",
"0.6168159",
"0.6167318",
"0.616016",
"0.6156985",
"0.6143557",
"0.60890365",
"0.6083203",
"0.60821736",
"0.6080804"... | 0.64439297 | 2 |
Initializes a new instance of the Hand class. All the parameters are optional. | def __init__(self, cards_on_table=None, cards=[], hands_list=[]):
self.cards = cards
self.cards_on_table = cards_on_table
self.hands_list = hands_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, hand, player):\n\n self.hand = hand\n self.player = player",
"def __init__(self):\n \n self.hand = []",
"def test_constructor(self):\n hand = Hand([Card(\"A\", \"D\")])\n assert isinstance(hand, Hand)",
"def __init__(self, hand, pot, pub, phase, s... | [
"0.82283485",
"0.7391746",
"0.7353016",
"0.73237914",
"0.7285615",
"0.72179824",
"0.7100277",
"0.696159",
"0.6951289",
"0.68544513",
"0.684719",
"0.67674893",
"0.67667985",
"0.675944",
"0.6739158",
"0.6701531",
"0.6700213",
"0.649125",
"0.6462933",
"0.6459502",
"0.6440037",
... | 0.66969347 | 17 |
Force the image to RGB mode. For RGBA images, convert all transparent pixels to bg color. | def rgb(img, bg, alpha):
if img.mode == 'RGBA':
pixels = img.load()
for y in range(img.size[1]):
for x in range (img.size[0]):
if pixels[x, y][3] <= alpha:
pixels[x, y] = bg
img = img.convert('RGB')
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grey_to_rgb(im):\n assert im.n_channels in [1, 3]\n\n if im.n_channels == 3:\n return im\n\n im.pixels = np.vstack([im.pixels] * 3)\n return im",
"def to_color(self):\n if self.channels == 4:\n color = opencv.cvtColor(self.img, opencv.COLOR_BGRA2BGR)\n return I... | [
"0.6840048",
"0.66243327",
"0.6607907",
"0.6532662",
"0.65304726",
"0.65245855",
"0.64903986",
"0.6476557",
"0.64389956",
"0.6404468",
"0.63255507",
"0.63248605",
"0.6295875",
"0.6244759",
"0.62244314",
"0.61437327",
"0.61011976",
"0.60889465",
"0.60659057",
"0.605277",
"0.60... | 0.71749574 | 0 |
Return set of all colors used in the image. | def unique_colors(img):
colors = {i[1] for i in img.getcolors(maxcolors=img.size[0]*img.size[1])}
return colors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colors(self):\r\n\t\treturn self._colors",
"def colors(self):\n return self._colors",
"def colors(self):\n return self[\"colors\"]",
"def colors(self):\n return self[\"colors\"]",
"def findAllColors(img):\n hist = cv2.calcHist([img], [0, 1, 2], None, [256] * 3, [0, 256] * 3)\n ... | [
"0.752",
"0.74290454",
"0.74279696",
"0.74279696",
"0.71429735",
"0.70386124",
"0.70238334",
"0.69688696",
"0.69288254",
"0.6822153",
"0.68082386",
"0.67926997",
"0.67322683",
"0.6703783",
"0.67006487",
"0.6649736",
"0.6569776",
"0.65616477",
"0.6556607",
"0.65423656",
"0.652... | 0.7413865 | 4 |
returns True if n is a quadratic residue mod p | def quadRes(p, n):
lamb = 1
alpha = (n - 1) // 2
p = p % n
while alpha != 0:
if alpha % 2:
alpha -= 1
lamb = (lamb * p) % n
else:
p = (p ** 2) % n
alpha = alpha // 2
return lamb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isQuadRes(n, p):\n if ModExpo(n, (p-1)//2, p) == 1:\n return True\n else:\n return False",
"def is_pentagonal_number(n):\n _, x = quadratic.solve(3, -1, -2 * n)\n return is_number(x) and x.is_integer()",
"def is_pentagonal(n):\r\n if ((1+(24*n+1)**0.5) / 6)%1 == 0:\r\n r... | [
"0.74193156",
"0.7122089",
"0.6668049",
"0.6622058",
"0.65868264",
"0.6571832",
"0.6556677",
"0.6509746",
"0.65030277",
"0.65008634",
"0.6434033",
"0.64006865",
"0.6364961",
"0.6332595",
"0.63078344",
"0.6280898",
"0.6270277",
"0.6258982",
"0.6247547",
"0.622158",
"0.6205278"... | 0.0 | -1 |
Retrieves an example from the dataset. | def __getitem__(self, idx):
# example = (self.ids[idx], self.questions[idx], self.qdmrs[idx].to_string())
if self.gold_type == 'qdmr':
golds = self.qdmrs[idx].to_string()
elif self.gold_type == 'program':
golds = self.programs[idx]
elif self.gold_type == 'minimize... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example(self):\n result = getattr(self, '_example', None)\n if result is None:\n # No example batch was found, so get one from the `.train` dataset\n result = next(iter(self.train))\n # And cache it for next time\n self._example = result\n return result",
"def as_example(self, dataset_item):\n... | [
"0.69881654",
"0.6527809",
"0.6453582",
"0.63048136",
"0.6032353",
"0.60322315",
"0.6019003",
"0.59715223",
"0.59709597",
"0.588927",
"0.58869344",
"0.5872147",
"0.5854683",
"0.575512",
"0.5744238",
"0.5725143",
"0.57142377",
"0.567846",
"0.5668369",
"0.56521827",
"0.56501746... | 0.51550627 | 81 |
Retrieves an example from the dataset. | def get_example(self, idx=-1):
if idx < 0:
idx = np.random.randint(len(self))
return self[idx] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example(self):\n result = getattr(self, '_example', None)\n if result is None:\n # No example batch was found, so get one from the `.train` dataset\n result = next(iter(self.train))\n # And cache it for next time\n self._example = result\n return result",
"def as_example(self, dataset_item):\n... | [
"0.6987724",
"0.65258443",
"0.6453469",
"0.63052505",
"0.603284",
"0.6031377",
"0.6017327",
"0.59717405",
"0.5971152",
"0.58908564",
"0.5887353",
"0.58718497",
"0.575435",
"0.57442844",
"0.57260615",
"0.5713277",
"0.56788653",
"0.56674653",
"0.5651973",
"0.56498337",
"0.56478... | 0.5854964 | 12 |
String for representing the Model object. | def __str__(self):
return self.title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return '%s (%s)' % (self.id,self.book.title) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Obtain SMPL with shape (beta) & pose (theta) inputs. Theta includes the global rotation. | def __call__(self, beta, theta, get_skin=False, name=None):
with tf.name_scope(name, "smpl_main", [beta, theta]):
num_batch = beta.shape[0].value
# 1. Add shape blend shapes
# (N x 10) x (10 x 6890*3) = N x 6890 x 3
v_shaped = tf.reshape(
tf.matm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slm_ml_beta_pval(x, y, w):\n\n assert x.size == y.size\n assert x.ndim == y.ndim == 1\n\n # Transform 1d numpy arrays to column vectors\n x = np.expand_dims(x, 1)\n y = np.expand_dims(y, 1)\n\n # Compute maximum likelihood estimation of spatial lag model\n res = ps.spreg.ml_lag.ML_Lag(y, x... | [
"0.54064417",
"0.53013915",
"0.5295999",
"0.5273878",
"0.526475",
"0.5259525",
"0.52557474",
"0.5218868",
"0.5194891",
"0.5111479",
"0.5110036",
"0.51008683",
"0.50779986",
"0.5064957",
"0.50410724",
"0.5023061",
"0.5020837",
"0.5002668",
"0.49993843",
"0.49970317",
"0.499042... | 0.6125285 | 0 |
It will return a tensor of shape 'shape' with 'cluster_count' neighborhood with center locations chosen randomly. A random value will be chosen for each cluster and all values in the neighborhood of radius 'cluster_radius' will have values in (point_valueeps, point_value+eps) | def generate_tensor(shape, cluster_count=3, cluster_radius=3, low=0, high=255, eps=10, dtype=np.int32):
tensor = np.zeros(shape, dtype)
clusters = []
for i in range(cluster_count + 1):
cluster = {}
coordinates = []
for dim in shape:
coordinate = np.random.randint(0, hi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_cluster_matrix(shape):\n N, k = shape\n A = np.zeros((N, k))\n for row in A: \n row[randint(0, k - 1)] = 1\n\n return A",
"def random_centers(k,):\n #centr = np.random.random((k, pos.shape[1]))\n return",
"def get_random_points(self, shape, device=\"gpu0\"):\n assert ... | [
"0.67926466",
"0.67853385",
"0.6705146",
"0.6689287",
"0.6687268",
"0.6647776",
"0.6587873",
"0.6395964",
"0.6355463",
"0.631329",
"0.62731665",
"0.61443233",
"0.6141526",
"0.6115306",
"0.6061933",
"0.60528433",
"0.60479367",
"0.59665155",
"0.595994",
"0.59328353",
"0.5929574... | 0.8064628 | 0 |
Makes the image transparent by subtracting some percentage of the black color channel. The ``transparency`` parameter specifies the percentage. | def transparentize(self, transparency):
if transparency:
t = ctypes.c_double(float(self.quantum_range * float(transparency)))
if t.value > self.quantum_range or t.value < 0:
raise ValueError('transparency must be a numbers.Real value ' +
'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetImageTransparency(image, transparencyPercentage):\n alpha = QImage(image)\n painter = QPainter(alpha)\n alphaValue = int(transparencyPercentage*255/100)\n painter.fillRect(alpha.rect(), QColor(alphaValue, alphaValue, alphaValue))\n painter.end()\n image.setAlphaChannel(alpha)",
"def set_... | [
"0.6353526",
"0.6277526",
"0.6112358",
"0.60481185",
"0.603573",
"0.60245913",
"0.60026073",
"0.5920518",
"0.58986104",
"0.5773416",
"0.5758188",
"0.5719884",
"0.56446",
"0.5623789",
"0.5602913",
"0.5582464",
"0.55060786",
"0.5415141",
"0.5273896",
"0.5272075",
"0.52265954",
... | 0.7222268 | 0 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# ADD : available analysis parameters
cities_list=['chicago','new york city','washington']
months_list=['all','january','february','march','april','may','june']
days_list=['all','monday','tuesday','wednesday','thursday','fri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.5761652 | 76 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
months_dict = {'january' : 1 , 'february' : 2 , 'march' : 3 , 'april' : 4 , 'may' : 5 , 'june' : 6, 'july' : 7, 'august' : 8, 'september' : 9}
days_dict = {'monday' : 0 , 'tuesday' : 1 , 'wednesday' : 2 , 'thursday' : 3, 'friday' : 4 , 'saturday' : 5 , 'sunday' : 6}
df = p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8108889",
"0.8045821",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7947432",
"0.79463065",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.7889219",
"0.788254... | 0.7956163 | 12 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# TO DO: display the most common month
df['Month'] = df['Start Time'].dt.month
most_common_month = df['Month'].mode()[0]
print('Most Common Start Month:', most_common_month)
# TO DO:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80234534",
"0.80220866",
"0.7914726",
"0.7826028",
"0.7821531",
"0.7813864",
"0.7765123",
"0.7739495",
"0.7735815",
"0.773377",
"0.76860726",
"0.7667975",
"0.7651258",
"0.7644125",
"0.76395637",
"0.763636",
"0.7624526",
"0.76224995",
"0.7612101",
"0.7599869",
"0.7583085",
... | 0.7307854 | 57 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# TO DO: display most commonly used start station
start_stations = df['Start Station'].value_counts()
print('Most Common Used Start Station:', start_stations.index[0])
# TO DO: displ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815675",
"0.7662213",
"0.7553417",
"0.74914914",
"0.74748665",
"0.7446617",
"0.7428588",
"0.74237514",
"0.74177027",
"0.7400495",
"0.7387161",
"0.7385634",
"0.73647535",
"0.735934",
"0.73566747",
"0.73548365",
"0.7351854",
"0.7351274",
"0.735057",
"0.73421645",
"0.7340198... | 0.7218835 | 40 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# TO DO: display total travel time
total_travel_time = df['Trip Duration'].sum()
print('Total Travel Time:', total_travel_time)
# TO DO: display mean travel time
mean_travel_time = df['Trip Dur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.7828922 | 38 |
Verify the label names provided do not include forbidden characters. | def _verify_labels_available(self):
if self._forbidden_label_characters is None:
return True
for label in self.training_labels.dtype.names:
for character in self._forbidden_label_characters:
if character in label:
raise ValueError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_forbidden_label_characters(self, characters):\n\n for column in self._labels.dtype.names:\n for character in characters:\n if character in column:\n raise ValueError(\"forbidden character '{0}' is in potential\"\n \" label '{1}' ... | [
"0.82888466",
"0.74261147",
"0.7059759",
"0.6945895",
"0.6925541",
"0.662191",
"0.6553247",
"0.6552863",
"0.6534766",
"0.6530666",
"0.6477988",
"0.6477897",
"0.64580745",
"0.6415884",
"0.6414851",
"0.6360268",
"0.63491863",
"0.63418967",
"0.6315544",
"0.62917554",
"0.6265083"... | 0.74511373 | 1 |
The label vector for all pixels. | def label_vector(self):
return self._label_vector | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pixel_label_vector(self, pixel_index):\n return self.label_vector",
"def labels(self):\n return self._get_labels(self.label_vector)",
"def list_of_labels(self):\n L = np.unique(self.box_label)\n return np.union1d(L, self.geom.list_of_elements_labels())",
"def labels(self) -> n... | [
"0.8160189",
"0.7647556",
"0.7464245",
"0.7444909",
"0.7360782",
"0.7352179",
"0.73173887",
"0.72418034",
"0.72388405",
"0.72256863",
"0.7218872",
"0.72132206",
"0.71830934",
"0.7161147",
"0.71277994",
"0.7114359",
"0.7066277",
"0.7034406",
"0.70281315",
"0.70278114",
"0.7026... | 0.8330376 | 0 |
Get the indices for the lowest power label terms in the label vector. | def _get_lowest_order_label_indices(self):
indices = OrderedDict()
for i, term in enumerate(self.label_vector):
if len(term) > 1: continue
label, order = term[0]
if order < indices.get(label, [None, np.inf])[-1]:
indices[label] = (i, order)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indices_of_label(self, label_name):\n return self.indices_of('label', label_name)",
"def _get_labels(self, label_vector):\n return () if label_vector is None else \\\n list(OrderedDict.fromkeys([label for term in label_vector \\\n for label, power in term if power != 0]))"... | [
"0.64978486",
"0.6378474",
"0.63684183",
"0.61969405",
"0.5969316",
"0.5947176",
"0.58710515",
"0.5867402",
"0.5863086",
"0.5766511",
"0.5762993",
"0.5742981",
"0.5684194",
"0.5631458",
"0.5599296",
"0.55970466",
"0.55939454",
"0.5556099",
"0.5515815",
"0.5513775",
"0.5490225... | 0.79349476 | 0 |
The label vector for a given pixel. | def pixel_label_vector(self, pixel_index):
return self.label_vector | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_vector(self):\n return self._label_vector",
"def human_readable_label_vector(self):\n return utils.human_readable_label_vector(self.label_vector)",
"def get_ground_vector(self, label):\n raise NotImplementedError",
"def _get_labels(self, ind):\n pass",
"def get_label(s... | [
"0.78296655",
"0.68697125",
"0.67874354",
"0.6724856",
"0.6645989",
"0.65660703",
"0.6552231",
"0.65338254",
"0.65087235",
"0.6487559",
"0.64699054",
"0.64114416",
"0.6410744",
"0.63639164",
"0.6313419",
"0.6293585",
"0.6282582",
"0.62656385",
"0.6263285",
"0.6235112",
"0.623... | 0.8921682 | 0 |
Return an array containing just the training labels, given the label vector. | def labels_array(self):
return _build_label_vector_rows(
[[(label, 1)] for label in self.labels], self.training_labels)[1:].T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_vector_array(self):\n\n lva = _build_label_vector_rows(self.label_vector, self.training_labels)\n\n if not np.all(np.isfinite(lva)):\n logger.warn(\"Non-finite labels in the label vector array!\")\n return lva",
"def labels2Vec(labels):\r\n global dict_words_n_vectors... | [
"0.76408017",
"0.7284747",
"0.7144544",
"0.7028117",
"0.6942029",
"0.6899227",
"0.67332506",
"0.658882",
"0.65399396",
"0.6429374",
"0.6401778",
"0.6391315",
"0.6367483",
"0.6316053",
"0.6307495",
"0.62854844",
"0.62518024",
"0.62458104",
"0.62405115",
"0.6239542",
"0.6227217... | 0.79108775 | 0 |
Filter a grayscale image with uneven brightness across it, such as you might see in a microscope image. Removes large objects using adaptive thresholding based on `min_object_size`, then calculates the mean in a circular neighborhood of diameter `kernel_size`. Smooths this mean, then subtracts the background variation ... | def equalize_exposure(image, iterations=1, kernel_size=None, min_object_size=500, dark_objects=True, stretch=False):
# Housekeeping
img = img_as_float(image.copy())
if stretch is True:
img = img/img.max()
if dark_objects is False:
img = 1-img # invert
img_in = img.copy() # for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_small_objects(img, min_size=7500):\n img2 = np.copy(img)\n img2 = np.uint8(img2)\n nb_components, output, stats, centroids = cv2.connectedComponentsWithStats(img2, connectivity=8)\n # connectedComponentswithStats yields every seperated component with information on each of them, such as size... | [
"0.64706206",
"0.6312088",
"0.61894965",
"0.6161807",
"0.6116456",
"0.60780954",
"0.59993887",
"0.5963144",
"0.5957664",
"0.5912628",
"0.5893338",
"0.5851966",
"0.5850059",
"0.5794523",
"0.57804793",
"0.5775863",
"0.5768622",
"0.5713448",
"0.5706504",
"0.56982875",
"0.5698287... | 0.6775272 | 0 |
Convenience wrapper for `skimage.draw.ellipse` and `skimage.draw.polygon`. Draws an ellipse at (center + ``offset``) of ``img`` with major and minor axes as a percentage of ``img.shape``. Alternatively, draws a rectangle centered at the offset that covers the given percentage of the height and width of the image. | def draw_mask(img, percentage_x=100, percentage_y=100, offset_x=0, offset_y=0, rotation=0, rectangle=True):
ydim, xdim = img.shape
mask = np.zeros((ydim, xdim))
# Convert percentages to fractions
offset_x = (xdim * offset_x/100)
offset_y = (ydim * offset_y/100)
percentage_x = percentage_x/100
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawEllipse(img, center, axes, angle, startAngle=0, endAngle=360, color = (0,0,255), fill = -1):\n\tcv2.ellipse(img, center, axes, angle, startAngle, endAngle, color, fill)",
"def draw_ellipse(image, bounds, width=1, outline: Color = 'white', antialias=4):\n\n # Use a single channel image (mode='L') as ma... | [
"0.67974865",
"0.64300925",
"0.63686156",
"0.58005464",
"0.5795213",
"0.5793865",
"0.5774169",
"0.5764719",
"0.56835324",
"0.56081563",
"0.559414",
"0.5571749",
"0.55247015",
"0.54754096",
"0.54754096",
"0.54754096",
"0.5475373",
"0.54694",
"0.5465637",
"0.5429203",
"0.542274... | 0.63136655 | 3 |
check whether this peak need to be keep or not | def isOverlap(peak, ref_distance_map, ref_distance_indexmap):
chromosome = peak[0]
start = int(peak[1])
end = int(peak[2])
if chromosome not in ref_distance_indexmap:
return False
indexes = ref_distance_indexmap[chromosome]
left_index = bisect(indexes, start)
right_index = bisect(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_peak_win(self):\n if self.peak_win[0] < 0.0:\n self.peak_win[0] = 0.0\n if self.logger is not None:\n self.logger.warning(('Start of peak window < 0 sec for cond: {}. ' +\n 'Setting to 0.').format(self.cond))\n if self.peak_win[1] > self.psc_dur:\n ... | [
"0.68637854",
"0.6679027",
"0.6361278",
"0.62237",
"0.61966306",
"0.6166271",
"0.6106665",
"0.60822225",
"0.60775304",
"0.60629255",
"0.6047418",
"0.6010898",
"0.59993297",
"0.5983516",
"0.5952819",
"0.59344816",
"0.5925719",
"0.5897181",
"0.5876247",
"0.5864989",
"0.5850096"... | 0.0 | -1 |
Effectively, this function checks if a number is positive If the number is not positive, the number is replaced by 0 | def naive_relu(x):
assert len(x.shape) == 2
x = x.copy()
for i in range(x.shape[0]):
for j in range(x.shape[1]):
x[i, j] = max(x[i, j], 0)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positive(num):\n return num if num > 0.0 else 0.0",
"def positive(num):\n return num if num > 0.0 else 0.0",
"def make_negative(number):\n if number < 0:\n return number\n else:\n return number * -1",
"def sign(num: float):\n return 1 if num >= 0 else -1",
"def _sign(self, ... | [
"0.75741535",
"0.75741535",
"0.72996163",
"0.7193092",
"0.7188947",
"0.7166097",
"0.706891",
"0.7063342",
"0.70541674",
"0.6952574",
"0.693869",
"0.69125706",
"0.68789375",
"0.68299246",
"0.68268836",
"0.6810385",
"0.6764053",
"0.66985554",
"0.66486454",
"0.6638206",
"0.66107... | 0.0 | -1 |
Returns a vector where the coefficients are the dot products between vector y and the rows of x | def naive_matrix_vector_dot(x, y):
assert len(x.shape) == 2
assert len(y.shape) == 1
assert x.shape[1] == y.shape[0]
z = np.zeros(x.shape[0])
for i in range(x.shape[0]):
for j in range(x.shape[1]):
z[i] += x[i, j] * y[j]
return z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector_dot(x, y):\n\n if(len(x) != len(y)):\n raise ValueError(\"vector lengths differ\")\n else:\n # return x1*y1+x2*y2+...xn*yn\n return sum([x[i] * y[i] for i in range(len(x))])",
"def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y))",
"def dot(x,y):\n\treturn sum([... | [
"0.75655377",
"0.75623",
"0.7211544",
"0.7117599",
"0.6998607",
"0.6945003",
"0.6682874",
"0.6638106",
"0.6566833",
"0.6551473",
"0.6545176",
"0.6520076",
"0.64751744",
"0.6471004",
"0.64705753",
"0.6462754",
"0.645829",
"0.64380956",
"0.642333",
"0.64229894",
"0.6383523",
... | 0.6976998 | 5 |
Matrix dot requires x.shape[1] == y.shape[0] | def naive_matrix_dot(x, y):
assert len(x.shape) == 2
assert len(y.shape) == 2
assert x.shape[1] == y.shape[0]
z = np.zeros((x.shape[0], y.shape[1]))
for i in range(x.shape[0]):
for j in range(y.shape[1]):
row_x = x[i, :]
column_y = y[:, j]
z[i, j] = naive... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naive_matrix_vector_dot(x, y):\n assert len(x.shape) == 2\n assert len(y.shape) == 1\n assert x.shape[1] == y.shape[0]\n\n z = np.zeros(x.shape[0])\n for i in range(x.shape[0]):\n for j in range(x.shape[1]):\n z[i] += x[i, j] * y[j]\n return z",
"def dot(a, b):\n return... | [
"0.7853408",
"0.7478568",
"0.74032456",
"0.7392542",
"0.734456",
"0.7272187",
"0.72554904",
"0.7213966",
"0.71137625",
"0.708254",
"0.7058603",
"0.7042258",
"0.70058733",
"0.69978625",
"0.69895977",
"0.698229",
"0.6953415",
"0.691596",
"0.6900425",
"0.6890385",
"0.6880768",
... | 0.7990329 | 0 |
One user only allow to review a book once | def test_single_review_per_user(self):
user1 = User.objects.create_user('John')
self.book.reviews.create(
user=user1,
rating=5,
notes="It's so awesome"
)
with transaction.atomic():
self.assertRaises(
IntegrityError,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_review_permitted(self, user):\n if user.is_authenticated or settings.OSCAR_ALLOW_ANON_REVIEWS:\n return not self.has_review_by(user)\n else:\n return False",
"def agree(user_id, review_id):\n review = Review.objects.get(pk=review_id)\n if user_id == review.user_id... | [
"0.6980502",
"0.67019975",
"0.6398248",
"0.6381262",
"0.6271941",
"0.61491233",
"0.6136312",
"0.6048181",
"0.5927348",
"0.59069073",
"0.5905987",
"0.58993644",
"0.57687443",
"0.56444836",
"0.56042373",
"0.5598359",
"0.5582909",
"0.55748767",
"0.5570418",
"0.55646867",
"0.5551... | 0.5738119 | 13 |
This function removes stopwords from doc. It works by tokenizing the doc and then checking if the word is present in stopwords | def remove_stopwords_fun(self):
tokens = str(self.doc).split()
cleaned_tokens = [token for token in tokens
if token.lower() not in self.stopword_list]
self.doc = ' '.join(cleaned_tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stop_words(document):\n\n stop_words = stopwords.words(\"english\")\n stop_words = set(stop_words + EXTENDED_STOP_WORDS)\n return [token for token in document if token not in stop_words]",
"def _remove_stopwords(self, doc: str):\n processed_tweet = [word for word in doc.split() if\n ... | [
"0.8245636",
"0.7993458",
"0.77301854",
"0.76271266",
"0.7530973",
"0.7504788",
"0.7464579",
"0.7456828",
"0.7430697",
"0.74110025",
"0.74013996",
"0.7366169",
"0.73484695",
"0.73205286",
"0.7277599",
"0.72673047",
"0.72409",
"0.72298217",
"0.7223564",
"0.72171193",
"0.719308... | 0.8493136 | 0 |
This function uses regex's complile method to remove all the HTML tags from the doc | def remove_html_tags_fun(self):
cleaner = re.compile('<.*?>')
cleaned_text = re.sub(cleaner, '', self.doc)
cleaned_text = re.sub('[\n\t]', '', cleaned_text)
self.doc = cleaned_text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_html_tags(text):\n print('VOU REMOVER AS TAGS DA STRING')\n clean = re.compile('<.*?>')\n print('',re.sub(clean, '', text))\n return re.sub(clean, '', text)",
"def remove_html_tags(self,text):\n #https://medium.com/@jorlugaqui/how-to-strip-html-tags-from-a-string-in-python-7cb81a2bb... | [
"0.77641433",
"0.7728183",
"0.7552811",
"0.75363183",
"0.7521789",
"0.7478069",
"0.7455409",
"0.7455409",
"0.7445343",
"0.7413711",
"0.740211",
"0.7396938",
"0.7379973",
"0.7337214",
"0.7322062",
"0.73187894",
"0.731528",
"0.7313469",
"0.73117423",
"0.7289772",
"0.7284027",
... | 0.87696666 | 0 |
This function is used to remove stopwords from predefined list Parameters ["first_word"] Example obj = NLP() obj.remove_stopwords(['new_stopword_here']) | def remove_stopwords(self, *args):
if self.remove_stopwords is False:
raise Exception("Error - enable stopword removal functionality")
if type(args) != list:
raise Exception("Error - expected a list")
if args == []:
raise Exception("Error - no items to remove ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n self.doc = ' '.join(cleaned_tokens)",
"def remove_stopwords(words: list) -> list:\n new_words = []\n f... | [
"0.7736731",
"0.7717607",
"0.76971424",
"0.76276153",
"0.7582472",
"0.75602907",
"0.7543819",
"0.7543819",
"0.7543819",
"0.7543819",
"0.75048316",
"0.74926174",
"0.74800986",
"0.7473974",
"0.74032813",
"0.7390513",
"0.734522",
"0.73390806",
"0.73061395",
"0.73023677",
"0.7263... | 0.7679187 | 3 |
This function prints all the stopwords that are present in the list Return Type list Example obj = NLP() obj.print_stopwords() | def print_stopwords(self):
if self.stopword_list == []:
raise Exception("Error - stopword list is empty")
print(self.stopword_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStopWords(self):\n\t\treturn self.stop_words",
"def getStopWords():\n import os\n cur_dir = os.getcwd()\n\n dk_addition = [line.rstrip('\\n') for line in open(os.path.join(cur_dir,'utils','danish_stopwords.txt'), encoding=\"utf-8\")] # danish stopword list\n\n custom... | [
"0.6898452",
"0.6854093",
"0.6694974",
"0.66808605",
"0.6665299",
"0.6610832",
"0.6608906",
"0.6535058",
"0.65346605",
"0.6499919",
"0.6469955",
"0.6466746",
"0.6455693",
"0.6443953",
"0.6433437",
"0.64328563",
"0.64278525",
"0.6426234",
"0.6383199",
"0.63683045",
"0.63464975... | 0.81608075 | 0 |
Testing the Profile class' object | def test_Profile(self):
self.assertEquals(self.user_1.username, 'testuser')
# self.assertEquals(self.user_1.password, '12345')
self.assertEquals(self.user_1.email,
'boggusmail@boggusmail.net') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get(self):\r\n profile = self.profile_manager.get('testing')\r\n self.assertIsInstance(profile, Profile)",
"def test_is_instance(self):\n self.assertTrue(isinstance(self.profile, Profile))",
"def test_init(self):\n self.assertTrue(self.profile.bio == \"very awesome\")",
"... | [
"0.820445",
"0.8011229",
"0.7704948",
"0.75586057",
"0.7299799",
"0.7198144",
"0.7183843",
"0.7160516",
"0.7150611",
"0.6966144",
"0.69260114",
"0.68853277",
"0.67087305",
"0.6706924",
"0.6682297",
"0.6654272",
"0.6649027",
"0.66143954",
"0.6609443",
"0.6601269",
"0.6597436",... | 0.75534123 | 4 |
Compute the DDQN argmax_a Q(s', a') | def get_ddqn_targets(qsa_target, q_targets, mask, estimator, next_states):
with torch.no_grad():
next_q_values = estimator(next_states)
argmax_actions = next_q_values.max(1, keepdim=True)[1]
qsa_target[mask] = q_targets.gather(1, argmax_actions)
return qsa_target | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_q_argmax(self):\n self.cur_head = self._sess.run(self.ucb_net._P_argmax,\n {self.state_ph: self.state,\n self.ucb_A_ph: self.ucb_A,\n self.ucb_b_ph: self.ucb_b})[0]\n x = self._sess.run(self._... | [
"0.71106255",
"0.6676644",
"0.6552188",
"0.64466786",
"0.63473934",
"0.6307508",
"0.623282",
"0.6092046",
"0.6040722",
"0.6023089",
"0.6003085",
"0.59490055",
"0.5929167",
"0.5852684",
"0.5803385",
"0.577629",
"0.5758296",
"0.5644242",
"0.5639915",
"0.56111395",
"0.5594791",
... | 0.52647585 | 60 |
r""" Do the estimator optimization step. Usefull when computing gradients across several steps/batches and optimizing using the accumulated gradients. | def update_estimator(self):
self.optimizer.step()
self.optimizer.zero_grad() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimizer_step(self, epoch, batch_idx, optimizer, optimizer_idx, second_order_closure=None):\n # if self.trainer.use_tpu:\n # xm.optimizer_step(optimizer)\n # else:\n # optimizer.step()\n optimizer.step()\n optimizer.zero_grad()\n\n # need to define here... | [
"0.7034254",
"0.6977685",
"0.68927234",
"0.68876964",
"0.68591446",
"0.6857839",
"0.6770871",
"0.67440027",
"0.67438537",
"0.67383814",
"0.66734546",
"0.66393304",
"0.66374946",
"0.6637007",
"0.663594",
"0.6618131",
"0.6598047",
"0.6585267",
"0.65740526",
"0.65729725",
"0.653... | 0.7480986 | 0 |
This function compares two models | def compareAB(model1_name, model2_name, X_test_B, X_test_S, analysis_dir="Analysis/"):
#Load best weights
model = tf.keras.models.load_model("Models/"+model1_name)
bkg_preds1 = model.predict(X_test_B).flatten()
sig_preds1 = model.predict(X_test_S).flatten()
model = tf.keras.models.load_model("Model... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def models_are_equivalent(model_a: TopLevelOscalModel, model_b: TopLevelOscalModel) -> bool:\n # this will change the second model as a side-effect\n model_b.metadata.last_modified = model_a.metadata.last_modified\n return model_a == model_b",
"def test_same_models(self):\n\t\t\n\t\t# TODO: finish\n\t\t... | [
"0.7753797",
"0.7328007",
"0.73104525",
"0.7292354",
"0.72099286",
"0.70938206",
"0.6936437",
"0.6903338",
"0.6769854",
"0.6725155",
"0.66343856",
"0.65777844",
"0.65125",
"0.64977247",
"0.6470571",
"0.6455895",
"0.6452334",
"0.6431843",
"0.6406671",
"0.63744867",
"0.6368579"... | 0.0 | -1 |
Gets the quarters the course is offered | def get_offered(description):
if 'Offered:' not in description:
return ''
local_parts_re = parts_re
local_quarters = quarters
check_parts = description.rsplit('Offer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quarters(self) -> localedata.LocaleDataDict:\n return self._data['quarters']",
"def get_quarter(self):\n\n self.quarter_nums = cal_data.calc_quarter(self.active_date[2],\n self.active_date[1])\n self.quarter = cal_data.get_quarter(self.act... | [
"0.73450804",
"0.62729603",
"0.5841355",
"0.55977887",
"0.5522017",
"0.54990166",
"0.54269874",
"0.540832",
"0.54080886",
"0.53976446",
"0.5371402",
"0.53569263",
"0.5341169",
"0.5341169",
"0.53325397",
"0.53231806",
"0.5277258",
"0.5242366",
"0.52258813",
"0.5190903",
"0.518... | 0.0 | -1 |
Transform a unit quaternion into its corresponding rotation matrix (to be applied on the right side). | def quat2transform(q):
x, y, z, w = q
xx2 = 2 * x * x
yy2 = 2 * y * y
zz2 = 2 * z * z
xy2 = 2 * x * y
wz2 = 2 * w * z
zx2 = 2 * z * x
wy2 = 2 * w * y
yz2 = 2 * y * z
wx2 = 2 * w * x
rmat = np.empty((3, 3), float)
rmat[0,0] = 1. - yy2 - zz2
rmat[0,1] = xy2 - wz2
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_to_rotation_matrix(quaternion):\n\n q_w, q_x, q_y, q_z = quaternion\n sqw, sqx, sqy, sqz = np.square(quaternion)\n norm = (sqx + sqy + sqz + sqw)\n rotation_matrix = np.zeros((3, 3))\n\n # division of square length if quaternion is not already normalized\n rotation_matrix[0, 0] = (... | [
"0.7545378",
"0.7471066",
"0.7374021",
"0.7350053",
"0.7305658",
"0.7285506",
"0.72790813",
"0.7278867",
"0.7256145",
"0.7239384",
"0.7188391",
"0.71671534",
"0.7139696",
"0.7111424",
"0.7110769",
"0.7103358",
"0.71023613",
"0.70715433",
"0.70638746",
"0.7059145",
"0.7031367"... | 0.70197755 | 21 |
function to extract non overlapping patches of shape patch_height patch_width from array | def get_patches_non_overlap(array, patch_height, patch_width):
total_patches_in_height = array.shape[0]//patch_height
total_patches_in_width = array.shape[1]//patch_width
# print("total patches in height from supplied image array : {}".format(total_patches_in_height))
# print("total patches in width... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_patches(image, patchshape, overlap_allowed=0.1, cropvalue=None, crop_fraction_allowed=0.1):\r\n jump_cols = int(patchshape[1] * overlap_allowed)\r\n jump_rows = int(patchshape[0] * overlap_allowed)\r\n\r\n # Restrict ourselves to the rectangle containing non-cropped pixels\r\n if cropvalue ... | [
"0.7041462",
"0.676175",
"0.67323136",
"0.6620813",
"0.65697014",
"0.65624285",
"0.6441754",
"0.63933766",
"0.6350235",
"0.63044304",
"0.62668127",
"0.62179095",
"0.620207",
"0.6159355",
"0.61497486",
"0.61309433",
"0.6127641",
"0.60902935",
"0.60513747",
"0.60498655",
"0.602... | 0.86732626 | 0 |
Returns a dictionary with IRIDE table names as keys and lists of dictionaries with key names from IRIDE definitions as values | def get_tabledata_for(doc):
plomino_table = doc.getForm().id
data = dict(ADDITIONAL_VALUES)
map = FIELDS_MAP[plomino_table]
for key in doc.getItems():
if key not in map:
continue
value = normalize_value(doc.getItem(key, None))
data[map[key]] = value
post_method = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tables_dict(self):\n return self.tables.table_name_map",
"def tables() -> dict[str, str]:\n return {\n \"land_use\": \"zone_id\",\n \"tours\": \"tour_id\",\n \"trips\": \"trip_id\",\n \"persons\": \"person_id\",\n \"households\": \"household_id\",\n }",
"def ... | [
"0.6578095",
"0.65523446",
"0.6427931",
"0.6396281",
"0.617586",
"0.60895866",
"0.60031897",
"0.58030415",
"0.5722489",
"0.56747836",
"0.5665729",
"0.5615583",
"0.56026495",
"0.55529374",
"0.5535452",
"0.5528628",
"0.5496971",
"0.5486551",
"0.54771787",
"0.5475563",
"0.545126... | 0.50452083 | 90 |
Returns an opened output stream. | def open_output(arg):
if arg == sys.stdout:
return arg
else:
return open(arg, 'w') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_output(name=None):\n return Output(name)",
"def outstream(self):\r\n #noinspection PyUnresolvedReferences\r\n return self._outstream",
"def open_output_file(output_file):\n # open output file\n if output_file:\n try:\n return codecs.open(output_file, \"w\", \"u... | [
"0.70521754",
"0.69922405",
"0.66267276",
"0.62901956",
"0.6246123",
"0.6195192",
"0.61377865",
"0.6075756",
"0.6075756",
"0.60124856",
"0.59406143",
"0.57956886",
"0.5768754",
"0.57558566",
"0.57237697",
"0.57223666",
"0.57181346",
"0.56944627",
"0.56534773",
"0.560823",
"0.... | 0.682071 | 2 |
Return a new array containing the original data centered around the desired value (0 by default). | def center(data, desired=0.0):
return (data -data.mean()) + desired | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center(emg_data: np.ndarray, center_value: float = None) -> np.ndarray:\n center_value = center_value if center_value else emg_data.mean(axis=1)\n emg_centered = np.copy(emg_data)\n for i in range(emg_data.shape[0]):\n emg_centered[i, :] = emg_data[i, :] - center_value[i]\n ... | [
"0.6305169",
"0.62006336",
"0.61792946",
"0.5939517",
"0.58721083",
"0.58713126",
"0.5841683",
"0.58001316",
"0.5784767",
"0.57834405",
"0.5741024",
"0.5709937",
"0.57065076",
"0.5699792",
"0.56853807",
"0.56714404",
"0.5610496",
"0.55895543",
"0.5589431",
"0.5581052",
"0.552... | 0.7088807 | 0 |
Selects random destinations. Returns a list of list of Selection objects. | def select_destinations(self, context, spec_obj, instance_uuids,
alloc_reqs_by_rp_uuid, provider_summaries,
allocation_request_version=None, return_alternates=False):
num_instances = spec_obj.num_instances
# TODO(danms): This needs to be extended to support multiple cells
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _select(self):\n sel = []\n\n # choose randomly while favouring fit individuals\n lp = len(self.population) // 2\n for _ in range(lp):\n idx1 = idx2 = int(math.sqrt(random.randrange(lp**2+1)))\n while idx1 == idx2:\n idx2 = int(math.sqrt(random.r... | [
"0.70677817",
"0.62784475",
"0.6105888",
"0.61033756",
"0.60421544",
"0.60114765",
"0.5927387",
"0.5914193",
"0.5911071",
"0.5902707",
"0.5817435",
"0.574426",
"0.5722713",
"0.5717739",
"0.5675371",
"0.5628562",
"0.5627276",
"0.56236565",
"0.5606458",
"0.5558213",
"0.554393",... | 0.5485183 | 22 |
Make a mock dataset. Feel free to add more complicated kwargs, and put other things in the run_params dictionary to control how the mock is generated. | def build_mock(sps, model,
filterset=None,
wavelength=None,
snr_spec=10.0, snr_phot=20., add_noise=False,
seed=101, **kwargs):
# We'll put the mock data in this dictionary, just as we would for real
# data. But we need to know which filters (and wavel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code_builder(request, tmp_path_factory) -> dataset_builder.DatasetBuilder:\n tmp_path = tmp_path_factory.mktemp('tfds_datasets') # Temporary data_dir\n builder_cls = request.param\n # Generate the dataset (only once for all tests as scope == 'module').\n builder = builder_cls(data_dir=tmp_path)\n builder... | [
"0.6181497",
"0.6163039",
"0.61408746",
"0.6077571",
"0.60196906",
"0.5977284",
"0.5947485",
"0.5912386",
"0.5838757",
"0.58219236",
"0.58044946",
"0.577402",
"0.5771943",
"0.57677144",
"0.5759707",
"0.573642",
"0.57021254",
"0.56838363",
"0.56619245",
"0.5644798",
"0.5633289... | 0.5990022 | 5 |
(list[str]) > (int, int) Returns indices of rightmost left end brackets and leftmost right end bracket. >>> endBrackets(['(', 'T', ')']) (0, 1) >>> endBrackets(['(', 'T', 'and', 'F', ')', 'oor', 'F']) (0, 3) >>> endBrackets(['(', '(', 'T', 'iif', 'F', ')', 'eeq', 'F', ')']) (1, 1) | def endBrackets(Code):
left = 0; right = len(Code)-1;
while right >= left:
if Code[left] in brackets: left += 1;
if Code[right] in brackets: right -= 1;
if not (Code[left] in brackets or Code[right] in brackets): break;
return (left-1, right+1); | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getEnds(self) -> List[int]:\n ...",
"def findEnd(elements, start_i):\n end_i = start_i + 1\n while end_i < len(elements):\n if isinstance(elements[end_i], EndTag) and elements[end_i].tagname == elements[start_i].tagname:\n break\n end_i += 1\n\n if end_i >= len(elemen... | [
"0.5458909",
"0.5448444",
"0.5390166",
"0.5284903",
"0.5142005",
"0.5115058",
"0.50304615",
"0.49878743",
"0.49625537",
"0.49386483",
"0.49283704",
"0.49209985",
"0.48623124",
"0.48590636",
"0.48408267",
"0.48383304",
"0.48155516",
"0.47854236",
"0.47535983",
"0.47290462",
"0... | 0.75261825 | 0 |
Load an existing SQLite database. Return a Database instance. | def load(dbname):
db = Database(dbname)
# Get the name of the objects
tables = get_table_list(db.cur)
# Create a Trace instance for each object
chains = 0
for name in tables:
db._traces[name] = Trace(name=name, db=db)
setattr(db, name, db._traces[name])
db.cur.execute('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_db(path_to_db):\n db_run = db(path_to_db) # Instantiates the DB by reading the file\n db_run.import_config_db() # Imports configuration DB\n db_run.conn.row_factory = sqlite3.Row # Better select results\n return(db_run)",
"def load_or_create_db(self):\n try:\n ... | [
"0.7439739",
"0.71361715",
"0.7067575",
"0.70600796",
"0.70092314",
"0.69258475",
"0.6883646",
"0.6867834",
"0.6856853",
"0.6853324",
"0.6853324",
"0.6853324",
"0.6843692",
"0.6833094",
"0.6831327",
"0.67798513",
"0.6774781",
"0.6764467",
"0.67592436",
"0.67563015",
"0.675520... | 0.0 | -1 |
Test getting nonexistent report. | def test_nonexistent_report(self):
command_line = ["report", "notreport"]
for prefix in [[], ["--propagate"]]:
self.check_system_exit(prefix + command_line, _PARSE_ERROR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_report_id_not_found(self) -> None:\n\n channel = self.make_request(\n \"GET\",\n \"/_synapse/admin/v1/event_reports/123\",\n access_token=self.admin_user_tok,\n )\n\n self.assertEqual(404, channel.code, msg=channel.json_body)\n self.assertEqual(... | [
"0.7624911",
"0.71265996",
"0.70916563",
"0.7060378",
"0.68481207",
"0.68275154",
"0.6729168",
"0.6646713",
"0.664156",
"0.6635975",
"0.6633377",
"0.66240263",
"0.6607126",
"0.6543978",
"0.6539158",
"0.65057343",
"0.64924186",
"0.64902806",
"0.6462956",
"0.6458721",
"0.645123... | 0.77942353 | 0 |
Test badly formatted filesystem UUID. | def test_bad_uuid_filesystem(self):
command_line = ["filesystem", "debug", "get-object-path", "--uuid=not"]
for prefix in [[], ["--propagate"]]:
self.check_system_exit(prefix + command_line, _PARSE_ERROR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_uuid(data):\n\n if not uuidutils.is_uuid_like(data):\n raise exceptions.DiagnoseException(\n \"'%s' is not a valid UUID\" % data)",
"def test_get_shortuuid_uuid(self):\n id = get_shortuuid()\n self.assertTrue(len(id) == 22)",
"def validate_uuid(self, uuid):\n ... | [
"0.71983624",
"0.7036204",
"0.7001199",
"0.69806474",
"0.69768965",
"0.69486225",
"0.6907577",
"0.67696375",
"0.67626375",
"0.6720668",
"0.6716371",
"0.67110217",
"0.6704599",
"0.6693978",
"0.66469556",
"0.66329867",
"0.65962917",
"0.65682924",
"0.6535362",
"0.6512739",
"0.65... | 0.7847062 | 0 |
Test badly formatted blockdev UUID. | def test_bad_uuid_blockdev(self):
command_line = ["blockdev", "debug", "get-object-path", "--uuid=not"]
for prefix in [[], ["--propagate"]]:
self.check_system_exit(prefix + command_line, _PARSE_ERROR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_uuid_blockdev_2(self):\n command_line = [\"pool\", \"extend-data\", \"poolname\", \"--device-uuid=not\"]\n for prefix in [[], [\"--propagate\"]]:\n self.check_system_exit(prefix + command_line, _PARSE_ERROR)",
"def test_get_shortuuid_uuid(self):\n id = get_shortuuid()... | [
"0.7498997",
"0.6969893",
"0.6875966",
"0.6758883",
"0.6673937",
"0.6642093",
"0.6628758",
"0.6615271",
"0.6517894",
"0.64675146",
"0.64505756",
"0.6423073",
"0.63428885",
"0.62639517",
"0.6258574",
"0.6224835",
"0.618351",
"0.6172508",
"0.6135588",
"0.6120024",
"0.6108279",
... | 0.803133 | 0 |
Get data (features and labels) used in experiments. | def get_data(dataset: str = None, scale: bool = True) -> tuple:
if dataset not in ['ecoli', 'glass', 'letter-recognition', 'lymphography', 'yeast',
'digits', 'breast-cancer', 'wine', 'mnist']:
raise ValueError("Invalid dataset provided.")
if dataset in dataset in ['ecol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(self):\n return self.X_train, self.X_test, self.y_train, self.y_test",
"def _generate_experimental_data(self):\n\n loginfo('Extracting dataset...')\n cfg = self.cfg_\n return ex.ExperimentalData(db=cfg.db,\n prediction_label=cfg.predictio... | [
"0.686119",
"0.68532175",
"0.6843999",
"0.6672966",
"0.66569084",
"0.6591148",
"0.64300555",
"0.6417017",
"0.6389412",
"0.6382001",
"0.6342793",
"0.63351786",
"0.6325042",
"0.6279978",
"0.6262135",
"0.6229701",
"0.62161106",
"0.62131226",
"0.62127554",
"0.6163851",
"0.6154426... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
return np.exp(x) / np.sum(np.exp(x), axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.6985568 | 82 |
Test successful setup of entry. | async def test_setup_entry(hass):
await setup_axis_integration(hass)
assert len(hass.data[AXIS_DOMAIN]) == 1
assert format_mac(MAC) in hass.data[AXIS_DOMAIN] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_setup_entry(\n hass: HomeAssistant, client: MagicMock, integration: MockConfigEntry\n) -> None:\n assert integration.state == ConfigEntryState.LOADED\n await hass.config_entries.async_unload(integration.entry_id)\n assert integration.state == ConfigEntryState.NOT_LOADED",
"def test_Ent... | [
"0.69260967",
"0.6753642",
"0.6734612",
"0.65916616",
"0.6449939",
"0.6424044",
"0.639753",
"0.6392475",
"0.6357911",
"0.62970614",
"0.6295186",
"0.628726",
"0.6286345",
"0.62527364",
"0.62489384",
"0.62441933",
"0.6233807",
"0.6216958",
"0.61908334",
"0.61851025",
"0.6168261... | 0.64368224 | 5 |
Test successful setup of entry. | async def test_setup_entry_fails(hass):
config_entry = MockConfigEntry(
domain=AXIS_DOMAIN, data={CONF_MAC: "0123"}, version=3
)
config_entry.add_to_hass(hass)
mock_device = Mock()
mock_device.async_setup = AsyncMock(return_value=False)
with patch.object(axis, "AxisNetworkDevice") as m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_setup_entry(\n hass: HomeAssistant, client: MagicMock, integration: MockConfigEntry\n) -> None:\n assert integration.state == ConfigEntryState.LOADED\n await hass.config_entries.async_unload(integration.entry_id)\n assert integration.state == ConfigEntryState.NOT_LOADED",
"def test_Ent... | [
"0.69260967",
"0.6753642",
"0.6734612",
"0.65916616",
"0.6449939",
"0.64368224",
"0.6424044",
"0.639753",
"0.6392475",
"0.6357911",
"0.62970614",
"0.6295186",
"0.628726",
"0.6286345",
"0.62527364",
"0.62489384",
"0.62441933",
"0.6233807",
"0.6216958",
"0.61908334",
"0.6185102... | 0.58766025 | 53 |
Converts a mac address into decimal notation | def mac_to_decimal(mac):
split = mac.split(":")
converted = []
for hex_value in split:
converted.append(str(int(hex_value, 16)))
return ".".join(converted) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_ntoa(mac):\n return '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(map(ord, list(mac)))",
"def mac_addr(address):\n\tprint(':'.join('%02x' % compat_ord(b) for b in address))\n\treturn ':'.join('%s' % format(compat_ord(b), '0>8b') for b in address)",
"def _mac_addr(address):\n return ':'.join('%02x' % ord... | [
"0.72261906",
"0.71254593",
"0.71215063",
"0.69997275",
"0.69997275",
"0.69997275",
"0.69997275",
"0.6982128",
"0.6773423",
"0.6559753",
"0.64638656",
"0.6447456",
"0.64358103",
"0.6366163",
"0.63467073",
"0.63436633",
"0.63248163",
"0.6271407",
"0.619147",
"0.61843497",
"0.6... | 0.80558246 | 0 |
Add Dune HD entities from a config_entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
unique_id = entry.entry_id
player: DuneHDPlayer = hass.data[DOMAIN][entry.entry_id]
async_add_entities([DuneHDPlayerEntity(player, DEFAULT_NAME, unique_id)], True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_setup_entry(\n hass: HomeAssistant,\n config_entry: ConfigEntry,\n async_add_entities: AddEntitiesCallback,\n) -> None:\n entities_to_create = hass.data[DATA_ZHA][Platform.DEVICE_TRACKER]\n\n unsub = async_dispatcher_connect(\n hass,\n SIGNAL_ADD_ENTITIES,\n func... | [
"0.629254",
"0.628149",
"0.6270485",
"0.6259277",
"0.6246057",
"0.62114185",
"0.61959124",
"0.6127469",
"0.6091641",
"0.608637",
"0.6076979",
"0.60728544",
"0.6032043",
"0.60175323",
"0.6017051",
"0.59960353",
"0.59955597",
"0.59853774",
"0.59614223",
"0.5956726",
"0.5952938"... | 0.631074 | 0 |
Return a boolean if volume is currently muted. | def is_volume_muted(self) -> bool:
return int(self._state.get("playback_mute", 0)) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_volume_muted(self):\n return self._isMuted",
"def is_volume_muted(self):\n return self._muted",
"def is_volume_muted(self):\n return self._muted",
"def is_volume_muted(self):\n return self._muted",
"def is_volume_muted(self):\n return self._state.get(\"mute\", None... | [
"0.8849281",
"0.88373685",
"0.88373685",
"0.88373685",
"0.88111585",
"0.87333494",
"0.8238356",
"0.8215848",
"0.7887102",
"0.78492475",
"0.7717994",
"0.7675144",
"0.69601905",
"0.69031775",
"0.6557327",
"0.6528415",
"0.649203",
"0.6469015",
"0.64277583",
"0.63973266",
"0.6295... | 0.87451166 | 5 |
Turn off media player. | def turn_off(self) -> None:
self._media_title = None
self._state = self._player.turn_off() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_video(self):\n\n # Enabling all the buttons, the speedCombo and the checkbox\n self.enable_btns()\n\n if self.mediaPlayer.state() == QMediaPlayer.PlayingState or self.mediaPlayer.state() == QMediaPlayer.PausedState:\n self.mediaPlayer.stop()\n else:\n pass... | [
"0.70308757",
"0.6834358",
"0.6793133",
"0.67812693",
"0.6767454",
"0.67081386",
"0.66996515",
"0.66895",
"0.6688312",
"0.6683773",
"0.66787255",
"0.666077",
"0.6645586",
"0.6634683",
"0.6572496",
"0.6571467",
"0.65361327",
"0.65145576",
"0.65045",
"0.6491209",
"0.64162374",
... | 0.8205774 | 0 |
Turn off media player. | def turn_on(self) -> None:
self._state = self._player.turn_on() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self) -> None:\n self._media_title = None\n self._state = self._player.turn_off()",
"def stop_video(self):\n\n # Enabling all the buttons, the speedCombo and the checkbox\n self.enable_btns()\n\n if self.mediaPlayer.state() == QMediaPlayer.PlayingState or self.medi... | [
"0.8205852",
"0.7030466",
"0.68343294",
"0.67930496",
"0.67830914",
"0.6768098",
"0.6708995",
"0.67011",
"0.669101",
"0.66873455",
"0.6685667",
"0.6679875",
"0.6658712",
"0.66462564",
"0.6634383",
"0.6573495",
"0.65710264",
"0.65352654",
"0.65138614",
"0.6506874",
"0.6489102"... | 0.0 | -1 |
Check if cmap is one of the colorbrewer maps | def check_colormap(cmap):
names = set(['BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral',
'Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu',
'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_color_cmap_c_combination(self):\n arr = self.arr\n out = ternary(arr, c=np.linspace(0, 10, 10), cmap=\"viridis\")\n self.assertTrue(hasattr(out, \"tax\"))\n self.assertEqual(\n type(out.tax), pyternary.ternary_axes_subplot.TernaryAxesSubplot\n )",
"def test_... | [
"0.5843804",
"0.5692596",
"0.5636734",
"0.552688",
"0.55212224",
"0.5518823",
"0.5495647",
"0.5456022",
"0.5441688",
"0.53898966",
"0.5335588",
"0.5322415",
"0.52619606",
"0.51933086",
"0.51814556",
"0.512174",
"0.51121014",
"0.5111982",
"0.50997084",
"0.5088438",
"0.5072949"... | 0.7758749 | 0 |
Returns a SpooledTemporaryFile this is a file that is initially stored in memory but once its size exceedes max_size it will start writing to disk. It is used because there is no way of knowing how large of a file the api will return. We are expecting a csv file. | def _api_call(self, url):
self.log('Request URL', url)
response = urllib2.urlopen(url)
# the response MUST be a csv file
content_type = response.info().get('content-type')
if 'csv' not in content_type:
raise Exception('ERROR - Non CSV response.')
# Decode th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_temp_batch_file(self):\n return tempfile.NamedTemporaryFile(delete=False)",
"def _build_b(self):\r\n\r\n use_file = self.store and self.content_l >= self.file_limit\r\n if use_file: return tempfile.NamedTemporaryFile(mode = \"w+b\")\r\n else: return netius.legacy.BytesIO()... | [
"0.7094382",
"0.69850975",
"0.65605533",
"0.64762425",
"0.63395995",
"0.63346845",
"0.6323567",
"0.6258411",
"0.62381077",
"0.6012729",
"0.6004162",
"0.5991984",
"0.5970093",
"0.596835",
"0.5967569",
"0.59420043",
"0.5880405",
"0.5863748",
"0.575363",
"0.57412237",
"0.5639996... | 0.6088513 | 9 |
Get the path of the compiler's run.sh script. | def runner_path():
git_base = os.popen('git rev-parse --show-toplevel').read().strip()
return os.path.join(git_base, RUNNER_SCRIPT_BASENAME) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getScriptPath():\n\treturn os.path.dirname(os.path.realpath(sys.argv[0]))",
"def get_script_directory():\n return os.path.dirname(__file__)",
"def getScriptDirectory():\n\n\treturn os.path.dirname(os.path.realpath(__file__))",
"def _getRunXBuildScript(self):\n\t\treturn os.path.join(self.getEngineRoot... | [
"0.78128856",
"0.74353504",
"0.73944753",
"0.71499777",
"0.7039568",
"0.70210826",
"0.6981369",
"0.6981369",
"0.6876073",
"0.68538165",
"0.6746146",
"0.665266",
"0.6643522",
"0.66289604",
"0.66289604",
"0.66259426",
"0.66017246",
"0.6583314",
"0.65341383",
"0.6472415",
"0.647... | 0.77952826 | 1 |
Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. | def sort_012(input_list):
n = len(input_list)
if n == 0:
return []
left_next = 0
right_next = n - 1
i = 0
while i <= right_next:
cur = input_list[i]
if cur == 0:
input_list[i], input_list[left_next] = input_list[left_next], input_list[i]
left_next ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(array):\n\n for i in range(0, len(array)):\n for j in range(len(array)-1, i, -1):\n if array[j] < array[j-1]:\n ## Move the lighter bubble up\n _temp = array[j]\n array[j] = array[j-1]\n array[j-1] = _temp\n \n ... | [
"0.6792707",
"0.6758305",
"0.6685668",
"0.66711134",
"0.6660409",
"0.6644065",
"0.66035944",
"0.659015",
"0.65542775",
"0.6552274",
"0.65011084",
"0.64874375",
"0.6465411",
"0.6446616",
"0.64315027",
"0.64290977",
"0.6422456",
"0.6421703",
"0.6418894",
"0.64047986",
"0.638907... | 0.0 | -1 |
generator for new random tokens For now, just UUIDs. | def new_token(*args, **kwargs):
return uuid.uuid4().hex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_token():\n return uuid4()",
"def generate_token(self):\n token = randint(100000000000000000, 999999999999999999)\n return str(token)",
"def generate_new_token(uid):\n random_token = uuid.uuid4()\n token = TokenAuth(user_id=uid, token=random_token)\n token.save... | [
"0.80620843",
"0.71133626",
"0.70683056",
"0.70095974",
"0.69477004",
"0.6836809",
"0.67922354",
"0.67269385",
"0.67252356",
"0.6712614",
"0.6712614",
"0.6700551",
"0.6683586",
"0.6667238",
"0.6651258",
"0.6640658",
"0.6628126",
"0.66250765",
"0.6621003",
"0.66192883",
"0.659... | 0.7473114 | 1 |
Decide if this position is in check for this colour (by iterating away from the king) | def in_check(self, colour):
from pieces import King, Queen, Bishop, Knight, Rook, Pawn
king_coord = self.white_king_coord if colour is WHITE else self.black_king_coord
if king_coord is None:
return False
for piece_class in King, Queen, Bishop, Knight, Rook, Pawn:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_in_check(self, mycolor):\n\n opponent = self.__players[self.get_opponent_color(mycolor)]\n\n x, y = None, None\n for (u, v) in self.__players[mycolor]:\n piece = self.get_piece(u, v)\n if not piece:\n raise ValueError()\n\n if self.get_... | [
"0.7654861",
"0.7067358",
"0.6948059",
"0.6937073",
"0.68143445",
"0.67938894",
"0.6746636",
"0.673443",
"0.67331177",
"0.6701681",
"0.667734",
"0.6626326",
"0.6577563",
"0.6576846",
"0.6570374",
"0.6519104",
"0.65172017",
"0.64874834",
"0.6480004",
"0.6476915",
"0.6475521",
... | 0.76546264 | 1 |
Fuzzy matching to try to connect Canadian styles to American model names | def choose_matching_model_for_style(model_style_name, model_choices):
model_choices = set(model_choices)
matching_models = []
# Remove punctuation and capitalize both terms for easier comparison
model_style_uc = model_style_name.replace("&", "And").upper()
model_style_alphanumeric = not_alphanumeric.sub("", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fuzzy_matching_basic(nlp: Language, countries: List[Dict[str, Any]]) -> None:\n ruler = SpaczzRuler(nlp)\n ruler.add_patterns(countries)\n doc = nlp(\"This is a test that should find Egypt and Argentina\")\n doc = ruler(doc)\n matches = [(ent.ent_id_, ent.text) for ent in doc.ents if ent.la... | [
"0.59728503",
"0.5711574",
"0.5695275",
"0.5613565",
"0.56111693",
"0.55739677",
"0.5496115",
"0.5459744",
"0.54576874",
"0.54250586",
"0.5369017",
"0.5362432",
"0.53396124",
"0.5334603",
"0.5323487",
"0.5304435",
"0.5284018",
"0.5281663",
"0.5270314",
"0.5266695",
"0.5259205... | 0.51195055 | 42 |
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. | def add_header(response):
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
response.headers['Cache-Control'] = 'public, max-age=0'
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response",
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m... | [
"0.8221727",
"0.8220911",
"0.8220911",
"0.8220911",
"0.8220911",
"0.81940746",
"0.81111443",
"0.80852413",
"0.79712725",
"0.78637785",
"0.7659569",
"0.72363365",
"0.71586627",
"0.71513546",
"0.71513546",
"0.71502376",
"0.71502376",
"0.7140211",
"0.7135492",
"0.7126684",
"0.71... | 0.8161616 | 11 |
Convert eido error into nice modified string | async def eido_error_string_converter(
e: eido.exceptions.EidoValidationError,
) -> Tuple[str, List[str]]:
property_names = []
error_type_list = []
for item_list in e.errors_by_type.values():
property_type = item_list[0]["type"]
property_name_list = []
for item in item_list:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cut_error_msg(e):\n\n return str(e)[:1000] + (' (...)' if len(str(e)) > 1000 else '')",
"def err_str(err):\n return \"\".join(format_exception_only(type(err), err))",
"def error(err):\n\n return str(err) + '\\n'",
"def err_to_str(exception):\n return '' if str(exception) is None else ': ' + s... | [
"0.7327042",
"0.7199894",
"0.7134401",
"0.69755816",
"0.67288876",
"0.66491395",
"0.653953",
"0.6503827",
"0.64996904",
"0.64886236",
"0.64669275",
"0.64344925",
"0.6426737",
"0.6388753",
"0.6350613",
"0.63339907",
"0.62993973",
"0.62726146",
"0.62632287",
"0.625801",
"0.6241... | 0.6435036 | 11 |
__eq__ Allows comparisons by value instead of object | def __eq__(self, other):
return self._reNum == other._reNum and self._imNum == other._imNum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return self.value == other.value",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq_... | [
"0.82932246",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025",
"0.81593025"... | 0.0 | -1 |
Setup WooCommerce API object | def api_setup(self):
self._api = WooCommerceAPI(
username=config.WooCommerceAPICred.USERNAME,
password=config.WooCommerceAPICred.PASSWORD,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpClass(self):\n self.content_type = \"application/json\"\n self.product_payload = {\"name\": \"Olive Oil\"}",
"def __init__(self):\n super().__init__()\n self._api_url = API_BASE_URL\n self._api_params = API_BASE_PARAMS.copy()",
"def __init__(self):\n self.api ... | [
"0.6345589",
"0.62395877",
"0.61878496",
"0.6184517",
"0.6146893",
"0.6123886",
"0.6081439",
"0.6081439",
"0.60414857",
"0.6036208",
"0.603289",
"0.6017541",
"0.6017541",
"0.5999669",
"0.59743947",
"0.5933244",
"0.5908148",
"0.59062046",
"0.5900145",
"0.5900145",
"0.5888453",... | 0.87556875 | 0 |
Test that /version gives expected response | def test_gets_to_version_page(self):
response = self.client.get('/version')
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_version(mocker):\n client = wsgi.application.test_client(mocker)\n\n url = '/api/v0/version'\n\n response = client.get(url)\n\n output = {\n \"message\": f\"AIOPS Publisher Version {wsgi.VERSION}\",\n \"status\": \"OK\",\n \"version\": wsgi.VERSION\n }\n assert r... | [
"0.8378657",
"0.8208732",
"0.789646",
"0.7606957",
"0.75739866",
"0.7500372",
"0.7497989",
"0.7490588",
"0.7464043",
"0.7415947",
"0.73981893",
"0.73143137",
"0.7292889",
"0.7228078",
"0.7207022",
"0.7190163",
"0.70712894",
"0.70650643",
"0.70431685",
"0.70288825",
"0.7020836... | 0.8499361 | 0 |
Makes a URL safe by removing optional hostname and port. | def make_safe_url(self, url):
# Split the URL into scheme, netloc, path, query and fragment
parts = list(urlsplit(url))
# Clear scheme and netloc and rebuild URL
parts[0] = '' # Empty scheme
parts[1] = '' # Empty netloc (hostname:port)
safe_url = urlunsplit(parts)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_url_safe(url):\n if not urlparse(url).scheme:\n url = \"http://\" + url\n\n parsed_url = urlparse(url)\n\n safe_path = urls.url_fix(parsed_url.path)\n\n return parsed_url.scheme + '://' + parsed_url.netloc + safe_path",
"def sanitize_url(url: str, protocol: str = 'https://') -> str:\n... | [
"0.7144651",
"0.71274525",
"0.694291",
"0.6897449",
"0.6839757",
"0.66851497",
"0.6674285",
"0.66430336",
"0.6606237",
"0.6572125",
"0.6551103",
"0.65305513",
"0.6510947",
"0.65021265",
"0.64449185",
"0.6412131",
"0.639297",
"0.6387144",
"0.6373869",
"0.6364142",
"0.6356565",... | 0.7627089 | 0 |
Return a MagicMock if import fails for any reason | def mocked_import(*args, **kwargs):
try:
return import_module(*args, **kwargs)
except Exception:
mocked_module = mock.MagicMock()
mocked_module.__name__ = args[0]
return mocked_module | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_file_loader_module_import_fail(\n mock_empty_os_environ, monkeypatch, file_str, filename, mock_module, tmpdir\n):\n # Check that without mocking everything is file:\n path = tmpdir / filename\n with open(tmpdir / filename, \"w\") as f:\n f.write(file_str)\n\n climate = core.Climate(p... | [
"0.7314671",
"0.703671",
"0.70151365",
"0.6937636",
"0.6889088",
"0.67984104",
"0.67358637",
"0.6701713",
"0.66045505",
"0.65019184",
"0.6466008",
"0.6412087",
"0.63232815",
"0.6296915",
"0.6259132",
"0.6258436",
"0.62300694",
"0.62182724",
"0.6206299",
"0.61965144",
"0.61598... | 0.7788996 | 0 |
The set of arguments for constructing a Canary resource. | def __init__(__self__, *,
artifact_s3_location: pulumi.Input[str],
code: pulumi.Input['CanaryCodeArgs'],
execution_role_arn: pulumi.Input[str],
runtime_version: pulumi.Input[str],
schedule: pulumi.Input['CanaryScheduleArgs'],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, resource, *args):\n self.args = list(args)\n self.flags = OrderedDict()\n self.additional_flags = []\n self._AddCommonFlags(resource)",
"def __init__(__self__,\n resource_name: str,\n opts: Optional[pulumi.ResourceOptions] = None,\n d... | [
"0.6738929",
"0.63125294",
"0.6201344",
"0.611214",
"0.6064065",
"0.60238415",
"0.60096765",
"0.60066205",
"0.598847",
"0.59444475",
"0.59375256",
"0.59337384",
"0.59100914",
"0.5908742",
"0.5907505",
"0.5904312",
"0.5902941",
"0.5900103",
"0.58898807",
"0.588213",
"0.5880099... | 0.0 | -1 |
Get an existing Canary resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None) -> 'Canary':
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
__props__ = CanaryArgs.__new__(CanaryArgs)
__props__.__dict__["artifact_config"] = Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_by_id(state_id):\n my_state = storage.get('State', state_id)\n if my_state is None:\n abort(404)\n return jsonify(my_state.to_dict())",
"def get_state_by_id(state_id):\n for key, value in storage.all(\"State\").items():\n if state_id == value.id:\n return jsonif... | [
"0.61935234",
"0.61328936",
"0.61136836",
"0.60995287",
"0.6034243",
"0.60212237",
"0.6000729",
"0.59986687",
"0.5946912",
"0.59265316",
"0.58821166",
"0.58080775",
"0.5702323",
"0.5695273",
"0.5691948",
"0.5691166",
"0.56803226",
"0.5629848",
"0.560919",
"0.5608509",
"0.5606... | 0.6837446 | 0 |
Loads all the variables found from the environment root. These variables apply to all services in all environments. | def load_global_variables(self):
return read_and_combine_yamls_in_dir(self.__get_environments_root_dir()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_all_variables(self, service, environment, extra_variables=None):\n all_vars = copy.deepcopy(self.config_vars)\n all_vars[EXCONF_VAR_SERVICE] = service\n all_vars[EXCONF_VAR_ENVIRONMENT] = environment\n all_vars.update(self.load_global_variables())\n all_vars.update(self.... | [
"0.7718931",
"0.7481851",
"0.6858284",
"0.68212247",
"0.67833817",
"0.67240375",
"0.6699491",
"0.6699491",
"0.6699491",
"0.6699491",
"0.6699491",
"0.6699491",
"0.6647782",
"0.6617163",
"0.65989256",
"0.6482498",
"0.64683074",
"0.6447678",
"0.6423812",
"0.6395767",
"0.63935435... | 0.7218615 | 2 |
Loads all the variables found for the given environment. These variables apply to all services in the given environment. | def load_env_variables(self, environment):
env_dir = os.path.join(self.__get_environments_root_dir(), environment)
return read_and_combine_yamls_in_dir(env_dir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_all_variables(self, service, environment, extra_variables=None):\n all_vars = copy.deepcopy(self.config_vars)\n all_vars[EXCONF_VAR_SERVICE] = service\n all_vars[EXCONF_VAR_ENVIRONMENT] = environment\n all_vars.update(self.load_global_variables())\n all_vars.update(self.... | [
"0.75456214",
"0.72147477",
"0.71489584",
"0.6570849",
"0.6490997",
"0.64716756",
"0.6376977",
"0.6346854",
"0.6346854",
"0.6346854",
"0.6346854",
"0.6346854",
"0.6346854",
"0.63025045",
"0.62350047",
"0.6207109",
"0.61823297",
"0.6163426",
"0.61408585",
"0.6119225",
"0.60653... | 0.7289236 | 1 |
r"""Converts an integer label 2D tensor to a onehot 3D tensor. | def one_hot(labels: torch.Tensor,
num_classes: int,
device: Optional[torch.device] = None,
dtype: Optional[torch.dtype] = None,
eps: Optional[float] = 1e-6) -> torch.Tensor:
if not torch.is_tensor(labels):
raise TypeError("Input labels type is not a torch.Tens... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_num_to_one_hot(label_tensor, num_labels=2):\n one_hot_tensor = tf.one_hot(label_tensor, num_labels)\n return tf.reshape(one_hot_tensor, [-1, num_labels])",
"def _onehot(integer_labels):\r\n n_rows = len(integer_labels)\r\n n_cols = integer_labels.max() + 1\r\n o... | [
"0.7763101",
"0.7675027",
"0.7574823",
"0.74852675",
"0.7479565",
"0.74173063",
"0.73279846",
"0.7322685",
"0.72918254",
"0.726556",
"0.7213813",
"0.715185",
"0.71323407",
"0.71125495",
"0.7070897",
"0.70457876",
"0.70108247",
"0.70108247",
"0.6988933",
"0.6942813",
"0.692801... | 0.0 | -1 |
Sets the range of the accelerometer to range. accel_range the range to set the accelerometer to. Using a predefined range is advised. | def set_accel_range(self, accel_range):
# First change it to 0x00 to make sure we write the correct value later
self.bus.write_byte_data(self.address, self.ACCEL_CONFIG, 0x00)
# Write the new range to the ACCEL_CONFIG register
self.bus.write_byte_data(self.address, self.ACCEL_CONFIG, ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_accel_range(self, accel_range):\n\t\t# First change it to 0x00 to make sure we write the correct value later\n\t\tself.bus.write_byte_data(self.address, self.ACCEL_CONFIG, 0x00)\n\n\t\t# Write the new range to the ACCEL_CONFIG register\n\t\tself.bus.write_byte_data(self.address, self.ACCEL_CONFIG, accel_ra... | [
"0.8560891",
"0.8427307",
"0.7137662",
"0.7018219",
"0.69972706",
"0.6957257",
"0.66478467",
"0.6595461",
"0.6414262",
"0.6414122",
"0.6367358",
"0.6334341",
"0.62489706",
"0.616668",
"0.6120851",
"0.60352284",
"0.5974493",
"0.59650695",
"0.59518915",
"0.59337837",
"0.5846012... | 0.8517671 | 1 |
Add another Comparer to this collection. | def add_comparer(self, comparer: BaseComparer):
if isinstance(comparer, ComparerCollection):
for c in comparer:
self._add_comparer(c)
else:
self._add_comparer(comparer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comparer(self, comparer):\n\n self._comparer = comparer",
"def comparer(self):\n return self._comparer",
"def added(self, comp):\n\t\tpass",
"def item_comparer(self, value):\n self.item_comparer_value = value",
"def comparator(self) -> Operator:\n return self.__comparator",
... | [
"0.6453569",
"0.5837209",
"0.57280874",
"0.5710855",
"0.5679192",
"0.5640105",
"0.5620999",
"0.56052965",
"0.5521508",
"0.5488429",
"0.544117",
"0.54165655",
"0.5400129",
"0.5393243",
"0.5354152",
"0.53055906",
"0.52602786",
"0.5231729",
"0.52099806",
"0.519714",
"0.5196772",... | 0.7513109 | 0 |
Weighted mean score of model(s) over all observations | def score(
self,
weights: Union[str, List[float]] = None,
metric=mtr.rmse,
model: Union[str, int, List[str], List[int]] = None,
observation: Union[str, int, List[str], List[int]] = None,
variable: Union[str, int, List[str], List[int]] = None,
start: Union[str, dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_average(model_df,cols):\n #wa = model_df[cols].apply(lambda x: (x[0]*x[1]).sum()/x[0].sum())\n wa = (model_df[cols[0]]*model_df[cols[1]]).sum()/model_df[cols[0]].sum()\n return wa",
"def modelmean(self, model_params, this_data, this_suff_stat):\n pass",
"def average_weights(self):\... | [
"0.70332307",
"0.70254093",
"0.69680727",
"0.68765414",
"0.6790573",
"0.6790573",
"0.6790573",
"0.6700972",
"0.6603083",
"0.6587961",
"0.6572004",
"0.6554735",
"0.64765143",
"0.64427716",
"0.6367768",
"0.6358858",
"0.63499683",
"0.62882394",
"0.62670875",
"0.6257497",
"0.6220... | 0.63238394 | 17 |
Converts the argument from a binary representation to ascii then converts it to a string | def main():
counter = 0
for i in sys.argv:
if counter != 0:
ascii_values = int(i, 2)
characters = chr(ascii_values)
print(characters, end='')
counter += 1
print() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def binstr(self, ctx, *, input_binary = None):\n\t\tif input_binary == None:\n\t\t\tawait ctx.send(\"Usage: `{}binstr [input_binary]`\".format(ctx.prefix))\n\t\t\treturn\n\t\t# Clean the string\n\t\tnew_bin = \"\"\n\t\tfor char in input_binary:\n\t\t\tif char is \"0\" or char is \"1\":\n\t\t\t\tnew_bin += ch... | [
"0.7040099",
"0.7031941",
"0.6700423",
"0.6522215",
"0.6514733",
"0.6403473",
"0.6387926",
"0.6370005",
"0.6363693",
"0.63469565",
"0.63139653",
"0.62527686",
"0.6250048",
"0.62430453",
"0.6241288",
"0.62403506",
"0.6237285",
"0.6169486",
"0.61623365",
"0.61515224",
"0.611993... | 0.0 | -1 |
Returns the Weyl group associated to self. | def weyl_group(self, prefix=None):
from sage.combinat.root_system.weyl_group import WeylGroup
return WeylGroup(self, prefix=prefix) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group(self):\n return self._group",
"def group(self):\n return self._group",
"def group(self):\n return self._group",
"def get_group(self):\n return self._group",
"def getGroup(self):\n\t\treturn self.Group",
"def group(self):\n return self.properties.get('Group', N... | [
"0.7906268",
"0.7906268",
"0.7906268",
"0.78902006",
"0.7584195",
"0.7420307",
"0.7394187",
"0.72912663",
"0.71758157",
"0.7161931",
"0.7157386",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.6984935",
"0.6984207",
"0.68993556",
"0.68971235",
"0.6893145",
"0.6883652"... | 0.7386063 | 7 |
Test if self has a descent at position `i`, that is if self is on the strict negative side of the `i^{th}` simple reflection hyperplane. If positive if True, tests if it is on the strict positive side instead. | def has_descent(self, i, positive=False):
s = self.scalar(self.parent().simple_coroots()[i])
if positive:
return s > 0
else:
return s < 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_reflective(self):\n return self._reflective",
"def testInvisibleNegative(self):\n slhafile=\"./testFiles/slha/higgsinoStop.slha\"\n model = Model(BSMList,SMList)\n model.updateParticles(slhafile)\n topos = decomposer.decompose(model, .1*fb, False, True, 5.*GeV)\n test... | [
"0.58238274",
"0.5752007",
"0.57258743",
"0.5700998",
"0.5577143",
"0.5497889",
"0.54611224",
"0.54175866",
"0.53962916",
"0.5395782",
"0.53506416",
"0.53044957",
"0.52587783",
"0.5244453",
"0.5236598",
"0.5218317",
"0.5217596",
"0.5210604",
"0.51798826",
"0.51655114",
"0.511... | 0.76402164 | 0 |
r""" Returns whether self is dominant. This is done with respect to the subrootsystem indicated by the subset of Dynkin nodes index_set. If index_set is None then the entire Dynkin node set is used. If positive is False then the dominance condition is replaced by antidominance. | def is_dominant(self, index_set = None, positive = True):
return self.first_descent(index_set, not positive) is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dominant_weight(self): # Or is_dominant_integral_weight?\n alphacheck = self.parent().simple_coroots()\n from sage.rings.semirings.non_negative_integer_semiring import NN\n return all(self.inner_product(alphacheck[i]) in NN\n for i in self.parent().inde... | [
"0.6259479",
"0.53261065",
"0.52400196",
"0.4914769",
"0.48978284",
"0.4878028",
"0.48514593",
"0.4793705",
"0.47593725",
"0.47518334",
"0.47433084",
"0.46526226",
"0.4632171",
"0.46230313",
"0.4604421",
"0.45926705",
"0.45479685",
"0.45146626",
"0.4513191",
"0.44990432",
"0.... | 0.78370166 | 0 |
r""" Returns the subset of Dynkin nodes whose reflections fix ``self``. If ``index_set`` is not None, only consider nodes in this set. Note that if ``self`` is dominant or antidominant, then its stabilizer is the parabolic subgroup defined by the returned node set. | def weyl_stabilizer(self, index_set=None):
if index_set is None:
index_set = self.parent().cartan_type().index_set()
alphavee = self.parent().coroot_lattice().basis()
return [i for i in index_set if self.scalar(alphavee[i]) == 0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def descents(self, index_set=None, positive=False):\n if index_set==None:\n index_set=self.parent().index_set()\n return [ i for i in index_set if self.has_descent(i, positive) ]",
"def py__simple_getitem__(self, index):\n if isinstance(index, slice):\n retu... | [
"0.51409805",
"0.50043744",
"0.4989534",
"0.4940502",
"0.4935269",
"0.4894771",
"0.4858762",
"0.47169214",
"0.46607944",
"0.46506235",
"0.46079034",
"0.45927814",
"0.45869038",
"0.4560439",
"0.4556505",
"0.452892",
"0.45240793",
"0.45061743",
"0.45009974",
"0.44907835",
"0.44... | 0.5112824 | 1 |
Return a unique ID for this object | def get_id(self):
#return self.__str__().__hash__()
object_type = self['object_type']
shortname = self.get_description()
object_name = self['name']
filename = self['filename']
id = "%s-%s-%s-%s" % ( object_type, shortname, object_name, filename)
import md5
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id(self):\n return self._id",
"def unique_id(self):\n return self._id",
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self... | [
"0.8665592",
"0.8665592",
"0.8440317",
"0.8440317",
"0.8440317",
"0.8440317",
"0.8440317",
"0.8440317",
"0.8440317",
"0.8440317",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
"0.837083",
... | 0.8288808 | 46 |
Deletes this object definition from its configuration files. | def delete(self, cascade=False):
if cascade == True:
raise NotImplementedError()
else:
result = config.item_remove(self._original_attributes)
self._event(level="write", message="Object was deleted")
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n self._instance.delete()\n self._instance = None\n self._data_defs = []",
"def delete(self):\n if self.is_running:\n raise errors.ChalmersError(\"Can not remove running program (must be stopped)\")\n\n if path.isfile(self.definition_filename):\n ... | [
"0.7129188",
"0.69116104",
"0.6685645",
"0.65170276",
"0.6507113",
"0.64859164",
"0.6419904",
"0.64156234",
"0.6400127",
"0.6390254",
"0.6369861",
"0.63425195",
"0.6338442",
"0.6268313",
"0.6244709",
"0.6215319",
"0.61811477",
"0.6165215",
"0.61497766",
"0.61399996",
"0.61399... | 0.5984034 | 38 |
Add the customers details | def add_customer_details(self):
customer = self.invoice.customer
addr = customer.get_billing_address()
self.fontSize(FONT_S, bold=True)
self.PDF.drawString(250, 127, "Billed To")
self.fontSize(FONT_XXS)
self.PDF.drawString(
250, 145, self.shortenStrings(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_customer(insert_dict):\n return cr.add_customer(insert_dict)",
"def add_customer(self, info, dup):\n if not dup:\n self.cursor.execute(\"INSERT INTO customerpersonal VALUES (%s,%s)\", (int(info['phone']), info['address']))\n\n self.cursor.execute(\"INSERT INTO customercredenti... | [
"0.71868837",
"0.71642345",
"0.6851698",
"0.68293905",
"0.6805611",
"0.6762024",
"0.6731194",
"0.6714445",
"0.6687886",
"0.66675144",
"0.66508263",
"0.66192836",
"0.6601514",
"0.6601051",
"0.6600497",
"0.65940017",
"0.6583454",
"0.6563231",
"0.65199476",
"0.6517513",
"0.64179... | 0.77027 | 0 |
Overwrites the nil_slot (first row) of the input Tensor with zeros. The nil_slot is a dummy slot and should not be trained and influence the training algorithm. | def zero_nil_slot(t, name=None):
with tf.name_scope(name, "zero_nil_slot", [t]) as name:
t = tf.convert_to_tensor(t, name="t")
s = tf.shape(t)[1]
z = tf.zeros(tf.pack([1, s]))
return tf.concat(0, [z, tf.slice(t, [1, 0], [-1, -1])], name=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_nil_slot(t, name=None):\n with tf.name_scope(name, \"zero_nil_slot\", [t]) as name:\n t = tf.convert_to_tensor(t, name=\"t\")\n s = tf.shape(t)[1]\n z = tf.zeros(tf.stack([1, s]))\n return tf.concat(axis=0, values=[z, tf.slice(t, [1, 0], [-1, -1])], name=name)",
"def zero_... | [
"0.7715188",
"0.7586192",
"0.7402092",
"0.65668076",
"0.62054354",
"0.61956364",
"0.6103971",
"0.60978776",
"0.60976475",
"0.60948086",
"0.6020554",
"0.591928",
"0.591848",
"0.5907246",
"0.59047395",
"0.5847722",
"0.5829298",
"0.5824217",
"0.57806695",
"0.57594943",
"0.573964... | 0.7831846 | 0 |
Compute number of errors for a network | def compute_accuracy(model: torch.nn.Module, data_loader: torch.utils.data.DataLoader,
model_type: str = "Baseline") -> float:
tot_err = 0
for input_data, target_data, _ in iter(data_loader):
# Get output from the model
if model_type == "Baseline":
res = mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __error(self,node_set):\n error=0\n for n in node_set:\n if(n.seq_num!=0):\n error+=LA.norm(n.node_vol-node_set[n.neighbor.parent].node_vol-n.impedance*n.branch_cur)\n #print n.node_vol, '\\n', node_set[n.neighbor.parent].node_vol\n \n ... | [
"0.6928827",
"0.6767077",
"0.670789",
"0.6556823",
"0.6518629",
"0.6353731",
"0.6347704",
"0.63253903",
"0.6312637",
"0.6310614",
"0.6293432",
"0.627118",
"0.6270912",
"0.6257534",
"0.6253675",
"0.62469536",
"0.6211159",
"0.6190853",
"0.61845875",
"0.6158958",
"0.6126254",
... | 0.0 | -1 |
Return the name of the device's vendor. | def vendor_name(self):
return self._device.vendor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vendor(self) -> str:\n return self.properties[DBUS_ATTR_VENDOR]",
"def vendor_id(self):\n return self._device.vendor_id",
"def vendor(self):\n return self._vendor",
"def get_created_vendor_name(self):\n global vendor_name\n return vendor_name",
"def bios_vendor(self):... | [
"0.8557363",
"0.79449624",
"0.76705587",
"0.7461614",
"0.7379092",
"0.72847074",
"0.7273895",
"0.7192627",
"0.711983",
"0.7083854",
"0.6990005",
"0.6977349",
"0.6927718",
"0.69242924",
"0.69242924",
"0.68627495",
"0.6857515",
"0.68286294",
"0.67641205",
"0.6738254",
"0.666813... | 0.921684 | 0 |
Return a string representation of the device's type. | def type(self):
return self._device.type_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type(self) -> str:\n return self._device_info[\"Type\"]",
"def device_type(self):\n # type: () -> string_types\n return self._device_type",
"def device_type(self):\n return Context.devtype2str[self.device_typeid]",
"def device_type(self):\n return Context.devtype2str[se... | [
"0.86088556",
"0.82700086",
"0.8255606",
"0.8255606",
"0.81402075",
"0.7726833",
"0.7634854",
"0.76082575",
"0.7562245",
"0.75471276",
"0.7536864",
"0.7492867",
"0.7448056",
"0.74460775",
"0.74230623",
"0.7346708",
"0.7346708",
"0.7346708",
"0.73424935",
"0.73203367",
"0.7298... | 0.85563576 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.