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 |
|---|---|---|---|---|---|---|
Add a line between two points [std1, corr1] and [std2, corr2] | def add_contours(self, std1, corr1, std2, corr2, **kwargs):
t = np.linspace(np.arccos(corr1), np.arccos(corr2))
r = np.linspace(std1, std2)
return self.ax.plot(t, r, 'red', linewidth=2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_stddev_contours(self, std, corr1, corr2, **kwargs):\n\n t = np.linspace(np.arccos(corr1), np.arccos(corr2))\n r = np.zeros_like(t) + std\n return self.ax.plot(t, r, 'red', linewidth=2)",
"def draw_line(cvs, p1, p2, antialias):\n xs, ys = np.array([p1[0], p2[0]]), np.array([p1[1], ... | [
"0.73186386",
"0.6330753",
"0.6172619",
"0.6076223",
"0.60636544",
"0.60072315",
"0.5959107",
"0.59067386",
"0.58517635",
"0.5826788",
"0.5796374",
"0.57432646",
"0.5697054",
"0.56763124",
"0.56763124",
"0.5629721",
"0.5583803",
"0.55724424",
"0.556278",
"0.5562631",
"0.55447... | 0.66322917 | 1 |
Compute the posterior distribution of live cells given stimulus dose and observable values. Input | def posterior(self, s, obs, idx):
if type(s) == np.ndarray:
return self._cond_dose_response(s, obs, idx)
else:
return self._posterior_given_stim(s, obs, idx) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def posterior(self, rnn_hidden, obs):\n hidden_obs = self.hidden_obs(torch.cat([rnn_hidden, obs], dim=-1)) # [batch, hidden]\n poster = self.poster(hidden_obs) # [batch, hidden]\n poster_mean = self.post_mean(poster) # [batch, state]\n # poster_sigma = F.softplus(self.post_sigma(post... | [
"0.5894701",
"0.584598",
"0.57622224",
"0.564624",
"0.5593989",
"0.5563269",
"0.54888",
"0.5483124",
"0.5474621",
"0.5428959",
"0.5423016",
"0.5397032",
"0.5379",
"0.53718823",
"0.5364652",
"0.53634334",
"0.5362777",
"0.5356767",
"0.533914",
"0.53335476",
"0.5319441",
"0.53... | 0.5514862 | 6 |
Check to see if the number is divisible by all possible 3 digit substrings. | def substring_divisible(number):
string = str(number)
for offset in xrange(1, len(string)-2):
substring = string[offset:offset+3]
# print '%s / %d' % (substring, PRIMES[offset-1])
if int(substring) % PRIMES[offset-1]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_divisible(num, n):\n return num % n == 0",
"def concats_divisible_by_divisors(num_string: str) -> bool:\n \n # check if all concatenated numbers are divisible by divisors in DIVISORS\n for i in range(divisor_count):\n # form number by concatenating digits of num_string\n indi... | [
"0.68361807",
"0.6700276",
"0.66646105",
"0.65157944",
"0.65157944",
"0.64472467",
"0.6445171",
"0.6416292",
"0.64152324",
"0.6393683",
"0.6390676",
"0.636498",
"0.6359953",
"0.63241255",
"0.6315646",
"0.62723976",
"0.6238878",
"0.6234731",
"0.6212701",
"0.6184209",
"0.617644... | 0.824374 | 0 |
Returns a key hexed from random bytes at the given length for crypto. | def GenerateRandomHexKey(length=_RANDOM_BYTE_LENGTH):
# After encoded in hex, the length doubles.
return os.urandom(length).encode('hex') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __generate_key(length):\n if length % 2 != 0:\n raise ValueError(\"'length' must be a multiple of 2\")\n length_bytes = int(length / 2) # length of key in bytes\n key_bytes = os.urandom(length_bytes)\n return binascii.hexlify(key_bytes).decode()",
"def genKey(length=32... | [
"0.83131474",
"0.8192357",
"0.8062324",
"0.7946797",
"0.7785568",
"0.778308",
"0.7620973",
"0.7614206",
"0.76092666",
"0.7577782",
"0.7569808",
"0.7401408",
"0.73823965",
"0.73588",
"0.72859305",
"0.7280881",
"0.7273216",
"0.7152287",
"0.70835525",
"0.7049502",
"0.70331925",
... | 0.8589039 | 0 |
Return the size of tree. | def size(self):
if len(self.children) == 0:
return 1
else:
return 1 + sum([x.size() for x in self.children]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree_size(self):\n if self._tree_size is not None:\n return self._tree_size\n if self.is_root:\n self.arbor._setup_tree(self)\n # pass back to the arbor to avoid calculating again\n self.arbor._store_node_info(self, '_tree_size')\n else:\n ... | [
"0.88174284",
"0.88089615",
"0.85781014",
"0.8544507",
"0.85161334",
"0.84127957",
"0.83828354",
"0.83263654",
"0.8154769",
"0.79699403",
"0.7859243",
"0.78302044",
"0.77896833",
"0.7780197",
"0.77206",
"0.763663",
"0.76130414",
"0.7611206",
"0.7600058",
"0.7578258",
"0.75292... | 0.78098524 | 12 |
Returns an int64_list from a bool / enum / int / uint. | def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _BoolsToInts(arg_list):\n result = []\n for arg in arg_list:\n if isinstance(arg, (list, tuple)):\n result.append(_BoolsToInts(arg))\n elif arg is True:\n result.append(1)\n elif arg is False:\n result.append(0)\n else:\n result.append(arg)\n\n return result",
"def convertT... | [
"0.68822104",
"0.6595804",
"0.6461252",
"0.6448161",
"0.6367609",
"0.62926817",
"0.6269916",
"0.621823",
"0.6104528",
"0.59533274",
"0.5947467",
"0.5901199",
"0.5863832",
"0.5863832",
"0.58563983",
"0.5844792",
"0.58434534",
"0.5829844",
"0.5801042",
"0.5793561",
"0.5793561",... | 0.55319947 | 47 |
Check for strings that are UUIDs (UUIDs enclosed in curly braces are valid) {1378F00BBCEA418FB1AFC343EA4F9417} {022CCD4DEDE340EBBE1DFE4041B0A050} | def is_uuid(self) -> bool:
ua = self.user_agent.strip('({})')
if len(ua) >= 2 and ua[1] == ':':
ua = self.user_agent[2:]
return uuid_like_name(ua) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkuuidsyntax(uuidtxt):\n score = 0\n if uuidtxt != None:\n if len(uuidtxt) < 10:\n score = 0\n elif uuidtxt.find(\"{\") > -1 or uuidtxt.find(\"}\") > -1 or uuidtxt.lower() != uuidtxt:\n score = 1\n else:\n score = 2\n return score",
"def is_va... | [
"0.73460853",
"0.73424226",
"0.7189792",
"0.68956435",
"0.68942934",
"0.6860537",
"0.68553716",
"0.67757565",
"0.67332566",
"0.6540647",
"0.64938307",
"0.6458208",
"0.6438391",
"0.6417305",
"0.63738537",
"0.6373422",
"0.6355799",
"0.6355799",
"0.63422585",
"0.6331449",
"0.630... | 0.58549315 | 29 |
Return the archive location URI. | def archive_location(self):
name = self.app.config['SIPSTORE_ARCHIVER_LOCATION_NAME']
return Location.query.filter_by(name=name).one().uri | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive_path(self):\n return os.path.join(self.destination_directory, self.__archive_name__)",
"def getArchiveURI(sha1,archivePath,fileType='jpg'):\n (sha1Path,filename)=getSha1Path(sha1)\n return(archivePath+'/'+sha1Path+'/'+filename+'.'+fileType)",
"def location_uri(self) -> Optional[str]:\n ... | [
"0.7043057",
"0.69406134",
"0.66881",
"0.6617685",
"0.65890115",
"0.6554932",
"0.6544251",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6497794",
"0.6494776",
"0.6486501",
"0.6429628",
"0.6412059",
"0.63765144",
"0.6333575",
"0.6287437",
... | 0.83230734 | 0 |
Set the message token/channel, then call the bas class constructor. | def _construct_message(self):
self.message = {"token": self._auth, "channel": self.channel}
super()._construct_message() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, message):\n self.message = message",
"def __init__(self, message):\n self.message = message",
"def __init__(self, message):\n self.message = message",
"def __init__(self, message, *args, **kwargs):\n self.message = message\n super().__init__(*args, **kwar... | [
"0.7340327",
"0.7340327",
"0.7340327",
"0.7285108",
"0.7276043",
"0.72251916",
"0.72251916",
"0.7214396",
"0.7208427",
"0.71547794",
"0.7151964",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.7... | 0.74445486 | 0 |
find minimum value in the binary tree | def find_min(self):
if self.left:
return self.left.find_min()
return self.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min(self) -> TreeNode:\n node = self.root\n while True:\n if not node.left:\n return node\n node = node.left",
"def min_value(tree):\n min_utility = float(\"inf\")\n \n if (is_terminal(tree)):\n return tree\n else:\n #options =... | [
"0.80589795",
"0.8056454",
"0.80371964",
"0.80029297",
"0.7998105",
"0.7936794",
"0.7902247",
"0.7878885",
"0.7868591",
"0.781862",
"0.7793568",
"0.7750907",
"0.7731552",
"0.7652422",
"0.7640436",
"0.7625846",
"0.7604106",
"0.75800264",
"0.7578118",
"0.7573239",
"0.7498809",
... | 0.7846781 | 9 |
find maximum value in the binary tree | def find_max(self):
if self.right:
return self.right.find_max()
return self.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_maximum_value(self):\n if self.root: \n self.max_val = self.root.value\n else:\n return 'No tree found'\n def inner(root):\n if root.left:\n inner(root.left)\n\n if root.right:\n inner(root.right)\n\n if self.max_val < root.value:\n self.max_val = roo... | [
"0.88481236",
"0.844402",
"0.83463925",
"0.81999785",
"0.80180365",
"0.79969794",
"0.7975098",
"0.7961988",
"0.7925224",
"0.7899093",
"0.78559816",
"0.78302693",
"0.78004664",
"0.7726644",
"0.7720577",
"0.76765054",
"0.7674523",
"0.75881475",
"0.74246013",
"0.736487",
"0.7358... | 0.7934586 | 8 |
Permute a mutation data table's gene, sample and NMAF columns. | def permute_table(dtable):
shuffle_field(dtable, 'gene')
shuffle_field(dtable, 'sample')
shuffle_field(dtable, 'Normalized')
if 'Filler' in dtable:
del dtable['Filler'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shuffle_columns(gene):\n import numpy as np\n return np.random.permutation(gene.tolist())",
"def permutation(self):\n perm = np.random.permutation(self.n_samples)\n self.data = self.data.iloc[perm]\n self.labels = self.labels.iloc[perm]\n self.labels_onehot = self.labels_one... | [
"0.61698025",
"0.59699166",
"0.5903071",
"0.5723355",
"0.5637398",
"0.5528464",
"0.5499227",
"0.543115",
"0.5423258",
"0.54104346",
"0.5405247",
"0.5401473",
"0.5346968",
"0.53442794",
"0.5332014",
"0.5327549",
"0.5315308",
"0.53120166",
"0.5284594",
"0.52702045",
"0.5233921"... | 0.6967431 | 0 |
Returns the score for a given review Returns 1 if there is no review with the given identifier | def getReviewScore(self, reviewId):
res = self.get_metadata_item_by_review_id(reviewId, self.score_index)
if res is None:
return -1
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_review(reviews, userId, BusinessId):\n reviews = reviews[(reviews['business_id'] == BusinessId) & (reviews['user_id'] == userId)]\n\n if reviews.empty:\n return np.nan\n elif len(reviews) > 1:\n return float(reviews['stars'].max())\n else:\n return float(reviews['stars'])",... | [
"0.6201799",
"0.6199192",
"0.6183983",
"0.60592645",
"0.60532284",
"0.5974433",
"0.5950267",
"0.5945879",
"0.5890353",
"0.58580697",
"0.58472925",
"0.581598",
"0.58078945",
"0.57990956",
"0.57932633",
"0.57251036",
"0.5703422",
"0.57010114",
"0.56840485",
"0.56757194",
"0.566... | 0.7393501 | 0 |
String representation of the building block | def __str__(self):
instructions = []
if self.directory:
instructions.append(comment('OpenMPI'))
else:
instructions.append(comment(
'OpenMPI version {}'.format(self.version)))
instructions.append(packages(ospackages=self.__ospackages))
if s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_string(self):\r\n return u\"{course_key}+{BLOCK_TYPE_PREFIX}+{block_type}+{BLOCK_PREFIX}+{block_id}\".format(\r\n course_key=self.course_key._to_string(),\r\n BLOCK_TYPE_PREFIX=self.BLOCK_TYPE_PREFIX,\r\n block_type=self.block_type,\r\n BLOCK_PREFIX=self.B... | [
"0.7110431",
"0.69718146",
"0.6937294",
"0.6923212",
"0.6873114",
"0.68384624",
"0.6801287",
"0.6765984",
"0.6750321",
"0.67492396",
"0.67296773",
"0.66733634",
"0.66658115",
"0.6658317",
"0.6654951",
"0.66429806",
"0.6605994",
"0.65886337",
"0.6574067",
"0.655521",
"0.653869... | 0.0 | -1 |
Return a custom 404 error. | def page_not_found(e):
return 'Sorry, Nothing at this URL.', 404 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_found():\n return HttpError(404)",
"def error_404(error):\n return '404 Error'",
"def error_404(error):\n return 'Bummer, there is nothing at this URL.'",
"def error_not_found(error):\n return 'No page here, dood. 404!', 404",
"def not_found(self, error):\n return jsonify({'error': 'NO... | [
"0.81159586",
"0.80410045",
"0.7738874",
"0.77369535",
"0.77182025",
"0.7689595",
"0.7670471",
"0.76112473",
"0.7602477",
"0.7570698",
"0.75528365",
"0.7545827",
"0.751882",
"0.74745256",
"0.7458403",
"0.7455682",
"0.74548143",
"0.74505144",
"0.7442062",
"0.7428278",
"0.74065... | 0.7254463 | 42 |
Accessor for the maximum number of issued credentials. | def max_creds(self) -> int:
return self._max_creds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_count(self):\n return self.config.get('max_count', 500)",
"def maxTimes(self)->int:\n return self._lic.params['maxAccessTimes'].value",
"def attempt_limit(self) -> int:\n return self._attempt_limit",
"def maxclients(self) -> Optional[int]:\n return pulumi.get(self, \"maxcl... | [
"0.66411006",
"0.6601515",
"0.65705186",
"0.6561411",
"0.65395725",
"0.6536631",
"0.65011877",
"0.64279604",
"0.63409424",
"0.63365984",
"0.63256127",
"0.63256127",
"0.6293164",
"0.6249128",
"0.6249128",
"0.62489957",
"0.62489957",
"0.62489957",
"0.62489957",
"0.62489957",
"0... | 0.82493174 | 0 |
Accessor for the revocation registry type. | def reg_def_type(self) -> str:
return self._reg_def_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_typ(self, refobj):\n enum = cmds.getAttr(\"%s.type\" % refobj)\n try:\n return JB_ReftrackNode.types[enum]\n except IndexError:\n raise ValueError(\"The type on the node %s could not be associated with an available type: %s\" %\n (refob... | [
"0.6687819",
"0.64504707",
"0.62291914",
"0.62291914",
"0.61967313",
"0.61791503",
"0.61791503",
"0.6154003",
"0.6153839",
"0.61267936",
"0.6124155",
"0.6096765",
"0.6083589",
"0.6083589",
"0.6083589",
"0.6083589",
"0.6083589",
"0.6083589",
"0.6083589",
"0.6083589",
"0.608358... | 0.60502154 | 63 |
Accessor for the revocation registry definition. | def reg_def(self) -> dict:
return self._reg_def | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_definition(\n cls, revoc_reg_def: dict, public_def: bool\n ) -> \"RevocationRegistry\":\n rev_reg = None\n\n reg_id = revoc_reg_def[\"id\"]\n tails_location = revoc_reg_def[\"value\"][\"tailsLocation\"]\n issuer_did_match = re.match(r\"^.*?([^:]*):3:CL:.*\", revoc_reg... | [
"0.6046955",
"0.5656428",
"0.5539884",
"0.5397157",
"0.5377235",
"0.52657837",
"0.526368",
"0.5181764",
"0.5142401",
"0.5141512",
"0.50868005",
"0.50826746",
"0.5072512",
"0.50693274",
"0.50633323",
"0.4959276",
"0.49344507",
"0.4922987",
"0.49180284",
"0.49130836",
"0.488868... | 0.53610677 | 5 |
Setter for the tails file public URI. | def tails_public_uri(self, new_uri: str):
self._tails_public_uri = new_uri | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tails_public_uri(self) -> str:\n return self._tails_public_uri",
"def set_uri(self, uri):\r\n self.uri = uri",
"def set_uri(self, uri):\n self.__uri = uri",
"def uri(self, uri):\n self._uri = uri",
"def uri(self, uri):\n self._uri = uri",
"def url(self):\n if... | [
"0.6992037",
"0.6649637",
"0.65161926",
"0.64215595",
"0.64215595",
"0.62572867",
"0.6217056",
"0.6217056",
"0.61789614",
"0.6056066",
"0.60459447",
"0.60445434",
"0.5995598",
"0.5985835",
"0.5982786",
"0.59488785",
"0.59331167",
"0.59251237",
"0.5923124",
"0.5891555",
"0.589... | 0.70854425 | 0 |
Return a human readable representation of this class. | def __repr__(self) -> str:
items = ("{}={}".format(k, repr(v)) for k, v in self.__dict__.items())
return "<{}({})>".format(self.__class__.__name__, ", ".join(items)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n class_dictionary = vars(self)\n out = self.__class__.__name__\n for k,v in class_dictionary.items():\n if v > 0:\n out += ' : ' + str(k) + ' = ' + str(v)\n ... | [
"0.8229985",
"0.81823826",
"0.80362755",
"0.7990366",
"0.7907257",
"0.78875196",
"0.7879061",
"0.78439665",
"0.78439665",
"0.78439665",
"0.78439665",
"0.78439665",
"0.781496",
"0.780656",
"0.780656",
"0.780656",
"0.780656",
"0.780656",
"0.780656",
"0.780656",
"0.780656",
"0... | 0.76719934 | 66 |
Plot a histogram of the envelope delays for all stations combined. | def plot_hist(delays):
fig = plt.figure()
ax = fig.add_subplot(111)
alldelays = []
for _s in delays.keys():
alldelays += delays[_s]
if len(alldelays) > 0:
n, bins, patches = ax.hist(alldelays, bins=np.arange(0, 30, 0.5),
color='green', histtype='bar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_spectrums_overlapping(\n self, energies_dict: dict, title:str,\n figsize: tuple = (16,12)\n ) -> None:\n \n plt.figure(figsize=figsize)\n plt.title(title)\n for key in energies_dict.keys():\n spectre, bins = np.histogram(energies_dict[key],range = (0... | [
"0.6014032",
"0.6012786",
"0.5984103",
"0.59256524",
"0.5846438",
"0.5844005",
"0.57922244",
"0.57795936",
"0.576851",
"0.574713",
"0.57314426",
"0.5656888",
"0.5621318",
"0.56128407",
"0.5601162",
"0.55484176",
"0.5535783",
"0.55001086",
"0.54999",
"0.5484467",
"0.54826164",... | 0.649759 | 0 |
Parses a value and returns the equivalent in seconds | def time_to_sec(duration):
duration, unit = val_to_type_unit(duration)
if unit in ['h', 'hr', 'hrs', 'hours', 'hour']:
duration *= 60 * 60
elif unit in ['m', 'min', 'mins', 'minutes', 'minute']:
duration *= 60
elif unit in [None, 's', 'sec', 'secs', 'seconds', 'second']:
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_time(value: str) -> float:\n return float(value[:-1]) * TIME[value[-1]]",
"def seconds(input=None):\n return int(get(input))",
"def convert_to_seconds(unit, value):\n seconds = 1\n minutes = 60\n hours = 3600\n days = 86400\n return value*eval(unit)",
"def parse_time(value):\n ... | [
"0.7704094",
"0.747785",
"0.7376642",
"0.73500556",
"0.7216641",
"0.6884994",
"0.6840191",
"0.6820855",
"0.6784685",
"0.67184466",
"0.6666218",
"0.6663636",
"0.66384137",
"0.6625512",
"0.6575972",
"0.65483385",
"0.6534206",
"0.6515571",
"0.64927226",
"0.64878094",
"0.647317",... | 0.0 | -1 |
Native code representation of the object instance | def __repr__(self):
r = str(self.current_instance_state())
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return '<%s.%s (%s) object at %s>' % (self.__class__.__module__, self.__class__.__name__, self._xc_func_name,\n hex(id(self)))",
"def __repr__(self):\n\n return (\n f\"<{type(self).__module__}.{type(self).__qualname__} {i... | [
"0.7270472",
"0.7131184",
"0.69435525",
"0.6897909",
"0.685291",
"0.681638",
"0.6646927",
"0.6586526",
"0.6586526",
"0.6586526",
"0.6586526",
"0.6586526",
"0.6584041",
"0.6556684",
"0.65347785",
"0.6465354",
"0.6465354",
"0.645931",
"0.6457175",
"0.64381856",
"0.64311254",
... | 0.6484423 | 15 |
Return first item in sequence where f(item) == True. | def find(f, seq):
for item in seq:
if f(item):
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finditem(func, seq):\n return next((item for item in seq if func(item)))",
"def first_true(iterable, default=False, pred=None):\n return next(filter(pred, iterable), default)",
"def _first(self, \n iterable, \n condition=lambda x: True):\n try:\n return n... | [
"0.7381083",
"0.69793993",
"0.68005335",
"0.67570746",
"0.67258066",
"0.6664692",
"0.66255635",
"0.6597727",
"0.64589864",
"0.64407694",
"0.6315168",
"0.6314598",
"0.63102686",
"0.6286507",
"0.6251015",
"0.6169875",
"0.6169091",
"0.6152609",
"0.6152609",
"0.6064589",
"0.60064... | 0.7370345 | 1 |
Write i2c block to a given register | def write_i2c_block_data(self, request, context):
status_response = smbusRpc_pb2.operation_status(code=0, exception='')
i2c_addr = request.i2c_addr
i2c_register = request.register
i2c_data = request.data
try:
client_id = self._get_client_id(context)
self.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _i2c_write(self, register, value, bank=None):\n if bank is not None:\n self.set_bank(bank)\n self.i2c.write_byte_data(self.address, register, value)",
"def _write_register(self, reg_addr, data):\n self.bus.write_i2c_block_data(self.I2C_ADDRESS, reg_addr, [ data & 0xFF ])",
"... | [
"0.7637494",
"0.7422023",
"0.7422023",
"0.73728794",
"0.72606826",
"0.71174926",
"0.7112865",
"0.7054888",
"0.6747012",
"0.65657216",
"0.6402857",
"0.63449144",
"0.6229089",
"0.6200044",
"0.6112666",
"0.605009",
"0.6019467",
"0.5994798",
"0.59945965",
"0.59791785",
"0.5954824... | 0.68757176 | 8 |
Get epoch time, as .timestamp() was only added in Python 3.3. | def _current_epoch_secs():
now = datetime.datetime.utcnow()
epoch = datetime.datetime(1970, 1, 1)
return (now - epoch).total_seconds() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def epoch():\n return datetime2epoch(datetime.now())",
"def epoch_time_now():\n return int(time.time())",
"def epoch():\n\treturn time.time()",
"def epochnow():\n return time.time()",
"def get_epoch(timestamp):\n timestamp_dt = datetime.datetime.strptime(timestamp, \"%Y-%m-%dT%H:%M:%SZ\... | [
"0.8682732",
"0.8562506",
"0.85258275",
"0.83454674",
"0.796864",
"0.79579186",
"0.7905645",
"0.78438467",
"0.7638975",
"0.7466613",
"0.74148923",
"0.7406296",
"0.7397465",
"0.7388534",
"0.7313057",
"0.7278134",
"0.7273138",
"0.72573966",
"0.72373724",
"0.7221113",
"0.7103867... | 0.766601 | 8 |
[GET] Grabs the user from the DB and returns it as a JSON response | def user():
if request.method == "GET":
user_id = request.args.get("user_id", None)
response = {}
if user_id is None:
response["ERROR"] = "Missing user_id in route"
return jsonify(response)
user = User.query.filter_by(user_id=user_id).one()
user_json ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(id):\r\n return jsonify(User.query.get_or_404(id).to_dict())",
"def get(self):\n response = users_db.get_user_by_id(get_jwt_identity())\n return Response(dumps(response), mimetype='application/json')",
"def get (self):\n\n logged_in, db_user = ADayThere.logged_in_user ()\n ... | [
"0.8109016",
"0.8056769",
"0.80395967",
"0.7950585",
"0.7904902",
"0.78335994",
"0.77978855",
"0.77816284",
"0.7780409",
"0.76906425",
"0.7659684",
"0.765311",
"0.76432043",
"0.7618835",
"0.7616256",
"0.7615878",
"0.7573799",
"0.7567805",
"0.7564251",
"0.7556705",
"0.75410986... | 0.6977178 | 81 |
Returns median ignoring NAN | def nanmedian(arr, **kwargs):
return ma.median( ma.masked_where(arr!=arr, arr), **kwargs ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nanmedian(arr1d): # This only works on 1d arrays\n cond = 1-np.isnan(arr1d)\n x = np.sort(np.compress(cond,arr1d,axis=-1))\n if x.size == 0:\n return np.nan\n return np.median(x)",
"def nanmedian(x, axis=0, preop=None):\n x = np.asarray(x)\n if axis is None:\n x = x.ravel()\... | [
"0.7612167",
"0.760392",
"0.75946695",
"0.75930095",
"0.7547139",
"0.7506518",
"0.74757653",
"0.7468638",
"0.7417313",
"0.73726755",
"0.7257516",
"0.72557527",
"0.7226571",
"0.7222345",
"0.72191626",
"0.7219064",
"0.718095",
"0.7178429",
"0.7170332",
"0.71539026",
"0.7150443"... | 0.7958463 | 0 |
Delete keys with the value ``None`` in a dictionary, recursively. This alters the input so you may wish to ``copy`` the dict first. | def del_none(d):
for key, value in list(d.items()):
if value is None:
del d[key]
elif isinstance(value, dict):
del_none(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_none(dict_):\n if isinstance(dict_, dict):\n for key, value in list(dict_.items()):\n if isinstance(value, dict):\n delete_none(value)\n elif value is None:\n del dict_[key]\n elif isinstance(value, list):\n for v_i ... | [
"0.79423374",
"0.76588416",
"0.75797796",
"0.7423728",
"0.7302791",
"0.72980106",
"0.7238777",
"0.7140412",
"0.7126415",
"0.7120261",
"0.71166044",
"0.7031242",
"0.70291317",
"0.70027316",
"0.6966311",
"0.6853151",
"0.68435395",
"0.6737293",
"0.671963",
"0.66950554",
"0.66418... | 0.7640417 | 2 |
Tests that creating a service uses the project from the context. | def test_create_uses_project_from_context(self):
serializer = ServiceSerializer(
data = dict(name = "service1", category = self.category.pk),
context = dict(project = self.project)
)
self.assertTrue(serializer.is_valid())
service = serializer.save()
servic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_project(self):\n pass",
"def test_create_project(self):\n pass",
"def test_create_project(self):\n pass",
"def create_test_service(context, **kw):\n service = get_test_service(context, **kw)\n service.create()\n return service",
"def test_ipam_services_create(s... | [
"0.7120619",
"0.7120619",
"0.7120619",
"0.7009091",
"0.68919146",
"0.68100005",
"0.6607628",
"0.656547",
"0.6527957",
"0.6507002",
"0.6404545",
"0.63257855",
"0.631524",
"0.6311549",
"0.6307608",
"0.62911063",
"0.6286749",
"0.62383205",
"0.61605096",
"0.6152352",
"0.6150751",... | 0.7107589 | 3 |
Tests that the project cannot be overridden by specifying it in the input data. | def test_cannot_override_project_on_create(self):
# Create a project whose PK will be given in the data
# We will specify cls.project in the context, which is the project that the
# service should be added to
project = self.consortium.projects.create(
name = 'Project 2',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_project_defaults(self):\n ep = exposed.ExposedProject()\n self.assertIsNone(ep.display)\n self.assertIsNone(ep.shared)\n self.assertIsNone(ep.settings)\n self.assertIsNone(ep.title)\n self.assertIsNone(ep.id)\n self.assertIsNone(ep.path())\n\n wit... | [
"0.6616126",
"0.6561542",
"0.6305697",
"0.61730504",
"0.61613035",
"0.61578214",
"0.6119646",
"0.61156946",
"0.59123534",
"0.58817554",
"0.587598",
"0.5840298",
"0.57811177",
"0.57562494",
"0.5735901",
"0.57326746",
"0.57326746",
"0.5721482",
"0.5713415",
"0.5702533",
"0.5699... | 0.55558145 | 36 |
Tests that an invalid category correctly fails. | def test_cannot_create_with_invalid_category(self):
serializer = ServiceSerializer(
data = dict(name = "service1", category = 10),
context = dict(project = self.project)
)
self.assertFalse(serializer.is_valid())
self.assertEqual(serializer.errors['category'][0].co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_category_invalid(self):\n # wiki and questions\n ques = QuestionFactory(title=u'q1 audio')\n ques.tags.add(u'desktop')\n ans = AnswerFactory(question=ques)\n AnswerVoteFactory(answer=ans, helpful=True)\n\n d1 = DocumentFactory(\n title=u'd1 audio',\n ... | [
"0.7839596",
"0.7582727",
"0.74574435",
"0.7391391",
"0.7366802",
"0.72090584",
"0.7174356",
"0.7065422",
"0.699625",
"0.69693434",
"0.6969298",
"0.6892669",
"0.6892437",
"0.68776846",
"0.6851545",
"0.6851545",
"0.6839208",
"0.6839208",
"0.6835304",
"0.6813542",
"0.679998",
... | 0.74922276 | 2 |
Tests that invalid requirements correctly fails for the list of services. | def test_list_cannot_create_with_invalid_requirement(self):
# Test with a string for the requirements
serializer = ServiceListSerializer(
data = dict(name = "service2", category = self.category.pk, requirements = "requirements1"),
context = dict(project = self.project)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _checkServices(self, expectedServices):\n it = iter(self._getServices())\n for (type_uri, service_uri) in expectedServices:\n for element in it:\n if type_uri in xrds.getTypeURIs(element):\n self.assertEqual(xrds.getURI(element), service_uri)\n ... | [
"0.6652535",
"0.63944703",
"0.63525254",
"0.6248919",
"0.6213733",
"0.6155486",
"0.61272925",
"0.6118433",
"0.60867417",
"0.60663563",
"0.6037591",
"0.59633803",
"0.59532416",
"0.59380984",
"0.59379965",
"0.5933373",
"0.59262633",
"0.5893517",
"0.58908415",
"0.58897734",
"0.5... | 0.7205704 | 0 |
Returns the derivative of the Bessel function | def dj(x,l=2):
return spec.spherical_jn(l,x,True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bessel_derivative(self):\n return np.array([t.der_bessel for t in self._trc])",
"def derivative(func: Callable, x: float, delta: float) -> float:\n return (func(x + delta) - func(x - delta)) / (2.0 * delta)",
"def _derivative_(self, x, diff_param=None):\n return 2*exp(-x**2)/sqrt(pi)",... | [
"0.71214515",
"0.6830747",
"0.6826476",
"0.680827",
"0.6800083",
"0.6793384",
"0.6793384",
"0.66337645",
"0.65562403",
"0.64426094",
"0.64143455",
"0.63654655",
"0.63443655",
"0.63384694",
"0.63263714",
"0.6302393",
"0.62842673",
"0.62700856",
"0.6257476",
"0.62192047",
"0.62... | 0.0 | -1 |
Returns the alpha_M parameter (unitless) | def alpha_M(z, c_M = 0):
I = CLASS(z_i)
return I.alpha_M(z, c_M) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha(self) -> float:\n return self.intrinsic_matrix[0, 1]",
"def _get_alpha(self, m_t, v_t):\n return max(0, ((-m_t * self._psi \n + math.sqrt((m_t ** 2 * self._phi ** 4) \n / 4 + v_t * self._phi ** 2 * self._xi)) \n ... | [
"0.7024431",
"0.68071014",
"0.6656122",
"0.6620876",
"0.66078854",
"0.66078854",
"0.66078854",
"0.64557284",
"0.6452207",
"0.6432217",
"0.6417361",
"0.64103806",
"0.6396868",
"0.6385246",
"0.63572574",
"0.63183844",
"0.6268445",
"0.6252516",
"0.6239953",
"0.62385505",
"0.6219... | 0.73521745 | 0 |
Returns the alpha_M parameter (unitless) | def alpha_B(z, c_B = 0):
I = CLASS(z_i)
return I.alpha_M(z, c_B) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha_M(z, c_M = 0):\n I = CLASS(z_i)\n return I.alpha_M(z, c_M)",
"def alpha(self) -> float:\n return self.intrinsic_matrix[0, 1]",
"def _get_alpha(self, m_t, v_t):\n return max(0, ((-m_t * self._psi \n + math.sqrt((m_t ** 2 * self._phi ** 4) \n ... | [
"0.73521745",
"0.7024431",
"0.68071014",
"0.6656122",
"0.6620876",
"0.66078854",
"0.66078854",
"0.66078854",
"0.64557284",
"0.6452207",
"0.6432217",
"0.6417361",
"0.64103806",
"0.6396868",
"0.6385246",
"0.63572574",
"0.63183844",
"0.6268445",
"0.6252516",
"0.6239953",
"0.6238... | 0.57899034 | 54 |
Returns M_^2 in units m_P | def M_star_sq(z, c_M=0):
zint = np.linspace(z,20,200) # alpha_M is approx zero beyond z = 20
integrand = alpha_M(zint, c_M)/(1+zint)
logM = integrate(zint, integrand, ax=0)
M = np.exp(logM)
return M | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def m2(self):\n return self.mass[1]",
"def get_M(self):\n return 1.0",
"def mu_gm1m2(m1: float, m2: float) -> float:\n from astropy.constants import G\n\n return G * (m1 + m2)",
"def M0(self):\n return (self.m_rr ** 2 + self.m_tt ** 2 + self.m_pp ** 2\n + 2 * self.m_... | [
"0.7324615",
"0.6829904",
"0.68202496",
"0.67821455",
"0.6618903",
"0.64933974",
"0.64864427",
"0.63713175",
"0.63448286",
"0.6344411",
"0.63325053",
"0.62987846",
"0.62113917",
"0.61521935",
"0.6132696",
"0.6132696",
"0.60993713",
"0.6095806",
"0.6094831",
"0.60927045",
"0.6... | 0.0 | -1 |
Initializes the parameters of the neural network to random values | def __init__(self, input_dim, hidden_dim, output_dim, epsilon):
self.W1 = np.random.randn(input_dim, hidden_dim) / np.sqrt(input_dim)
self.W2 = np.random.randn(hidden_dim,output_dim) / np.sqrt(hidden_dim)
self.b1 = np.zeros((1, hidden_dim))
self.b2 = np.zeros((1, output_dim))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_parameters(self):\n for i in range(1, self.L):\n self.W[i - 1] = np.random.randn(self.layer_dims[i], self.layer_dims[i - 1]) * 0.01\n self.b[i - 1] = np.zeros((self.layer_dims[i], 1))",
"def create_random(self):\n number_of_layers = random.choice(self.parameter_... | [
"0.7439151",
"0.74228984",
"0.7330529",
"0.7275741",
"0.7183611",
"0.7177239",
"0.7172136",
"0.7160283",
"0.7126808",
"0.7113416",
"0.70987576",
"0.7087519",
"0.70722723",
"0.7015661",
"0.7011332",
"0.6968827",
"0.6952228",
"0.6943982",
"0.6943128",
"0.693684",
"0.6932757",
... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.0 | -1 |
Creates a default kernel configuration suitable for general purpose inference. Currently configures an assignment sampler followed by a component hyperparameter sampler. | def default_kernel_config(defn):
# XXX(stephentu): should the default config also include cluster_hp?
return list(it.chain(
default_assign_kernel_config(defn),
default_feature_hp_kernel_config(defn))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_kernel_config(defn):\n return [('beam', {}),\n ('hypers',\n {\n 'alpha_a': 4.0,\n 'alpha_b': 2.0,\n 'gamma_a': 3.0, \n 'gamma_b': 6.0\n }\n )]",
"def default_assign_kerne... | [
"0.74664825",
"0.6669633",
"0.64068115",
"0.6141077",
"0.60617054",
"0.59325707",
"0.58984137",
"0.5889346",
"0.58742774",
"0.5873526",
"0.5721628",
"0.56768763",
"0.56751627",
"0.5664445",
"0.56459564",
"0.5641544",
"0.5609423",
"0.56089675",
"0.5594062",
"0.558959",
"0.5588... | 0.6721311 | 1 |
Returns the current value of the underlying state object. Note that the returned value is a copy, so modifications to it will not be seen by the runner. | def get_latent(self):
return copy.deepcopy(self._latent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(self):\n return self._current_value",
"def get_current_state(self):\n\n return deepcopy(self.state)",
"def _get_state(self):\n return self.__state",
"def _get_state(self):\n return self.__state",
"def _get_state(self):\n return self.__state",
"def _get_state(self):\n r... | [
"0.80514616",
"0.77472425",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225",
"0.77185225"... | 0.0 | -1 |
Return a list of all known nodes. Items in the list are unique. | def get_known(self):
pool = set()
# Add neighbours:
pool.update(self.neighbours)
# Add fingers:
for f in SUCC_FINGERS:
pool.update(self.best_finger_succ[f])
for f in PRED_FINGERS:
pool.update(self.best_finger_pred[f])
return list(pool) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_nodes(self):\n # NOTE: return copy, so no one will screw\n # our list?\n return self.nodes",
"def get_all_nodes(self):\n return self._get_all_nodes()",
"def get_node_list(self):\n return []",
"def getNodes(self):\n return self.__allNodes",
"def get_node... | [
"0.80580425",
"0.7921569",
"0.7901952",
"0.7900873",
"0.7839311",
"0.768085",
"0.76684755",
"0.76684755",
"0.7654098",
"0.76400435",
"0.76306534",
"0.76205885",
"0.76079094",
"0.753844",
"0.74888945",
"0.7442686",
"0.7442686",
"0.7437385",
"0.7426283",
"0.7413756",
"0.740591"... | 0.0 | -1 |
Return a list of the closest known nodes. Close in the virtual sense, to self.ident, and to the possible fingers on the Chord DHT. | def get_close(self):
pool = set()
for f in SUCC_FINGERS:
pool.update(self.best_finger_succ[f])
for f in PRED_FINGERS:
pool.update(self.best_finger_pred[f])
return list(pool) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findClosestNodes(self, target: hash.hash.Hash):\n # TODO: make more efficient\n # See: http://stackoverflow.com/questions/30654398/implementing-find-node-on-torrent-kademlia-routing-table\n \n nodes = []\n \n for bucket in self.buckets:\n nodes = nodes + buc... | [
"0.65930384",
"0.6451432",
"0.6441099",
"0.6154325",
"0.6110815",
"0.6110729",
"0.6098832",
"0.596274",
"0.59549946",
"0.59381306",
"0.5893561",
"0.5875066",
"0.58516437",
"0.582783",
"0.5764664",
"0.573509",
"0.5721345",
"0.569594",
"0.567349",
"0.5671407",
"0.56553555",
"... | 0.0 | -1 |
Get the best predecessor for finger f. | def get_best_pred_finger(self,f):
return min(self.best_finger_pred[f],\
key=lambda kn:dist_ident(kn.ident,self.get_finger_pred_loc(f))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_succ_finger(self,f):\n return min(self.best_finger_succ[f],\\\n key=lambda kn:dist_ident(self.get_finger_succ_loc(f),kn.ident))",
"def predecessor(self, key):\r\n index = self.locate_predecessor(key)\r\n return self.keys[index] if index >= 0 else None",
"def add... | [
"0.78589743",
"0.6463797",
"0.6380368",
"0.63363165",
"0.6327055",
"0.6273297",
"0.62648135",
"0.6178588",
"0.61382604",
"0.6114862",
"0.6012184",
"0.59667087",
"0.5960902",
"0.5955692",
"0.59211004",
"0.5917483",
"0.5893443",
"0.5854102",
"0.5837635",
"0.5813187",
"0.5765961... | 0.7758518 | 1 |
Return bytesIO.getvalue(), making sure the result is a str. This is necessary because getvalue() returns a bytes object in Python 3. | def getBytesIOString(bytesIO):
if _BytesIOValueIsStr:
# We don't need to convert.
return bytesIO.getvalue()
else:
# Assume value is a Python 3 bytes object. Convert to str.
return "".join(map(_bytesElementToChr, bytesIO.getvalue())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getvalue(self):\n try:\n buffer_value = self.buffer.getvalue().decode()\n except UnicodeDecodeError:\n return self.buffer.getvalue()\n return super().getvalue() + buffer_value",
"def to_str(value: bytes) -> str:\n if value is not None:\n out = valu... | [
"0.7136646",
"0.708613",
"0.7069398",
"0.69311607",
"0.68839103",
"0.6821514",
"0.68155074",
"0.6760254",
"0.669473",
"0.6689737",
"0.6595317",
"0.6570502",
"0.6566499",
"0.6455121",
"0.6454829",
"0.64306384",
"0.6425795",
"0.64017624",
"0.6376336",
"0.6372872",
"0.63647157",... | 0.79677886 | 0 |
Converts a sqlite3.Row to a string representing JSON | def row_to_json(row: sqlite3.Row) -> str:
d = {}
for key in row.keys():
d[key] = row[key]
return json.dumps(d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_list_to_json(rows: List[sqlite3.Row]) -> str:\n l = []\n for row in rows:\n l.append(row_to_json(row))\n\n return json.dumps(l)",
"def to_json_line(bq_row):\n row = dict()\n for key in bq_row:\n row[key] = bq_row[key]\n\n # default=str converts non JSON serializable object... | [
"0.81565416",
"0.74537444",
"0.74064386",
"0.7377652",
"0.7289121",
"0.6780555",
"0.672762",
"0.6564707",
"0.6396816",
"0.6321192",
"0.6316652",
"0.6303767",
"0.6242757",
"0.6235095",
"0.6218394",
"0.6139007",
"0.6124461",
"0.61206156",
"0.6118917",
"0.61147624",
"0.6109016",... | 0.90898705 | 0 |
Converts a List[sqlite3.Row] to a string representing JSON | def row_list_to_json(rows: List[sqlite3.Row]) -> str:
l = []
for row in rows:
l.append(row_to_json(row))
return json.dumps(l) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_to_json(row: sqlite3.Row) -> str:\n d = {}\n for key in row.keys():\n d[key] = row[key]\n\n return json.dumps(d)",
"def convert_to_json(self, rows):\n\t\tjson_list = []\n\t\tfor row in rows:\n\t\t\tjson_record = {}\n\t\t\tjson_record[\"movie_id\"] = row[0]\n\t\t\tjson_record[\"title\"] = ... | [
"0.7739139",
"0.752135",
"0.7446329",
"0.712356",
"0.694361",
"0.6843901",
"0.6843901",
"0.6747058",
"0.6747058",
"0.6701383",
"0.66863126",
"0.6674621",
"0.66703725",
"0.6659731",
"0.6658011",
"0.6646014",
"0.6643814",
"0.6618622",
"0.65742904",
"0.6567026",
"0.6566061",
"... | 0.91807425 | 0 |
returns a string representation of the question type in the real time database. | def get_question_type(type):
if type == 'בחירה יחידה':
return 'SingleChoice'
elif type == 'בחירה מרובה':
return 'MultipleChoice'
elif type == 'שאלה פתוחה':
return 'OpenQuestion' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _type_str(self):\n try:\n record_name = RECORD_TYPES[self.type]\n return '{0} record'.format(record_name)\n except KeyError:\n return '{0} type 0x{1:04x}'.format(self.__class__.__name__,\n self.type)",
"def __str__(s... | [
"0.6865402",
"0.66809237",
"0.66203624",
"0.66063035",
"0.65406144",
"0.65385854",
"0.65357155",
"0.64439434",
"0.6422072",
"0.6417245",
"0.63635415",
"0.6254435",
"0.62316257",
"0.62316257",
"0.62316257",
"0.62316257",
"0.62316257",
"0.62316257",
"0.62316257",
"0.62316257",
... | 0.6093655 | 60 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.8081514",
"0.7890486",
"0.7534929",
"0.72789717",
"0.72789717",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
... | 0.0 | -1 |
Returns player who has the next turn on a board. | def player(board):
number_of_X = 0
number_of_O = 0
for row in board:
number_of_X += row.count("X")
number_of_O += row.count("O")
if number_of_X <= number_of_O:
return("X")
else:
return("O") | {
"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 |
Returns the optimal action for the current player on the board. | def minimax(board):
if terminal(board):
return None
else:
if len(actions(board)) == 9:
for action in actions(board):
return action
else:
if player(board) == 'X':
# v = max_value(board)
# for action in actions(boar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction",
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min... | [
"0.7766856",
"0.76323676",
"0.75855315",
"0.75285065",
"0.75175256",
"0.74667144",
"0.7460485",
"0.74263537",
"0.7416421",
"0.73943585",
"0.7375846",
"0.7333894",
"0.73147565",
"0.7306611",
"0.7284639",
"0.72650313",
"0.72650313",
"0.7250975",
"0.72331834",
"0.7203267",
"0.71... | 0.70789856 | 32 |
Normalize a URI (And return a URIResult) | def normalize_uri_result(uri):
ref = uri_reference(uri).normalize()
return ref._replace(
authority=normalize_uri_authority(ref),
query=normalize_uri_query(ref),
path=normalize_uri_path(ref),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_uri(uri):\n return normalize_uri_result(uri).unsplit()",
"def _urlnorm(self, uri):\r\n (scheme, authority, path, query, fragment) = parse_uri(uri)\r\n if not scheme or not authority:\r\n raise Exception(\"Only absolute URIs are allowed. uri = %s\" % uri)\r\n autho... | [
"0.8090733",
"0.76550364",
"0.7136166",
"0.7022947",
"0.6984481",
"0.6822511",
"0.68086845",
"0.6780735",
"0.66093105",
"0.6543287",
"0.6404623",
"0.63960683",
"0.6173417",
"0.6112646",
"0.6043692",
"0.6000578",
"0.5998875",
"0.59867203",
"0.5972129",
"0.58413917",
"0.5839414... | 0.81375635 | 0 |
Function that turns a 3d field F3d in [Fx,Fy,Fz] format to a [[fx1,fy1,fz1], ... ,[fxn,fyn,fzn]] fomat Where FX is the zyx array corresponding to the x component of the field and fx1 is the x component of the field at the first point Inputs f3d field which will be converted by the function. C.Losada de la Lastra 2015 | def F3d_2_vtkFromat(F3d):
#asign variables
[Fx,Fy,Fz] = F3d
#generate the output array
F3dVTK = N.array([N.zeros(3) for i in range(len(Fx)*len(Fy[0])*len(Fz[0][0]))])
#loop and rearange
c=0
for k in range(len(Fz)):
for j in range(len(Fz[0])):
for i in range(len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_3d_tranpose(): \n dic,data = ng.pipe.read_lowmem(\"common_data/3d_pipe/ft/test%03d.ft3\")\n fdic,fdata = ng.pipe.read(\"common_data/3d_pipe/ft/test%03d.ft3\")\n\n assert_array_equal(data.transpose()[0,1,2],fdata.transpose()[0,1,2])\n assert_array_equal(data.transpose((2,0,1))[0,1,2],\n ... | [
"0.6738585",
"0.6631589",
"0.6503169",
"0.6495769",
"0.6400366",
"0.6348327",
"0.62344724",
"0.61679155",
"0.61502033",
"0.6063375",
"0.60627055",
"0.60346746",
"0.598228",
"0.5907918",
"0.5868698",
"0.584995",
"0.58388567",
"0.5815556",
"0.58086735",
"0.5725239",
"0.5707815"... | 0.7350591 | 0 |
Test our custom Hypermedia resource handles URls that aren't registered. | def test_hypermedia_custom_resource_non_registered_urls():
data = {
'name': 'Wort wort',
'slug': 'sluggy',
'not_valid': 'nooo',
# This should not appear!
'author': 'http://dev/api/foobar/1'
}
instance = HypermediaBlogsResource(**data)
assert not hasattr(instance, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hypermedia_custom_resource():\n data = {\n 'name': 'Wort wort',\n 'slug': 'sluggy',\n 'not_valid': 'nooo',\n 'author': 'http://dev/api/authors/1'\n }\n instance = HypermediaBlogsResource(**data)\n assert hasattr(instance, 'get_authors')",
"def test_dynamic_url(sel... | [
"0.7026299",
"0.6746552",
"0.6544264",
"0.6300041",
"0.6172381",
"0.6109873",
"0.5962861",
"0.5946122",
"0.59105587",
"0.5873638",
"0.58107054",
"0.5787485",
"0.5779619",
"0.574595",
"0.57324624",
"0.57148445",
"0.57081646",
"0.57043415",
"0.5655195",
"0.56529117",
"0.5642978... | 0.769136 | 0 |
Says whether this matrix is uppertriangular. True can be returned even if the matrix is not square. | def is_upper(self):
return self.rep.is_upper() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_upper_triangular(self):\n self.check_square()\n\n for i in range(self.rows):\n for j in range(i):\n if self[i, j] != 0:\n return False\n return True",
"def is_upper(self):\n M = self.rep\n for i in range(self.rows):\n ... | [
"0.844744",
"0.7495243",
"0.6773453",
"0.6493323",
"0.6323144",
"0.61934626",
"0.6140013",
"0.60975486",
"0.6014325",
"0.6014325",
"0.60010576",
"0.59452",
"0.5910085",
"0.5894454",
"0.5873557",
"0.5872957",
"0.58713764",
"0.5847847",
"0.58093315",
"0.5774065",
"0.57679564",
... | 0.58007485 | 19 |
True if the matrix is diagonal. Can return true for nonsquare matrices. A matrix is diagonal if ``M[i,j] == 0`` whenever ``i != j``. Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DM >>> M = DM([[ZZ(1), ZZ(0)], [ZZ(0), ZZ(1)]], ZZ) >>> M.is_diagonal True See Also ======== is_upper is_lo... | def is_diagonal(self):
return self.rep.is_diagonal() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isDiag(matrix):\n if np.isscalar(matrix) == True:\n return True\n elif type(matrix) is np.ndarray:\n if matrix.size == 1:\n return True\n elif np.count_nonzero(matrix - np.diag(np.diagonal(matrix))) == 0:\n return True\n else:\n return False\n ... | [
"0.7821849",
"0.74941677",
"0.74941677",
"0.7441418",
"0.7399577",
"0.7367698",
"0.73122686",
"0.7057577",
"0.7038562",
"0.6748433",
"0.6681966",
"0.66680706",
"0.66487104",
"0.65727955",
"0.6539708",
"0.6457882",
"0.64341956",
"0.63791597",
"0.62553805",
"0.61958116",
"0.617... | 0.80671704 | 0 |
Get the diagonal entries of the matrix as a list. Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DM >>> M = DM([[ZZ(1), ZZ(2)], [ZZ(3), ZZ(4)]], ZZ) >>> M.diagonal() [1, 4] See Also ======== is_diagonal diag | def diagonal(self):
return self.rep.diagonal() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonal(self):\n M = self.rep\n m, n = self.shape\n return [M[i, i] for i in range(min(m, n))]",
"def get_diagonal(board, diagonal):\n if diagonal == 1:\n positions = (0, 4, 8)\n elif diagonal == 3:\n positions = (2, 4, 6)\n return [board[x] for x in positions]",
... | [
"0.78579056",
"0.75239784",
"0.7518303",
"0.7450371",
"0.7341942",
"0.72809136",
"0.7010292",
"0.6982171",
"0.6929335",
"0.68225384",
"0.6723642",
"0.6715104",
"0.6712493",
"0.6658152",
"0.66512823",
"0.65816116",
"0.6556377",
"0.65435493",
"0.65220404",
"0.6462548",
"0.64548... | 0.72988534 | 5 |
r""" Returns the negative of DomainMatrix | def neg(A):
return A.from_rep(A.rep.neg()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neg__(self):\r\n return mat4(map(lambda x: -x, self.mlist))",
"def __neg__(self):\n # \n # TODO - your code here\n #\n result = [];\n for row in self.g:\n result.append([-1*n for n in row]);\n \n return Matrix(result);",
"def __neg_... | [
"0.7331656",
"0.7195881",
"0.67628396",
"0.6760654",
"0.6758093",
"0.6562137",
"0.6547884",
"0.65024996",
"0.65024996",
"0.6491416",
"0.6484659",
"0.643803",
"0.6413707",
"0.64084524",
"0.6406073",
"0.63454807",
"0.6325115",
"0.62976116",
"0.6248668",
"0.62286276",
"0.6221134... | 0.5823869 | 33 |
Cancel factors between the elements of a matrix and a denominator. Returns a matrix of numerators and matrix of denominators. Requires ``gcd`` in the ground domain. Examples ======== >>> from sympy.polys.matrices import DM >>> from sympy import ZZ >>> M = DM([[2, 3], [4, 12]], ZZ) >>> denom = ZZ(6) >>> numers, denoms =... | def cancel_denom_elementwise(self, denom):
K = self.domain
M = self
if K.is_zero(denom):
raise ZeroDivisionError('denominator is zero')
elif K.is_one(denom):
M_numers = M.copy()
M_denoms = M.ones(M.shape, M.domain)
return (M_numers, M_deno... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_denom(self, denom):\n M = self\n K = self.domain\n\n if K.is_zero(denom):\n raise ZeroDivisionError('denominator is zero')\n elif K.is_one(denom):\n return (M.copy(), denom)\n\n elements, data = M.to_flat_nz()\n\n # First canonicalize the d... | [
"0.6634346",
"0.5153074",
"0.5128968",
"0.5110255",
"0.50896513",
"0.5068658",
"0.5046499",
"0.50334495",
"0.499617",
"0.4993697",
"0.49848732",
"0.4969663",
"0.49391907",
"0.49382338",
"0.49351898",
"0.4918057",
"0.49062005",
"0.4899771",
"0.48944438",
"0.4885724",
"0.487889... | 0.7187386 | 0 |
Return the gcd of the elements of the matrix. Requires ``gcd`` in the ground domain. Examples ======== >>> from sympy.polys.matrices import DM >>> from sympy import ZZ >>> M = DM([[2, 4], [4, 12]], ZZ) >>> M.content() 2 See Also ======== primitive cancel_denom | def content(self):
K = self.domain
elements, _ = self.to_flat_nz()
return dup_content(elements, K) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GCD(cls,*num):\n from fractions import gcd\n if hasattr(num[0],'__iter__'): return cls.GCD(*num[0])\n if len(num) > 2:\n return reduce(lambda x,y:gcd(x,y),num)\n else:\n return gcd(*num)",
"def gcd(self,num,den):\n if(den==0): \n return num\... | [
"0.62480825",
"0.6070639",
"0.60561955",
"0.5941702",
"0.58882046",
"0.58882046",
"0.5834273",
"0.5786104",
"0.57750976",
"0.5754546",
"0.57521963",
"0.5741501",
"0.5728168",
"0.5716041",
"0.5695814",
"0.5695319",
"0.5682274",
"0.5654655",
"0.5594947",
"0.5592289",
"0.558544"... | 0.0 | -1 |
r""" Returns reducedrow echelon form with denominator and list of pivots. Requires exact division in the ground domain (``exquo``). Examples ======== >>> from sympy import ZZ, QQ >>> from sympy.polys.matrices import DomainMatrix >>> A = DomainMatrix([ ... [ZZ(2), ZZ(1), ZZ(0)], ... [ZZ(1), ZZ(2), ZZ(1)], ... [ZZ(0), ZZ... | def rref_den(self, *, method='auto', keep_domain=True):
return _dm_rref_den(self, method=method, keep_domain=keep_domain) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_orthonormalize_right_qr(A: np.ndarray, Aprev: np.ndarray, qd: Sequence[int], qD: Sequence[Sequence[int]]):\n # flip left and right virtual bond dimensions\n A = A.transpose((0, 2, 1))\n # perform QR decomposition and replace A by reshaped Q matrix\n s = A.shape\n assert len(s) == 3\n q0... | [
"0.5662891",
"0.54957014",
"0.5401048",
"0.5270808",
"0.5204519",
"0.51671714",
"0.48634428",
"0.4818971",
"0.48176032",
"0.47955397",
"0.4788307",
"0.47826388",
"0.4776309",
"0.4766484",
"0.4749962",
"0.47082475",
"0.47054073",
"0.46979412",
"0.45984504",
"0.45855892",
"0.45... | 0.42696482 | 61 |
r""" Return diagonal matrix with entries from ``diagonal``. Examples ======== >>> from sympy.polys.matrices import DomainMatrix >>> from sympy import ZZ >>> DomainMatrix.diag([ZZ(5), ZZ(6)], ZZ) | def diag(cls, diagonal, domain, shape=None):
if shape is None:
N = len(diagonal)
shape = (N, N)
return cls.from_rep(SDM.diag(diagonal, domain, shape)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonal(matrix):\n if sp.sparse.issparse(matrix):\n diag = np.array(matrix.diagonal())\n else:\n diag = np.diagonal(matrix).copy()\n return diag",
"def diagonal(self):\n M = self.rep\n m, n = self.shape\n return [M[i, i] for i in range(min(m, n))]",
"def get_dia... | [
"0.75419396",
"0.7343016",
"0.7339475",
"0.73322403",
"0.7324302",
"0.72696435",
"0.7268999",
"0.71389306",
"0.70959455",
"0.70923465",
"0.7087194",
"0.7062203",
"0.7036768",
"0.6925176",
"0.6907123",
"0.6873534",
"0.68501925",
"0.67881244",
"0.67330426",
"0.6728541",
"0.6726... | 0.8093071 | 0 |
r""" Checks for two DomainMatrix matrices to be equal or not | def __eq__(A, B):
if not isinstance(A, type(B)):
return NotImplemented
return A.domain == B.domain and A.rep == B.rep | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, DFM):\n return NotImplemented\n # Compare domains first because we do *not* want matrices with\n # different domains to be equal but e.g. a flint fmpz_mat and fmpq_mat\n # with the same entries will compare equal.\n r... | [
"0.7310266",
"0.7251817",
"0.7118429",
"0.70799834",
"0.705573",
"0.7045561",
"0.7029675",
"0.7021802",
"0.698679",
"0.6981819",
"0.6960576",
"0.6892625",
"0.6877056",
"0.68619347",
"0.6841737",
"0.6838758",
"0.6808563",
"0.6802841",
"0.67947996",
"0.6767748",
"0.6723825",
... | 0.67667663 | 20 |
Test a registry with a missing standard name. Check that it does not validate and does not generate any Fortran or metadata files | def test_missing_standard_name(self):
# Setup test
infilename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_simple.xml")
filename = os.path.join(_TMP_DIR, "reg_no_std_name.xml")
out_source_name = "physics_types_no_std_name"
out_source = os.path.join(_TMP_DIR, out_source_name + '.F9... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_registry(self):\n validate_registry()",
"def test_no_metadata_file_registry(self):\n # Setup test\n infilename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_mf.xml\")\n filename = os.path.join(_TMP_DIR, \"reg_no_mf.xml\")\n out_source_name = \"physics_types_no_mf\"\n ... | [
"0.68783224",
"0.6453713",
"0.64522105",
"0.63392645",
"0.6313093",
"0.61355084",
"0.60785717",
"0.59977686",
"0.5938566",
"0.5891832",
"0.5828589",
"0.5826495",
"0.5821727",
"0.5809477",
"0.57814956",
"0.5778031",
"0.5775003",
"0.57567817",
"0.5706741",
"0.569216",
"0.562601... | 0.7792895 | 0 |
Test a registry with a DDT variable that has a kind attribute. Check that it raises an exception and does not generate any Fortran or metadata files | def test_ddt_with_kind(self):
# Setup test
infilename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_ddt.xml")
filename = os.path.join(_TMP_DIR, "reg_ddt_with_kind.xml")
out_source_name = "physics_types_ddt_with_kind"
out_source = os.path.join(_TMP_DIR, out_source_name + '.F90')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ddt_with_unknown_type(self):\n # Setup test\n infilename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_ddt.xml\")\n filename = os.path.join(_TMP_DIR, \"reg_ddt_var_unknown.xml\")\n out_source_name = \"physics_types_ddt_var_unknown_type\"\n out_source = os.path.join(_TMP_D... | [
"0.62541693",
"0.6181157",
"0.6161756",
"0.5971583",
"0.5942705",
"0.58668464",
"0.5816771",
"0.5774226",
"0.5762913",
"0.5747795",
"0.57199615",
"0.56552935",
"0.5652728",
"0.5602194",
"0.559683",
"0.5592391",
"0.55627656",
"0.5551885",
"0.5521057",
"0.55121905",
"0.54599315... | 0.7301836 | 0 |
Get the new state, reward, and done state of the action. | def step(self, action):
self.move_step(action) # Move.
r, d = self.check_goal() # Check the reward and done state, and create
# new environment.
s_new= self.render_env() # Render the new environment.
return s_new, r, d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\r\n reward = self.__execute(action)\r\n self.__totalReward += reward\r\n status = self.__status()\r\n state = self.__observe()\r\n logging.debug(\"action: {:10s} | reward: {: .2f} | status: {}\".format(Action(action).name, reward, status))\r\n retur... | [
"0.7568853",
"0.7404111",
"0.71776295",
"0.7073127",
"0.7050767",
"0.6966503",
"0.69647443",
"0.6957431",
"0.69570696",
"0.69411266",
"0.68772703",
"0.68572736",
"0.68553555",
"0.6851779",
"0.6833063",
"0.6803432",
"0.6769455",
"0.6756298",
"0.6752057",
"0.6748703",
"0.673830... | 0.6354836 | 69 |
Get authorization header for user using the passed client. | def get_authorization_header(client, user):
# obtain authorization token
response = client.post(
reverse('token-obtain'),
data={'username': user.username, 'password': user.raw_password},
content_type='application/json'
)
token = response.json()['access']
return {'HTTP_AUTHORI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_oauth_headers(self, user):\n access_token = AccessTokenFactory.create(user=user, application=ApplicationFactory()).token\n headers = {\n 'HTTP_AUTHORIZATION': 'Bearer ' + access_token\n }\n return headers",
"def _get_oauth_headers(self, user):\n access_token... | [
"0.6606202",
"0.6606202",
"0.65720737",
"0.65720737",
"0.64708054",
"0.60986817",
"0.60356957",
"0.60226136",
"0.5895739",
"0.5854155",
"0.5800252",
"0.5783965",
"0.5766352",
"0.57551414",
"0.5745023",
"0.57149726",
"0.5712809",
"0.56914514",
"0.56868017",
"0.56868017",
"0.56... | 0.81782097 | 0 |
Get the raw data of the replacement text from correct yaml file | def get_replacement_data(
yaml_files: List[str], data_type: str = "translation", language: str = ""
) -> Dict[Any, Dict[Any, Any]]:
data = {}
logging.debug(f" --- Starting get_replacement_data() for data_type = {data_type} and language = {language}")
if convert_vars.making_template:
lang = "en"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _info(self):\n text = ''.join(self._lines)\n rendered_text = jinja2.Template(text).render()\n return yaml.load(rendered_text)",
"def _get_yaml_content(self):\n\n with open('.travis.yml') as f:\n content = yaml.load(f)\n\n return content",
"def _read(self, text)... | [
"0.63911444",
"0.6182076",
"0.614977",
"0.6144118",
"0.6126104",
"0.5768432",
"0.5742558",
"0.57341444",
"0.567105",
"0.56645757",
"0.55821717",
"0.55663025",
"0.55575216",
"0.5523943",
"0.55035734",
"0.55023074",
"0.54623216",
"0.5405846",
"0.53910786",
"0.5389414",
"0.53699... | 0.61133593 | 5 |
Insert a sequence at the given position. | def insert(self, position, insert):
assert all(new in self.ALPHABET for new in insert)
if position < 1 or position - 1 > len(self.sequence):
raise ValueError(f"Insertion position {position} out of bonds for given sequence.")
self.sequence = f"{self.sequence[: position - 1]}{insert}{s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_at(sequence, index, element):\n # ... and the rest is up to you\n\n new_sequence = sequence[:index] + element + sequence[index:]\n return new_sequence",
"def insert(self, pos, length):\n if pos in self.insertions:\n self.insertions[pos] += length\n else:\n ... | [
"0.71550727",
"0.70287114",
"0.6779251",
"0.65152967",
"0.65025556",
"0.6484994",
"0.64291614",
"0.64140797",
"0.6331637",
"0.6325899",
"0.6309266",
"0.6307709",
"0.6244849",
"0.62239134",
"0.6169491",
"0.6159841",
"0.61403745",
"0.6126771",
"0.6121638",
"0.61068463",
"0.6040... | 0.78549856 | 0 |
Updates the boids' accelerations by all of its behavioral rules. The effect of each rule is filtered by the mutual influence matrix and weighted by its own coefficient. | def update_acc_by_rules(self) -> None:
for rule, coeff in self.rules.items():
acc_delta = rule(self) # can't call self.rule
self.update_acc(acc_delta, coeff) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_behaviour(self, boids, boids_in_radius):\r\n avg_velocity, center_of_mass, avg_vector, total = self.compute_in_radius(boids_in_radius)\r\n \r\n alignment = self.align(boids, avg_velocity, total)\r\n cohesion = self.cohesion(boids, center_of_mass, total)\r\n separation =... | [
"0.66462886",
"0.65182894",
"0.62520367",
"0.6176411",
"0.58295554",
"0.5811342",
"0.57856274",
"0.5667284",
"0.5651299",
"0.56139237",
"0.5607561",
"0.5546322",
"0.5546322",
"0.5546322",
"0.5546322",
"0.5542807",
"0.55238605",
"0.55109304",
"0.54686683",
"0.54572076",
"0.545... | 0.6409487 | 2 |
Append a new rule to the boids' default behavioral rules appends a new rule to the boids' existing rule | def append_rules(self, *args: Tuple[Callable, float]) -> None:
for rule, _ in args:
setattr(Boids, rule.__name__, rule)
self.rules.update({rule: coeff for (rule, coeff) in args}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_rule(self, rule):\n self.rule.append(rule)",
"def add_rule(self, rule) -> None:\n self.add_rules([rule])",
"def add_rule(self, rule):\n \n self.rules.append(rule)",
"def add_rule(rule):\n global RULE_DICT\n\n if rule[0] not in RULE_DICT:\n RULE_DICT[rule[0]] =... | [
"0.71578425",
"0.69797266",
"0.69791746",
"0.6923265",
"0.68801445",
"0.68325424",
"0.6799666",
"0.6794736",
"0.6519926",
"0.6495337",
"0.6444254",
"0.6375227",
"0.6325688",
"0.62689775",
"0.6252311",
"0.6248839",
"0.6220549",
"0.60842717",
"0.60406107",
"0.6034459",
"0.60220... | 0.7229486 | 0 |
Limits the magnitude of the input matrix/vector along the 0th axis. This function will only activate if the magnitude of the input is greater than the specified limit. | def maglim(arr: np.ndarray, limit: float) -> np.ndarray:
norm = np.linalg.norm(arr, axis=0)
return arr / np.where(norm>limit, norm/limit, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit(self, lim: float):\n if self.mag() > lim:\n self.values = tuple(self.norm()*lim)\n return self",
"def limit_vec(self, vec, limit=None):\n mag = np.linalg.norm(vec)\n if not limit:\n limit = self.vec_mag_limit\n\n if mag < limit:\n retu... | [
"0.6425002",
"0.639677",
"0.58209056",
"0.58038825",
"0.5767511",
"0.56844366",
"0.559588",
"0.55820006",
"0.5580737",
"0.54883015",
"0.54722536",
"0.54082",
"0.540348",
"0.53970385",
"0.5388405",
"0.5331233",
"0.53288496",
"0.52706766",
"0.5270119",
"0.52564836",
"0.52482295... | 0.6473633 | 0 |
Return all the tags on this object, regardless of category. | def all(self) -> list:
return list(self.__holder.db_tags) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_categories(self):\r\n return self._tags",
"def get_tags(self):\n\n return self.tags",
"def get_tags(self):\n return self.tags",
"def tags(self) -> List[Tag]:\n return self._tags",
"def get_tags(self) -> Set[Text]:\r\n return {tag for tag in self.tags}",
"def get... | [
"0.80873924",
"0.76988554",
"0.7685985",
"0.7613178",
"0.75967216",
"0.7576979",
"0.7533801",
"0.7497775",
"0.7497775",
"0.7497775",
"0.7497775",
"0.7497775",
"0.7497775",
"0.7497775",
"0.7497775",
"0.7278242",
"0.7269573",
"0.7268734",
"0.7265938",
"0.7265938",
"0.72120774",... | 0.0 | -1 |
Return all the tags on this object, in the given category. | def with_category(self, category: str) -> list:
return list(self.__holder.db_tags.filter(
lambda t: t.category == category)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_categories(self):\r\n return self._tags",
"def tag(self, category_tagger={}):\n self.tags.update(category_tagger)\n return self.tags",
"def search(cls, tag_name: str, category: ty.Optional[str] = None\n ) -> ty.Set[db.Entity]:\n tags = cls.select(lambda t: t.name ... | [
"0.72470844",
"0.6895858",
"0.68126684",
"0.6623663",
"0.6261047",
"0.62491196",
"0.62253946",
"0.6223657",
"0.617257",
"0.6166665",
"0.6159755",
"0.6157589",
"0.6147112",
"0.6143004",
"0.61422914",
"0.6136447",
"0.61342096",
"0.61030024",
"0.60924834",
"0.6087911",
"0.607700... | 0.8041095 | 0 |
Set the IO pin used for Gpio | def set_pin(self, pin):
if pin not in range(0, 14):
raise Exception("Incorrect pin {} selected. Pins available (0 to 13)".format(pin))
else:
self.pin = pin
self.gpio_pin = mraa.Gpio(pin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pin(self):\n GPIO.setwarnings(False)\n GPIO.setmode(GPIO.BOARD)\n GPIO.setup(self.pin, GPIO.OUT)\n GPIO.output(self.pin, GPIO.LOW)\n time.sleep(3)\n GPIO.output(self.pin, GPIO.HIGH)",
"def write_pin(self, attr):\n \n self.logging.debug(\"Setting \" ... | [
"0.77708316",
"0.72250545",
"0.7117954",
"0.7034014",
"0.697967",
"0.6922211",
"0.67139626",
"0.66982925",
"0.66900015",
"0.664088",
"0.6617076",
"0.65627766",
"0.6547264",
"0.65464395",
"0.65358406",
"0.65099466",
"0.6469963",
"0.64698595",
"0.64566153",
"0.6448463",
"0.6402... | 0.72110295 | 2 |
Creates a new `Progress` instance from a raw unparsed dict. | def from_raw_dict(cls, data: Dict[str, str]):
print(data)
return cls(**{field: cls._PARSERS.get(field, str)(data[field])
for field in cls.__dataclass_fields__ # type: ignore
if field in data}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(cls, d):\n assert \"status\" in d\n assert \"metadata\" in d\n return cls(**d)",
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _dict):\n return cls.from_dic... | [
"0.7018969",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"0.6626099",
"... | 0.6170516 | 53 |
Gets the name of this V1Parameter. Name must be set and it can be referenced in Template Items using ${PARAMETER_NAME}. Required. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getName(self):\n return _libsbml.Parameter_getName(self)",
"def get_name(self, ):\n return self.get_parameter('name')",
"def get_name(self) -> str:\n # read the original value passed by the command\n name = self.raw_param.get(\"name\")\n\n # this parameter does not need d... | [
"0.8336643",
"0.77589035",
"0.7642262",
"0.7572355",
"0.71773744",
"0.6917043",
"0.6913706",
"0.6864129",
"0.685302",
"0.68067783",
"0.680277",
"0.678839",
"0.6762121",
"0.67531896",
"0.6750995",
"0.6750995",
"0.671956",
"0.6679734",
"0.6679734",
"0.6679734",
"0.6679734",
"... | 0.0 | -1 |
Gets the display_name of this V1Parameter. | def display_name(self):
return self._display_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_name(self):\n return self.properties.get(\"displayName\", None)",
"def display_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) ->... | [
"0.750886",
"0.73503536",
"0.73503536",
"0.73503536",
"0.73503536",
"0.73503536",
"0.73503536",
"0.73219526",
"0.73219526",
"0.73219526",
"0.73219526",
"0.73219526",
"0.7288173",
"0.72772527",
"0.72772527",
"0.72772527",
"0.72772527",
"0.72772527",
"0.72772527",
"0.72772527",
... | 0.71122587 | 73 |
Sets the display_name of this V1Parameter. | def display_name(self, display_name):
self._display_name = display_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_display_name(self, display_name):\n self._call('set_display_name', display_name=display_name)",
"def display_name(self, display_name: str):\n\n self._display_name = display_name",
"def display_name(self, display_name):\n self._display_name = display_name",
"def display_name(self,... | [
"0.7599665",
"0.7508359",
"0.72949785",
"0.72949785",
"0.72949785",
"0.72949785",
"0.72949785",
"0.72949785",
"0.66742635",
"0.66123646",
"0.6387324",
"0.62462187",
"0.5896558",
"0.58026224",
"0.57787293",
"0.57521135",
"0.57521135",
"0.57521135",
"0.57521135",
"0.57521135",
... | 0.73505455 | 7 |
Gets the description of this V1Parameter. Description of a parameter. Optional. | def description(self):
return self._description | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def param_description(hf, var):\n val = hf['/input/params/%s' % var].value\n if type(val) != str:\n val = val.decode('UTF-8')\n val = unpickle(val)\n desc = val.description\n\n if desc:\n return desc\n return var",
"def description(self) -> Optional[pulumi.Input[str]]:\n re... | [
"0.67779255",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
"0.6743164",
... | 0.0 | -1 |
Sets the description of this V1Parameter. Description of a parameter. Optional. | def description(self, description):
self._description = description | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_description(self, description):\n self.__description = description",
"def set_description(self, description):\r\n self.__description = description",
"def set_description(self, description):\n self.description = description",
"def description(self, description):\n if descri... | [
"0.705752",
"0.70541906",
"0.7035205",
"0.6985398",
"0.6980727",
"0.6980727",
"0.6980727",
"0.6980727",
"0.69634897",
"0.69586897",
"0.6945588",
"0.6931753",
"0.6931753",
"0.6931753",
"0.6931753",
"0.68970704",
"0.6831176",
"0.67569405",
"0.67543674",
"0.6739382",
"0.6705501"... | 0.6927959 | 49 |
Gets the _from of this V1Parameter. From is an input value for the generator. Optional. | def _from(self):
return self.__from | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"from_\")",
"def from_(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"from_\")",
"def from_(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"from_\")",
"def get_from(self, ):\n return self.get_paramet... | [
"0.74373275",
"0.74373275",
"0.74373275",
"0.7194117",
"0.64394814",
"0.62438667",
"0.62062824",
"0.6194226",
"0.6194226",
"0.6189661",
"0.59630805",
"0.592034",
"0.58989894",
"0.58940274",
"0.5869902",
"0.5831524",
"0.57826793",
"0.5742681",
"0.57424104",
"0.5712392",
"0.563... | 0.6890081 | 6 |
Sets the _from of this V1Parameter. From is an input value for the generator. Optional. | def _from(self, _from):
self.__from = _from | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _from(self, _from):\n if _from is None:\n raise ValueError(\"Invalid value for `_from`, must not be `None`\") # noqa: E501\n\n self.__from = _from",
"def set_from(self, a_from):\n if isinstance(a_from, (str, )):\n self.set_parameter('from', a_from)\n if isin... | [
"0.76100576",
"0.7499724",
"0.6521606",
"0.6521606",
"0.645407",
"0.64262307",
"0.6399411",
"0.6157603",
"0.6157603",
"0.6157603",
"0.6012709",
"0.5913504",
"0.58679134",
"0.5815317",
"0.5745893",
"0.57153845",
"0.57153845",
"0.57153845",
"0.5621879",
"0.53952944",
"0.5382046... | 0.7228746 | 5 |
Gets the required of this V1Parameter. | def required(self):
return self._required | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required(self) -> pulumi.Input[bool]:\n return pulumi.get(self, \"required\")",
"def required(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"required\")",
"def required(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"required\")",
"def required(... | [
"0.6975728",
"0.69183755",
"0.69183755",
"0.68999743",
"0.66399527",
"0.6597883",
"0.6597883",
"0.6591579",
"0.6480089",
"0.6414753",
"0.6408342",
"0.63553196",
"0.634542",
"0.6259731",
"0.619959",
"0.6185172",
"0.6085996",
"0.6053564",
"0.6019357",
"0.60031337",
"0.5997075",... | 0.72549653 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
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.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.7961088",
"0.7961088",
"0.79433626",
"0.79303336",
"0.7926563",
"0.7897525",
"0.78826123",
"0.78826123",
"0.78806067",
"0.7872423",
"0.7868354",
"0.78668815",
"0.7825702",
"0.7819993",
"0.78162885",
"0.78078854",
"0.78068... | 0.79670393 | 47 |
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.8457167",
"0.8393036",
"0.81455255",
"0.8139734",
"0.81333447",
"0.8094964",
"0.8093362",
"0.8093362",
"0.8093362",
"0.80863476",
"0.80863476",
"0.8077286",
"0.8077286",
"0.806682"
] | 0.0 | -1 |
Test case for dashboards_v2_update | def test_dashboards_v2_update(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_dashboard(self):\n os.unlink(self.dboard._path)\n self.dboard.update_dashboard()\n self.assertTrue(os.path.isfile(self.dboard._path))",
"def test_update_scenario(self):\n pass",
"def test_update_case(self):\n pass",
"def test_update(self):\n # this is... | [
"0.74163353",
"0.7246876",
"0.7155249",
"0.7070719",
"0.7010909",
"0.7010909",
"0.7010909",
"0.6946631",
"0.6806688",
"0.6731626",
"0.6626995",
"0.66035193",
"0.64835584",
"0.64800835",
"0.64792293",
"0.6466244",
"0.6455214",
"0.64326435",
"0.64298064",
"0.6385786",
"0.634503... | 0.9138029 | 0 |
Returns the topk items ordered by a relevancy score. Obtained probabilities are used as recommendation score. | def recommend_k_items(self, x, k, remove_seen=True):
# obtain scores
score = self.model.predict(x)
if remove_seen:
# if true, it removes items from the train set by setting them to zero
seen_mask = np.not_equal(x, 0)
score[seen_mask] = 0
# get the to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item_based_topk(self, items, top_k=10, sort_top_k=False):\n\n # convert item ids to indices\n item_ids = items[self.col_item].map(self.item2index)\n\n # if no ratings were provided assume they are all 1\n if self.col_rating in items.columns:\n ratings = items[self.col... | [
"0.71710426",
"0.7149169",
"0.6856658",
"0.6834214",
"0.68246776",
"0.6760741",
"0.6760536",
"0.67306244",
"0.6693146",
"0.66901475",
"0.6671577",
"0.6577725",
"0.63678414",
"0.63514674",
"0.6309947",
"0.62948525",
"0.6253606",
"0.6252747",
"0.62473625",
"0.6206402",
"0.61816... | 0.7145789 | 2 |
Calculate negative ELBO (NELBO). | def _get_vae_loss(self, x, x_bar):
log_softmax_var = tf.nn.log_softmax(x_bar)
self.neg_ll = -tf.reduce_mean(
input_tensor=tf.reduce_sum(input_tensor=log_softmax_var * x, axis=-1)
)
a = tf.keras.backend.print_tensor(self.neg_ll) # noqa: F841
# calculate positive Kullb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_elbo(self, current_params):\n return -self.full_neg_posterior(current_params) - self.create_normal_logq(current_params)",
"def get_elbo(self, current_params):\n return -self.neg_posterior(current_params) - self.create_normal_logq(current_params)",
"def tot_neg_elbo(self):\n\n\n ... | [
"0.7168848",
"0.71661013",
"0.71584994",
"0.6613478",
"0.6594607",
"0.6560377",
"0.631102",
"0.63086635",
"0.62857795",
"0.6270272",
"0.62088966",
"0.6094955",
"0.6089229",
"0.5907097",
"0.58984536",
"0.58747256",
"0.58610594",
"0.585848",
"0.58384037",
"0.58297944",
"0.58282... | 0.6439545 | 6 |
Returns the topk items ordered by a relevancy score. Obtained probabilities are used as recommendation score. | def recommend_k_items(self, x, k, remove_seen=True):
# return optimal model
self.model.load_weights(self.save_path)
# obtain scores
score = self.model.predict(x)
if remove_seen:
# if true, it removes items from the train set by setting them to zero
seen_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item_based_topk(self, items, top_k=10, sort_top_k=False):\n\n # convert item ids to indices\n item_ids = items[self.col_item].map(self.item2index)\n\n # if no ratings were provided assume they are all 1\n if self.col_rating in items.columns:\n ratings = items[self.col... | [
"0.71710426",
"0.7145789",
"0.6856658",
"0.6834214",
"0.68246776",
"0.6760741",
"0.6760536",
"0.67306244",
"0.6693146",
"0.66901475",
"0.6671577",
"0.6577725",
"0.63678414",
"0.63514674",
"0.6309947",
"0.62948525",
"0.6253606",
"0.6252747",
"0.62473625",
"0.6206402",
"0.61816... | 0.7149169 | 1 |
Generate instance masks for num_categories of the given image ID. | def load_mask(self, image_id):
info = self.image_info[image_id]
num_cards = info['cards']
# count = len(num_cards)
count = 1 # there will only ever be 1 card per image (for simplicity) TODO: do multiple documents?
mask = np.zeros([info['height'], info['width'], count], dtype=np.u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_mask(self, image_id):\n image_info = self.image_info[image_id]\n annotations = image_info['annotations']\n instance_masks = []\n class_ids = []\n \n for annotation in annotations:\n class_id = annotation['category_id']\n mask = Image.new('1',... | [
"0.7168982",
"0.68232125",
"0.6819072",
"0.6754465",
"0.67494434",
"0.66466624",
"0.6646137",
"0.6609447",
"0.66015846",
"0.65896213",
"0.6575726",
"0.65696466",
"0.6507139",
"0.6501369",
"0.64992666",
"0.6493003",
"0.6472146",
"0.6458939",
"0.64004475",
"0.6388024",
"0.63486... | 0.7008365 | 1 |
Generates random string of given length. | def generate_random_alphanumeric(length):
return ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) \
for _ in range(length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length):\r\n return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(length))",
"def generate_random_... | [
"0.8931698",
"0.8839906",
"0.87027717",
"0.862099",
"0.8618227",
"0.8617294",
"0.85954386",
"0.8574947",
"0.8534365",
"0.85126984",
"0.85051626",
"0.84650296",
"0.8443502",
"0.84123546",
"0.83955485",
"0.8380645",
"0.83545065",
"0.8348835",
"0.83404094",
"0.83308583",
"0.8312... | 0.0 | -1 |
Generates a random barcode of the form FLIM, where the are alphanumeric characters. That gives a random range of 60 million possible barcodes. | def new_barcode(num_digits=5, chars=string.digits+string.uppercase):
return 'FLIM-'+(''.join([random.choice(chars) for _ in xrange(num_digits)])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_code():\n return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(10)])",
"def code_generator():\n digits = [str(num) for num in range(10)]\n random.shuffle(digits)\n return digits[:3]",
"def __generate_number_boleto_fake(self):\n numbers = \"0123456789\"... | [
"0.7138197",
"0.6684884",
"0.6545216",
"0.65020794",
"0.6493189",
"0.6441008",
"0.6403886",
"0.6377922",
"0.63652015",
"0.6309812",
"0.63042516",
"0.62489617",
"0.6127796",
"0.61220354",
"0.60194755",
"0.6000993",
"0.60008746",
"0.5996696",
"0.5958608",
"0.5949149",
"0.593747... | 0.7978328 | 0 |
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.91900426",
"0.9168249",
"0.8901578",
"0.8770551",
"0.8511197",
"0.8479612",
"0.84444356",
"0.8299865",
"0.81868285",
"0.81055766",
"0.8079376",
"0.80653954",
"0.8050165",
"0.77025265",
"0.76141983",
"0.76136565",
"0.76024383",
"0.76024383",
"0.76024383",
"0.7540682",
"0.75... | 0.0 | -1 |
Turn all LEDs off. | def all_off(self):
self.fill_off()
self.update()
self.fill_off()
self.update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_all_off(self):\n for led_type in LED:\n self.led_off(led_type)\n logging.info('LED: ALL - Status: 0')",
"def off(self):\n for light in self.all:\n GPIO.output(light, 0)",
"def turn_off(self):\n print(\"Turning the lights off\")\n self.led.all_of... | [
"0.8985069",
"0.86606133",
"0.8338021",
"0.7999493",
"0.79426444",
"0.77855045",
"0.77235276",
"0.7641416",
"0.7628676",
"0.7491996",
"0.74485344",
"0.74444056",
"0.74116737",
"0.7399586",
"0.73635733",
"0.73297215",
"0.73277986",
"0.7293217",
"0.7254837",
"0.72381693",
"0.72... | 0.6727476 | 52 |
Moves every bullet and checks collision with enemy | def move_bullets(self, vel, enemies):
self.cooldown(SCREEN)
for bullet in self.bullets:
bullet.move(vel)
if bullet.off_screen(HEIGHT):
self.bullets.remove(bullet)
else:
for enemy in enemies:
if bullet.bullet_collisio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def e_collisions(rect, enemy_list):\r\n for enemy in enemy_list:\r\n if rect.colliderect(enemy[1]) and rect.bottom - 4 < enemy[1].top:\r\n dropped_objects.append([[enemy[1].x, enemy[1].y], heart_img, [0, 0], 45])\r\n enemy_list.remove(enemy)",
"def check_collide_enemy(self):\n ... | [
"0.68499255",
"0.6699276",
"0.6641216",
"0.6632509",
"0.6631075",
"0.6597619",
"0.6576827",
"0.6536081",
"0.65184474",
"0.6454792",
"0.644817",
"0.64457405",
"0.6440626",
"0.6424823",
"0.6412154",
"0.6411753",
"0.6411751",
"0.6408061",
"0.63944864",
"0.6362468",
"0.63506466",... | 0.74962366 | 0 |
The worker who communicated to this server for the first time, will get a unique ID. | def signup():
if work_status == Db.WorkStatusNames.finished_work.value:
raise_http_error("Forbidden", "This server doesn't need anymore workers, it finished it's job")
new_worker_id = str(id_generator())
print("New worker entered " + new_worker_id)
sign_up_data = {"worker_id": new_worker_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def worker_id(self):\n return self._worker_id",
"def worker_id(self):\n return self.assignment.WorkerId",
"def get_request_id(): # pragma: no cover\n from time import time\n return int(time()) # TODO check if this is good enough. My gut tells me \"no\"! Depends if it has to be unique acro... | [
"0.73427",
"0.6750778",
"0.6677065",
"0.6639651",
"0.6544856",
"0.64145404",
"0.6392464",
"0.63923246",
"0.63904136",
"0.63639605",
"0.6351515",
"0.63004917",
"0.62970066",
"0.6291544",
"0.6285231",
"0.6285231",
"0.62826437",
"0.628178",
"0.62793946",
"0.6276424",
"0.6273457"... | 0.0 | -1 |
Create an subject from the values dictionary. | def subject_create(context, values):
return _subject_update(context, values, None, purge_props=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_property_create(context, values, session=None):\n prop_ref = models.SubjectProperty()\n prop = _subject_property_update(context, prop_ref, values, session=session)\n return prop.to_dict()",
"def subject_member_create(context, values, session=None):\n memb_ref = models.SubjectMember()\n ... | [
"0.6719623",
"0.61484027",
"0.6093333",
"0.56392276",
"0.5612736",
"0.5576184",
"0.5552742",
"0.54739",
"0.5399233",
"0.5387403",
"0.53574824",
"0.53574824",
"0.53574824",
"0.53574824",
"0.53574824",
"0.53174007",
"0.530313",
"0.5256148",
"0.5249234",
"0.52405345",
"0.5212260... | 0.7354736 | 0 |
Get an subject or raise if it does not exist. | def _subject_get(context, subject_id, session=None, force_show_deleted=False):
_check_subject_id(subject_id)
session = session or get_session()
try:
query = session.query(models.Subject).options(
sa_orm.joinedload(models.Subject.properties)).options(
sa_orm.joinedload(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_subject(subject_id: SubjectID) -> Optional[Subject]:\n subject = DbSubject.query.get(subject_id)\n\n if subject is None:\n return None\n\n return _db_entity_to_subject(subject)",
"def _get_v2_subject_metadata(self, request, subject_id):\n db_api = subject.db.get_api()\n sub... | [
"0.7166992",
"0.60514516",
"0.60401314",
"0.6003597",
"0.60032964",
"0.598148",
"0.5942868",
"0.578982",
"0.5784934",
"0.574257",
"0.56569445",
"0.5612184",
"0.5577021",
"0.5571173",
"0.5479306",
"0.54013395",
"0.54000425",
"0.5384278",
"0.53687537",
"0.5359544",
"0.5326008",... | 0.68371254 | 1 |
Removed protected attributes from values dictionary using the models __protected_attributes__ field. | def _drop_protected_attrs(model_class, values):
for attr in model_class.__protected_attributes__:
if attr in values:
del values[attr] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_attributes(self):\n attrs = {}\n\n # Only fetch the fields we need.\n for a in self.attributes.only('name', 'value', 'attribute').iterator():\n if a.attribute.multi:\n if a.name not in attrs:\n attrs[a.name] = []\n attrs[a.n... | [
"0.6295131",
"0.59958804",
"0.59696347",
"0.5935034",
"0.5811424",
"0.568888",
"0.567086",
"0.5664389",
"0.56493944",
"0.5640074",
"0.56233746",
"0.56223124",
"0.5611786",
"0.5591424",
"0.5586236",
"0.5567396",
"0.5558045",
"0.5536151",
"0.5524247",
"0.55179757",
"0.5494092",... | 0.8467441 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.