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 |
|---|---|---|---|---|---|---|
Converts a (fully thermalized) thermal relic particle of mass m [keV] to the halfmode mass scale in solar masses (no little h) | def mthermal_to_halfmode(self, m_thermal):
# scaling of 3.3 keV from Viel et al
omega_matter = self.cosmo.astropy.Om0
return 10**9 * ((omega_matter/0.25)**-0.4 * (self.cosmo.h/0.7)**-0.8 *m_thermal / 2.32) ** (-3.33) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halfmode_to_thermal(self, m_half_mode):\n\n omega_matter = self.cosmo.astropy.Om0\n return 2.32 * (omega_matter / 0.25)**0.4 * (self.cosmo.h/0.7)**0.8 * \\\n (m_half_mode / 10 ** 9) ** (-0.3)",
"def convert_H_kJmol(en_H):\n return en_H/kJmol_H",
"def convert_eV_kJmol(en_eV):\... | [
"0.70939034",
"0.6377796",
"0.6322603",
"0.6225168",
"0.6143618",
"0.6096646",
"0.6038688",
"0.60381716",
"0.5980571",
"0.59789026",
"0.59466153",
"0.5916686",
"0.5886301",
"0.5847671",
"0.58191854",
"0.5802256",
"0.5795111",
"0.5779207",
"0.5726857",
"0.57080853",
"0.5707743... | 0.7435225 | 0 |
This function reads the data in filename that is in specified format and returns a pandas dataframe with time data as the index and 'CLG' as the header of the cooling load data. The final dataframe contains 'CLG' as the cooling load data column and 'Duration' as the duration of each data point in seconds. | def read_data(filename: str, header: int=None,
time_format: str='%m/%d/%y %I:%M:%S %p CST') -> pd.DataFrame:
# initialize the dataframe
ext = filename.split('.')[-1]
# read the file. Read the file as two columns first to conduct
# preprocessing before
if ext == 'xlsx' or ext == 'xls'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(input_file):\n print('loading file:', input_file)\n df = pd.DataFrame()\n show_progress = make_show_progress()\n chunk_iterator = pd.read_csv(input_file,\n compression='gzip',\n chunksize=100_000,\n ... | [
"0.63693887",
"0.6290327",
"0.62711126",
"0.622093",
"0.6199883",
"0.6197973",
"0.615947",
"0.61581355",
"0.6143208",
"0.6139555",
"0.61050403",
"0.609087",
"0.6090725",
"0.60748935",
"0.6057953",
"0.6051809",
"0.59933627",
"0.5968924",
"0.5968924",
"0.5968924",
"0.5968845",
... | 0.7345012 | 0 |
Returns the approximate ASCII equivalent of a Unicode string. | def asciify(s):
# http://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms
return unicodedata.normalize('NFKD', s).encode('ascii', 'ignore') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _UnicodeToAscii(string):\n return unicode(string).encode('utf-8')",
"def nearest_ascii(ustring):\n if not isinstance(ustring,unicode):\n try:\n ustring = ustring.decode('utf-8')\n except:\n try:\n ustring = ustring.decode(\"iso-8859-1\")\n exc... | [
"0.77450705",
"0.7382292",
"0.7158503",
"0.70793474",
"0.70754915",
"0.6963415",
"0.6952346",
"0.6884019",
"0.6880141",
"0.6867429",
"0.6854845",
"0.6810565",
"0.66994303",
"0.6643134",
"0.65601885",
"0.6532973",
"0.639304",
"0.6357269",
"0.6332328",
"0.63103914",
"0.6290041"... | 0.6340566 | 18 |
Check whether this instance represents the same struct as another. | def __eq__(self, other):
# Check that we share the same class as this object
if not isinstance(other, type(self)):
return False
return hash(self) == hash(other) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other: Any) -> bool:\n return (\n super().__eq__(other)\n and isinstance(other, Struct)\n and self._valid_struct_metadata().fields == other._valid_struct_metadata().fields\n and list(self._valid_struct_metadata().fields.keys()) == list(other._vali... | [
"0.84375256",
"0.7783164",
"0.7489894",
"0.7341421",
"0.7285961",
"0.71639484",
"0.7161677",
"0.7148265",
"0.71335155",
"0.7118545",
"0.7112248",
"0.70678455",
"0.7058698",
"0.70511794",
"0.70469135",
"0.7033385",
"0.70293015",
"0.70252687",
"0.70233804",
"0.70233804",
"0.702... | 0.6993028 | 22 |
Constructor for Thread_Manager class | def __init__(self, action, conn, alog, public, private):
threading.Thread.__init__(self)
self.action = action.lower()
self.conn = conn
self.algo = alog
self.dowrite = True
self.exitcode = 'EXIT'
if public is not None:
self.setPublic(public)
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,Thread):\n\t\tthreading.Thread.__init__(self)",
"def __init__(self, thread_name, url, update_delay, workQueue, queueLock):\n threading.Thread.__init__(self)\n self.update_delay = update_delay\n self.url = url\n self.thread_name = thread_name\n self.workQueue =... | [
"0.77351415",
"0.7476969",
"0.72141093",
"0.7083855",
"0.7049516",
"0.7046543",
"0.7030316",
"0.7019918",
"0.70124257",
"0.69931024",
"0.6979858",
"0.69791305",
"0.6973487",
"0.69682056",
"0.6902304",
"0.68881243",
"0.6834333",
"0.68261886",
"0.6810146",
"0.68023974",
"0.6791... | 0.6113245 | 86 |
Transforms a string representation of a tuple of two integers into a tuple of two integers. | def str2tuple(str):
pack = (int(str[1]), int(str[4]))
return pack | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_tuple(self, tuple_str):\n return ast.literal_eval(tuple_str)",
"def processed(N:int)->tuple:\n l1= str(N)\n a,b = '',''\n for i in range(len(l1)):\n if l1[i] == '4':\n a+='2'\n b+='2'\n else:\n a+=str(l1[i])\n b+='0'\n re... | [
"0.70985883",
"0.69838136",
"0.69016916",
"0.6877339",
"0.68478525",
"0.6728182",
"0.66446537",
"0.662482",
"0.6480986",
"0.6437317",
"0.6428713",
"0.6407667",
"0.6404419",
"0.6399186",
"0.6399186",
"0.63869536",
"0.63754606",
"0.6367485",
"0.63356954",
"0.6330007",
"0.632542... | 0.7305644 | 0 |
Set the accidental for this note. 'accidental' should be a signed integer with 1 representing flat, +1 representing sharp, etc. | def setAccidental(self, accidental):
acc = _int(accidental)
if acc != None:
self.accidental = acc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAccidentalString(self, accidental = None):\n if accidental == None:\n accidental = self.getAccidental()\n #print(\"accidental = {}\".format(accidental))\n accidental = _int(accidental)\n sign = 0\n self.naturalChar\n if accidental > 0:\n sign =... | [
"0.5795111",
"0.5599377",
"0.557651",
"0.55095553",
"0.5509422",
"0.5353195",
"0.5351781",
"0.52609384",
"0.5196728",
"0.5179942",
"0.51471883",
"0.49968067",
"0.4958792",
"0.4933277",
"0.4926034",
"0.49238023",
"0.4915336",
"0.48641232",
"0.48541516",
"0.47727752",
"0.476961... | 0.86524457 | 0 |
Get the duration indication in GNU lilypond format. For a poweroftwo (i.e. quarter note, eighth note, whole note, etc.), we simply return a string of the reciprocal. For nonpoweroftwo (i.e. 11/16ths), we will end up with a combination of notes tied together, or potentially a single dotted note. We can use 'alignBeat' t... | def _getLilyDuration(self, alignBeat = None):
# To tie notes, we can simply replace the duration with power-of-two
# durations (or dotted durations) with tildes (~) between them.
if self.duration == None:
return ""
if self._isBasisDuration():
return int(1/self.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getLilyDurationAligned(self, alignBeat):\n # Hmmm... didn't seem to get it right. Poke further into this\n _dbg(\" - - - - - - - - alignBeat = {}\".format(alignBeat))\n if alignBeat == None:\n alignBeat = self.getBeatNum()\n if alignBeat == None:\n ... | [
"0.68036497",
"0.5621705",
"0.5557042",
"0.53580177",
"0.52045864",
"0.50076294",
"0.49916777",
"0.49472263",
"0.4930237",
"0.49296102",
"0.4908419",
"0.4869012",
"0.4839436",
"0.48368979",
"0.48200044",
"0.48136064",
"0.48131472",
"0.48131302",
"0.4798531",
"0.47539356",
"0.... | 0.72937536 | 0 |
Return the note duration as a float (i.e. 0.125 = 1/8 for an eighth note) Includes effect of dotting. | def getDuration(self):
if self.getDot():
return self.duration*1.5
else:
return self.duration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duration_in_seconds(self):\n \"Should not set track length\"\n return self.duration / float(self.samplerate)",
"def getDurationNoDot(self):\n return self.duration",
"def _get_duration(self):\n try:\n dur = self.im.info[\"duration\"] / 1000.0\n except KeyError:\... | [
"0.68490505",
"0.6718765",
"0.6713106",
"0.6597471",
"0.6550927",
"0.6531802",
"0.65290374",
"0.65290374",
"0.65259284",
"0.64721316",
"0.6440315",
"0.63908714",
"0.6374058",
"0.63707644",
"0.63258004",
"0.63214004",
"0.6286742",
"0.62797207",
"0.62383914",
"0.6235691",
"0.62... | 0.7369315 | 0 |
Returns the owner of the partition if it's set, ``None`` otherwise. | def get_partition_owner(self, partition_id: int) -> typing.Optional[uuid.UUID]:
return self._service.get_partition_owner(partition_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"owner\")",
"def get_owner(self):\n owner = gdef.PSID()\n lpbOwnerDefaulted = gdef.BOOL()\n winproxy.GetSecurityDescriptorOwner(self, owner, lpbOwnerDefaulted)\n # Return None of owner is NULL\n r... | [
"0.6949778",
"0.69415265",
"0.69086343",
"0.6873669",
"0.6823751",
"0.68132085",
"0.66302115",
"0.66210866",
"0.65440536",
"0.64692396",
"0.64692396",
"0.6439871",
"0.64327735",
"0.64327735",
"0.64327735",
"0.6424673",
"0.6407317",
"0.64040196",
"0.64023954",
"0.62932056",
"0... | 0.7684712 | 0 |
Returns partition count of the connected cluster. If partition table is not fetched yet, this method returns ``0``. | def get_partition_count(self) -> int:
return self._service.partition_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cluster_count(self) -> int:\n return len(self.get_all_cluster_ids())",
"def partition_count(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"partition_count\")",
"def get_partitions_count(self):\n\t\treturn call_sdk_function('PrlVmDevHd_GetPartitionsCount', self.handle)",... | [
"0.751464",
"0.74452156",
"0.7376273",
"0.7158251",
"0.7158251",
"0.70008534",
"0.6834168",
"0.6773639",
"0.6751129",
"0.67418104",
"0.6720927",
"0.65831697",
"0.65495694",
"0.64086074",
"0.6392807",
"0.63839084",
"0.632428",
"0.627672",
"0.62492824",
"0.62492824",
"0.6221422... | 0.7809669 | 0 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def haversine(lon1, lat1, lon2, lat2):
from math import radians, cos, sin, asin, sqrt
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.81450045",
"0.7863265",
"0.76322985",
"0.76064754",
"0.75978696",
"0.75965863",
"0.75944835",
"0.75720793",
"0.75630087",
"0.7555095",
"0.7528691",
"0.7517629",
"0.7492963",
"0.7467739",
"0.7452678",
"0.7434477",
"0.73914117",
"0.7357736",
"0.73484355",
"0.73318124",
"0.73... | 0.0 | -1 |
This function takes two strings as inputs and a pandas dataframe. csv_fn describes the desired filename output_dir is the directory to save the csv. df_to_save is a pandas dataframe containing data to save This function will not overwrite data The function tests if a file exists in the output_dir. If a file exists, it ... | def save_csv(csv_fn, output_dir, df_to_save):
# import packages
import os
import pandas as pd
if os.path.isfile(output_dir + '/' + csv_fn):
print('Data already saved and will not be saved again')
else:
df_to_save.to_csv(output_dir + '/' + csv_fn, index = False)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_dataframe_to_csv(data: pd.DataFrame, filename: str) -> bool:\n try:\n data = clean_data(data)\n data.to_csv(filename)\n return True\n except(FileNotFoundError):\n print('Error: Could not save the dataframe to csv.')\n return False",
"def output(df, path=\"./outpu... | [
"0.6632944",
"0.6578133",
"0.65454394",
"0.6395366",
"0.63184744",
"0.62098193",
"0.6105281",
"0.60757923",
"0.6039225",
"0.5987491",
"0.59771335",
"0.59611803",
"0.5942032",
"0.58776754",
"0.5870842",
"0.58581376",
"0.5847338",
"0.58298826",
"0.5768396",
"0.5731613",
"0.5720... | 0.8312101 | 0 |
Returns the number of rows of the matrix. | def getNumRows(self):
return self.__rows | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNumRows(self):\n return _hypre.HypreParMatrix_GetNumRows(self)",
"def number_of_rows(self):\n if self.number_of_columns():\n return self._number_of_rows\n else:\n return 0",
"def getNumRows(self) -> int:\n ...",
"def num_rows(self):\n return (le... | [
"0.8295652",
"0.8206466",
"0.80020875",
"0.77729154",
"0.77431625",
"0.7730627",
"0.7730627",
"0.7648053",
"0.7550788",
"0.7511804",
"0.75068337",
"0.74959564",
"0.73783237",
"0.73595786",
"0.73125243",
"0.7307936",
"0.72910464",
"0.7286942",
"0.72865605",
"0.72865605",
"0.72... | 0.7950137 | 3 |
Returns the number of rows of the matrix. | def getNumCols(self):
return self.__cols | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNumRows(self):\n return _hypre.HypreParMatrix_GetNumRows(self)",
"def number_of_rows(self):\n if self.number_of_columns():\n return self._number_of_rows\n else:\n return 0",
"def getNumRows(self) -> int:\n ...",
"def getNumRows(self):\n return s... | [
"0.8295652",
"0.8206466",
"0.80020875",
"0.7950137",
"0.77729154",
"0.77431625",
"0.7730627",
"0.7730627",
"0.7648053",
"0.7550788",
"0.7511804",
"0.75068337",
"0.74959564",
"0.73783237",
"0.73595786",
"0.73125243",
"0.7307936",
"0.72910464",
"0.7286942",
"0.72865605",
"0.728... | 0.0 | -1 |
Returns the item on the ith row and jth column. i row number j columns number | def getItem(self, i, j):
if i < 0:
raise IndexError('Row index must be nonnegative.')
if j < 0:
raise IndexError('Column index must be nonnegative.')
return self.__m[i - 1][j - 1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getitem(self, i, j):\n # XXX: flint matrices do not support negative indices\n # XXX: They also raise ValueError instead of IndexError\n m, n = self.shape\n if i < 0:\n i += m\n if j < 0:\n j += n\n try:\n return self.rep[i, j]\n ... | [
"0.7824742",
"0.7482301",
"0.72873783",
"0.7226684",
"0.72138155",
"0.71621454",
"0.6820395",
"0.6756808",
"0.6731647",
"0.6725486",
"0.67210186",
"0.66855884",
"0.66498524",
"0.6647623",
"0.66454077",
"0.6630182",
"0.6617095",
"0.66155773",
"0.65978444",
"0.65973294",
"0.658... | 0.79887265 | 0 |
Returns true if this matrix is equal to the other matrix. Two matrices are considered equal if they have the same number of rows, columns and every item on indices i,j in the first matrix is equal to the item on the same indices in the second matrix. | def __eq__(self, other):
# Check the number of rows and columns
if self.getNumRows() != other.getNumRows() or\
self.getNumCols() != other.getNumCols():
return False
# Check items
for i in range(1, self.getNumRows() + 1):
for j in range(1, self.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, Matrix):\n return NotImplemented\n\n if self.num_cols != other.num_cols:\n return False\n\n if self.num_rows != other.num_rows:\n return False\n\n for i in xrange(self.num_rows):\n for j in x... | [
"0.8523804",
"0.83159006",
"0.8203679",
"0.8076699",
"0.7828403",
"0.78106374",
"0.77462",
"0.77418506",
"0.7594752",
"0.7566956",
"0.75530577",
"0.7528019",
"0.75049347",
"0.7461793",
"0.7429661",
"0.74099725",
"0.7405225",
"0.7322349",
"0.7276581",
"0.72669894",
"0.7256958"... | 0.78503597 | 4 |
Returns True, if this matrix is NOT equal to the other matrix, False otherwise. See __eq__() for more details about equality. | def __ne__(self, other):
return not (self == other) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, Matrix):\n return NotImplemented\n\n if self.num_cols != other.num_cols:\n return False\n\n if self.num_rows != other.num_rows:\n return False\n\n for i in xrange(self.num_rows):\n for j in x... | [
"0.814846",
"0.8128927",
"0.7669753",
"0.75515014",
"0.7538494",
"0.75107646",
"0.747331",
"0.742499",
"0.74068564",
"0.7401699",
"0.73922354",
"0.7372464",
"0.73167884",
"0.7294912",
"0.72945005",
"0.72945005",
"0.72945005",
"0.72945005",
"0.72945005",
"0.72945005",
"0.72945... | 0.0 | -1 |
Estimate the function U (exponent of the likelihood), which needs to be minimized. | def ilike(init_par, alpha, delta, plx_obs, mualpha_obs, mudelta_obs, vrad_obs, sigma_obs, sigma_vrad, ccoef, N):
detD, gfunc, U = np.zeros(N), np.zeros(N), np.zeros(N)
for i in range(N):
if np.isfinite(vrad_obs[i]):
detD[i], gfunc[i] = _like4(init_par, alpha[i], delta[i], plx_obs[i],
mualpha_obs[i]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exp(self, X, U):\n raise NotImplementedError",
"def gelu(x):\r\n return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))",
"def estimate(self, U, mu=None):\n raise NotImplementedError",
"def gelu(x):\n return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))",
"def gelu(x):\n return... | [
"0.6852779",
"0.6606735",
"0.6605992",
"0.65416837",
"0.65416837",
"0.65416837",
"0.65416837",
"0.65416837",
"0.65416837",
"0.65416837",
"0.65416837",
"0.65046865",
"0.6322317",
"0.6293291",
"0.62871826",
"0.6209027",
"0.6157307",
"0.6151959",
"0.60813856",
"0.6058225",
"0.60... | 0.0 | -1 |
Applies network layers and ops on input image(s) x. | def forward(self, data_batch):
x = data_batch[0]
im_info = data_batch[1]
gt_boxes = data_batch[2]
num_boxes = data_batch[3]
rel_mat = data_batch[4]
if self.training:
self.iter_counter += 1
input_imgs = x.clone()
sources = list()
loc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_network(inputs):\n return apply_layer(tf.sigmoid(apply_layer(inputs, 64)), 1)",
"def forward(self, x):\n for task_module_name in self.task_module_name_path[self.task_idx]:\n for layer in self.task_modules[task_module_name]:\n x = layer(x)\n #x = self.task_... | [
"0.65635645",
"0.6369926",
"0.6366342",
"0.6353145",
"0.6308525",
"0.63080144",
"0.6259044",
"0.6207936",
"0.61983746",
"0.6192247",
"0.6176785",
"0.6163958",
"0.61539495",
"0.61442596",
"0.61295325",
"0.61276245",
"0.6121304",
"0.6115892",
"0.61109567",
"0.60991436",
"0.6084... | 0.0 | -1 |
Test if GetRandomBlocks method raises an error when given a negative blocks argument | def test_get_random_blocks_lower_than_zero(mock_beta_create_proxy_stub):
client = ProxyClient()
with pytest.raises(ValueError) as e:
client.get_random_blocks(-1)
assert "argument blocks cannot be lower or equal to 0" in e.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_random_blocks_equal_to_zero(mock_beta_create_proxy_stub):\n client = ProxyClient()\n with pytest.raises(ValueError) as e:\n client.get_random_blocks(0)\n assert \"argument blocks cannot be lower or equal to 0\" in e.value",
"def test_block_bad_batch(self):\n pass",
"def test... | [
"0.7740838",
"0.67258775",
"0.6421531",
"0.64108264",
"0.63322735",
"0.62282574",
"0.6223805",
"0.59830964",
"0.59261537",
"0.5921892",
"0.59001166",
"0.58945477",
"0.58546156",
"0.5831333",
"0.5830992",
"0.5825677",
"0.58246607",
"0.5810305",
"0.5805559",
"0.58002365",
"0.57... | 0.7863878 | 0 |
Test if GetRandomBlocks method raises an error when given 0 as a blocks argument | def test_get_random_blocks_equal_to_zero(mock_beta_create_proxy_stub):
client = ProxyClient()
with pytest.raises(ValueError) as e:
client.get_random_blocks(0)
assert "argument blocks cannot be lower or equal to 0" in e.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_random_blocks_lower_than_zero(mock_beta_create_proxy_stub):\n client = ProxyClient()\n with pytest.raises(ValueError) as e:\n client.get_random_blocks(-1)\n assert \"argument blocks cannot be lower or equal to 0\" in e.value",
"def test_block_bad_batch(self):\n pass",
"def t... | [
"0.7923534",
"0.68935853",
"0.65593106",
"0.648416",
"0.64344877",
"0.64289355",
"0.628009",
"0.612363",
"0.6088816",
"0.60799915",
"0.6017341",
"0.6012769",
"0.599657",
"0.59847265",
"0.5966976",
"0.5962124",
"0.5954565",
"0.594753",
"0.5930776",
"0.59181386",
"0.58925587",
... | 0.79978067 | 0 |
Determines exponential decay coefficient for despike filter. Fits an exponential decay function to the washout phase of standards to determine the washout time of your laser cell. The exponential coefficient reported is `nsd_below` standard deviations below the fitted exponent, to ensure that no real data is removed. | def find_expcoef(self, nsd_below=0., analyte=None, plot=False,
trimlim=None):
if analyte is None:
analyte = self.internal_standard
elif analyte not in self.minimal_analytes:
self.minimal_analytes.append(analyte)
print('Calculating exponential dec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_call_function_ExponentialDecay():\n a = 0.4 # Decay constant\n u0 = 3.2 # Function value u(t) for some known time t\n der_u = -1.28 # Analytic value for the derivative of u at the known time t\n eps = 10**(-7)# Since we are dealing with floating point numbers,\n ... | [
"0.64651",
"0.6414678",
"0.6395542",
"0.6353037",
"0.6284289",
"0.619193",
"0.6128068",
"0.6025675",
"0.6006096",
"0.5982528",
"0.58514756",
"0.5788993",
"0.57204634",
"0.5636638",
"0.5630312",
"0.5624656",
"0.55801344",
"0.55738604",
"0.5567606",
"0.5559123",
"0.5549107",
... | 0.67636365 | 0 |
Function to find local minima. | def findmins(self, x, y):
return x[np.r_[False, y[1:] < y[:-1]] & np.r_[y[:-1] < y[1:], False]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_local_minima(self, arr):\n\n # walks through array, finding local minima ranges\n\n # hacky way to initalize a new array to all false\n minima = (arr == -1) # initialize at all false\n min_range_start = 0\n decreasing = False\n for i in range(len(arr[:-1])):\n\n ... | [
"0.82634",
"0.80356014",
"0.72508687",
"0.722432",
"0.7163608",
"0.6978347",
"0.6950988",
"0.6911961",
"0.6828705",
"0.6797028",
"0.66628855",
"0.6649223",
"0.6498752",
"0.62362677",
"0.61901444",
"0.6162041",
"0.6161774",
"0.61223155",
"0.6084352",
"0.606724",
"0.6034333",
... | 0.55240524 | 57 |
Checks required directories are present. | def check_dir_exist(scheme):
if os.path.exists(scheme.prefix) is False:
print("ERROR: Required directory '{}' is missing! Exiting!").format(scheme.prefix)
sys.exit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_required_directories(self) -> None:\n\n if self._all_stages:\n for stage in self._all_stages:\n stage_cfg = self._app_cfg['stages'][stage]\n processor_cfg = stage_cfg['configuration']\n\n # Populate all the directories requested in the confi... | [
"0.742164",
"0.71260244",
"0.7083781",
"0.6989242",
"0.6961291",
"0.6729945",
"0.66952467",
"0.6656373",
"0.66277355",
"0.66277355",
"0.66277355",
"0.66277355",
"0.66277355",
"0.66277355",
"0.66277355",
"0.6619923",
"0.661422",
"0.6566125",
"0.655705",
"0.6537162",
"0.6523642... | 0.6185223 | 47 |
Return all nonabstract subclasses of the given kind class. | def __subkinds__(cls) -> typing.Iterable[type['dsl.Any']]:
def scan(subs: typing.Iterable[type['dsl.Any']]) -> typing.Iterable[type['dsl.Any']]:
"""Scan the class subtree of the given types.
Args:
subs: Iterable of classes to descend from.
Returns:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subclasses(cls) -> Iterator:\n for subclass in cls.__subclasses__():\n if subclass._type_definition.description: # type: ignore\n yield subclass\n yield from subclass.subclasses()",
"def getleafsubclasses(cls):\n scls = itersubclasses(cls)\n return [s for s ... | [
"0.6954449",
"0.68638784",
"0.63774365",
"0.63503635",
"0.62841254",
"0.6278294",
"0.6278294",
"0.62574106",
"0.6215135",
"0.61901516",
"0.6176975",
"0.6136451",
"0.61119455",
"0.6106036",
"0.6077145",
"0.6020922",
"0.59892297",
"0.59687406",
"0.5966659",
"0.5891039",
"0.5884... | 0.6926327 | 1 |
Check the given kind is of our type. | def match(cls, kind: 'dsl.Any') -> bool:
return isinstance(kind, cls) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_type(self, obj):\n return isinstance(obj, self.type_)",
"def CheckType(self, *args, **kwargs):\n pass",
"def is_type(self, typ):\n return typ == self.__class__.__name__",
"def is_valid_type(type):\n return type in type_to_adapter",
"def ContainsHandlesOrInterfaces(kind):\n #... | [
"0.7114784",
"0.69722956",
"0.6845358",
"0.6817635",
"0.66755646",
"0.65869826",
"0.6571978",
"0.64874387",
"0.6454575",
"0.6449043",
"0.6442731",
"0.6386812",
"0.63858825",
"0.6375703",
"0.63279814",
"0.63035226",
"0.62628084",
"0.6258652",
"0.6245005",
"0.6239373",
"0.62293... | 0.7642859 | 0 |
Ensure the given kind is of our type. | def ensure(cls, kind: 'dsl.Any') -> 'dsl.Any':
if not cls.match(kind):
raise _exception.GrammarError(f'{kind} is not a {cls.__name__}')
return kind | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_kind(kind: Any) -> None:\r\n if not kind in {\"T\", \"P\"}:\r\n raise ValueError(f\"`kind` should be 'T' or 'P', but got {kind}.\")",
"def match(cls, kind: 'dsl.Any') -> bool:\n return isinstance(kind, cls)",
"def type(self, kind):\n self.type = kind",
"def CheckType(self, ... | [
"0.7181561",
"0.69750905",
"0.6655074",
"0.6431849",
"0.6235251",
"0.62069523",
"0.61729264",
"0.61724645",
"0.6121802",
"0.60761887",
"0.6051545",
"0.604867",
"0.5996533",
"0.5992606",
"0.588941",
"0.58583516",
"0.58414704",
"0.5819663",
"0.5781005",
"0.57751024",
"0.5767717... | 0.7514466 | 0 |
Register a mock post request. | def post(self, *args, **kwargs):
self.request("post", *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mocked_requests_post(*args, **kwargs):\n response = {'message': 'Success!',\n 'data': {}}\n return MockResponse(json.dumps(response), 200, HEADERS)",
"def simulate_post(app, path, **kwargs) -> _ResultBase:\n return simulate_request(app, 'POST', path, **kwargs)",
"def simulate_post(s... | [
"0.7315056",
"0.7138311",
"0.6985317",
"0.6948394",
"0.6948394",
"0.6832909",
"0.6787354",
"0.6784518",
"0.67397577",
"0.6710557",
"0.66817945",
"0.65151757",
"0.64861983",
"0.6441692",
"0.63584286",
"0.632622",
"0.62594336",
"0.6240954",
"0.6235903",
"0.6201013",
"0.61735284... | 0.65058917 | 12 |
Register a mock patch request. | def patch(self, *args, **kwargs):
self.request("patch", *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_get(request):\n try:\n mp = request.getfixturevalue(\"monkeypatch\")\n except AttributeError: # pytest < 3\n mp = request.getfuncargvalue(\"monkeypatch\")\n mp.setattr(requests.Session, 'request', get_mockreturn)\n return mp",
"def inject_new_request(self):\n\n self.__... | [
"0.6766908",
"0.67187726",
"0.66860074",
"0.66543317",
"0.64593565",
"0.638943",
"0.63776773",
"0.6327596",
"0.625722",
"0.62134624",
"0.6044763",
"0.60439515",
"0.6013835",
"0.6000538",
"0.59469205",
"0.59418523",
"0.5936507",
"0.5924047",
"0.59188974",
"0.5839334",
"0.58083... | 0.6207198 | 10 |
Create a ClientSession that is bound to this mocker. | def create_session(self, loop):
session = ClientSession(loop=loop, json_serialize=json_dumps)
# Setting directly on `session` will raise deprecation warning
object.__setattr__(session, "_request", self.match_request)
return session | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session_client(session_app):\n yield Client(session_app)",
"def session(self) -> ClientSession:\r\n return self._session",
"async def create_session() -> aiohttp.ClientSession:\n\n headers = generate_header()\n\n client_session = aiohttp.ClientSession(headers=headers)\n return client_ses... | [
"0.70474505",
"0.6882821",
"0.68207735",
"0.67518646",
"0.6738343",
"0.67058945",
"0.66463405",
"0.66459435",
"0.6604116",
"0.65733504",
"0.6540843",
"0.6503026",
"0.64969736",
"0.64745903",
"0.6466513",
"0.6432825",
"0.6417912",
"0.64003724",
"0.636132",
"0.6356676",
"0.6325... | 0.70267636 | 1 |
curStt = current state curAct = current action reward = reward nxtStt = next state | def _update_q_table(self, curStt, curAct, reward, nxtStt):
if curStt is None:
return
eta = max(kMinLearningRate, kInitialLearningRate * (0.85 ** (self.num_steps // 100)))
maxNextQVal = learning_utils.max_dict_val(self.qTable[nxtStt])
self.qTable[curStt][curAct] = (self.qTabl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\r\n s = self.get_state()\r\n\r\n elements = np.arange(self.S)\r\n # weights = np.squeeze(self.nextStateProbability[s,action])\r\n weights = self.nextStateProbability[s, action]\r\n nexts = choices(elements, weights, k=1)[0]\r\n\r\n # p = self.nextSt... | [
"0.7082473",
"0.7045007",
"0.7027352",
"0.69990915",
"0.6974461",
"0.6915199",
"0.68023753",
"0.67664236",
"0.676617",
"0.6729915",
"0.6729292",
"0.6713853",
"0.67036295",
"0.6700871",
"0.6688881",
"0.66736895",
"0.6639472",
"0.66282433",
"0.6621675",
"0.6616349",
"0.65975267... | 0.0 | -1 |
Returns edge's vertices as a list | def edge_vertices(edge):
return [edge.vertex1, edge.vertex2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertices(self):\n return list(self._graph)",
"def get_vertices(self) -> []:\n return [i for i in self.adj_list]",
"def vertices(self):\n return list(self.__graph.values())",
"def vertices(self):\n s = set([x for x in self.edges.keys()])\n t = set([y for v in self.edges.... | [
"0.8404468",
"0.83918446",
"0.82920134",
"0.82107794",
"0.8026785",
"0.80223805",
"0.8017165",
"0.79836",
"0.7967742",
"0.79570633",
"0.79317445",
"0.79241127",
"0.79241127",
"0.79241127",
"0.7920825",
"0.7906056",
"0.7826281",
"0.77438474",
"0.7732046",
"0.7639237",
"0.75940... | 0.8856634 | 0 |
Delete the text between the two selection marks, if they are set, and place the cursor appropriately afterwards. Return True if something was deleted. | def delete(self):
if not self.selection.isSelection(): return False
# Save the current text
self.saveText()
sm1, sm2 = self.selection.order(self.selection.selectionMark,
self.selection.selectionMark2)
w1 = sm1[0]
w2 = sm2[0]
cx = sm1[1]
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doDeleteSelection(self):\n upperRow, upperCol, lowerRow, lowerCol = self.startAndEnd()\n self.doDelete(upperRow, upperCol, lowerRow, lowerCol)",
"def test_clear_selected_text(self):\n before_b = \"\"\"\\\n first line\n line 1\n line a\n line b\n line c\n las... | [
"0.660908",
"0.6541954",
"0.6492143",
"0.64192325",
"0.64179283",
"0.6404032",
"0.6344019",
"0.62987113",
"0.6115034",
"0.6092004",
"0.604098",
"0.59450394",
"0.5920913",
"0.5900359",
"0.5855375",
"0.5835758",
"0.57988596",
"0.5795234",
"0.57716674",
"0.57663816",
"0.5765438"... | 0.7505395 | 0 |
Return all environment variables available for current process. | def get_formatted_env_vars() -> str:
res = ""
for k, v in os.environ.items():
res += '{0}={1}\n'.format(k, v)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_env(self):\n env = {}\n for k, v in os.environ.items():\n k = k.decode() if isinstance(k, bytes) else k\n v = v.decode() if isinstance(v, bytes) else v\n env[k] = v\n return list(env.items())",
"def get_environment_vars():\n return {env: os.enviro... | [
"0.8115542",
"0.7964731",
"0.7775684",
"0.7766181",
"0.76928884",
"0.76126736",
"0.7568638",
"0.7375996",
"0.7368754",
"0.735972",
"0.73025984",
"0.72721595",
"0.72641325",
"0.7205365",
"0.71693134",
"0.71298754",
"0.71298754",
"0.71298754",
"0.71298754",
"0.7114081",
"0.7041... | 0.69035584 | 24 |
Return tuple with available actions. | def get_available_actions() -> tuple:
return tuple(method for method in dir(cli_commands) if callable(getattr(cli_commands, method))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_available_actions(self):\n return self.actions",
"def get_available_actions(self, state):\n pass",
"def get_actions(self):\n return []",
"def _get_actions(self):\n return self.__actions",
"def _get_actions(self):\n return self.__actions",
"def _get_actions(self):\n retur... | [
"0.8403378",
"0.80288595",
"0.79524237",
"0.7837824",
"0.7837824",
"0.7837824",
"0.7758686",
"0.7727043",
"0.7601043",
"0.75835586",
"0.75835586",
"0.7538213",
"0.752104",
"0.75169027",
"0.7483114",
"0.74823105",
"0.7364206",
"0.7333445",
"0.7325183",
"0.7307025",
"0.7277639"... | 0.8085617 | 1 |
calculates the sum of the total energies of the moons. Each moon's potential energy is the sum of the absolute values of its position components. Its kinetic energy is the sum of the absolute values of its velocity components. The total energy for a moon is the product of the kinetic and potential energies. | def calc_energy(pos, vels):
total_energy = 0
for i in range(len(pos)):
abs_positions = [abs(x) for x in pos[i]]
abs_vels = [abs(x) for x in vels[i]]
total_energy += sum(abs_positions) * sum(abs_vels)
return total_energy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_energy(self):\n energy = 0.5 * self.masses * np.sum(self.velocities * self.velocities, axis=1)\n avg_energy = np.mean(energy) # average kinetic energy of all particles\n return avg_energy",
"def energy(self):\n sum_energy = 0.0\n for i in range(0,self.natom... | [
"0.73617697",
"0.72068477",
"0.7046775",
"0.69424105",
"0.690531",
"0.68383294",
"0.68272346",
"0.68118083",
"0.67827535",
"0.6751506",
"0.6734464",
"0.6704174",
"0.6699093",
"0.6698451",
"0.66969305",
"0.6648148",
"0.6613368",
"0.65449625",
"0.6540692",
"0.6533759",
"0.65335... | 0.6066597 | 49 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, SharedFileMetadata):
return False
return self.to_dict() == other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, SharedFileMetadata):
return True
return self.to_dict() != other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
... | 0.0 | -1 |
Create the Metrics table. | def _create_metrics_table(font, format, base, create_glyph_metrics):
# we don't set PCF_COMPRESSED_METRICS
metrics = tuple(create_glyph_metrics(_g, base) for _g in font.glyphs)
table_bytes = (
bytes(le.uint32(format))
+ bytes(base.int32(len(metrics)))
+ b''.join(bytes(_t) for _t in m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_db(self, overwrite=False):\n current = list(self._cur.execute(\"select * from sqlite_master where type='table' and name='metrics'\"))\n if overwrite and len(current) >= 1:\n self._cur.execute('''DROP TABLE IF EXISTS metrics''')\n self._conn.commit()\n elif len... | [
"0.69029194",
"0.65370923",
"0.6484914",
"0.6387254",
"0.6361798",
"0.63576704",
"0.63134766",
"0.63074017",
"0.6268688",
"0.62463653",
"0.62414247",
"0.62226003",
"0.61748683",
"0.61669487",
"0.61395085",
"0.61179066",
"0.609004",
"0.60509336",
"0.5999917",
"0.59846944",
"0.... | 0.65096515 | 2 |
1hot encodes a tensor | def to_categorical(y, num_classes):
return np.eye(num_classes, dtype='uint8')[y] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[i,j] = 1\n \n return output",
"def one_hot_encode(self, arr, n_labels):\n one_hot = np.zeros((np.multiply(*arr.shape), n_labels), dtype=np.float32)\... | [
"0.8256395",
"0.8060953",
"0.80125964",
"0.79155993",
"0.7913623",
"0.7881918",
"0.78416723",
"0.7807666",
"0.7765339",
"0.7737043",
"0.7737043",
"0.77327216",
"0.77262837",
"0.77125543",
"0.76853484",
"0.76786506",
"0.7584764",
"0.75599515",
"0.7554624",
"0.75346327",
"0.753... | 0.0 | -1 |
Return the value of the state (computed in __init__). | def getValue(self, state):
return self.values[state] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self, state):\n raise NotImplementedError",
"def value(self, state):\n raise NotImplementedError",
"def value(self, state):\n\t\traise NotImplementedError",
"def getValue(self, state):\n util.raiseNotDefined()",
"def getValue(self, state):\n util.raiseNotDefined()",
... | [
"0.83014333",
"0.83014333",
"0.826012",
"0.8086146",
"0.8086146",
"0.79581815",
"0.79296756",
"0.78013283",
"0.77367806",
"0.77336967",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
"0.76010257",
... | 0.77333474 | 15 |
The policy is the best action in the given state according to the values currently stored in self.values. You may break ties any way you see fit. Note that if there are no legal actions, which is the case at the terminal state, you should return None. | def computeActionFromValues(self, state):
"*** YOUR CODE HERE ***"
#check if teminal
if self.mdp.isTerminal(state):
return None
else:
# get all actions for state
actionArr = self.mdp.getPossibleActions(state)
#Q val and action at index ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPolicy(self, state):\n \"*** YOUR CODE HERE ***\"\n # OUR CODE HERE\n possibleActions = self.mdp.getPossibleActions(state)\n #checking for terminal state (no possible actions)\n if len(possibleActions) is 0: \n return None\n \n #attempt at using the Counter\n eValsActions = ut... | [
"0.77924305",
"0.77131164",
"0.76167905",
"0.7607455",
"0.74945945",
"0.74680775",
"0.73742",
"0.73439854",
"0.7342425",
"0.73399556",
"0.7336353",
"0.73147756",
"0.73122734",
"0.7311828",
"0.7294938",
"0.7275715",
"0.72449946",
"0.72449946",
"0.71578217",
"0.7089983",
"0.708... | 0.68166065 | 38 |
Get a specific user by id. | def read_user_by_id(
user_id: int = Path(description="User id", example=1),
) -> schemas.User:
user = next((usr for usr in users if usr.id == user_id), None)
if not user:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"User with id={user_id} doesn't exist... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def get(self, id):\n\t\ttry:\n\t\t\tflask_app.logger.debug('We are getting the user: %d', id)\n\t\t\treturn user_service.get(id)\n\t\texcept AssertionError as e:\n\t\t\tuser_space... | [
"0.88417065",
"0.85353214",
"0.8532302",
"0.84828997",
"0.84399986",
"0.8371879",
"0.8312722",
"0.82950485",
"0.82752454",
"0.82303536",
"0.8205734",
"0.8205734",
"0.8205734",
"0.8205734",
"0.817708",
"0.8158661",
"0.81535053",
"0.8136354",
"0.81239873",
"0.812295",
"0.811521... | 0.8231121 | 9 |
Validate room has tiles. | def test_room_has_tiles(self):
self.assertGreaterEqual(self.room.tile_set.count(), 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_room_has_tiles(self):\n self.assertEqual(self.room.tile_set.count(), self.room.grid_size ** 2)",
"def test_tile_has_room(self):\n self.assertIs(self.tile1.room, self.room)\n self.assertIs(self.tile2.room, self.room)",
"def valid_tile(self, i, j):\n if (i >= 0 and i < self.r... | [
"0.7704127",
"0.705601",
"0.67850906",
"0.6374446",
"0.6367504",
"0.6290029",
"0.62320554",
"0.6210687",
"0.6171894",
"0.61524284",
"0.61337817",
"0.6098545",
"0.60813946",
"0.60603607",
"0.6059063",
"0.6058305",
"0.60373294",
"0.5990226",
"0.598417",
"0.5969097",
"0.59622383... | 0.7631565 | 1 |
Validate tiles have room. | def test_tile_has_room(self):
self.assertIs(self.tile1.room, self.room)
self.assertIs(self.tile2.room, self.room) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_room_has_tiles(self):\n self.assertEqual(self.room.tile_set.count(), self.room.grid_size ** 2)",
"def test_room_has_tiles(self):\n self.assertGreaterEqual(self.room.tile_set.count(), 2)",
"def is_valid_room(self, x, y):\r\n return 0 <= x < self.__nx and 0 <= y < self.__ny",
"def... | [
"0.76864284",
"0.7679924",
"0.68422973",
"0.68355393",
"0.65969",
"0.6463397",
"0.64245325",
"0.635184",
"0.6240748",
"0.62203586",
"0.61672276",
"0.61662745",
"0.61648524",
"0.6101781",
"0.6092568",
"0.60869837",
"0.6085178",
"0.6063352",
"0.60469484",
"0.6036171",
"0.601497... | 0.75068253 | 2 |
Validate room has tiles. | def test_room_has_tiles(self):
self.assertEqual(self.room.tile_set.count(), self.room.grid_size ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_room_has_tiles(self):\n self.assertGreaterEqual(self.room.tile_set.count(), 2)",
"def test_tile_has_room(self):\n self.assertIs(self.tile1.room, self.room)\n self.assertIs(self.tile2.room, self.room)",
"def valid_tile(self, i, j):\n if (i >= 0 and i < self.rows) and (j >= 0... | [
"0.7631565",
"0.705601",
"0.67850906",
"0.6374446",
"0.6367504",
"0.6290029",
"0.62320554",
"0.6210687",
"0.6171894",
"0.61524284",
"0.61337817",
"0.6098545",
"0.60813946",
"0.60603607",
"0.6059063",
"0.6058305",
"0.60373294",
"0.5990226",
"0.598417",
"0.5969097",
"0.59622383... | 0.7704127 | 0 |
Tests a nested json object | def test_nested_obj(self):
jobj = JObject(keys = ['status', JObject(parent = 'nest', keys= ['a','b']),
'result'])
jdic = json.loads('{"status": "success", "result": "yes", "nest": {"a":1,"b":2}}')
self.assertTrue(check_json_object(jdic, jobj)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nested_objf(self):\n jobj = JObject(keys = ['status', JObject(parent = 'nest', keys= ['a','b']), \n 'result'])\n jdic = json.loads('{\"status\": \"success\", \"result\": \"yes\", \"nest\": {\"a\":1,\"bc\":2}}')\n self.assertFalse(check_json_object(jdic, j... | [
"0.837899",
"0.7476193",
"0.734045",
"0.70384514",
"0.6960546",
"0.69479436",
"0.68555593",
"0.6681071",
"0.6660543",
"0.66485333",
"0.6594173",
"0.6524314",
"0.65115094",
"0.65007097",
"0.6478751",
"0.64783305",
"0.6455583",
"0.64046764",
"0.64046764",
"0.6401401",
"0.631943... | 0.83437496 | 1 |
Tests a nested json object | def test_nested_objf(self):
jobj = JObject(keys = ['status', JObject(parent = 'nest', keys= ['a','b']),
'result'])
jdic = json.loads('{"status": "success", "result": "yes", "nest": {"a":1,"bc":2}}')
self.assertFalse(check_json_object(jdic, jobj)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nested_obj(self):\n jobj = JObject(keys = ['status', JObject(parent = 'nest', keys= ['a','b']), \n 'result'])\n jdic = json.loads('{\"status\": \"success\", \"result\": \"yes\", \"nest\": {\"a\":1,\"b\":2}}')\n self.assertTrue(check_json_object(jdic, jobj... | [
"0.83437496",
"0.7476193",
"0.734045",
"0.70384514",
"0.6960546",
"0.69479436",
"0.68555593",
"0.6681071",
"0.6660543",
"0.66485333",
"0.6594173",
"0.6524314",
"0.65115094",
"0.65007097",
"0.6478751",
"0.64783305",
"0.6455583",
"0.64046764",
"0.64046764",
"0.6401401",
"0.6319... | 0.837899 | 0 |
r"""Method that serializes using repr. | def _func_serialize(self, args): # pragma: no cover
return repr(args).encode("utf-8") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repr_(object_):\n return repr(object_)",
"def repr(x) -> String:\n pass",
"def srepr(obj):\n return repr(str(obj))",
"def _repr_(self):\n return repr(self.element())",
"def __str__(self):\r\n return repr(self)",
"def repr(self):\n raise InterpreterError(\"Unimplemented rep... | [
"0.8041274",
"0.7581183",
"0.75757635",
"0.75125456",
"0.75091517",
"0.7482744",
"0.7460879",
"0.741524",
"0.7297219",
"0.72680026",
"0.7257146",
"0.72568077",
"0.72568077",
"0.72568077",
"0.723906",
"0.72315437",
"0.7197695",
"0.71682173",
"0.715862",
"0.7145029",
"0.7122028... | 0.0 | -1 |
r"""Method that serializes using repr. | def func_serialize(self, args): # pragma: no cover
return repr(args).encode("utf-8") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repr_(object_):\n return repr(object_)",
"def repr(x) -> String:\n pass",
"def srepr(obj):\n return repr(str(obj))",
"def _repr_(self):\n return repr(self.element())",
"def __str__(self):\r\n return repr(self)",
"def repr(self):\n raise InterpreterError(\"Unimplemented rep... | [
"0.8040005",
"0.7579492",
"0.75745773",
"0.75117767",
"0.75083095",
"0.74822277",
"0.7460173",
"0.7414785",
"0.7296227",
"0.7267139",
"0.72562736",
"0.7255979",
"0.7255979",
"0.7255979",
"0.72375643",
"0.7230206",
"0.7196173",
"0.7168388",
"0.7157207",
"0.71445584",
"0.712068... | 0.0 | -1 |
r"""Method that serializes using repr. | def _func_serialize(self, args):
return args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repr_(object_):\n return repr(object_)",
"def repr(x) -> String:\n pass",
"def srepr(obj):\n return repr(str(obj))",
"def _repr_(self):\n return repr(self.element())",
"def __str__(self):\r\n return repr(self)",
"def repr(self):\n raise InterpreterError(\"Unimplemented rep... | [
"0.8041274",
"0.7581183",
"0.75757635",
"0.75125456",
"0.75091517",
"0.7482744",
"0.7460879",
"0.741524",
"0.7297219",
"0.72680026",
"0.7257146",
"0.72568077",
"0.72568077",
"0.72568077",
"0.723906",
"0.72315437",
"0.7197695",
"0.71682173",
"0.715862",
"0.7145029",
"0.7122028... | 0.0 | -1 |
Pydantic validator for 'color' fields, stored as float values. | def parse_color(raw_color) -> list[float]:
if isinstance(raw_color, str):
return list(to_rgba(raw_color))
return list(raw_color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_color(color):\n if not isinstance(color, (list, tuple)):\n raise ValueError(\"Color has to be list, or tuple\")\n if len(color) != 3:\n raise ValueError(\"Color have to contain exactly 3 values: [R, G, B]\")\n for channel in color:\n validate_channel_value(channel)",
"... | [
"0.6340296",
"0.6321515",
"0.60925937",
"0.60722464",
"0.6015246",
"0.5970754",
"0.591337",
"0.5883051",
"0.5872581",
"0.5682112",
"0.56716675",
"0.56398314",
"0.56013125",
"0.5587806",
"0.5570233",
"0.5567383",
"0.55535704",
"0.5503893",
"0.54972774",
"0.5483965",
"0.5478762... | 0.52171755 | 31 |
Create a new instance filled with data from a dict | def get_from_dict(cls, data):
s = cls()
for x in data:
if x in s.__dict__:
s.__dict__[x] = data[x]
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(cls, data):\r\n instance = cls()\r\n for key, value in data.items():\r\n instance.__dict__[key] = value\r\n return instance",
"def from_dict(cls, data):\n return cls(**data)",
"def from_dict(cls, data: Dict[str, any]):\n return cls(**data)",
"def fr... | [
"0.8499117",
"0.84953666",
"0.8203479",
"0.8074491",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.807109",
"0.... | 0.7745505 | 54 |
Rotate x by d bits to the right. | def rotate_right(x, d):
d = d % N
out = x >> d
for i in range(d):
bit = (x & 2**i)>>i
out |= bit << (N+i-d)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_left(x, d):\n d = d % N\n out = x << d\n excess = out \n out = out & (2**N-1)\n for i in range(d):\n bit = (x & 2**(N-1-d+1+i))>> (N-1-d+1+i)\n out |= bit << i\n return out",
"def ROT(self, n, d):\n m = d % self.bits\n\n if m > 0:\n return (n <<... | [
"0.7741098",
"0.73934054",
"0.69882625",
"0.6870834",
"0.67119545",
"0.670654",
"0.66789126",
"0.6512578",
"0.6386141",
"0.6373165",
"0.63133234",
"0.6213941",
"0.6165624",
"0.6106975",
"0.60689616",
"0.6062601",
"0.60613406",
"0.6017785",
"0.60149693",
"0.5989342",
"0.598933... | 0.8759155 | 0 |
Return ith bit of x | def bit_component(x, i):
return (x & 2**i) >> i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitget(x, n):\n return (x >> n) & 1",
"def get_bit(x, k):\n\n return (x >> k) & 1",
"def bintogray(x: int) -> int:\n assert x >= 0\n return x ^ (x >> 1)",
"def bit_in_place(x, n):\n return (x & 2**n)",
"def get_jth_bit(x,j):\n return 1 & (x >> j)",
"def get_bit(num, i):\r\n retur... | [
"0.8165742",
"0.7865018",
"0.7779134",
"0.7749941",
"0.7677355",
"0.7677312",
"0.74217135",
"0.7313628",
"0.7261065",
"0.72412646",
"0.7225677",
"0.71477795",
"0.71237415",
"0.71147555",
"0.7058111",
"0.7013975",
"0.69909656",
"0.6961087",
"0.6920864",
"0.6905907",
"0.689747"... | 0.8021896 | 1 |
Return the exit point of hypercube i. | def f(i):
return e(2**N-1-i) ^ 2**(N-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_exit_position(labyrinth: Labyrinth) -> Tuple[int, int]:\n return labyrinth.get_exit_position()",
"def i (self):\n\n return self.end - 1",
"def get_exit_junction(self, id):\n return self.sections[id][-1]",
"def getEta( self, i : int ):\n return enumerate(self._Vals[i][ \\\... | [
"0.61058974",
"0.58478206",
"0.57447",
"0.5718174",
"0.56607354",
"0.56471753",
"0.56067854",
"0.5600481",
"0.55777776",
"0.5538399",
"0.54872316",
"0.5483473",
"0.5468939",
"0.54635125",
"0.54585654",
"0.5456396",
"0.5453032",
"0.54391664",
"0.5433484",
"0.54305494",
"0.5382... | 0.0 | -1 |
Return the Hilbert index of point p | def TR_algo2(p, vd=2):
# h will contain the Hilbert index
h = 0
# ve and vd contain the entry point and dimension of the current subcube
# we choose here a main traversal direction N-2 (i.e. z for a cube) to match
# the illustrations
ve = 0
for i in range(M-1, -1, -1):
# the cell lab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pentagonal_index(P):\n return (1 + sqrt(1 + 24 * P)) / 6",
"def get_pent_idx(pent):\n pidx = 0\n for i in range(pent.shape[0]):\n for j in range(pent.shape[1]):\n if pent[i][j] != 0:\n pidx = pent[i][j]\n break\n if pidx != 0:\n break... | [
"0.73465323",
"0.6523453",
"0.6260551",
"0.6189357",
"0.61781377",
"0.61645234",
"0.6135419",
"0.6101155",
"0.6022699",
"0.5997809",
"0.5899292",
"0.5838814",
"0.5804911",
"0.5775439",
"0.57406306",
"0.5737077",
"0.57341826",
"0.57304424",
"0.5722181",
"0.5715056",
"0.5689412... | 0.5950255 | 10 |
Max at x= pi/3, Min at x= 5pi/3. | def f5(x):
return 2* sin(x) + sin(2*x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clamp(x: float, min_x: float, max_x: float) -> float:\n if x < min_x:\n return min_x\n elif x > max_x:\n return max_x\n return x",
"def construct(self, x):\n return self.max(x * 0.2, x)",
"def clamp(value, mn, mx):\n\n return max(min(value, mx), mn)",
"def appmag(x, xlim=... | [
"0.61691886",
"0.6020761",
"0.6018333",
"0.59840316",
"0.5979493",
"0.5908504",
"0.58974016",
"0.58869725",
"0.5864893",
"0.58221036",
"0.5779535",
"0.5740534",
"0.5740534",
"0.5738942",
"0.5725311",
"0.5716748",
"0.5706076",
"0.5699617",
"0.5699617",
"0.56651753",
"0.5663078... | 0.0 | -1 |
Creates dataframe of values of key variable, rows are time and columns are symbols. | def variable_extractor(variable: str, df, frequency: str):
#Extract list of unique symbols from dataset
symbols = list(df['symbol'].unique())
df_master=pd.DataFrame()
for symbol in symbols:
print(symbol)
subset = df.loc[df['symbol'] == symbol]
#Drop random duplicates in data
subset.drop_duplicates(inplace=T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataframe(self):\n dictionary = OrderedDict(zip(self.keys, [[value] for value in self.values]))\n dataframe = pd.DataFrame(dictionary)\n return dataframe",
"def to_observations_dataframe(self, sql_ctx, ts_col='timestamp', key_col='key', val_col='value'):\n ssql_ctx = sql_ctx._ssql... | [
"0.60266125",
"0.6000418",
"0.5980432",
"0.5954871",
"0.5823408",
"0.5762141",
"0.5761252",
"0.5755099",
"0.5749679",
"0.57414186",
"0.5723556",
"0.5665265",
"0.56378543",
"0.55755496",
"0.55700207",
"0.5552657",
"0.55246943",
"0.5517312",
"0.5460048",
"0.5452598",
"0.5416995... | 0.0 | -1 |
Converts the specified Tensor to a ``coo_matrix``. | def to_coo_matrix(tensor):
if not isinstance(tensor, CooTensor):
raise ValueError("The Tensor must be an Instance of CooTensor.")
s = tensor.shape
if len(s) > 2:
raise ValueError("Only one- and two-dimensional COO tensors are "
"supported.")
if len(s) == 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_coo_matrix(self):\n row_indices, column_indices, nonzero_elements = self.to_ijv()\n return coo_matrix((nonzero_elements, (row_indices, column_indices)),\n shape=(self.size, self.size))",
"def to_tensor(mtx):\n\n if not isinstance(mtx, coo_matrix):\n raise V... | [
"0.7374052",
"0.6949848",
"0.65512097",
"0.64886487",
"0.6406249",
"0.59786797",
"0.5954822",
"0.59018415",
"0.5873858",
"0.58156514",
"0.5760898",
"0.5601871",
"0.5522299",
"0.548397",
"0.53748983",
"0.5344623",
"0.5334342",
"0.53278524",
"0.53235424",
"0.52707905",
"0.52453... | 0.8501659 | 0 |
Line that doesn't start with Track ID raises ValueError | def testBadLine(self):
self.assertRaises(
ValueError,
tools._trackInfo,
'not a real line'
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testSingleDigitTrackID(self):\n\n trackLine = _buildTrackLine(5, 'video', {'hello': 'goodbye'})\n\n trackID, trackType, trackDict = tools._trackInfo(trackLine)\n\n self.assertEqual(\n 5,\n trackID\n )",
"def testDoubleDigitTrackID(self):\n\n trackLine ... | [
"0.6597592",
"0.6559629",
"0.6507991",
"0.6494863",
"0.6358727",
"0.6078353",
"0.60187113",
"0.59858674",
"0.59858674",
"0.59014034",
"0.58424234",
"0.58030105",
"0.57829833",
"0.5701664",
"0.5639642",
"0.5603148",
"0.55337334",
"0.55337334",
"0.55337334",
"0.55337334",
"0.55... | 0.6707055 | 0 |
Tests that a default_track key is added to the dictionary | def testNoDefaultTrack(self):
trackLine = _buildTrackLine(0, 'video', {'hello': 'goodbye'})
trackID, trackType, trackDict = tools._trackInfo(trackLine)
self.assertTrue(
'default_track' in trackDict.keys()
)
self.assertEqual(
trackDict['default_track'],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDefaultTrackTrue(self):\n\n trackLine = _buildTrackLine(0, 'video',\n {'hello': 'goodbye', 'default_track': '1'})\n\n trackID, trackType, trackDict = tools._trackInfo(trackLine)\n\n self.assertTrue(\n 'default_track' in trackDict.keys()\n ... | [
"0.76266444",
"0.64104724",
"0.6243642",
"0.6175727",
"0.59782034",
"0.5968197",
"0.58747035",
"0.5733871",
"0.5647445",
"0.5644865",
"0.56189287",
"0.55625564",
"0.55470544",
"0.547424",
"0.5473437",
"0.546784",
"0.5456964",
"0.5445123",
"0.5428331",
"0.54133415",
"0.5412658... | 0.7154742 | 1 |
Tests that the language setting was read correctly | def testLanguage(self):
if self.language in tools.LANGUAGES:
self.assertEqual(
self.language,
self.config.language
)
else:
self.assertNotEqual(
self.language,
self.config.language
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_settings(self):\n \n self.assertTrue(settings.USE_I18N, msg=\"setting USE_I18N must be True to have languages working\")",
"def test_set_language(self):\n # Test for default languages\n self.assertEqual(self.scraper.language_original, 'jpn')\n self.assertEqual(self.scr... | [
"0.77329516",
"0.74919087",
"0.73760307",
"0.7365057",
"0.71979874",
"0.71692675",
"0.7078376",
"0.7029029",
"0.6957166",
"0.6952647",
"0.6952647",
"0.68127465",
"0.6797086",
"0.67602295",
"0.66661924",
"0.66584176",
"0.6616644",
"0.65922046",
"0.65753114",
"0.6483044",
"0.64... | 0.81987476 | 0 |
Tests that a NoOptionError becomes a ValueError | def testNoSup2SubOptionError(self):
# Build out custom ini file
self.sup2Sub = ""
self.handBrake = "/usr/apps/Handbrake/HandBrakeCLI"
self.java = "/usr/apps/Java/jre7/bin/java"
self.mkvExtract = "/usr/apps/bin/mkvTools/mkvextract"
self.mkvMerge = "/usr/apps/bin/mkvTools/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_config_options_output():\n\n with pytest.raises(InputError):\n _check_input_config({\"unknown_key_1\": 1})",
"def test_invalidValues(self):\n argV = \"--fooint egg\".split()\n self.assertRaises(usage.UsageError, self.usage.parseOptions, argV)",
"def test_option_unhandle... | [
"0.68053734",
"0.67548466",
"0.67541",
"0.6729731",
"0.6708106",
"0.67021185",
"0.66941124",
"0.6656509",
"0.6619542",
"0.6602076",
"0.647067",
"0.64351535",
"0.6396275",
"0.63900423",
"0.6382029",
"0.6366851",
"0.63334876",
"0.6315655",
"0.6314539",
"0.6297938",
"0.6252087",... | 0.0 | -1 |
Tests that a NoOptionError becomes a ValueError | def testNoHandbrakeOptionError(self):
# Build out custom ini file
self.sup2Sub = "/usr/apps/bin/mkvTools/BDSup2Sub.jar"
self.handBrake = ""
self.java = "/usr/apps/Java/jre7/bin/java"
self.mkvExtract = "/usr/apps/bin/mkvTools/mkvextract"
self.mkvMerge = "/usr/apps/bin/mkv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_config_options_output():\n\n with pytest.raises(InputError):\n _check_input_config({\"unknown_key_1\": 1})",
"def test_invalidValues(self):\n argV = \"--fooint egg\".split()\n self.assertRaises(usage.UsageError, self.usage.parseOptions, argV)",
"def test_option_unhandle... | [
"0.68053734",
"0.67548466",
"0.67541",
"0.6729731",
"0.6708106",
"0.67021185",
"0.66941124",
"0.6656509",
"0.6619542",
"0.6602076",
"0.647067",
"0.64351535",
"0.6396275",
"0.63900423",
"0.6382029",
"0.6366851",
"0.63334876",
"0.6315655",
"0.6314539",
"0.6297938",
"0.6252087",... | 0.0 | -1 |
Tests that a NoOptionError becomes a ValueError | def testNoJavaOptionError(self):
# Build out custom ini file
self.sup2Sub = "/usr/apps/bin/mkvTools/BDSup2Sub.jar"
self.handBrake = "/usr/apps/Handbrake/HandBrakeCLI"
self.java = ""
self.mkvExtract = "/usr/apps/bin/mkvTools/mkvextract"
self.mkvMerge = "/usr/apps/bin/mkvT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_config_options_output():\n\n with pytest.raises(InputError):\n _check_input_config({\"unknown_key_1\": 1})",
"def test_invalidValues(self):\n argV = \"--fooint egg\".split()\n self.assertRaises(usage.UsageError, self.usage.parseOptions, argV)",
"def test_option_unhandle... | [
"0.68053734",
"0.67548466",
"0.67541",
"0.6729731",
"0.6708106",
"0.67021185",
"0.66941124",
"0.6656509",
"0.6619542",
"0.6602076",
"0.647067",
"0.64351535",
"0.6396275",
"0.63900423",
"0.6382029",
"0.6366851",
"0.63334876",
"0.6315655",
"0.6314539",
"0.6297938",
"0.6252087",... | 0.0 | -1 |
Tests that a NoOptionError becomes a ValueError | def testNoMkvExtractOptionError(self):
# Build out custom ini file
self.sup2Sub = "/usr/apps/bin/mkvTools/BDSup2Sub.jar"
self.handBrake = "/usr/apps/Handbrake/HandBrakeCLI"
self.java = "/usr/apps/Java/jre7/bin/java"
self.mkvExtract = ""
self.mkvMerge = "/usr/apps/bin/mkv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_config_options_output():\n\n with pytest.raises(InputError):\n _check_input_config({\"unknown_key_1\": 1})",
"def test_invalidValues(self):\n argV = \"--fooint egg\".split()\n self.assertRaises(usage.UsageError, self.usage.parseOptions, argV)",
"def test_option_unhandle... | [
"0.6805354",
"0.6754944",
"0.675383",
"0.6730079",
"0.6707134",
"0.6701782",
"0.6694025",
"0.66571283",
"0.6618601",
"0.66032016",
"0.64691454",
"0.64353293",
"0.63972616",
"0.6389419",
"0.63816524",
"0.63667107",
"0.63324565",
"0.63150746",
"0.63148206",
"0.6298182",
"0.6252... | 0.0 | -1 |
Tests that a NoOptionError becomes a ValueError | def testNoMkvMergeOptionError(self):
# Build out custom ini file
self.sup2Sub = "/usr/apps/bin/mkvTools/BDSup2Sub.jar"
self.handBrake = "/usr/apps/Handbrake/HandBrakeCLI"
self.java = "/usr/apps/Java/jre7/bin/java"
self.mkvExtract = "/usr/apps/bin/mkvTools/mkvextract"
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_config_options_output():\n\n with pytest.raises(InputError):\n _check_input_config({\"unknown_key_1\": 1})",
"def test_invalidValues(self):\n argV = \"--fooint egg\".split()\n self.assertRaises(usage.UsageError, self.usage.parseOptions, argV)",
"def test_option_unhandle... | [
"0.68053734",
"0.67548466",
"0.67541",
"0.6729731",
"0.6708106",
"0.67021185",
"0.66941124",
"0.6656509",
"0.6619542",
"0.6602076",
"0.647067",
"0.64351535",
"0.6396275",
"0.63900423",
"0.6382029",
"0.6366851",
"0.63334876",
"0.6315655",
"0.6314539",
"0.6297938",
"0.6252087",... | 0.0 | -1 |
Tests that a NoSectionError becomes a ValueError | def testNoPrograms(self):
# Get our formatted ini file
self.configFile = CONFIG_NO_PROGRAMS
# Build our config
with tempfile.NamedTemporaryFile(mode='r+b') as f:
f.write(self.configFile)
# Calling readlines on the temp file. Without this Config fails to
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_invalid_section(self):\n arm = self.ar[2009][11]\n self.assertRaises(KeyError, arm.__getitem__, 'invalid_section')",
"def test_get_invalid_line(self):\n ars = self.ar[2009][11]['general']\n self.assertRaises(KeyError, ars.__getitem__, 'invalid_section')",
"def test_inva... | [
"0.76698405",
"0.75208616",
"0.72662467",
"0.69059795",
"0.67185265",
"0.6636408",
"0.6626025",
"0.65526724",
"0.6547628",
"0.65169734",
"0.6458622",
"0.64029896",
"0.63382655",
"0.6309335",
"0.62974524",
"0.6264021",
"0.6182466",
"0.6086827",
"0.60711986",
"0.60711986",
"0.6... | 0.0 | -1 |
Tests that a missing config file raises an IOError | def testNoConfig(self):
mockOpen = mock.mock_open()
with mock.patch('__builtin__.open', mockOpen, create=True):
self.assertRaises(
IOError,
tools.Config,
'fakeIniFile.ini'
)
mockOpen.assert_called_once_with('fakeIniFil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_configuration_raises_an_exception_when_file_does_not_exist():\n with pytest.raises(FileNotFoundError):\n config.load_configuration(invalid_configuration_path)",
"def test_load_configuration_fails_gracefully_when_file_does_not_exist():\n config.load_configuration(invalid_con... | [
"0.8346775",
"0.8234966",
"0.80062044",
"0.7951011",
"0.7857871",
"0.7852942",
"0.77534795",
"0.77063656",
"0.7669143",
"0.76485527",
"0.76378626",
"0.7540922",
"0.7426771",
"0.74144524",
"0.737455",
"0.7356379",
"0.7330501",
"0.73291516",
"0.7321104",
"0.7281949",
"0.7239212... | 0.7454143 | 12 |
Simple method to generate a random cluster name. | def generate_cluster_name():
ADJECTIVES = (
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "quiet", "white", "cool", "winter", "quick",
"patient", "twilight", "crimson", "wispy", "weathered", "blue",
"broken", "cold", "damp", "falling", "fro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_rand_name() -> str:\n suf = \"\".join(random.choices(string.ascii_uppercase + string.digits, k=6))\n return f\"exporters_{suf}\"",
"def generate_name(self):\n letters = string.ascii_letters\n random_name = ''.join(random.choice(letters) for _ in range(10))\n assert isinsta... | [
"0.7510601",
"0.7331269",
"0.72372246",
"0.7102206",
"0.70758575",
"0.7029581",
"0.69771934",
"0.697214",
"0.69636816",
"0.6956957",
"0.6947118",
"0.690397",
"0.68392766",
"0.68318564",
"0.6766923",
"0.67474395",
"0.67360234",
"0.66894734",
"0.66666394",
"0.66622615",
"0.6662... | 0.8211141 | 0 |
Return a taxlot state populated with pseudo random data | def get_taxlot_state(self, organization=None, **kw):
taxlot_details = {}
if 'no_default_data' not in kw:
taxlot_details = self.get_details()
else:
del kw['no_default_data']
taxlot_details.update(kw)
org = self._get_attr('organization', organization)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_state(self):\n \n self.state = np.random.choice(['checkout', 'dairy', 'drinks', 'fruit', 'spices'], p=self.tr_array_dict[f'{self.state}'])",
"def rand(self):\n return self.State.rand()",
"def sample(self):\n x = self.state\n# dx = self.theta * (self.mu - x) + self.sig... | [
"0.7410216",
"0.6749461",
"0.67086345",
"0.670357",
"0.670357",
"0.670357",
"0.670357",
"0.670357",
"0.6696778",
"0.66843545",
"0.66800725",
"0.66706353",
"0.6645671",
"0.6628989",
"0.66086066",
"0.6599826",
"0.64371413",
"0.63752556",
"0.6357058",
"0.63456243",
"0.6310371",
... | 0.0 | -1 |
Returns the number of stages in this | def __len__(self):
return len(self.trained_rqrmi) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_stages(self) -> int:\n return self.pg_mesh.size(self.pipeline_axis)",
"def N_stages(self):\n return 5",
"def num_stages(tree, order):\n p = len(order)\n stages = cstree_to_stages(tree, order)\n return sum([len(stages[i]) for i in range(1,p)])",
"def n_delay_stages(self):\n ... | [
"0.81587046",
"0.7908782",
"0.74789083",
"0.7388166",
"0.7388166",
"0.7368886",
"0.7368886",
"0.7337495",
"0.71867603",
"0.7008982",
"0.6951378",
"0.6835542",
"0.6823154",
"0.67896664",
"0.6672923",
"0.66471636",
"0.6536639",
"0.6488809",
"0.647391",
"0.64570665",
"0.6455402"... | 0.0 | -1 |
Calculate the maximum error per error of this | def calculate_submodel_error(self, stage_idx, submodel_idx):
return rqrmilib.calculate_submodel_error(self._get_native_object(), self.probe, stage_idx, submodel_idx) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_error(self) -> float:\n return float(np.max(np.abs(self._flattened_errors())))",
"def max_abs_error(self) -> float:\n return np.max(np.abs([self.error]))",
"def max_error(self):\n print('Maximum residual error: ' + str(max_error(self.model.dataset.get_y_test(), self.model.get_predi... | [
"0.7917384",
"0.7289082",
"0.71025336",
"0.682215",
"0.66918457",
"0.6672711",
"0.65993714",
"0.6493282",
"0.6483064",
"0.64011896",
"0.6376022",
"0.6365558",
"0.63627565",
"0.6328789",
"0.63164604",
"0.6298619",
"0.6269994",
"0.6268558",
"0.62555546",
"0.6236161",
"0.6218333... | 0.0 | -1 |
note that having hours and minutes expressed like that, like an integer is not exactly minutes that we extract but it is ok, we don't care to be exact | def __init__(self, data_frame, mins_set):
# super(FeaturePrevDelays, self).__init__()
self.df = data_frame.copy()
self.mins_set = mins_set | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minutes(input=None):\n return get(input).minutes",
"def verify_time_value(hour, minute):\r\n new_hour = (hour % 24) + (minute // 60)\r\n new_minute = (minute % 60)\r\n return new_hour, new_minute",
"def calculate_minutes(time):\n return int(time / 60)",
"def minutes_in(sec):\r\... | [
"0.7146892",
"0.7065685",
"0.6955095",
"0.6948912",
"0.68261474",
"0.677383",
"0.6756453",
"0.6741671",
"0.6671318",
"0.66596556",
"0.6536567",
"0.64848804",
"0.64676696",
"0.6424378",
"0.6418419",
"0.64164245",
"0.63955694",
"0.63903695",
"0.6352076",
"0.63452417",
"0.633590... | 0.0 | -1 |
note that having hours and minutes expressed like that, like an integer is not exactly minutes that we extract but it is ok, we don't care to be exact | def getFlightsBefore(df, target, mins):
shouldHaveDeparted = target['DEP_TIME'] - df['CRS_ELAPSED_TIME']
condition_mins_before = (shouldHaveDeparted - mins) < df['DEP_TIME']
return df[condition_mins_before] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minutes(input=None):\n return get(input).minutes",
"def verify_time_value(hour, minute):\r\n new_hour = (hour % 24) + (minute // 60)\r\n new_minute = (minute % 60)\r\n return new_hour, new_minute",
"def calculate_minutes(time):\n return int(time / 60)",
"def minutes_in(sec):\r\... | [
"0.7146356",
"0.70648575",
"0.6956252",
"0.69500357",
"0.68280107",
"0.6773244",
"0.6755413",
"0.6742382",
"0.6672722",
"0.6662035",
"0.6535638",
"0.64853364",
"0.64686257",
"0.6424768",
"0.64191633",
"0.64163697",
"0.6397655",
"0.6391035",
"0.6350088",
"0.6347226",
"0.633680... | 0.0 | -1 |
Initialize a list of context modality queues. | def __init__(self):
self.queues=[] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_queues(self):\n for step in self.get_children():\n if step.kind == StepKinds.queue:\n step.init_object(self.context, None)",
"def init_email_queue():\n g.setdefault('email_queue', [])",
"def __init__(self, contexts):\n self._contexts = set(contexts)",
"def ... | [
"0.7016182",
"0.60048276",
"0.5960835",
"0.5944115",
"0.59045446",
"0.5831289",
"0.5778298",
"0.57445073",
"0.5739378",
"0.57386106",
"0.5724419",
"0.5716647",
"0.5715617",
"0.571021",
"0.571021",
"0.5705724",
"0.5700557",
"0.5681897",
"0.5678331",
"0.56767684",
"0.56714165",... | 0.6296364 | 1 |
Retrieves the object lifecycle policy that is assigned to a container. | def get_lifecycle_policy(ContainerName=None):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_container_policy(ContainerName=None):\n pass",
"def get_metric_policy(ContainerName=None):\n pass",
"def get_acl_policy(client, container_name, policy_name, **kwargs):\n acl = _get_acl(client, container_name, **kwargs)\n return acl.get(policy_name)",
"def get_policy(self):\n\n retu... | [
"0.7081821",
"0.60000235",
"0.59135735",
"0.5802629",
"0.57051605",
"0.5657881",
"0.5645516",
"0.5562184",
"0.5531622",
"0.54111326",
"0.539277",
"0.53679305",
"0.53557134",
"0.53557134",
"0.53380495",
"0.5336885",
"0.52579087",
"0.52471215",
"0.52471215",
"0.52471215",
"0.52... | 0.7961994 | 0 |
Returns the metric policy for the specified container. | def get_metric_policy(ContainerName=None):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_container_policy(ContainerName=None):\n pass",
"def get_acl_policy(client, container_name, policy_name, **kwargs):\n acl = _get_acl(client, container_name, **kwargs)\n return acl.get(policy_name)",
"def get_lifecycle_policy(ContainerName=None):\n pass",
"def put_metric_policy(ContainerNam... | [
"0.746879",
"0.6348673",
"0.59763455",
"0.57475805",
"0.57050383",
"0.56452477",
"0.5509333",
"0.54830515",
"0.5449665",
"0.544359",
"0.54223645",
"0.54223645",
"0.5418407",
"0.5418407",
"0.54044306",
"0.5383104",
"0.5383104",
"0.5383104",
"0.5375872",
"0.5375872",
"0.5375872... | 0.82179594 | 0 |
Returns center cropped image | def center_crop(img, dim):
width, height = img.shape[1], img.shape[0]
# process crop width and height for max available dimension
crop_width = dim[0] if dim[0] < img.shape[1] else img.shape[1]
crop_height = dim[1] if dim[1] < img.shape[0] else img.shape[0]
mid_x, mid_y = int(width / 2), int(height ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_center(image, cropx, cropy):\n x,y = image.shape\n startx = x//2 - cropx//2\n starty = y//2 - cropy//2 \n return image[startx:startx+cropx, starty:starty+cropy]",
"def crop_center_img(self):\n # TODO Task 1.1\n img = self.data\n img_with_missing_crop = np.copy(img)\n ... | [
"0.79635006",
"0.7638714",
"0.7604035",
"0.74084735",
"0.7401292",
"0.72852284",
"0.7282013",
"0.7278357",
"0.7261779",
"0.7242558",
"0.720674",
"0.7204407",
"0.7199382",
"0.7156357",
"0.71003985",
"0.7044506",
"0.69623893",
"0.69574785",
"0.6903202",
"0.6899601",
"0.68447286... | 0.64628863 | 50 |
returns User by id | def user_by_id(user_id):
user = User.query.filter(User.id == user_id).one_or_none()
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def find_by_id(cls, _id):\n user = cls.query.filter_by(id=_id).first()\n return user",
"def get_user_by_id(id):\n user = session.query(User).get(id)\n return... | [
"0.89417994",
"0.8824981",
"0.8734924",
"0.87324154",
"0.87194836",
"0.86791855",
"0.8623251",
"0.86078745",
"0.8606199",
"0.8487517",
"0.8438154",
"0.84215486",
"0.8421524",
"0.8350351",
"0.8350351",
"0.8350351",
"0.8350351",
"0.83491975",
"0.83491975",
"0.83491975",
"0.8349... | 0.8238837 | 27 |
returns a random 5 letter salt | def make_salt():
return ''.join(random.choice(string.letters) for x in xrange(5)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_salt(length=5):\n return ''.join(random.choice(letters) for x in xrange(length))",
"def make_salt(length=5):\n return ''.join(random.choice(letters) for x in xrange(length))",
"def get_salt():\n return os.urandom(32)",
"def make_salt(length=5):\n\n return ''.join(random.choice(letters) f... | [
"0.838676",
"0.838676",
"0.83250403",
"0.8305351",
"0.8040241",
"0.7862458",
"0.76230365",
"0.75456125",
"0.74129015",
"0.69884706",
"0.6899022",
"0.68986285",
"0.6892041",
"0.6872964",
"0.6865737",
"0.68409353",
"0.6751032",
"0.6666501",
"0.6662519",
"0.66305554",
"0.6568977... | 0.8880013 | 0 |
returns a hash of a users password with a salt | def make_pw_hash(name, password, salt=None):
if not salt:
salt = make_salt()
pw_hash = hashlib.sha256(name + password + salt).hexdigest()
return '%s,%s' % (pw_hash, salt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_pass(password, salt):\n return hashlib.pbkdf2_hmac('sha512', password.encode(), salt, 100000)",
"def hash_password(password, salt):\n password = str(password).encode('utf-8')\n salt = str(salt).encode('utf-8')\n return hashlib.sha512(password + salt).hexdigest()",
"def make_pw_hash(passwor... | [
"0.789756",
"0.78636295",
"0.77901417",
"0.7730578",
"0.768756",
"0.7604238",
"0.7556197",
"0.7539098",
"0.75012565",
"0.7489846",
"0.7463768",
"0.74317575",
"0.73689",
"0.7339132",
"0.7319152",
"0.7288687",
"0.7288687",
"0.7288077",
"0.72797346",
"0.72797346",
"0.72797346",
... | 0.7051414 | 38 |
Fixture to return a valid and clean HTML document to apply AMP updates individually. | def parsed_html():
return utils.parse_html(
"""
<!doctype hmtl>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Page title</title>
<link rel="stylesheet" href="/static/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_insert_html_amp(parsed_html):\n parsed_amp = utils.insert_html_amp(parsed_html)\n assert parsed_amp.find(\"html\", amp=\"\") is not None",
"def parsed_html_lean():\n return utils.parse_html(\n \"\"\"\n <!doctype hmtl>\n <html>\n <head>\n <title>Pag... | [
"0.59690094",
"0.58179677",
"0.5676586",
"0.56587267",
"0.5591079",
"0.5577823",
"0.55416346",
"0.5529195",
"0.54893357",
"0.54767084",
"0.545902",
"0.541129",
"0.5399592",
"0.5392265",
"0.53831947",
"0.5364844",
"0.53414625",
"0.53403145",
"0.5319267",
"0.52802557",
"0.52754... | 0.57061946 | 2 |
Asserts that the 'amp' attribute is added to the html tag. | def test_insert_html_amp(parsed_html):
parsed_amp = utils.insert_html_amp(parsed_html)
assert parsed_amp.find("html", amp="") is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ampersand_properly_escaped(self):\n test_string = \"<p>This contains an ampersand right here '&'</p>\"\n cleaned = sanitizeFeedback(test_string)\n self.assertIn(\"&\", cleaned)",
"def escAmp(self) :\n #self.logdebug(\"AMP\")\n self.handleTag(self.escamptags)",
"d... | [
"0.68157226",
"0.62454605",
"0.61902803",
"0.60673475",
"0.6049661",
"0.5746528",
"0.5740527",
"0.57229173",
"0.57192004",
"0.5650699",
"0.56448936",
"0.5596914",
"0.55138737",
"0.55057657",
"0.548961",
"0.5460036",
"0.54530156",
"0.5434824",
"0.53922135",
"0.5386164",
"0.537... | 0.77884364 | 0 |
Asserts that a link to the canonical path is added to the HTML head. | def test_insert_canonical_link(parsed_html):
path = "/index"
parsed_amp = utils.insert_canonical_link(parsed_html, path)
assert parsed_amp.head.find("link", rel="canonical", href=path) is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_error_html_using_head(self):\n pass",
"def assert_has_valid_head(self, response, expected):\r\n assert 'head' in response\r\n head = response['head']\r\n assert isinstance(head, str)\r\n assert head == expected",
"def test_url_link(self):\n con... | [
"0.6856303",
"0.6156874",
"0.6021811",
"0.60046375",
"0.5925323",
"0.5897818",
"0.5891872",
"0.5863174",
"0.5818116",
"0.5810792",
"0.58039325",
"0.5783887",
"0.5701464",
"0.56842446",
"0.5638846",
"0.56153",
"0.55672973",
"0.55060166",
"0.5494245",
"0.54718566",
"0.54557705"... | 0.8045322 | 0 |
Accept a list of lists (or list of tuples and lists) and return a flattened version | def deep_flatten(iterables):
for item in iterables:
if is_iterable(item):
yield from deep_flatten(item)
else:
yield item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flattened(list_of_lists):\n res = functools.reduce(operator.iconcat, list_of_lists, [])\n return res",
"def flatten(list_of_lists: List[List]) -> List:\n return list(itertools.chain(*list_of_lists))",
"def flatten(list_to_flatten): \n flattened_list = []\n for item in list_to_flatten:\n ... | [
"0.85051334",
"0.8476608",
"0.84013826",
"0.83931917",
"0.83518296",
"0.833161",
"0.8227277",
"0.8217426",
"0.8191328",
"0.8190932",
"0.81824595",
"0.81824595",
"0.81742203",
"0.81426144",
"0.8126793",
"0.8084596",
"0.8075714",
"0.80647874",
"0.80254644",
"0.8018223",
"0.8017... | 0.0 | -1 |
Merges all the dictionaries into as few dictionaries as possible. | def _coalesce_dicts(self, list_of_dicts):
coalesced_list_of_dicts = [{}]
for item in list_of_dicts:
found = False
for dict_items in coalesced_list_of_dicts:
if list(item.keys())[0] not in dict_items:
dict_items.update(item)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_n_dictionnaries(dicts):\n result = dicts[0]\n for i in range(1, len(dicts)):\n result = merge_2_dictionnaries(result, dicts[i])\n return result",
"def merge_animal_dicts(*dicts):\n full = dicts[0]\n for d in dicts:\n full.update(d)\n return full",
"def merge_dicts(*dic... | [
"0.7256769",
"0.71413743",
"0.7040129",
"0.69672",
"0.6897366",
"0.6843114",
"0.6755827",
"0.6723397",
"0.6719228",
"0.67089236",
"0.67089236",
"0.67089236",
"0.67089236",
"0.67089236",
"0.67089236",
"0.6697761",
"0.66071165",
"0.66024125",
"0.6578238",
"0.656405",
"0.6519286... | 0.6377169 | 35 |
Create a new seating chart. | def new_seating_chart(size=22):
return {number: None for number in range(1, size + 1)} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_make_seating_chart_process(dinner, diners, manually_placed_diners, randomly_placed_diners, past_dinners, past_seatings):\n chart = make_new_seating_chart(diners=diners, manually_placed_diners=manually_placed_diners, randomly_placed_diners=randomly_placed_diners, past_dinners=past_dinners, past_seatings... | [
"0.5763927",
"0.55743885",
"0.53430283",
"0.5306146",
"0.5228889",
"0.5118821",
"0.5054946",
"0.5034148",
"0.49886057",
"0.49752808",
"0.49586824",
"0.49536833",
"0.49523908",
"0.48969913",
"0.48961723",
"0.48957846",
"0.48904166",
"0.48837548",
"0.4877383",
"0.48407984",
"0.... | 0.579867 | 0 |
Freeze all the weights by setting requires_grad to False | def freeze_params(m):
for p in m.parameters():
p.requires_grad = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freeze(self):\n # Freeze.\n self.frozen = True\n for param in self.parameters():\n param.requires_grad = False",
"def __freeze(self):\r\n features_layer = self._model._net\r\n for param in features_layer.parameters():\r\n param.requires_grad = False",
... | [
"0.81631815",
"0.7908931",
"0.77484065",
"0.77478063",
"0.7694787",
"0.746842",
"0.7456295",
"0.74498236",
"0.73032796",
"0.7245206",
"0.72387993",
"0.72262824",
"0.71992236",
"0.7145669",
"0.7145669",
"0.711434",
"0.7063409",
"0.70443094",
"0.70348674",
"0.7030669",
"0.69208... | 0.69701934 | 20 |
Gets the owner of this TestPlanIssueDetail. | def owner(self):
return self._owner | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOwner(self):\r\n return self.owner",
"def get_owner(self):\n return self.__owner",
"def getOwner(self):\n return self.__owner",
"def getOwner(self):\n return self.__owner",
"def owner(self):\n return Organization.objects.get(id=self.owner_id)",
"def owner(self):\... | [
"0.71161115",
"0.7075287",
"0.7052409",
"0.7052409",
"0.69507414",
"0.67558926",
"0.6718249",
"0.67091703",
"0.67091703",
"0.67091703",
"0.6680901",
"0.6666222",
"0.6649977",
"0.65801406",
"0.6565256",
"0.65402627",
"0.6504112",
"0.6504112",
"0.64886105",
"0.6440581",
"0.6431... | 0.692629 | 7 |
Sets the owner of this TestPlanIssueDetail. | def owner(self, owner):
self._owner = owner | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_owner(self, owner):\n self.__owner = owner",
"def owner(self, owner: str):\n\n self._owner = owner",
"def owner(self, owner):\n\n self._owner = owner",
"def owner(self, owner):\n\n self._owner = owner",
"def owner(self, owner):\n\n self._owner = owner",
"def own... | [
"0.70983773",
"0.6771875",
"0.67020285",
"0.67020285",
"0.67020285",
"0.67020285",
"0.6676566",
"0.6306297",
"0.6278709",
"0.6238215",
"0.6213264",
"0.61993736",
"0.6060206",
"0.6023476",
"0.59288657",
"0.5669604",
"0.56364274",
"0.5562024",
"0.55263364",
"0.5462739",
"0.5405... | 0.6732022 | 5 |
Gets the severity of this TestPlanIssueDetail. | def severity(self):
return self._severity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def severity(self) -> Optional[pulumi.Input['TestIssueSeverity']]:\n return pulumi.get(self, \"severity\")",
"def severity(self) -> str:\n return pulumi.get(self, \"severity\")",
"def severity(self) -> str:\n return pulumi.get(self, \"severity\")",
"def severity(self) -> str:\n re... | [
"0.82225686",
"0.7859186",
"0.7859186",
"0.7859186",
"0.7491916",
"0.74205047",
"0.7208666",
"0.7208666",
"0.7208666",
"0.7194543",
"0.6959317",
"0.6742522",
"0.6671019",
"0.6655535",
"0.66492915",
"0.6576344",
"0.62409383",
"0.5917493",
"0.57924616",
"0.5733837",
"0.56714875... | 0.7868182 | 1 |
Gets the status of this TestPlanIssueDetail. | def status(self):
return self._status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_detail(self):\n return self._status_detail",
"def get_status(self):\n return self._status",
"def getStatus(self):\n return self._status",
"def get_status(self):\n return self.status",
"def get_status(self):\n return self.status",
"def get_status(self):\n ... | [
"0.70674473",
"0.66238564",
"0.6603019",
"0.6600034",
"0.6600034",
"0.6600034",
"0.6561272",
"0.6522415",
"0.6512805",
"0.65098226",
"0.64825624",
"0.64804274",
"0.6476045",
"0.6464838",
"0.64631706",
"0.6426171",
"0.64123756",
"0.64123756",
"0.64123756",
"0.6392122",
"0.6387... | 0.6389646 | 30 |
Sets the status of this TestPlanIssueDetail. | def status(self, status):
self._status = status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_status(self, status):\n self.status = status",
"def set_status(self, status):\n self.status = status",
"def set_status(self, status):\n self.status = status",
"def status_detail(self, status_detail):\n self._status_detail = status_detail",
"def status_detail(self, status... | [
"0.64805764",
"0.64805764",
"0.64805764",
"0.6432109",
"0.64300716",
"0.63455045",
"0.62634236",
"0.62159175",
"0.6202387",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.6148618",
"0.614861... | 0.6187141 | 12 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, TestPlanIssueDetail):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8089139",
"0.8089139",
"0.8054507",
"0.79827213",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
By default, max age is a week. | def __init__(self, ttl=604800):
self.data = OrderedDict()
self.ttl = ttl | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_age(self):\n return self._max_age",
"def max_age(self):\n return self._max_age",
"def max_age(self):\n return 120 if self.realtime else 1800",
"def max_age(self):\n\n return self._max_age",
"def max_age_in_days(self) -> Optional[pulumi.Input[int]]:\n return pulumi... | [
"0.750575",
"0.750575",
"0.7348481",
"0.7257512",
"0.7229502",
"0.72253233",
"0.7128516",
"0.7095817",
"0.6975417",
"0.654333",
"0.64865565",
"0.64492816",
"0.6414338",
"0.6344842",
"0.63357466",
"0.62918645",
"0.62671214",
"0.6265992",
"0.6223956",
"0.6204128",
"0.61905795",... | 0.0 | -1 |
Compute the sum of all reaction compounds. | def sum_biomass_weight(reaction):
return sum(-coef * met.formula_weight
for (met, coef) in iteritems(reaction.metabolites)) / 1000.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sum(self):\n s = 0\n for element, value in self.items():\n s += value\n return s",
"def summation(self):\n return sum(self.read_ints())",
"def sum(self):\n return sum(self.items())",
"def sum(self):\n return self._reduce_for_stat_function(F.sum, only_... | [
"0.65965444",
"0.6360908",
"0.6237028",
"0.6141608",
"0.61279815",
"0.61279815",
"0.61279815",
"0.6049533",
"0.598539",
"0.5938046",
"0.5913415",
"0.5884845",
"0.5863395",
"0.58112794",
"0.58112794",
"0.5804841",
"0.5802595",
"0.5762229",
"0.5761556",
"0.5741148",
"0.5736586"... | 0.56337935 | 26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.