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 |
|---|---|---|---|---|---|---|
Train the provided keras model. The train and validation data may be given as a (X, Y) tuples or as batch generators. | def main(
model=Sequential(),
train_data=([], []), # (X, Y) or batch generator
val_data=([], []), # (X, Y) or batch generator (no generator when using tensorboard).
epochs=10,
batch_size=32,
n_train_batches=None,
n_val_batches=None,
loss="binary_crossentro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_model(model, x_train, y_train, x_test, y_test,\n epochs=None, batch_size=None):\n\n # Training\n if batch_size is None:\n batch_size = 128\n if epochs is None:\n epochs = 20\n\n print('x_train shape:', x_train.shape)\n print('x_test shape:', x_test.shape)\n\n ... | [
"0.7570889",
"0.72540927",
"0.7197917",
"0.7098029",
"0.7079394",
"0.70779413",
"0.7069681",
"0.7057481",
"0.70420337",
"0.698384",
"0.69490373",
"0.6914304",
"0.6874435",
"0.68590474",
"0.68566406",
"0.6856409",
"0.6856077",
"0.68044865",
"0.6787625",
"0.6772411",
"0.6760422... | 0.0 | -1 |
Returns the cross product of two vectors | def cross(v1: Vec2, v2: Vec2) -> float:
return v1.x * v2.x + v1.y * v2.y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_cross(a,b):\r\n return [a[1] * b[2] - a[2] * b[1],\r\n a[2] * b[0] - a[0] * b[2],\r\n a[0] * b[1] - a[1] * b[0]]",
"def cross(a, b):\n #return np.cross(a,b)\n\n return vector(a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] -... | [
"0.86737233",
"0.86428434",
"0.85831934",
"0.8459429",
"0.8380033",
"0.82918686",
"0.82186884",
"0.8206147",
"0.8129146",
"0.8097375",
"0.80907226",
"0.8062627",
"0.79926574",
"0.7878959",
"0.78296506",
"0.774443",
"0.7649261",
"0.76229763",
"0.760088",
"0.75927854",
"0.74453... | 0.80259854 | 12 |
Returns the normalised (length scaled to 1) version of the input vector | def norm(v: Vec2) -> Vec2:
t = length(v)
return Vec2(v.x / t, v.y / t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(vector):\n return vector / np.linalg.norm(vector)",
"def normalize(vec):\n return vec / length(vec)",
"def normalize(v):\n return v / np.linalg.norm(v)",
"def normalize(v):\n return np.array(v) / np.linalg.norm(v)",
"def normalize(self, vec):\n length = math.sqrt( vec[0... | [
"0.8412167",
"0.8302273",
"0.8302211",
"0.8266341",
"0.8169584",
"0.8101434",
"0.8079701",
"0.80685115",
"0.8046882",
"0.80222285",
"0.80093133",
"0.79763794",
"0.7949378",
"0.79310757",
"0.7921497",
"0.79008293",
"0.7895176",
"0.78568214",
"0.7855854",
"0.78214765",
"0.78152... | 0.7188056 | 86 |
Returns the normal vector between two points | def nor_vector(p1: Vec2, p2: Vec2) -> Vec2:
return Vec2(p1.y - p2.y, p2.x - p1.x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(point_one, point_two):\n return numpy.array([point_one[1] - point_two[1], point_two[0] - point_one[0]])",
"def normal(self) -> Vector:\n return normalize(cross(self.d1, self.d2))",
"def normal(self) -> Vec:\n # The three points are in clockwise order, so compute differences\n ... | [
"0.8578433",
"0.8012082",
"0.7716698",
"0.7705324",
"0.7582754",
"0.7479023",
"0.7476993",
"0.7474553",
"0.7269726",
"0.71905434",
"0.6984859",
"0.69728416",
"0.69652104",
"0.6964969",
"0.6872618",
"0.68472695",
"0.68157995",
"0.6797447",
"0.6776186",
"0.67705375",
"0.6757878... | 0.6584558 | 33 |
Checks if s is a number | def is_number(s):
try:
float(s)
return True
except ValueError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_number(s):\r\n try:\r\n int(s)\r\n return True\r\n except ValueError:\r\n return False",
"def is_number(s):\n try:\n int(s)\n return True\n except ValueError:\n return False",
"def is_number(s):\r\n try:\r\n float(s)\r\n return True\... | [
"0.8619565",
"0.85530144",
"0.8539221",
"0.84451944",
"0.8409463",
"0.83992535",
"0.83746153",
"0.82961017",
"0.8229176",
"0.8173118",
"0.81699723",
"0.81008804",
"0.7932275",
"0.7881321",
"0.77923834",
"0.77769893",
"0.7761348",
"0.77518684",
"0.7715149",
"0.77110827",
"0.76... | 0.8460403 | 3 |
Given the path to a task.yaml, build a tester for it, replacing tester with same file basename if present. Does not (currently) rerun tests when a tester is updated. | def newtask(path):
global testers
import testmaker, yaml
if not path.endswith('.yaml'):
print('ignoring', path)
return
print('newtask',(path,))
with open(path) as f: p = yaml.safe_load(f)
t = testmaker.loadyaml(p)
name = path.rsplit('/', 1)[-1].rsplit('.', 1)[0]
testers[n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __make(tests_path: Text) -> NoReturn:\n logger.info(f\"make path: {tests_path}\")\n test_files = []\n if os.path.isdir(tests_path):\n files_list = load_folder_files(tests_path)\n test_files.extend(files_list)\n elif os.path.isfile(tests_path):\n test_files.append(tests_path)\n ... | [
"0.62515557",
"0.61329",
"0.583615",
"0.57948947",
"0.5726791",
"0.5611881",
"0.55781555",
"0.55708975",
"0.5532598",
"0.54969645",
"0.54925644",
"0.5484686",
"0.54701746",
"0.54597014",
"0.54355574",
"0.5429451",
"0.53778154",
"0.5372531",
"0.5333598",
"0.5320233",
"0.531497... | 0.7055689 | 0 |
Convert a `datetime` object to unix timestamp (seconds since epoch). | def datetime2ts(dt):
return int(time.mktime(dt.timetuple())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_epoch(datetime_obj):\n if sys.version_info[0:2] < (3, 3):\n import calendar\n\n return (\n calendar.timegm(datetime_obj.timetuple())\n + datetime_obj.microsecond / 1000000\n )\n else:\n return datetime_obj.timestamp()",
"def datetimeToUnix(date):\n ... | [
"0.7843194",
"0.7827934",
"0.77624255",
"0.7719876",
"0.7683781",
"0.757491",
"0.7449089",
"0.74101746",
"0.7389223",
"0.73839813",
"0.73707974",
"0.73652226",
"0.7338275",
"0.7307772",
"0.7244886",
"0.7176233",
"0.70825726",
"0.70825726",
"0.7065916",
"0.70600116",
"0.703561... | 0.6728318 | 41 |
Converts unsigned integer (raw) to floatingpoint value using fixedpoint format of the current object. | def float(self, uint_val):
if uint_val < 0:
raise ValueError("Value must be non-negative!")
if uint_val > 2**self.word_length - 1:
raise ValueError("Value must be <= "+str(2**self.word_length-1))
if self.signed and (uint_val >= 2**(self.word_length-1)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_float(self) -> float:\n return (1.0 * self.as_int) / sensor_fixed_point_conversion",
"def _eight_byte_real_to_float(value):\n short1, short2, long3 = struct.unpack('>HHL', value)\n exponent = (short1 & 0x7f00) // 256 - 64\n mantissa = (((short1 & 0x00ff) * 65536 + short2) * 4294967296 +\n ... | [
"0.66083324",
"0.65131307",
"0.6510133",
"0.6243346",
"0.61032045",
"0.6030408",
"0.5900468",
"0.58996016",
"0.5882101",
"0.58805734",
"0.5877148",
"0.5876463",
"0.5867485",
"0.5861485",
"0.58268636",
"0.5823998",
"0.58026844",
"0.579907",
"0.57937896",
"0.5724157",
"0.572154... | 0.61576086 | 4 |
returns list of spaceseparated words | def txt_to_word_list(text):
return [w for w in text.split()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_of_words(self):\n\t\treturn str.split(re.sub(r'\\W+', ' ', self.body.encode('ascii', 'replace')))",
"def get_word_list(sentence):\n sentence = space1.sub(r'\\1 \\2', sentence)\n sentence = space2.sub(r\"\\1 \\2\", sentence)\n sentence = space3.split(sentence)\n sentence = \" \".join(sentence... | [
"0.8016059",
"0.7871227",
"0.78429455",
"0.7737485",
"0.770225",
"0.76670074",
"0.7642308",
"0.7573908",
"0.7548197",
"0.75459874",
"0.7540796",
"0.7507687",
"0.74860626",
"0.748066",
"0.748066",
"0.74565727",
"0.74565727",
"0.74565727",
"0.74565727",
"0.74565727",
"0.7434909... | 0.7372729 | 23 |
imports text, returns list of lowercase words without punctuation or numbers | def imp_txt_word_list_vocab(txt_file_loc, min_word_freq = 1):
txt = open(txt_file_loc).read()
#clean_txt = txt_lower_alpha_only(txt)
#clean_txt_list = txt_to_word_list(clean_txt)
clean_txt_list = txt_to_word_list(txt)
vocab = sorted(set(clean_txt_list))
return clean_txt_list, vocab | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_text(text):\n words = word_tokenize(text)\n return [word.lower() for word in words if word not in string.punctuation]",
"def words(self):\n punctuation = '''!()-[]{};:'\"\\,<>./?@#$%^&*_~'''\n lst = []\n for lines in self.lines:\n words = lines.split(' ')... | [
"0.8222362",
"0.7645082",
"0.7643214",
"0.7598121",
"0.75904936",
"0.7570054",
"0.75312895",
"0.74924874",
"0.74824244",
"0.74578744",
"0.73998475",
"0.73077285",
"0.7259491",
"0.7250081",
"0.72484636",
"0.72186697",
"0.721098",
"0.7207618",
"0.72069734",
"0.7187452",
"0.7172... | 0.0 | -1 |
slice a list with a list of indices | def slice_by_index(lst, indices):
slicer = itemgetter(*indices)(lst)
if len(indices) == 1:
return [slicer]
return list(slicer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_sub_list(mylist, indices):\n return [mylist[ii] for ii in indices]",
"def slice_by_index(lst, indexes):\r\n if not lst or not indexes:\r\n return []\r\n slice_ = itemgetter(*indexes)(lst)\r\n if len(indexes) == 1:\r\n return [slice_]\r\n return list(slice_)",
"def parti... | [
"0.77810895",
"0.77111036",
"0.7491785",
"0.7240183",
"0.72143036",
"0.72143036",
"0.69962764",
"0.6980504",
"0.69579154",
"0.68468386",
"0.6771956",
"0.6640604",
"0.6579689",
"0.65484923",
"0.6454098",
"0.64345235",
"0.635987",
"0.6286912",
"0.6247175",
"0.62437004",
"0.6227... | 0.8247251 | 0 |
Obtain the indices of dataset samples whose class labels are not None. | def discard_none_targets(dataset):
indices = []
for (ii,sample) in enumerate(dataset):
target = sample[1]
if target is not None:
indices.append(ii)
return Subset(dataset,indices) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_relevant_indices(dataset, classes, target_classes):\n indices = []\n for i in range(len(dataset)):\n # Check if the label is in the target classes\n label_index = dataset[i][1] # ex: 3\n label_class = classes[label_index] # ex: 'cat'\n if label_class in target_classes:\n ... | [
"0.76218337",
"0.6992517",
"0.6771868",
"0.66888374",
"0.6654937",
"0.65756434",
"0.64397",
"0.6415795",
"0.63517404",
"0.63361394",
"0.62671083",
"0.6251699",
"0.61776084",
"0.6075448",
"0.6040351",
"0.6039544",
"0.601172",
"0.5995058",
"0.5974828",
"0.5945033",
"0.59420174"... | 0.61762136 | 13 |
Test the name property. | def testName(self):
dis_meta = DiseaseMeta()
self.util.stringTypeTest(self, dis_meta, "name")
self.util.stringPropertyTest(self, dis_meta, "name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name(self):\n self.assertTrue(type(x.name) == str)",
"def test_name_property(self):\n v1 = versions.Version(version='1.2.3', name='foo')\n expected = 'foo'\n\n self.assertEqual(v1.name, expected)",
"def test_property_name(self):\n \n name = self.location.name\... | [
"0.7994545",
"0.7621826",
"0.75134736",
"0.75109535",
"0.741161",
"0.7379381",
"0.7315784",
"0.7302214",
"0.7277098",
"0.72736675",
"0.7271381",
"0.7256727",
"0.7250427",
"0.72418636",
"0.7220323",
"0.7208508",
"0.7182417",
"0.7174923",
"0.7158955",
"0.7103506",
"0.7091203",
... | 0.7574307 | 2 |
Normalize a path in order to provide a more consistent output. Currently it generates a relative path but in the future we may want to make this user configurable. | def normpath(path: Union[str, BasePathLike]) -> str:
# convertion to string in order to allow receiving non string objects
return os.path.relpath(str(path)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizePath(path):\n\tfrom os.path import normpath, sep\n\tresult = normpath(path)\n\tresult = result.replace(\"/\",sep)\n\tresult = result.replace(\"\\\\\",sep)\n\treturn adaptPath(result)",
"def normalizePath(path):\n if path == None or len(path) == 0 or path == '/':\n return '/'\n ... | [
"0.8207893",
"0.78640497",
"0.7770286",
"0.7528235",
"0.75112534",
"0.7475242",
"0.7468532",
"0.73854613",
"0.73714185",
"0.7312265",
"0.7271633",
"0.72645074",
"0.725596",
"0.72018355",
"0.706862",
"0.6982975",
"0.6960922",
"0.6958029",
"0.6953111",
"0.69516176",
"0.6913815"... | 0.63050896 | 46 |
Expand the environment or ~ variables in a list. | def expand_paths_vars(paths: List[str]) -> List[str]:
paths = [expand_path_vars(p) for p in paths]
return paths | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expandvars(self,v):\n if not v: return None\n if isinstance(v,(list)):\n for i in range(len(v)):\n v[i] = os.path.expandvars(os.path.expanduser(str(v[i])))\n return v\n \n return os.path.expandvars(os.path.expanduser(str(v)))",
"def test_expand... | [
"0.692476",
"0.62955403",
"0.60755813",
"0.5949875",
"0.5928469",
"0.5847522",
"0.5804107",
"0.5778391",
"0.5730699",
"0.5639701",
"0.55907375",
"0.5588175",
"0.55718786",
"0.5557809",
"0.546992",
"0.54064965",
"0.53334385",
"0.5330786",
"0.53276366",
"0.52986574",
"0.5295397... | 0.6680147 | 1 |
Identify whether the other object represents the same rule match. | def __eq__(self, other: object) -> bool:
if isinstance(other, Lintable):
return bool(self.name == other.name)
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, MatchOriginData):\n return False\n\n return self.__dict__ == other.__dict__",
"def __eq__(self, other):\n if not isinstance(other, CreateCustomRuleInput):\n return False\n\n return self.__dict__ == other.__dict_... | [
"0.74165326",
"0.73031646",
"0.72919506",
"0.7281328",
"0.72579575",
"0.7236654",
"0.72320426",
"0.72241837",
"0.72063935",
"0.7191499",
"0.71474063",
"0.7143251",
"0.71426344",
"0.71426344",
"0.71402246",
"0.7134233",
"0.7134233",
"0.7113497",
"0.7111423",
"0.7106187",
"0.71... | 0.0 | -1 |
Approximation of unwhitened sum of squares signal energy in a given EP tile. See T1200125 for equation number reference. | def measure_hrss_slowly(z_j_b, lal_filters, spec_corr, psd, delta_t, dof):
# FIXME: Make sure you sum in time correctly
# Number of finest bands in given tile
nb = len(z_j_b)
# eqn. 56 -- unwhitened mean square of filter with itself
uw_ss_ii = numpy.array([uw_sum_sq(lal_filters[i], lal_filters[i], s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_function(self, x):\n \n return -T.dot(T.transpose(x), T.dot(self.W, x)) -\\\n T.dot(T.transpose(self.b), x)",
"def internalenergy(temp,pres):\n g = liq_g(0,0,temp,pres)\n g_t = liq_g(1,0,temp,pres)\n g_p = liq_g(0,1,temp,pres)\n u = g - temp*g_t - pres*g_p\n return u",
... | [
"0.63601464",
"0.62539434",
"0.62245685",
"0.616231",
"0.6084196",
"0.6079508",
"0.60697776",
"0.60441935",
"0.603823",
"0.601595",
"0.5999475",
"0.59755313",
"0.59504557",
"0.59400225",
"0.58925873",
"0.58602667",
"0.5830066",
"0.5821009",
"0.5794547",
"0.5790851",
"0.578870... | 0.0 | -1 |
Returns True if t1 is after t2; false otherwise. | def is_after(t1, t2):
return (t1.hour, t1.minute, t1.second) > (t2.hour, t2.minute, t2.second) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_after(self, other):\n if self.is_before(other) or self == other:\n return False\n else:\n return True",
"def is_after(self, other):\n if self.is_before(other) == False:\n if self != other:\n return True\n return False",
"def isA... | [
"0.7511494",
"0.7428792",
"0.73918927",
"0.72017086",
"0.7096774",
"0.70904505",
"0.6688045",
"0.65591663",
"0.6534562",
"0.6506694",
"0.64707786",
"0.6426176",
"0.6426176",
"0.64058036",
"0.63308537",
"0.6290219",
"0.6253135",
"0.62463325",
"0.6236625",
"0.61826825",
"0.6154... | 0.7214233 | 3 |
Get the Chandle for this object. | def get(self):
return self._partition | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def candle(self):\n return self._decorator_wrapper(EventName.candle)",
"def last_candle(self):\r\n if self.length() > 0:\r\n return self.candles[0]\r\n else:\r\n return None",
"def characteristic_handle(self) -> int:\n return self.__characteristic_handle",
"d... | [
"0.6470328",
"0.6256702",
"0.6147464",
"0.6052278",
"0.60000485",
"0.59595615",
"0.5935613",
"0.57902753",
"0.5737238",
"0.5665406",
"0.5580148",
"0.5514285",
"0.5514285",
"0.5514285",
"0.54378784",
"0.5428972",
"0.5428972",
"0.5322513",
"0.53149897",
"0.5306125",
"0.5275792"... | 0.0 | -1 |
Returns player who has the next turn on a board. | def getPlayer(self):
return self.currentPlayer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None",
"def next_player(self,board, prev_player):\r\n... | [
"0.7911148",
"0.7521969",
"0.74204457",
"0.73687756",
"0.71954805",
"0.69775087",
"0.69621766",
"0.69253695",
"0.69208723",
"0.69010353",
"0.6845991",
"0.6841043",
"0.6838282",
"0.68265843",
"0.67751175",
"0.67751175",
"0.6769739",
"0.6713109",
"0.67060393",
"0.66561204",
"0.... | 0.0 | -1 |
Calculate the autocorrelation function of a time series. This speed of this method is O(n^2) | def acf_slow(d):
if type(d) is list:
d = np.array(d)
# Subtract mean
d -= d.mean(axis=0)
autocorr = np.zeros([len(d)])
for l in range(d.shape[0]): # cycle through lags
N = d.shape[0] - l
for n in range(N):
autocorr[l] += d[n] * d[n + l]
autocorr[l] /= ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_acf(values_in_series):\n\n autocorrelation_by_lag = numpy.correlate(\n values_in_series, values_in_series, mode='same')\n\n # Remove negative lags.\n lag_0_index = numpy.argmax(autocorrelation_by_lag)\n autocorrelation_by_lag = autocorrelation_by_lag[lag_0_index:]\n lags = numpy.... | [
"0.7735281",
"0.75395817",
"0.7440919",
"0.7440919",
"0.7346414",
"0.72815865",
"0.7139987",
"0.70166475",
"0.69921875",
"0.6929242",
"0.6833575",
"0.6820564",
"0.6796687",
"0.67915106",
"0.67695844",
"0.6678685",
"0.66619706",
"0.6660308",
"0.66104496",
"0.656711",
"0.656325... | 0.71557415 | 6 |
read a file with YAML | def _read(self, text):
return yaml.safe_load(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_yaml(file):\n with open(file, mode='r') as stream:\n out = yaml.load(stream)\n\n return out",
"def read_yaml_file(yaml_file):\n with open(yaml_file, 'r') as yfile:\n loaded_file = yaml.safe_load(yfile)\n return loaded_file",
"def load_yaml(file: Text):\n with open(file... | [
"0.784021",
"0.7652534",
"0.7619344",
"0.75680465",
"0.7559281",
"0.7503645",
"0.74814636",
"0.7386022",
"0.7383449",
"0.73474467",
"0.734703",
"0.7327594",
"0.7305",
"0.72601146",
"0.7255489",
"0.7232545",
"0.7222416",
"0.7211228",
"0.7189048",
"0.71708214",
"0.71488625",
... | 0.71801 | 19 |
Return iterable in the same order but with duplicates removed. This works in Python 3.6+ since dictionaries are ordered | def uniques_only_trey_oneline(iterable):
return dict.fromkeys(iterable).keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dedup(iterable):\n return iter(OrderedDict.fromkeys(iterable))",
"def eliminate_duplicates(iterable):\n class NoElement: pass\n\n prev_elem = NoElement\n for elem in sorted(iterable):\n if prev_elem is NoElement:\n prev_elem = elem\n yield elem\n continue\n... | [
"0.81948745",
"0.7385429",
"0.725567",
"0.72229606",
"0.71631867",
"0.7149663",
"0.70712864",
"0.7001986",
"0.6951116",
"0.6946598",
"0.6929761",
"0.6921914",
"0.68927634",
"0.6840553",
"0.67957073",
"0.6725425",
"0.6715183",
"0.6680391",
"0.6673832",
"0.66714597",
"0.6655318... | 0.6339467 | 36 |
A simple view, returning all of the known trucks via a GET method. | def list():
trucks = Foodtruck.query.all()
return jsonify(foodtrucks=[truck.to_dict() for truck in trucks]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foodtruck_list(request):\n\t#print \"foodtruck_list\"\n\tif request.method == 'GET':\n\t\tfoodtrucks = FoodTruck.objects.all()\n\t\tserializer = FoodTruckSerializer(foodtrucks, many=True)\n\t\treturn Response(serializer.data)\n\n\telif request.method == 'POST':\n\t\tserializer = FoodTruckSerializer(data=reques... | [
"0.7183321",
"0.6580369",
"0.6433618",
"0.623038",
"0.6180392",
"0.6180392",
"0.6180392",
"0.6180392",
"0.6180392",
"0.6173764",
"0.61090547",
"0.60794055",
"0.5968324",
"0.5894808",
"0.5882965",
"0.57796127",
"0.5768651",
"0.57647085",
"0.57162154",
"0.56334955",
"0.56268895... | 0.60605496 | 12 |
Guess if a string represents an integer, a float or a string. | def guess_string_format(string):
try:
_ = int(string)
return int
except ValueError:
try:
_ = float(string)
return float
except ValueError:
return str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isFloat(string):\n try: float(string)\n except ValueError: return 0\n else: return 1",
"def is_valid_numeric(inString):\r\n return is_int(inString) or is_float(inString)",
"def is_float(string):\n try:\n return float(string)\n except ValueError:\n return False",
"def isflo... | [
"0.72040254",
"0.7028497",
"0.6930676",
"0.69170105",
"0.6907254",
"0.6810131",
"0.6798136",
"0.6798136",
"0.6781475",
"0.676639",
"0.6757173",
"0.67541885",
"0.67481023",
"0.67467874",
"0.6711003",
"0.670908",
"0.6695139",
"0.6684942",
"0.66145384",
"0.66106594",
"0.65754104... | 0.7209435 | 0 |
This method updates all the boids in the boid_list. It also cages the birds to the screen. Also applies the other acceleration vectors for direction and the center | def update(self,time,position):
v=math3d.VectorN(0,0)
n=math3d.VectorN(0,0)
for boids in self.boid_list:
boids.update(time,position)
if boids.circlePos[0]>=800:
boids.circlePos[0]=800
if boids.circlePos[0]<=0:
boids.circlePos[0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n self.tick()\n\n self.ball.update(self)\n for c in self.balls:\n print(\"updated ball\")\n c.update(self)\n for c in self.balls:\n for z in self.blocks:\n print(\"updated ball/block\")\n collideWithBlock(z... | [
"0.67598754",
"0.6613098",
"0.66030896",
"0.6506299",
"0.6384019",
"0.6108415",
"0.60864866",
"0.60656047",
"0.60605615",
"0.6049861",
"0.60067594",
"0.6001963",
"0.5957287",
"0.59385467",
"0.5938105",
"0.5922463",
"0.5902874",
"0.58866394",
"0.5878988",
"0.58664656",
"0.5837... | 0.6370588 | 5 |
Mean of all negative values in the top q quantile. To prevent the task weight from converging to inf (as a loss of 0 is plausible), a bias is added to the loss. This value should be in the range of the other losses. The loss is first calculated per batch and then averaged over batches. | def top_quantile_positive_constraint(x: Tensor, q: float, bias: float = 0.1) -> Tensor:
if x.dim() != 2:
raise ValueError(
f'operation only supported for 2D tensors (got {x.dim()}D).'
)
if not (0. <= q <= 1.):
raise ValueError(
f'`q` must be in range [0, 1] but ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _weighted_mean_absolute_percentage_error_compute(sum_abs_error: Tensor, sum_scale: Tensor, epsilon: float=1.17e-06) ->Tensor:\n return sum_abs_error / torch.clamp(sum_scale, min=epsilon)",
"def target_loss(self, inp_hist):\n active_targ = self.get_active_target(inp_hist)\n return torch.mean(... | [
"0.64859354",
"0.62392974",
"0.6139379",
"0.6069552",
"0.6067106",
"0.59391665",
"0.58857954",
"0.58789164",
"0.58648175",
"0.585211",
"0.5846",
"0.58099604",
"0.58015126",
"0.5794797",
"0.57792324",
"0.5724701",
"0.5693818",
"0.5665244",
"0.56383383",
"0.5629568",
"0.5619762... | 0.55218285 | 34 |
Mean absolute error (MAE) loss, handels NaN values. | def nanmae(
pred: Tensor,
target: Tensor) -> Tensor:
cnt = torch.any(torch.isfinite(target), dim=-1).sum(dtype=target.dtype)
mae = torch.nansum(torch.abs(pred-target), dim=-1)
return mae.sum() / cnt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_MAE(e):\n\n return np.mean(np.abs(e))",
"def calculate_mae(e):\n return np.mean(np.abs(e))",
"def compute_mae(e):\n return np.mean(np.abs(e))",
"def evaluate_mae(y_true, y_pred):\n\n mae_eval = mean_absolute_error(y_true, y_pred)\n\n return mae_eval",
"def mae(t, y):\n\treturn me... | [
"0.68812037",
"0.66803825",
"0.6660287",
"0.6497328",
"0.64686453",
"0.6456922",
"0.6400183",
"0.6372237",
"0.63696796",
"0.63363314",
"0.6335962",
"0.6325937",
"0.6230878",
"0.6225074",
"0.620972",
"0.6193347",
"0.6192467",
"0.6174726",
"0.61600536",
"0.6080393",
"0.60561436... | 0.7049201 | 0 |
Implementation of the x86 rol instruction. | def ROL(byte, count):
return ((byte << count) | (byte >> (32 - count))) & 0xffffffff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rol(n, rotations=1, width=8):\n rotations %= width\n if rotations < 1:\n return n\n n &= mask(width) ## Should it be an error to truncate here?\n return ((n << rotations) & mask(width)) | (n >> (width - rotations))",
"def rol(n, rotations, width=8):\n rotations %= width\n if rotation... | [
"0.7165254",
"0.71121866",
"0.6180292",
"0.6101773",
"0.6101773",
"0.6101773",
"0.6101773",
"0.59783983",
"0.5917511",
"0.58628976",
"0.5807017",
"0.57683676",
"0.57302815",
"0.57302815",
"0.5688365",
"0.56819534",
"0.5665364",
"0.56240195",
"0.5604291",
"0.55729115",
"0.5555... | 0.511642 | 50 |
Compute the output of the function at the input value(s) `x`. | def __call__(self,x):
arr = np.array(x,copy=False,dtype=float)
res = self._filterfunc(arr.ravel(),*self.parvals)
return res.reshape(arr.shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, x):\n return self.function(x)",
"def fn(self, x):\n\n return math.exp(x*2) - math.exp(x) - 2",
"def fn(self, x):\n\n return math.exp(x*2) - math.exp(x) - 2",
"def my_fn(x):\n return 0.4*(0.5*(np.exp(x*4) - np.exp(-x*4)) - 8*x + 0.3*x**2 - 2*x**3 + 0.8)",
"def get_re... | [
"0.73718786",
"0.72787917",
"0.72787917",
"0.71420735",
"0.6966613",
"0.6925913",
"0.69028556",
"0.6845049",
"0.68385816",
"0.68020797",
"0.6799378",
"0.67661667",
"0.67202246",
"0.67147905",
"0.6687891",
"0.66761696",
"0.66345704",
"0.66076064",
"0.65974927",
"0.65674996",
"... | 0.0 | -1 |
Finds a local minimum for the model. | def minimize(self,x0,method='fmin',**kwargs):
return self._optimize(x0,'min',method,**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min(self):\n return self.min",
"def find_min(self):\n return self.min",
"def get_fmin(self):\n return self.model.predict(self.model.X)[0].min()",
"def find_local_min_x(self, Ns=None):\n if Ns is None:\n Ns = self.num\n with self.fix_evaluator():\n ... | [
"0.7670912",
"0.7670912",
"0.76676595",
"0.7288137",
"0.7208786",
"0.70354706",
"0.7032521",
"0.6977403",
"0.6972407",
"0.69700986",
"0.6926061",
"0.69096446",
"0.69096446",
"0.6869981",
"0.68651783",
"0.6859705",
"0.6813175",
"0.6809171",
"0.680595",
"0.68058",
"0.67931443",... | 0.0 | -1 |
Check if the email OR username already in db | def checkUserExists(self, email, username):
query = "SELECT * FROM User WHERE Email='"+email+"' OR UserName = '"+username+"';"
self.cur.execute(query)
data = self.cur.fetchall()
if len(data):
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_user_from_db(username: str, email: str) -> bool:\n if User.objects.filter(Q(username=username) | Q(email=email)).first():\n raise UniqueUser(\"Пользователь уже существует\")\n else:\n return True",
"def validate_email(self, data, field_name):\n existing = User.objects.filter(... | [
"0.787303",
"0.7488891",
"0.73068523",
"0.7299068",
"0.72565824",
"0.7225294",
"0.71840054",
"0.7180363",
"0.7177107",
"0.71703833",
"0.7124527",
"0.7085896",
"0.70809263",
"0.7060986",
"0.69872713",
"0.69664735",
"0.6935176",
"0.6924156",
"0.69227",
"0.69043344",
"0.68981975... | 0.7829487 | 1 |
Makes name from MAC address unique to each network card | def generate_unique_name():
return 'titanic-' + str(get_mac()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_mac():\n rand_str = generate_name(choices=\"0123456789abcdef\", length=12)\n return \":\".join(re.findall(\"..\", rand_str))",
"def generate_mac():\n rand_str = generate_name(choices=\"0123456789abcdef\", length=12)\n return \":\".join(re.findall(\"..\", rand_str))",
"def get_mac_strin... | [
"0.77104056",
"0.77104056",
"0.7080568",
"0.70453703",
"0.70065475",
"0.6982775",
"0.6940603",
"0.69020206",
"0.68679667",
"0.67746574",
"0.67423177",
"0.6724778",
"0.67189115",
"0.67064834",
"0.67002094",
"0.66889113",
"0.6650022",
"0.6597506",
"0.6565654",
"0.6479159",
"0.6... | 0.7258363 | 2 |
Cleans up EMR output into Kaggle csv format | def post_process_output_file():
parsed_data = []
unparseable_data = []
with open('../output/part-00000', 'r') as input_file:
for line in input_file:
line = line.strip()
try:
csv_splits = line.split(',')
csv_spli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_csv(self, out_folder):\n import pandas as pd\n\n df = pd.DataFrame(zip(self.results['cids'],\n self.results['differences'],\n self.results['experimental_values']),\n columns=['cids', 'differences',\n ... | [
"0.6288476",
"0.6248816",
"0.59843725",
"0.58115685",
"0.5757058",
"0.5735818",
"0.571397",
"0.56865567",
"0.56739",
"0.5652337",
"0.5648782",
"0.5646039",
"0.5634061",
"0.5621876",
"0.5577428",
"0.55388415",
"0.5537008",
"0.5529574",
"0.55197775",
"0.5510212",
"0.5490069",
... | 0.527783 | 47 |
with probability P, replace nodes with random feedforward regulons | def recurse(hp):
global G
nodes = G.nodes(data=True)
p_insert = hp.p_insert if count_boxes() > hp.initial_boxes else 1.
for node in nodes:
try:
if node[1]["shape"] is "square":
if random.random() < p_insert:
insert_motif(hp, id=node[0])
exc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutate_nonstructural(self):\n # TODO consider clamping weights and biases?\n for link in self.gene_links:\n # Disable/Enable links\n if event(link_toggle_prob): # Chance of toggling link\n link.enabled = True if link.enabled is False else False\n i... | [
"0.64214045",
"0.64182",
"0.63031924",
"0.60669047",
"0.60192364",
"0.5956496",
"0.5953079",
"0.59085584",
"0.58748174",
"0.58664787",
"0.5812515",
"0.5787991",
"0.57766044",
"0.5762312",
"0.57369924",
"0.5724387",
"0.5721887",
"0.5714858",
"0.5704319",
"0.5682425",
"0.566576... | 0.0 | -1 |
The forward function for the GroverFunctionalGroupPredictor (semantic motif prediction) layer. It takes atom/bond embeddings produced from node and bond hidden states from GroverEmbedding module and the atom, bond scopes and produces prediction logits for different each embedding. The scopes are used to differentiate a... | def forward(self, embeddings: Dict, atom_scope: List, bond_scope: List):
preds_bond_from_atom = self.linear_bond_from_atom(
self.readout(embeddings["bond_from_atom"], bond_scope))
preds_bond_from_bond = self.linear_bond_from_bond(
self.readout(embeddings["bond_from_bond"], bond_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_pass_fc(self, embeddings):\n with tf.variable_scope('fc', reuse=tf.AUTO_REUSE):\n embedding_dims = embeddings.get_shape().as_list()[-1]\n # Always maps to a space whose dimensionality is the number of classes\n # at meta-training time.\n w_fc = weight_variable([embedding_dims, se... | [
"0.5871899",
"0.5671492",
"0.54299814",
"0.5419425",
"0.54140234",
"0.53628427",
"0.5310061",
"0.52689236",
"0.5240053",
"0.5199414",
"0.5178958",
"0.5170266",
"0.51133317",
"0.50984645",
"0.5093212",
"0.50851935",
"0.50787383",
"0.5069935",
"0.5057529",
"0.5055849",
"0.50544... | 0.5502521 | 2 |
Selects the message features from source corresponding to the atom or bond indices in index. | def _index_select_nd(source: torch.Tensor, index: torch.Tensor) -> torch.Tensor:
index_size = index.size() # (num_atoms/num_bonds, max_num_bonds)
suffix_dim = source.size()[1:] # (hidden_size,)
final_size = index_size + suffix_dim # (num_atoms/num_bonds, max_num_bonds, hidden_size)
target = source.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_vectors_using_index(src_tensor, index_tensor) -> torch.FloatTensor:\n if index_tensor.size()[-1] != 1:\n raise ValueError(\"Expecting last index to be 1. Found {}\".format(index_tensor.size()))\n flat_idx_tensor = index_tensor.view(index_tensor.size(0), -1, 1) # B * CP * 1\n\n # B * CP ... | [
"0.57587135",
"0.567538",
"0.5464777",
"0.5415628",
"0.5394167",
"0.53540564",
"0.53370816",
"0.53158647",
"0.531273",
"0.52664036",
"0.524895",
"0.51557934",
"0.5135974",
"0.51354283",
"0.5119744",
"0.5088901",
"0.50476474",
"0.504218",
"0.50391346",
"0.49722013",
"0.4962011... | 0.6307741 | 0 |
Checks validity of rotation matrices. Raises TypeError If the rotation matrices are not valid types. ValueError If the rotation matrices are not valid shapes. | def _rotations_guard_clauses(R1: Union[list, np.ndarray], R2: Union[list, np.ndarray]) -> None:
for label, rotation_matrix in zip(['R1', 'R2'], [R1, R2]):
if not isinstance(rotation_matrix, (list, np.ndarray)):
raise TypeError(f"{label} must be an array. Got {type(rotation_matrix)}")
r1, r2 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_asssert_rotation_matrix_behaves_like_check_matrix():\n random_state = np.random.RandomState(2345)\n for _ in range(5):\n a = pr.random_axis_angle(random_state)\n R = pr.matrix_from_axis_angle(a)\n original_value = R[2, 2]\n for error in [0, 1e-8, 1e-7, 1e-5, 1e-4, 1]:\n ... | [
"0.6436697",
"0.6334364",
"0.62727654",
"0.61362",
"0.6064522",
"0.6042975",
"0.60379344",
"0.60021853",
"0.5986439",
"0.59339076",
"0.5773826",
"0.57531196",
"0.5742311",
"0.56832695",
"0.5648835",
"0.56157583",
"0.55678475",
"0.55671436",
"0.55496097",
"0.5510357",
"0.54628... | 0.64847517 | 0 |
Checks validity of quaternions. Raises TypeError If the quaternions are not valid types. ValueError If the quaternions are not valid shapes. | def _quaternions_guard_clauses(q1: Union[list, np.ndarray], q2: Union[list, np.ndarray]) -> None:
for label, quaternion in zip(['q1', 'q2'], [q1, q2]):
if not isinstance(quaternion, (list, np.ndarray)):
raise TypeError(f"{label} must be an array. Got {type(quaternion)}")
q1, q2 = np.copy(q1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_quaternions():\n Q_list = [[1, 0, 0, 0]]\n Q = pr.check_quaternions(Q_list)\n assert_array_almost_equal(Q_list, Q)\n assert_equal(type(Q), np.ndarray)\n assert_equal(Q.dtype, np.float64)\n assert_equal(Q.ndim, 2)\n assert_array_equal(Q.shape, (1, 4))\n\n Q = np.array([\n ... | [
"0.7567907",
"0.75199366",
"0.64795345",
"0.63153595",
"0.6238377",
"0.6038222",
"0.60075325",
"0.60049284",
"0.58727884",
"0.5844665",
"0.5765659",
"0.56890297",
"0.56494164",
"0.5642835",
"0.5610702",
"0.55680317",
"0.5567554",
"0.55621505",
"0.5528193",
"0.55151206",
"0.54... | 0.71484584 | 2 |
Euclidean distance between two unit quaternions as defined in [Huynh]_ and | def qdist(q1: np.ndarray, q2: np.ndarray) -> float:
_quaternions_guard_clauses(q1, q2)
q1, q2 = np.copy(q1), np.copy(q2)
if q1.ndim == 1:
q1 /= np.linalg.norm(q1)
q2 /= np.linalg.norm(q2)
if np.allclose(q1, q2) or np.allclose(-q1, q2):
return 0.0
return min(np.lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(cls, q0, q1):\n q = Quaternion.log_map(q0, q1)\n return q.norm",
"def quat_diff(q1, q2):\n q1 = np.asarray(q1)\n if np.dot(q1, q2) < 0:\n # Quaternions have opposite handedness, flip q1 since it's already an ndarray\n q1 = -1 * q1\n q_inv = q1 * np.array([1.0, -1... | [
"0.7577467",
"0.7440493",
"0.7182569",
"0.6882823",
"0.6804164",
"0.6797553",
"0.6726708",
"0.6678801",
"0.6657061",
"0.66298974",
"0.65738976",
"0.6568971",
"0.6567321",
"0.6479824",
"0.6473558",
"0.6413479",
"0.64032185",
"0.6400051",
"0.63728106",
"0.6357321",
"0.6345775",... | 0.7589446 | 0 |
Given a state batch, I want to remove the second dimension, because it's useless and prevents me from feeding the tensor into my CNN | def process_state_batch(self, batch):
return np.squeeze(batch, axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _drop_batch_shape(self, tensor: tf.Tensor):\n tensor_shape = tensor._shape_as_list()\n if len(tensor_shape) < 3: return tensor\n if tensor_shape[0] != 1: raise Exception(\"KalmanFilterWithSparseSites doesn't support batches\")\n\n return tf.squeeze(tensor, axis=0)",
"def process_s... | [
"0.6956802",
"0.6865693",
"0.6460208",
"0.6453441",
"0.6198062",
"0.60029525",
"0.60029525",
"0.6002362",
"0.59786546",
"0.5968577",
"0.5959629",
"0.5927282",
"0.5923967",
"0.58983195",
"0.58892363",
"0.5799725",
"0.5764765",
"0.576043",
"0.5757455",
"0.57512915",
"0.5729642"... | 0.7006635 | 0 |
Retrieves id of this space | def id(self):
return self.values.get('id') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_id(self):\n return self.id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n ... | [
"0.728139",
"0.72283375",
"0.72283375",
"0.72283375",
"0.72283375",
"0.72283375",
"0.72283375",
"0.7203751",
"0.71871567",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824",
"0.7169824... | 0.0 | -1 |
Produce a bytestring corresponding to the current bitfield | def __bytes__(self):
bits = self + [False] * (-len(self) % 8)
return bytes(BITCHARMAP[tuple(bits[x:x + 8])]
for x in range(0, len(bits), 8)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitfield_to_string(bitfield):\n retval = bytearray((len(bitfield) + 7) // 8)\n\n for piece, bit in enumerate(bitfield):\n if bit:\n retval[piece // 8] |= 1 << (7 - piece % 8)\n\n return bytes(retval)",
"def _get_bit_string(value):\n\n return \"{0:b}\".format(value).zfill(8)",
... | [
"0.7677098",
"0.7360045",
"0.70953596",
"0.6509801",
"0.64925027",
"0.64826536",
"0.6464648",
"0.63824284",
"0.63370824",
"0.6318414",
"0.62691694",
"0.6258679",
"0.6201738",
"0.61771345",
"0.60064477",
"0.5992814",
"0.5947659",
"0.59398174",
"0.59239656",
"0.59044915",
"0.58... | 0.69402146 | 3 |
Map a day to the last business day of its month. | def _to_ceiling_busi_day(date):
try:
date = parse(date)
except TypeError:
date = date
date = date.replace(day=1)
ceiling_busi_day = pd.date_range(date, periods=1, freq='BM').strftime('%Y-%m-%d')[0]
return ceiling_busi_day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_month(d):\n return date(d.year, d.month, monthrange(d.year, d.month)[1])",
"def get_business_day_of_month(year, month, count):\n r = rrule.rrule(\n rrule.MONTHLY, byweekday=(rrule.MO, rrule.TU, rrule.WE, rrule.TH, rrule.FR),\n dtstart=datetime.datetime(year, month, 1),\n bysetp... | [
"0.6417374",
"0.6355838",
"0.61985475",
"0.61226815",
"0.6090505",
"0.60846263",
"0.60735995",
"0.59315777",
"0.5874385",
"0.5874385",
"0.57873386",
"0.5709538",
"0.5537759",
"0.5517917",
"0.542579",
"0.5410117",
"0.5409074",
"0.5391374",
"0.5378327",
"0.53561866",
"0.5353224... | 0.55174416 | 14 |
Map multiple days to the last business days of their month. | def to_ceiling_busi_day(*args):
ceiling_busi_day = [DateUtils._to_ceiling_busi_day(date) for date in args]
return ceiling_busi_day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_business_day_of_month(year, month, count):\n r = rrule.rrule(\n rrule.MONTHLY, byweekday=(rrule.MO, rrule.TU, rrule.WE, rrule.TH, rrule.FR),\n dtstart=datetime.datetime(year, month, 1),\n bysetpos=count)\n res = r[0]\n if (res is None or res.month != month or res.year != year)... | [
"0.59864277",
"0.5939895",
"0.589658",
"0.5844983",
"0.5735029",
"0.57322353",
"0.57030416",
"0.568024",
"0.5626477",
"0.56121117",
"0.55622965",
"0.55086684",
"0.54662234",
"0.54576164",
"0.5416095",
"0.53992",
"0.5388589",
"0.5363166",
"0.5361785",
"0.53025377",
"0.52599233... | 0.5551857 | 11 |
Map a day to the previous last business day of its month. | def _to_floor_busi_day(date):
try:
date = parse(date)
except TypeError:
date = date
date = date + relativedelta(months=-1)
date = date.replace(day=1)
floor_busi_day = pd.date_range(date, periods=1, freq='BM').strftime("%Y-%m-%d")[0]
return floor_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_month():\n return datetime.now() + relativedelta(months=-1)",
"def floor_end_month(date):\n return datetime(date.year, date.month, 1) + timedelta(days=-1)",
"def last_month_day():\r\n return (datetime.now().replace(day=1) + relativedelta(months=1) + timedelta(days=-1)).strftime(\r\n '%... | [
"0.5708739",
"0.57057786",
"0.5704799",
"0.56521344",
"0.5583704",
"0.55392194",
"0.55337304",
"0.54691386",
"0.54078746",
"0.54078746",
"0.5379643",
"0.5368529",
"0.53611714",
"0.5352234",
"0.53521615",
"0.528622",
"0.52817905",
"0.52368283",
"0.5191346",
"0.51579076",
"0.50... | 0.44358882 | 65 |
Calculates the Euclidean distance between two points. | def euclidean_distance(x, y):
distance = 0
for i, j in zip(x, y):
distance += (i - j) ** 2
return math.sqrt(distance) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, point2)]))",
"def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-point_two)",
"def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array... | [
"0.8550962",
"0.84894866",
"0.842017",
"0.83857816",
"0.836532",
"0.83231467",
"0.8295445",
"0.8293594",
"0.8259977",
"0.8207562",
"0.8182812",
"0.8158064",
"0.8147019",
"0.8116608",
"0.8050444",
"0.8009833",
"0.7977984",
"0.79753816",
"0.7974776",
"0.7961696",
"0.7955595",
... | 0.79395825 | 21 |
Read meta data file using Pandas. | def read_meta_data(data_dir):
meta_data = pd.read_csv(join(data_dir, 'index.csv'))
return meta_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_metadata(self, file=None):\n if file is None:\n file = self.meta_data_file\n\n try:\n self.meta_data = self.input_dataframe(file, index_col=None)\n except IOError:\n self.meta_data = self.create_default_meta_data(self.expression_matrix)",
"def read_m... | [
"0.73386085",
"0.73341453",
"0.73341453",
"0.7113683",
"0.6679284",
"0.6670796",
"0.6660636",
"0.6637433",
"0.6594487",
"0.6589895",
"0.6552023",
"0.648536",
"0.64826113",
"0.6464248",
"0.6450424",
"0.6450424",
"0.6433928",
"0.6360513",
"0.6343204",
"0.6341269",
"0.63369244",... | 0.74914736 | 0 |
Get size of dataset. | def __len__(self):
return len(self.meta_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset_size(self):\n return self.dataset.size",
"def get_size(self):\n return self._data_size",
"def __len__(self):\n return self._dataset.size(dirs=self._dirs)",
"def dataset_size(self):\n if not self._dataset_size:\n # pylint: disable=attribute-defined-outside-in... | [
"0.88441783",
"0.8155916",
"0.8047864",
"0.80127466",
"0.7962023",
"0.792798",
"0.7917013",
"0.7845642",
"0.7826513",
"0.7826513",
"0.7826513",
"0.7826513",
"0.78204846",
"0.77418983",
"0.77418983",
"0.77418983",
"0.77418983",
"0.77418983",
"0.7731975",
"0.77085286",
"0.76258... | 0.0 | -1 |
Tests tokenize function creates tokens no shorter than min_words long | def test_tokenize_min_words(self):
obj_ut = list(sentiment.tokenize(
['a', 'brown', 'cat', 'chases', 'mice'], min_words=2))
self.assertEqual(obj_ut,
[('a brown', 0),
('brown cat', 1),
('cat chases', 2),
('chases mice', 3)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenizer(s):\n\n tokens = tokenize(s.lower()) # apply the nltk tokenizer\n tokens = [t for t in tokens if doc_frequency[t]>5 and t not in stop_words]# and doc_frequency[t]<3000]\n \n return tokens",
"def test_tokenize_max_words(self):\n\t\tobj_ut = list(sentiment.tokenize(\n\t\t\t['a', 'brown',... | [
"0.7178936",
"0.7139372",
"0.71374404",
"0.70634365",
"0.70067215",
"0.6993733",
"0.68765354",
"0.6846928",
"0.6774793",
"0.67073464",
"0.6659778",
"0.6634745",
"0.6617235",
"0.6605715",
"0.6545629",
"0.6414513",
"0.64069164",
"0.64044225",
"0.63662624",
"0.63547283",
"0.6330... | 0.7823009 | 0 |
Tests tokenize function creates 1word tokens when no min_words or max_words args are provided | def test_tokenize_no_min_no_max(self):
obj_ut = list(sentiment.tokenize(
['a', 'brown', 'cat', 'chases', 'mice']))
self.assertEqual(obj_ut,
[('a', 0), ('brown', 1), ('cat', 2), ('chases', 3), ('mice', 4)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tokenize_min_words(self):\n\t\tobj_ut = list(sentiment.tokenize(\n\t\t\t['a', 'brown', 'cat', 'chases', 'mice'], min_words=2))\n\t\tself.assertEqual(obj_ut, \n\t\t\t[('a brown', 0), \n\t\t\t('brown cat', 1), \n\t\t\t('cat chases', 2), \n\t\t\t('chases mice', 3)])",
"def tokenize_text(self, text, maxword... | [
"0.7436839",
"0.6962107",
"0.6933279",
"0.6725482",
"0.6522635",
"0.6473286",
"0.6404335",
"0.63993233",
"0.6357763",
"0.6343346",
"0.63339347",
"0.6265903",
"0.62342936",
"0.6190195",
"0.6174405",
"0.61577135",
"0.61543953",
"0.6147295",
"0.61462885",
"0.6126319",
"0.6117012... | 0.7068394 | 1 |
Tests tokenize function creates tokens up to max_words long | def test_tokenize_max_words(self):
obj_ut = list(sentiment.tokenize(
['a', 'brown', 'cat', 'chases', 'mice'], max_words=4))
self.assertEqual(obj_ut,
[('a', 0), ('brown', 1), ('cat', 2), ('chases', 3), ('mice', 4),
('a brown', 0), ('brown cat', 1), ('cat chases', 2), ('chases mice', 3),
('a brown cat', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize_text(self, text, maxword=options[\"Tokenizer\",\n \"skip_max_word_size\"]):\n short_runs = set()\n short_count = 0\n for w in text.split():\n n = len(w)\n if n < 3:\n # count how many short words... | [
"0.7556813",
"0.72685426",
"0.6943897",
"0.68935955",
"0.6874114",
"0.6840428",
"0.6838501",
"0.6838501",
"0.6838501",
"0.6838501",
"0.6837977",
"0.68116516",
"0.6788256",
"0.6761216",
"0.6755642",
"0.6713281",
"0.6690313",
"0.6601749",
"0.65600353",
"0.6542224",
"0.6530406",... | 0.7695473 | 0 |
Tests tokenize function correctly defaults to 1word tokens if zero values given for min_words or max_words | def test_tokenize_zero_value(self):
text = ['a', 'brown', 'cat', 'chases', 'mice']
min_words = max_words = 0
args = [text, min_words, max_words]
func = sentiment.tokenize
self.assertRaises(sentiment.SentimentException,
lambda y: list(func(*y)), args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tokenize_min_words(self):\n\t\tobj_ut = list(sentiment.tokenize(\n\t\t\t['a', 'brown', 'cat', 'chases', 'mice'], min_words=2))\n\t\tself.assertEqual(obj_ut, \n\t\t\t[('a brown', 0), \n\t\t\t('brown cat', 1), \n\t\t\t('cat chases', 2), \n\t\t\t('chases mice', 3)])",
"def test_tokenize_no_min_no_max(self)... | [
"0.74428505",
"0.7395102",
"0.70649135",
"0.68296355",
"0.677883",
"0.6558463",
"0.65152246",
"0.63875896",
"0.6341141",
"0.6312081",
"0.6247154",
"0.6231889",
"0.62297887",
"0.62283695",
"0.6222513",
"0.6222513",
"0.62158126",
"0.6210395",
"0.618864",
"0.6182444",
"0.6172443... | 0.67089224 | 5 |
Return the current datetime object of the server. | def getCurServerDateTime(self):
secondsPassed = globalClock.getRealTime() - self.globalClockRealTimeUponLogin + \
self.debugSecondsAdded
curDateTime = self.serverTimeZone.normalize(
self.serverDateTime + timedelta(seconds=secondsPassed))
return curDateTime | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_datetime ( ) :\n return datetime.datetime.now( )",
"def get_now():\n return dt.datetime.now(dt.timezone.utc)",
"def _get_now():\n return datetime.now(tz=timezone.utc)",
"def now():\r\n return datetime.datetime.now()",
"def get_current_time():\n return datetime.now()",
... | [
"0.81210876",
"0.76823807",
"0.76795286",
"0.7664812",
"0.7620383",
"0.7618343",
"0.7618343",
"0.7590834",
"0.75568765",
"0.75568765",
"0.7551887",
"0.75388426",
"0.7509153",
"0.75063294",
"0.74833375",
"0.74776167",
"0.74554366",
"0.7400479",
"0.73609203",
"0.7358235",
"0.73... | 0.7511773 | 12 |
Return the current UNnormalized datetime object of the server. | def getCurServerDateTimeForComparison(self):
# PartyInfo.startTime is in PST, this force the return value to always be in PST
secondsPassed = globalClock.getRealTime() - self.globalClockRealTimeUponLogin + \
self.debugSecondsAdded
curDateTime = self.serverDateTime + timed... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def now(cls):\n return DateTime(*time.localtime())",
"def _get_now():\n return datetime.now(tz=timezone.utc)",
"def getCurServerDateTime(self):\n secondsPassed = globalClock.getRealTime() - self.globalClockRealTimeUponLogin + \\\n self.debugSecondsAdded\n curDateT... | [
"0.7253964",
"0.7118432",
"0.7106112",
"0.6988884",
"0.6962494",
"0.69610417",
"0.69600457",
"0.69148326",
"0.6908834",
"0.68999445",
"0.6885034",
"0.68571126",
"0.6829407",
"0.6796175",
"0.67898667",
"0.67872626",
"0.6786502",
"0.6783718",
"0.6766852",
"0.6760221",
"0.675341... | 0.66299164 | 29 |
Return a string representation of the current server time. | def getCurServerTimeStr(self):
curDateTime = self.getCurServerDateTime()
result = curDateTime.strftime(self.ClockFormat)
if result[0] == '0':
result = result [1:]
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_now() -> str:\n return datetime_to_str(datetime_now())",
"def servertime(self):\r\n return servertime.Servertime(self)",
"def get_current_timestamp_str(self):\n return str(time.mktime(datetime.datetime.now().timetuple()))",
"def time_str(self):\n return datetime.now().strftim... | [
"0.7767128",
"0.7660021",
"0.7591328",
"0.7591238",
"0.7590785",
"0.75155073",
"0.7464057",
"0.7463064",
"0.73918265",
"0.73857415",
"0.73349476",
"0.7334551",
"0.73203987",
"0.7296026",
"0.727787",
"0.727787",
"0.727607",
"0.7248114",
"0.72119623",
"0.7204593",
"0.7149526",
... | 0.7998153 | 0 |
Converts a date string and returns a last logged in time, any errors returns current server time. | def convertStrToToontownTime(self, dateStr):
curDateTime = self.getCurServerDateTime()
try:
# warning time.mktime was giving a different result in published build vs
# what I was seeing in my local dev environment, it was ahead by 1 hour
# interpretation of the -1 for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date_str_time(self, dt_str):\n return self.get_hr_min_sec(dt_str.split(' ')[1])",
"def get_time():\r\n \r\n dt = datetime.datetime.now()\r\n dt_parsed = dt.strftime(\"%Y-%m-%d %H:%M:%S\")\r\n return dt_parsed",
"def get_last(self):\n last = self.site.sidereal_time()\n d... | [
"0.63558567",
"0.6307519",
"0.62726545",
"0.62036693",
"0.62036693",
"0.61592233",
"0.6059284",
"0.60283744",
"0.5964704",
"0.5956724",
"0.58997905",
"0.58327717",
"0.58205825",
"0.57993823",
"0.5776358",
"0.57730126",
"0.57726294",
"0.57644075",
"0.57569486",
"0.57569486",
"... | 0.58196574 | 13 |
For a given value return the distributions pdf value | def getPDFValue(self, value):
pdfValue = self.pdfSample.get(value, None)
if pdfValue != None:
return pdfValue
pdfValue = self.__pdfFunction(value)
self.pdfSample[value] = pdfValue
return pdfValue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf(self, value=None):\n if value is None:\n value = self.value\n return self.rv.pdf(\n value, *self._pymc_dists_to_value(self.args), **self.kwds\n )",
"def pdf(self,x):\n if x in self.values:\n pdfValue = self.mapping[x]\n else:\n ... | [
"0.7795019",
"0.77185094",
"0.76879877",
"0.76879877",
"0.76497275",
"0.7582317",
"0.74036366",
"0.7308391",
"0.72494185",
"0.721395",
"0.71842057",
"0.7161197",
"0.7100504",
"0.7054195",
"0.70429176",
"0.7018095",
"0.70162594",
"0.69983196",
"0.69874555",
"0.6959895",
"0.695... | 0.71282244 | 12 |
Return the distributions pdf value | def getPDF(self):
return self.pdfSample | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf(self,x):\n returnPdf = self._distribution.pdf(x)\n return returnPdf",
"def pdf(self,x):\n coordinate = distribution1D.vectord_cxx(len(x))\n for i in range(len(x)):\n coordinate[i] = x[i]\n pdfValue = self._distribution.pdf(coordinate)\n return pdfValue",
"def pdf(self,x):\n co... | [
"0.79719913",
"0.7856866",
"0.7856866",
"0.7755001",
"0.77126354",
"0.75632846",
"0.74612856",
"0.74053645",
"0.7390061",
"0.7336582",
"0.7323256",
"0.7246222",
"0.72140604",
"0.7188575",
"0.71725005",
"0.71304256",
"0.7127767",
"0.7126612",
"0.71046823",
"0.7089801",
"0.7069... | 0.66864616 | 49 |
For a given value return the distributions cdf value | def getCDFValue(self, value):
cdfValue = self.cdfSample.get(value, None)
if cdfValue != None:
return cdfValue
cdfValue = self.cdfFunction(value)
self.cdfSample[value] = cdfValue
return cdfValue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(self, value):\n return self._normal.cdf(value)",
"def cdf(self, value):\n cdf = torch.where(\n value < 1., \n self.base.cdf(value), \n torch.ones_like(value) # all of the mass\n )\n cdf = torch.where(value < 0., torch.zeros_like(cdf)... | [
"0.8412861",
"0.8279831",
"0.80099815",
"0.7779055",
"0.7683178",
"0.7653447",
"0.7653447",
"0.76445764",
"0.74256355",
"0.739681",
"0.7223585",
"0.72195387",
"0.7132974",
"0.70386225",
"0.70377827",
"0.7030018",
"0.69915074",
"0.694934",
"0.69286174",
"0.6925641",
"0.6891278... | 0.71978915 | 12 |
Return the distributions cdf value | def getCDF(self):
return self.cdfSample | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(self, value):\n return self._normal.cdf(value)",
"def cdf(self,x):\n return self.categoricalDist.cdf(x)",
"def cdf(self, value):\n cdf = torch.where(\n value < 1., \n self.base.cdf(value), \n torch.ones_like(value) # all of the mass\n ... | [
"0.8097849",
"0.79469645",
"0.7820513",
"0.7785864",
"0.7697637",
"0.7697637",
"0.76924103",
"0.7676411",
"0.74098766",
"0.7403379",
"0.7359594",
"0.7295659",
"0.72411484",
"0.7011814",
"0.69938797",
"0.69807535",
"0.69708544",
"0.69696635",
"0.6960342",
"0.6796876",
"0.67924... | 0.75616944 | 8 |
Test time to seconds conversion. | def test_time_to_seconds(self):
correct_time = "1970-01-01T00:00:05+00:00"
wrong_time = "1/1/1970 00:00:03"
self.assertEqual(time_to_seconds(correct_time), 5)
self.assertFalse(time_to_seconds(wrong_time)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_seconds(time):\n return 3600 * time",
"def test_interval_to_seconds_with_seconds(self):\n self.assert_interval_to_seconds(0, \"0s\", \"0second\", \"0seconds\")\n self.assert_interval_to_seconds(1, \"1s\", \"1second\", \"1seconds\")\n self.assert_interval_to_seconds(60, \"60s\", \"6... | [
"0.7364642",
"0.73522073",
"0.69063056",
"0.68669313",
"0.67898095",
"0.6637118",
"0.6598444",
"0.6592258",
"0.65606076",
"0.6547641",
"0.65475935",
"0.6547375",
"0.6511577",
"0.6507475",
"0.6489566",
"0.64760095",
"0.64410436",
"0.6419421",
"0.640136",
"0.6395666",
"0.639205... | 0.78760225 | 0 |
Predicts labels probabilities for sequences in X. Default behaviour is to call _predict and set the predicted class probability to 1, other class probabilities to 0. Override if better estimates are obtainable. | def predict_proba(self, X):
self.check_is_fitted()
X = self._check_clusterer_input(X)
return self._predict_proba(X) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, X):\n prob = self.predict_proba(X)\n if self.rule == 'fda':\n prob_1 = prob[:, :self.n_class_]\n prob_2 = prob[:, self.n_class_:]\n return np.vstack((self.labels_[prob_1.argmax(1)], self.labels_[prob_2.argmax(1)]))\n else:\n return ... | [
"0.76805025",
"0.7619194",
"0.75322515",
"0.73527807",
"0.733651",
"0.73364085",
"0.73246306",
"0.73153305",
"0.73053825",
"0.7301052",
"0.72857374",
"0.72740185",
"0.72740185",
"0.7248252",
"0.720821",
"0.719479",
"0.71689826",
"0.7145303",
"0.71434736",
"0.71353424",
"0.712... | 0.0 | -1 |
Predicts labels probabilities for sequences in X. Default behaviour is to call _predict and set the predicted class probability to 1, other class probabilities to 0. Override if better estimates are obtainable. | def _predict_proba(self, X):
preds = self._predict(X)
n_instances = len(preds)
if hasattr(self, "n_clusters") and self.n_clusters is not None:
n_clusters = self.n_clusters
else:
n_clusters = max(preds) + 1
dists = np.zeros((X.shape[0], n_clusters))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, X):\n prob = self.predict_proba(X)\n if self.rule == 'fda':\n prob_1 = prob[:, :self.n_class_]\n prob_2 = prob[:, self.n_class_:]\n return np.vstack((self.labels_[prob_1.argmax(1)], self.labels_[prob_2.argmax(1)]))\n else:\n return ... | [
"0.76805025",
"0.7619194",
"0.75322515",
"0.73527807",
"0.733651",
"0.73364085",
"0.73246306",
"0.73153305",
"0.73053825",
"0.7301052",
"0.72857374",
"0.72740185",
"0.72740185",
"0.7248252",
"0.720821",
"0.719479",
"0.71689826",
"0.7145303",
"0.71434736",
"0.71353424",
"0.712... | 0.0 | -1 |
Remove all boxes with any side smaller than min_size. | def _filter_boxes(boxes, min_size):
ws = boxes[:, 2] - boxes[:, 0] + 1
hs = boxes[:, 3] - boxes[:, 1] + 1
keep = np.where((ws >= min_size) & (hs >= min_size))[0]
return keep | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_small_boxes(boxes, min_size):\r\n ws, hs = boxes[:, 2] - boxes[:, 0], boxes[:, 3] - boxes[:, 1]\r\n keep = (ws >= min_size) & (hs >= min_size)\r\n keep = np.where(keep)[0]\r\n return keep",
"def remove_small_boxes(boxlist, min_size):\n # TODO maybe add an API for querying the ws / hs\n ... | [
"0.844285",
"0.81151116",
"0.7921694",
"0.7921694",
"0.79018307",
"0.7636337",
"0.75476605",
"0.66610324",
"0.6600835",
"0.6247463",
"0.6089499",
"0.6043841",
"0.59839225",
"0.59649944",
"0.59573674",
"0.58060014",
"0.57966226",
"0.5783344",
"0.5774629",
"0.57445675",
"0.5741... | 0.78406245 | 5 |
Updates weights. Negative Hebbian update (unlearn) | def update_weights_negative(self):
eta = self.config.eta
self.w_xh -= eta * (self.x.T @ self.h)
self.w_th -= eta * (self.t.T @ self.h)
self.w_ho -= eta * (self.h.T @ self.o)
self.w_hz -= eta * (self.h.T @ self.z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\n self.weights -= self.loss_grads\n self.loss_grads = np.zeros(self.weights.shape)",
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_we... | [
"0.7873968",
"0.7873195",
"0.78386354",
"0.7715271",
"0.7577719",
"0.7513132",
"0.74567974",
"0.74028665",
"0.72505033",
"0.7126775",
"0.70925975",
"0.7029768",
"0.70059425",
"0.69631034",
"0.69447905",
"0.69251555",
"0.6880043",
"0.6856809",
"0.68467754",
"0.6846533",
"0.684... | 0.8130028 | 0 |
Constructor for the MapReduceAuxData class | def __init__(self,
pattern_vec=None,
):
# Initialize members of the class
self.pattern_vec = pattern_vec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n data_extract=DataExtracter()\n self.data = tuple()",
"def __init__(self):\n self.model = None\n self.joined_datasets = None\n self.id_col = None\n self.val_col = None\n self.pop_col = None\n self.total_population_per_unit = None\n ... | [
"0.62819743",
"0.597591",
"0.59606344",
"0.59390336",
"0.5924592",
"0.5921895",
"0.59106183",
"0.58837575",
"0.5882265",
"0.58619475",
"0.5854151",
"0.58410925",
"0.5837465",
"0.5819172",
"0.581583",
"0.58150274",
"0.5802492",
"0.5795226",
"0.57949543",
"0.57782996",
"0.57728... | 0.0 | -1 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
pattern_vec = None
if dictionary.get('patternVec') != None:
pattern_vec = list()
for structure in dictionary.get('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83181584",
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",... | 0.0 | -1 |
Return the name of the sensor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91896784",
"0.9168378",
"0.890185",
"0.8770976",
"0.8511273",
"0.8479953",
"0.844435",
"0.8299758",
"0.8186503",
"0.8105667",
"0.8079737",
"0.8066149",
"0.8049647",
"0.7700968",
"0.7612295",
"0.7611456",
"0.7600605",
"0.7600605",
"0.7600605",
"0.75392073",
"0.75166553",
... | 0.0 | -1 |
Return the state attributes of the sensor. | def device_state_attributes(self):
return self._attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self) -> Dict[str, any]:\n return self._device.state_attributes",
"def d... | [
"0.8418945",
"0.8243777",
"0.8243777",
"0.8200083",
"0.8169021",
"0.8169021",
"0.8159991",
"0.8159991",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"... | 0.82497084 | 1 |
Inits Queue with empty double ended queue | def __init__(self):
self.queue = deque() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __post_init__(self) -> None:\n self.gtex += [None]\n self.bm += [None]\n self._q: queue.Queue = queue.Queue(maxsize=self.maxsize)",
"def __init__(self):\n self.queue = []\n self.queue.append(Queue())\n self.queue.append(Queue())\n self.tag = 0 # using to recor... | [
"0.7694868",
"0.7457041",
"0.74498767",
"0.743925",
"0.7283713",
"0.7276494",
"0.7248483",
"0.7242406",
"0.72088766",
"0.70874584",
"0.70587325",
"0.70511174",
"0.7042047",
"0.7026834",
"0.7009527",
"0.70026433",
"0.69568497",
"0.69568497",
"0.69568497",
"0.69568497",
"0.6956... | 0.7038382 | 15 |
Returns True if Queue is empty | def is_empty(self):
return len(self.queue) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.queue == []",
"def is_empty(self):\n return len(self.__queue) > 0",
"def empty(self) -> bool:\n if self.queue.empty():\n return True\n else:\n return False",
"def is_empty(self):\n return len(self.the_queue) == 0",
"... | [
"0.9193944",
"0.91158444",
"0.91068226",
"0.9096734",
"0.90714824",
"0.9039081",
"0.90290016",
"0.90068",
"0.89579934",
"0.8913944",
"0.88941854",
"0.88941854",
"0.8888737",
"0.8878628",
"0.8843232",
"0.88201505",
"0.87453896",
"0.8740174",
"0.8670031",
"0.8664805",
"0.858089... | 0.9125751 | 1 |
Returns length of Queue | def size(self):
return len(self.queue) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\r\n return len(self.queue)",
"def size(self):\r\n return len(self.queue)",
"def __len__(self):\n\n return len(self._queue)",
"def size(self):\n return len(self.__queue)",
"def qsize(self):\r\n return len(self._queue)",
"def __len__(self) -> int:\n ... | [
"0.8456888",
"0.8456888",
"0.8406829",
"0.8366472",
"0.8334224",
"0.824883",
"0.81700844",
"0.8165595",
"0.8138574",
"0.80899036",
"0.8051029",
"0.7991055",
"0.7926158",
"0.79091537",
"0.7888806",
"0.77817297",
"0.76830995",
"0.767615",
"0.76214266",
"0.76045525",
"0.75941944... | 0.8399036 | 4 |
Return given path value as normalized unicode string on OS/X, on other platform return the original string as unicode | def normalized(path, normalization='NFC'):
if sys.platform != 'darwin':
return path if type(path) == str else str(path, 'utf-8')
if not isinstance(path, str):
path = str(path, 'utf-8')
return unicodedata.normalize(normalization, path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeNativePath(path: unicode) -> unicode:\n ...",
"def convertString(path):\n if (\"win\" in sys.platform):\n return path.replace(\"/\",\"\\\\\")\n elif (\"linux\" in sys.platform):\n return path.replace(\"\\\\\",\"/\")",
"def normalized_file_path(path: str) -> str:\n # C... | [
"0.8119283",
"0.7034302",
"0.7010487",
"0.6773394",
"0.6737866",
"0.64908725",
"0.6461322",
"0.64436513",
"0.64111835",
"0.6390163",
"0.6388797",
"0.6385912",
"0.63545835",
"0.63376623",
"0.62392914",
"0.6163324",
"0.6161025",
"0.6155425",
"0.6147813",
"0.6143042",
"0.6131500... | 0.7794775 | 1 |
Add a number of tab characters to the front of a string. | def fwrite(string, target_file, tabs=0, newlines=1):
target_file.write('\t'*tabs + string + '\n'*newlines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_tab(self):\n if(self.tab):\n return '\\t'\n return ''",
"def replace_tabs(string: str, tab_width: int = 4) -> str:\n\n return string.replace('\\t', ' '*tab_width)",
"def tabify(st: str, width: int) -> str:\n assert width % 8 == 0\n if len(st) >= width:\n # Ensur... | [
"0.74124485",
"0.72337896",
"0.7171161",
"0.6938555",
"0.6867993",
"0.6807047",
"0.6751568",
"0.6559485",
"0.6550525",
"0.65448415",
"0.64446324",
"0.6322173",
"0.63051385",
"0.62808716",
"0.6253747",
"0.61565596",
"0.6093703",
"0.6058676",
"0.6004649",
"0.5996189",
"0.596641... | 0.501926 | 63 |
Implements DataLoader load method. Builds the entire input pipeline inside the load method. Users can define states inside the DataLoader class and returns a tf.data dataset object. | def load(
self,
input_context: Optional[tf.distribute.InputContext] = None
) -> tf.data.Dataset:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_dataloader(self) -> torch.utils.data.DataLoader: \n return torch.utils.data.DataLoader(self.dataset_train, **self.dl_kwargs)",
"def train_dataloader(self) -> DataLoader:\n return DataLoader(\n self.train_dataset,\n batch_size=self.hparams.batch_size,\n ... | [
"0.7339448",
"0.731622",
"0.73107284",
"0.71992004",
"0.7164705",
"0.71143275",
"0.6999015",
"0.6935387",
"0.69105166",
"0.68948245",
"0.6857811",
"0.6850325",
"0.67290443",
"0.6680146",
"0.66609997",
"0.66552454",
"0.6638516",
"0.6608029",
"0.656589",
"0.6562846",
"0.6560433... | 0.7494908 | 0 |
Ensure we can't create a vessel with a preexisting code | def test_unique_vessel_code(self):
data = {'code': test_utils.VESSEL_CODE}
response = self.client.post(self.base_url, data, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_vessel_invalid_input(self):\n url = reverse('vessel-create')\n payload = json.dumps({\n \"code2\": \"MV101\"\n })\n response = self.post(url, payload)\n self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)",
"def helper_test_create_vess... | [
"0.6003455",
"0.5730956",
"0.57016057",
"0.56095755",
"0.55377525",
"0.5492474",
"0.5451939",
"0.5413038",
"0.54090935",
"0.53960973",
"0.53693604",
"0.5369284",
"0.53218365",
"0.5319182",
"0.53014606",
"0.5287196",
"0.5270861",
"0.52232707",
"0.5208031",
"0.520738",
"0.52015... | 0.6210318 | 0 |
Find the hardware on the system. For nonwindows systems, this just finds the system soundcard for testing Otherwise it looks for the requested hardware. Keeps track of available hardware in the self.hardware list | def find_hardware(self, device_info=None):
if os.name is not 'nt': # If not on a Windows system, just set up soundcard
self.setup_soundcard()
self.hardware.append('Soundcard')
self.out_samplefreq = 44100
else:
if 'NIDAQ' in self.required_hardware and self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_system_hardware(self):\n return self._get_system_status()[\"hardware\"]",
"def hardware(self):\n return self._hardware",
"def getHardware(self):\n return (self.vendorId, self.deviceId, self.physicalMemory, self.osInfo, self.cpuSpeed[0])",
"def get_hardware_id():\r\n try:\r\n ... | [
"0.76546514",
"0.7088417",
"0.6735531",
"0.66123235",
"0.65838367",
"0.65313935",
"0.64705694",
"0.6455422",
"0.62843555",
"0.62464154",
"0.6243066",
"0.61964685",
"0.6188225",
"0.61180997",
"0.6108692",
"0.610349",
"0.60865813",
"0.6037912",
"0.60305846",
"0.60235363",
"0.60... | 0.81314677 | 0 |
This method will add the edges that are within the builtEdgeList list. If an edge includes a node that is not in the graph, Netwrokx will automatically add those nodes. | def addTweetHashtagEdges(self):
self.hashtagGraph.add_edges_from(self.builtEdgeList) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_edges(self):\n print(\"Constructing Edges.\")\n # -----------------------------------------\n # TODO: You should write this method!\n\n # Note: this method may take some time to run - it is likely to be O(N^2), and some lists have N = 10,000 words or more.\n # (I've ha... | [
"0.738525",
"0.72437537",
"0.6843867",
"0.6774413",
"0.6663112",
"0.66531014",
"0.65730786",
"0.65200466",
"0.6451026",
"0.64384407",
"0.6426136",
"0.6417128",
"0.63256663",
"0.6265693",
"0.6217891",
"0.6215874",
"0.6207587",
"0.6204628",
"0.61530936",
"0.61426336",
"0.612878... | 0.5935829 | 25 |
add the features that have physics means, using the particle mass (index_A = 0) as the weight, and then standardize the features and return mean and std | def compute_physics(tx, index_A, index_B, index_C,
mean=[], std=[]):
tx_new = tx[:,index_A] * tx[:,index_B] / tx[:,index_C]
return standardize(tx_new,mean,std) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_means(opts, train_data, sampler):\n exp_names = train_data[\"exp_names\"].value\n means = []\n stds = []\n if opts[\"flags\"].normalize is True:\n running_stats = []\n # a running stat for each channel\n running_stats = RunningStats(3)\n # loop over the experimen... | [
"0.6230966",
"0.62027484",
"0.60839814",
"0.6082904",
"0.60230947",
"0.59739435",
"0.5951906",
"0.59280294",
"0.59280294",
"0.5865397",
"0.5846537",
"0.5829107",
"0.5828704",
"0.57896334",
"0.5789182",
"0.57815456",
"0.57780963",
"0.5775184",
"0.5774262",
"0.5769154",
"0.5753... | 0.64761895 | 0 |
Verifies the username, password pair. Computes the hash of the provided password and compares it with the hashed password (for the same user) stored in the database. | def verify_user(self, username, password):
(user_exists, ) = self.session.query(exists().where(User.username == username))
if not user_exists[0]:
color_print("Error: User %s does not exist" % username, color='red')
return False
# There will be exactly one row for the username because usernames are
# con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_password(username, password):\n if username in user_auth and check_password_hash(user_auth.get(username), password):\n return username",
"def verify_password(self, password):\n return check_password_hash(self.password_hash, password)",
"def verifyPw(username,password):\n hashed_pw = ... | [
"0.7540642",
"0.7508731",
"0.7450682",
"0.7328197",
"0.73143286",
"0.7305841",
"0.72830355",
"0.72751594",
"0.72749597",
"0.7274153",
"0.7252135",
"0.722608",
"0.7221978",
"0.72186875",
"0.71992403",
"0.71944785",
"0.71839",
"0.71832377",
"0.71753514",
"0.71741295",
"0.717359... | 0.76888996 | 0 |
Remove line break and lowercase all words | def normalize_text(text):
# mystring.replace('\n', ' ').replace('\r', '')
return text.replace('\n', ' ').replace('\r', '').lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(self, s):\n stripped = re.sub(\"[^\\w\\s]\", \"\", s)\n stripped = re.sub(\"_\", \"\", stripped)\n\n stripped = re.sub(\"\\s+\", \" \", stripped)\n\n stripped = stripped.strip()\n\n return stripped.lower()",
"def no_caps_and_ponctuation(text):\n return re.sub(... | [
"0.7211861",
"0.7128288",
"0.712411",
"0.7045214",
"0.70426816",
"0.6987598",
"0.6971761",
"0.69540215",
"0.6952506",
"0.6922984",
"0.68949276",
"0.68834645",
"0.6880535",
"0.68475765",
"0.683375",
"0.6828032",
"0.68072593",
"0.68072593",
"0.67858374",
"0.6757351",
"0.6756360... | 0.7494174 | 0 |
Luhn credit card number check | def check_number(self):
digits = self.number
_sum = 0
alt = False
ix = []
for x in str(digits):
ix.append(int(x))
for d in reversed(ix):
assert 0 <= d <= 9
if alt:
d *= 2
if d > 9:
d -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def luhn(card_number):\n card_number = str(card_number)\n sum = 0\n num_digits = len(card_number)\n odd_even = num_digits & 1\n\n for i in range(0, num_digits):\n digit = int(card_number[i])\n if not (( i & 1 ) ^ odd_even ):\n digit = digit * 2\n if digit > 9:\n ... | [
"0.81264967",
"0.7992284",
"0.79761803",
"0.7823757",
"0.7803642",
"0.76708627",
"0.76300025",
"0.7605557",
"0.74227905",
"0.73553336",
"0.73398876",
"0.73044974",
"0.72029907",
"0.7131771",
"0.7043754",
"0.7032966",
"0.6885796",
"0.67151755",
"0.6702277",
"0.66505086",
"0.66... | 0.6506351 | 25 |
Measure the distance errors between the contours of two segmentations. The manual contours are drawn on 2D slices. We calculate contour to contour distance for each slice. | def distance_metric(seg_A, seg_B, dx, k):
# Extract the label k from the segmentation maps to generate binary maps
seg_A = (seg_A == k)
seg_B = (seg_B == k)
table_md = []
table_hd = []
X, Y, Z = seg_A.shape
for z in range(Z):
# Binary mask at this slice
slice_A = seg_A[:, :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_metric(seg_A, seg_B, dx):\n table_md = []\n table_hd = []\n X, Y, Z = seg_A.shape\n for z in range(Z):\n # Binary mask at this slice\n slice_A = seg_A[:, :, z].astype(np.uint8)\n slice_B = seg_B[:, :, z].astype(np.uint8)\n\n # The distance is defined only when b... | [
"0.6666884",
"0.61812997",
"0.580347",
"0.56066823",
"0.5553183",
"0.5551577",
"0.54965144",
"0.54695475",
"0.5430692",
"0.5421786",
"0.52974904",
"0.5282126",
"0.52729326",
"0.5260727",
"0.5260454",
"0.52586293",
"0.5245522",
"0.5197083",
"0.51744723",
"0.5171268",
"0.516455... | 0.62926424 | 1 |
Return the difference in time to the nearest second. | def time_difference_in_seconds(readings: List[Reading]) -> int:
initial, final = latest_two_readings(readings)
seconds = (final.timestamp - initial.timestamp).total_seconds()
if seconds == 0:
raise UsageEstimatorError("Two readings taken at the exact same second")
return int(seconds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestep(self) -> Optional[float]:\n dt = None\n if len(self.time) > 1 and self.is_equidistant:\n dt = (self.time[1] - self.time[0]).total_seconds() # type: ignore\n return dt",
"def SECOND(time):\n\n return _make_datetime(time).second",
"def time_difference(time1: Time, t... | [
"0.6842055",
"0.67835456",
"0.6742962",
"0.67150253",
"0.6679834",
"0.6538413",
"0.64997965",
"0.64931417",
"0.6484354",
"0.6439211",
"0.6352422",
"0.6291171",
"0.6265371",
"0.6261167",
"0.6258603",
"0.6251773",
"0.6233076",
"0.623305",
"0.6221378",
"0.6221165",
"0.61940086",... | 0.6119622 | 25 |
Closes a connection to the database | async def close_connection(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_connection(cls):\n db.close()",
"def close_connection(exception):\n db = database()\n\n if db is not None:\n db.close()",
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close_connection(exce... | [
"0.8270815",
"0.8260583",
"0.8149634",
"0.797785",
"0.7972176",
"0.7963676",
"0.7919027",
"0.789694",
"0.78788996",
"0.78747874",
"0.7833351",
"0.78224564",
"0.7819624",
"0.78008324",
"0.77640253",
"0.7691107",
"0.76885533",
"0.76879",
"0.76783955",
"0.7663483",
"0.76127505",... | 0.0 | -1 |
GIVEN a Flask application configured for testing WHEN the '/weather?max' page is requested (GET) and cache is empty THEN check that the response is valid | def test_get_last_cities_nocache(client):
response = client.get("/weather/1")
assert response.status_code == 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index():\n\n with flask_app.test_client() as client:\n response = client.get(\"/\")\n assert response.status_code == 200\n assert b\"milhouse\" in response.data\n\n response = client.get(\"/?url=https://imgs.xkcd.com/comics/bad_code.png\")\n assert response.status_cod... | [
"0.65644103",
"0.65194863",
"0.6336169",
"0.6248646",
"0.62100285",
"0.5998866",
"0.599428",
"0.5923396",
"0.59167427",
"0.5902848",
"0.58910483",
"0.58660793",
"0.5853419",
"0.58461714",
"0.581465",
"0.5789921",
"0.57820475",
"0.578048",
"0.5756646",
"0.5730581",
"0.56991494... | 0.6315911 | 3 |
GIVEN a Flask application configured for testing WHEN the '/weather/' page is requested (GET) THEN return response to validate | def test_get_city(client):
response = client.get("/weather/curitiba")
assert response.status_code == 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_main_app(self):\n resp = self.app.get('/')\n # ensure relevant pieces of UI are returned\n assert 'Foggy Fork' in resp.data\n assert 'A San Francisco Food Truck Map' in resp.data\n assert 'Where in the fog are you looking for food?' in resp.data\n assert '<div id=... | [
"0.66506636",
"0.6406529",
"0.6352848",
"0.63261324",
"0.625784",
"0.6195047",
"0.6115886",
"0.6108001",
"0.6089882",
"0.6077622",
"0.60711324",
"0.6071124",
"0.6065297",
"0.6060113",
"0.6032976",
"0.602024",
"0.6014905",
"0.59990865",
"0.59926695",
"0.5941779",
"0.5939662",
... | 0.56681055 | 52 |
GIVEN a Flask application configured for testing WHEN the '/weather?max' page is requested (GET) THEN check that the response is valid | def test_get_last_cities(client):
response = client.get("/weather/1")
print(response.data)
assert response.status_code == 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_00_app_get(self):\r\n # GET as Anonymous\r\n url = '/api/app'\r\n action = 'get'\r\n self.check_limit(url, action, 'app')",
"def test_index():\n\n with flask_app.test_client() as client:\n response = client.get(\"/\")\n assert response.status_code == 200\n ... | [
"0.66782355",
"0.6651742",
"0.64360696",
"0.6384756",
"0.6365384",
"0.62164885",
"0.61822206",
"0.6177432",
"0.6151567",
"0.61384934",
"0.6132116",
"0.6098549",
"0.6079426",
"0.60753006",
"0.6057107",
"0.6049094",
"0.6042166",
"0.60304946",
"0.6007402",
"0.6005681",
"0.598468... | 0.5750017 | 46 |
Get a character from the grayscale character list that match the light value. The light value must be between 0 and 255. | def get_char_from_light(light: int):
index = int((light * (ASCII_SCALE_SIZE - 1)) / 255)
return ASCII_SCALE[index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _color(self,c):\n return self.colorlist[c%len(self.colorlist)]",
"def light(color, dist):\n return tuple( float(x*dist*dist) for x in color )",
"def _return_char(num_image):\n\n # check image (segment) against the full dictionary of\n # characters and return first match\n for digit, ... | [
"0.5912373",
"0.56806356",
"0.5626468",
"0.557112",
"0.55659556",
"0.5427918",
"0.5423793",
"0.5395167",
"0.5378838",
"0.5371031",
"0.535242",
"0.533797",
"0.53228307",
"0.5319983",
"0.5258186",
"0.52522093",
"0.5232765",
"0.522028",
"0.5204281",
"0.51886606",
"0.51601315",
... | 0.68724024 | 0 |
Return a JSON list of stations from the dataset. | def stations():
# Query all stations
stations = session.query(Station.station).all()
all_stations = list(np.ravel(stations))
return jsonify(all_stations) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stationdata():\n # * Return a JSON list of stations from the dataset.\n # as this should be a list, I'm just grabbing the station name\n session = Session(engine)\n results = session.query(Station.name).all()\n session.close()\n\n stations = list(np.ravel(results))\n return jsonify(stati... | [
"0.87502384",
"0.87111616",
"0.87103224",
"0.8391929",
"0.83858776",
"0.8351123",
"0.8318487",
"0.83133906",
"0.83088475",
"0.82849854",
"0.82565653",
"0.8246363",
"0.82374954",
"0.8237443",
"0.82318974",
"0.81887966",
"0.81722414",
"0.8110365",
"0.8088061",
"0.80655205",
"0.... | 0.82893324 | 9 |
Return a JSON list of Temperature Observations (tobs) for the previous year. | def tobs():
# Query all stations
sel3 = [Measurement.tobs]
tob = session.query(*sel3).\
filter(Measurement.date.between ('2016-08-23', '2017-08-23')).\
group_by(Measurement.date).\
order_by(Measurement.date).all()
# Create a list of all_tobs
all_tobs= list(np.ravel(stations))
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prior_year_temp():\n\n tobs_data = session.query(Measurements.tobs).all()\n return jsonify (tobs_data)",
"def tobsdata():\n # query for the dates and temperature observations from a year from the last data point.\n # * Return a JSON list of Temperature Observations (tobs) for the previous year.... | [
"0.8065112",
"0.7783624",
"0.773062",
"0.76812226",
"0.7508171",
"0.74726635",
"0.746267",
"0.7448276",
"0.73504597",
"0.73167944",
"0.7093705",
"0.7087905",
"0.6986817",
"0.6969893",
"0.69484746",
"0.68117803",
"0.68083787",
"0.6737605",
"0.6672057",
"0.66408783",
"0.6577659... | 0.5832629 | 32 |
Generate a swagger schema from all known routes. | def index():
definition = {
"swagger": "2.0",
"info": {
"title": flask.current_app.config.get("APPNAME", "Not specified"),
"version": flask.current_app.config.get("VERSION", "Not specified"),
},
"host": request.host,
"schemes": ["http"],
"consu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _CreateRouterMethodSchemas(self, visiting: Set[str]) -> None:\n router_methods = self.router.__class__.GetAnnotatedMethods()\n for method_metadata in router_methods.values():\n args_type = method_metadata.args_type\n if args_type:\n self._CreateSchema(args_type, visiting)\n\n result... | [
"0.6424369",
"0.6366478",
"0.63492835",
"0.619159",
"0.60823977",
"0.60723346",
"0.603122",
"0.6019372",
"0.59894145",
"0.5976304",
"0.5880774",
"0.5811771",
"0.58007115",
"0.5797521",
"0.57869375",
"0.57136196",
"0.569574",
"0.5676841",
"0.56242734",
"0.5623872",
"0.56130207... | 0.65504 | 0 |
Return the name of current file Returns String Current file name | def get_file_name(self):
return self.__file_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCurrentFileName(self):\n return os.path.basename(self.filePath)",
"def get_file_name(self):\n return str(self.get_file())",
"def get_name(self):\n return self.file_name",
"def file_name(self):\n return self.__file_name",
"def get_name(self):\n return self._file.nam... | [
"0.84127605",
"0.832154",
"0.79407763",
"0.78530616",
"0.7852721",
"0.7826426",
"0.7801451",
"0.779462",
"0.77681637",
"0.77681637",
"0.77681637",
"0.77681637",
"0.77681637",
"0.7712202",
"0.7635543",
"0.7635543",
"0.7635249",
"0.76340604",
"0.7631612",
"0.76270235",
"0.75959... | 0.7864795 | 3 |
Take a dict of ints paired with True and return only the prime numbers | def eliminate_non_primes(primes_dict, highest):
for i in range(2, highest):
if primes_dict[i] == True:
loop =1
for j in range(i**2, highest, i*loop):
primes_dict[j]=False
loop = loop+1
primes = []
for i in range(2, highest):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes():\n D = {} # map composite integers to primes witnessing their compositeness\n q = 2 # first integer to test for primality\n while True:\n if q not in D:\n yield q # not marked composite, must be prime\n D[q*q] = [q] # first multiple of q not already ma... | [
"0.6520681",
"0.64145803",
"0.6346482",
"0.631886",
"0.6184793",
"0.6159824",
"0.6135138",
"0.6123195",
"0.6094911",
"0.60856414",
"0.60854685",
"0.6076059",
"0.60584515",
"0.6048789",
"0.60296834",
"0.60254186",
"0.6019608",
"0.60082453",
"0.5988904",
"0.59877264",
"0.597444... | 0.65969014 | 0 |
Check if the URL is a correct form. | def _match_url(self, _url):
regex = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain
r'localhost|' # localhost
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_url(self):\n pass",
"def check_url_invalidity(self) -> bool:\n validate = URLValidator()\n try:\n validate(self.args.url)\n return False\n except ValidationError:\n return True",
"def valid(url):\n return 0 < len(urlparse(url)[1])",
... | [
"0.7723862",
"0.7395648",
"0.7281943",
"0.72535956",
"0.7238318",
"0.71106386",
"0.71105325",
"0.71085393",
"0.71053106",
"0.70669407",
"0.705207",
"0.7019822",
"0.70168287",
"0.70058876",
"0.69160455",
"0.68971807",
"0.68751866",
"0.68737614",
"0.6850362",
"0.68226963",
"0.6... | 0.0 | -1 |
Returns True if the stack has no items and empty; Otherwise, False | def is_empty(self):
return len(self.top) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self): #checks to see if stack is empty or not\n if self.num_items == 0:\n return True\n else:\n return False",
"def is_empty(self):\n return self._stack_items == []",
"def is_empty(self):\n return len(self.the_stack) == 0",
"def e... | [
"0.93386024",
"0.90147007",
"0.8985325",
"0.8866811",
"0.88366747",
"0.88219416",
"0.88154095",
"0.8795824",
"0.87622666",
"0.87622666",
"0.8717837",
"0.8598782",
"0.858632",
"0.8586263",
"0.8577555",
"0.8577555",
"0.8573332",
"0.85551804",
"0.8549487",
"0.84522074",
"0.84522... | 0.8235041 | 28 |
Add item into the stack following first in last out (LIFO) That is, the most recently added element is at the top of the stack. Returns None | def push(self, item):
# Reassign the link to top of the stack and update the
self.top = [item] + self.top | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(self, item): # 05:27 Lecture Week 2 \"Stacks\" (16:24)\n oldfirst = self.first # Save a link to the list\n self.first = self._Node(item, oldfirst) # first points to most recent Node\n self.N += 1",
"def push(self, item: Any) -> None:\r\n node: Node = Node(item)\r\n if self.is_... | [
"0.76266706",
"0.7450331",
"0.73456734",
"0.72751915",
"0.72124594",
"0.7066459",
"0.7056833",
"0.7056833",
"0.7029557",
"0.6982932",
"0.6921495",
"0.6867892",
"0.68029225",
"0.67837363",
"0.67820346",
"0.6778757",
"0.6753848",
"0.6745709",
"0.671234",
"0.6710992",
"0.6630664... | 0.7164944 | 5 |
Search the master index for a row that matches the cell_index, xy, and date contained in the cell_roi_df and return that row If no matching index found, return None | def find_cell_row(cell_roi_df, master_index_df):
cell_roi_cols = ['cell_index', 'xy', 'date']
if 'sub_coord' in master_index_df.columns:
master_index_cols = ['sub_coord', 'xy', 'date']
elif 'cell_index' in master_index_df.columns:
master_index_cols = ['cell_index', 'xy', 'date']
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_cell_master_index(cell_roi_df, active_imp_path):\n # Get the path to the directory holding the directory\n # holding the active imp\n exptdir = get_exptdir(active_imp_path)\n # Get all files that look like master indexes in that\n # exptdir (e.g. data/20200221_byc/20200221_byc_master_index.... | [
"0.7754411",
"0.62423754",
"0.6118758",
"0.58939916",
"0.56631315",
"0.56072426",
"0.55878174",
"0.55064887",
"0.5495891",
"0.5470728",
"0.5470696",
"0.5371193",
"0.53637755",
"0.53613746",
"0.5323753",
"0.5271997",
"0.5268485",
"0.5255287",
"0.52486855",
"0.5245664",
"0.5229... | 0.8627173 | 0 |
Return the master_index_df and its path that has a single row matching the cell_index, xy, and date values in cell_roi_df | def find_cell_master_index(cell_roi_df, active_imp_path):
# Get the path to the directory holding the directory
# holding the active imp
exptdir = get_exptdir(active_imp_path)
# Get all files that look like master indexes in that
# exptdir (e.g. data/20200221_byc/20200221_byc_master_index.csv)
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_cell_row(cell_roi_df, master_index_df):\n cell_roi_cols = ['cell_index', 'xy', 'date']\n \n if 'sub_coord' in master_index_df.columns:\n master_index_cols = ['sub_coord', 'xy', 'date']\n elif 'cell_index' in master_index_df.columns:\n master_index_cols = ['cell_index', 'xy', 'dat... | [
"0.7843348",
"0.6955154",
"0.59548473",
"0.55531305",
"0.52561575",
"0.5242668",
"0.52237785",
"0.5203251",
"0.5157068",
"0.5122657",
"0.5114173",
"0.51086044",
"0.5082152",
"0.50414467",
"0.5019215",
"0.5012823",
"0.5008613",
"0.49802607",
"0.49741748",
"0.49331513",
"0.4894... | 0.78142315 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.