query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Handle updated data from the coordinator. | def _handle_coordinator_update(self) -> None:
self._update_from_rest_data()
self.async_write_ha_state() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _handle_coordinator_update(self) -> None:\n self._update_data()\n self.async_write_ha_state()",
"def _handle_coordinator_update(self) -> None:\n self.update_from_latest_data()\n self.async_write_ha_state()",
"def _handle_coordinator_update(self) -> None:\n self._thermosta... | [
"0.8382766",
"0.8251621",
"0.79713356",
"0.7916281",
"0.7603569",
"0.7557993",
"0.7358644",
"0.7336086",
"0.7178118",
"0.7178118",
"0.7178118",
"0.7178118",
"0.7118628",
"0.7113253",
"0.6962891",
"0.6899875",
"0.6793388",
"0.67592835",
"0.67307264",
"0.66545016",
"0.6622291",... | 0.83799595 | 1 |
Update state from the rest data. | def _update_from_rest_data(self) -> None: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n self.data_service.update()\n self._state = self.data_service.data[self._json_key]",
"def update(self):\n self.data_service.update()\n self._state = self.data_service.data[self._json_key]\n self._attributes = self.data_service.attributes[self._json_key]",
"... | [
"0.7464082",
"0.7345038",
"0.7095148",
"0.6935037",
"0.688717",
"0.6846429",
"0.6788398",
"0.674589",
"0.6723376",
"0.6698431",
"0.6698142",
"0.6698142",
"0.6672436",
"0.66672236",
"0.6620751",
"0.65926933",
"0.6502901",
"0.6456487",
"0.6435798",
"0.6421655",
"0.64123446",
... | 0.78239757 | 0 |
Returns the number of rows and columns in the file. | def xFileInfo(filename):
delim = getDelimiter(filename)
f = open(filename, 'r')
reader = csv.reader(f, delimiter=delim)
num_rows = 0
for (row_i, row) in enumerate(reader):
if row_i == 0: #ignore empty strings (e.g. at end of row)
num_cols = len([val for val in row if val])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_len(fname):\n with open(fname) as f:\n for i, l in enumerate(f):\n pass\n Nrows = i + 1\n return Nrows",
"def get_col_count(files: List[str],\n dialect: csv.Dialect) -> int:\n for record in csv.reader(fileinput.input(files[0]), dialect):\n field_cnt ... | [
"0.7361192",
"0.7129871",
"0.70098907",
"0.69920206",
"0.69475377",
"0.69475377",
"0.69472617",
"0.6940272",
"0.69255877",
"0.6785789",
"0.67762715",
"0.6716077",
"0.6696763",
"0.66965425",
"0.66910267",
"0.66910267",
"0.66482913",
"0.66420263",
"0.6634468",
"0.6623555",
"0.6... | 0.7355778 | 1 |
Return a 2d array version of the input csv file. | def csvToArray(filename):
(num_rows, num_cols) = xFileInfo(filename)
X = numpy.zeros((num_rows, num_cols), dtype=float) #[row_i][col_i] : float
delim = getDelimiter(filename)
f = open(filename, 'r')
reader = csv.reader(f, delimiter=delim)
for (row_i, row) in enumerate(reader):
col_i = 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_2_numpy(file, path=INPUT_PATH, sep=',', type='int8'):\n file_path = path + file\n reader = csv.reader(open(file_path, \"r\"), delimiter=sep)\n x = list(reader)\n dataset = numpy.array(x).astype(type)\n return dataset",
"def csvread(file):\r\n thisfile = open(file)\r\n thisreader = cs... | [
"0.7369199",
"0.70016205",
"0.6973074",
"0.692204",
"0.67857",
"0.6770922",
"0.67499197",
"0.6745051",
"0.67402184",
"0.6710519",
"0.66884685",
"0.6623503",
"0.6600082",
"0.65895736",
"0.65832907",
"0.65782887",
"0.6531841",
"0.65317434",
"0.65293145",
"0.6484483",
"0.6482863... | 0.7018829 | 1 |
Reduce armor by AMOUNT, and if the True DragonKing has no armor remaining, signal the end of the game. | def reduce_armor(self, amount):
super().reduce_armor(amount)
if self.armor <=0 and self.is_true_king:
terminators_win() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def defend(self):\n\n # get the total amount of defense from each piece of armor\n\n # if hero is alive return total amount of defense\n # if hero dead return zero defense\n\n total_armor_defense = 0\n if len(self.armors) > 0 and self.health > 0:\n for armor in self.ar... | [
"0.6578414",
"0.6396055",
"0.6335813",
"0.6276856",
"0.6185058",
"0.6146651",
"0.61250633",
"0.60396993",
"0.5998618",
"0.5880459",
"0.58799756",
"0.5861807",
"0.5858857",
"0.5835011",
"0.58267784",
"0.5823309",
"0.5776775",
"0.5763782",
"0.57628846",
"0.57590044",
"0.5757191... | 0.82151866 | 0 |
r"""Returns the ith eigenvector (solution of the discrete Fredhom equation) | def eigen_vector_i(self, i):
return self._eig_vec[:,i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetEigenvector(self, i):\n return _hypre.HypreAME_GetEigenvector(self, i)",
"def GetEigenvector(self, i):\n return _hypre.HypreLOBPCG_GetEigenvector(self, i)",
"def eigen_vector_i_all(self):\n return self._eig_vec",
"def get_second_eigenvector(graph):\n ###TODO\n pass",
"def ... | [
"0.77358747",
"0.718795",
"0.64949745",
"0.6493093",
"0.6374428",
"0.6330454",
"0.6178145",
"0.60567135",
"0.6039423",
"0.602888",
"0.60242105",
"0.6022393",
"0.60218215",
"0.60106206",
"0.60065806",
"0.6005213",
"0.59300894",
"0.58867073",
"0.588001",
"0.5857024",
"0.5854726... | 0.7234605 | 1 |
r"""Returns the ith eigenvalue. | def lambda_i(self, i):
return self._eig_val[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eigen_vector_i(self, i):\n return self._eig_vec[:,i]",
"def get_i_eigen_function(i, X, K, times_bigger_than_machine_epsilon=1.0):\n la, v = linalg.eigh(K) # eigh uses the knowledge that K is symmetric p.s.d\n cutoff = times_bigger_than_machine_epsilon * np.finfo(float).eps\n # Get the index ... | [
"0.7226294",
"0.6715",
"0.65015507",
"0.64335394",
"0.62042934",
"0.61246467",
"0.61068934",
"0.60985476",
"0.6095872",
"0.6043164",
"0.60344183",
"0.6026354",
"0.59301054",
"0.59040815",
"0.5853039",
"0.5852324",
"0.58362424",
"0.58246666",
"0.5802336",
"0.5794023",
"0.57878... | 0.7072033 | 1 |
r"""mean error of the correlation function as function of s | def mean_error(r_t_s, r_t_s_exact):
err = np.mean(np.abs(r_t_s - r_t_s_exact), axis = 0)
return err | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMeanRMS (self,arr):\n print \"You are trying get mean rms for a gaussian error with catastrophic errorbar.\"\n print \"I refuse to do so, but feel free to give me hard time about it\"\n raise NotImplementedError",
"def get_mean_squared_error(self):\n return self.mean_squared_er... | [
"0.68561",
"0.6845326",
"0.6818447",
"0.6613322",
"0.6613322",
"0.659327",
"0.6538566",
"0.6526992",
"0.652022",
"0.6508544",
"0.64419633",
"0.6379463",
"0.6342198",
"0.6325132",
"0.63003176",
"0.62845266",
"0.62728924",
"0.6256988",
"0.6251854",
"0.62417436",
"0.6227797",
... | 0.7260695 | 0 |
Iterate over this `QTiling` Yields a `QPlane` at each Q value | def __iter__(self):
for q in self._iter_qs():
yield snrQPlane(q, self.frange, self.duration, self.sampling,
mismatch=self.mismatch, fdelay = self._fdelay) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n return zip(self._phases, self.data)",
"def __iter__(self):\n for element in self.focals:\n yield element",
"def __iter__(self):\n for k in range(len(self)):\n yield np.ravel(self.xyz[k, :])",
"def Vrep_generator(self):\n for V in self.Vr... | [
"0.5999481",
"0.5990309",
"0.59282637",
"0.58226854",
"0.57534504",
"0.5739716",
"0.5684951",
"0.5649744",
"0.5607259",
"0.5547521",
"0.5530425",
"0.550816",
"0.54781365",
"0.54751706",
"0.54596776",
"0.5452081",
"0.5450902",
"0.5439217",
"0.54304284",
"0.54277533",
"0.542073... | 0.770656 | 0 |
The `(left, right)` padding required for the IFFT | def padding(self):
pad = self.ntiles - self.windowsize
return (int((pad - 1)/2.), int((pad + 1)/2.)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def padding(self) -> Tuple[int, int, int, int]:\n return (self.ipadding[0].to_pixels(self.width),\n self.ipadding[1].to_pixels(self.width),\n self.ipadding[2].to_pixels(self.height),\n self.ipadding[3].to_pixels(self.height))",
"def padding(self):\n\t\treturn s... | [
"0.6507085",
"0.6441506",
"0.63539886",
"0.61706245",
"0.61002773",
"0.5890281",
"0.58514357",
"0.5795316",
"0.57882065",
"0.5773338",
"0.5708867",
"0.5700763",
"0.5682644",
"0.5667075",
"0.5655253",
"0.5635127",
"0.5617207",
"0.55957866",
"0.5593418",
"0.5590209",
"0.5564513... | 0.6638898 | 0 |
Iterate over this `QPlane` Yields a `QTile` at each frequency | def __iter__(self): # for each frequency, yield a QTile
for freq in self._iter_frequencies():
yield snrQTile(self.q, freq, self.duration, self.sampling,
mismatch=self.mismatch, shift = self.freq_timeshift(freq)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n for q in self._iter_qs():\n yield snrQPlane(q, self.frange, self.duration, self.sampling,\n mismatch=self.mismatch, fdelay = self._fdelay)",
"def itercubes(self, **kwargs):\n for ifuslot in self.fplane.ifuslots:\n yield ifuslot, se... | [
"0.6371492",
"0.57698804",
"0.5754739",
"0.5650575",
"0.55389345",
"0.5488318",
"0.5485744",
"0.5485744",
"0.5430581",
"0.54252946",
"0.53771406",
"0.5375497",
"0.53678626",
"0.52797896",
"0.52757806",
"0.527066",
"0.52448547",
"0.523123",
"0.52173597",
"0.5216255",
"0.521438... | 0.6674148 | 0 |
Return (batch) action embedding which is the concatenation of the embeddings of the traversed edge and the target node. | def get_action_embedding(self, action: Action, kg: KnowledgeGraph):
relation_embedding = kg.get_relation_embeddings(action.rel)
if self.relation_only:
action_embedding = relation_embedding
else:
entity_embedding = kg.get_entity_embeddings(action.ent)
action_em... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combined_emb(self) -> Tensor:\n return self._combined_emb",
"def _get_word_tensor(embedding_op: tf.Operation) -> tf.Tensor:\n assert embedding_op.type == 'AddV2'\n add = embedding_op.inputs[0].op\n assert add.type == 'AddV2'\n identity = add.inputs[0].op\n assert ide... | [
"0.60153514",
"0.5904948",
"0.58927727",
"0.5781083",
"0.5692151",
"0.5674533",
"0.56136405",
"0.55874205",
"0.55434144",
"0.5531833",
"0.55285585",
"0.55158997",
"0.5508879",
"0.54888654",
"0.548679",
"0.54677886",
"0.5460174",
"0.5394147",
"0.53601515",
"0.5356663",
"0.5355... | 0.7001667 | 0 |
Simulate SSL connections utilizing SSL session resumption feature. The first connection executes the full SSL handshake. The second connection performs SSL session resumption via a session ID (default) or a session ticket (with_ticket=True), hence an abbreviated handshake. | def sim_session_resumption(sim, with_ticket = False):
client_ctx = sim.client_ssl_context()
server_ctx = sim.server_ssl_context()
client_ctx.set_cipher_list('AES256-SHA256')
if with_ticket:
server_ctx.set_session_cache_mode(SSL.SESS_CACHE_OFF)
label = 'ssl_session_ticket'
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_renegotiate(self):\n server, client = loopback(\n lambda s: loopback_server_factory(s, TLSv1_2_METHOD),\n lambda s: loopback_client_factory(s, TLSv1_2_METHOD),\n )\n\n server.send(b\"hello world\")\n\n assert b\"hello world\" == client.recv(len(b\"hello wo... | [
"0.6693096",
"0.6604959",
"0.63357896",
"0.63292015",
"0.61651635",
"0.6123532",
"0.6121732",
"0.6002009",
"0.59775776",
"0.5917692",
"0.59063673",
"0.5890179",
"0.58868223",
"0.58637214",
"0.5852497",
"0.57634115",
"0.5757666",
"0.5719414",
"0.5712573",
"0.5686157",
"0.56721... | 0.7314262 | 0 |
Encode a list of keyvalue pairs into an uWSGI request header structure. | def encode_uwsgi_vars(values):
# See http://uwsgi-docs.readthedocs.io/en/latest/Protocol.html#the-uwsgi-vars
buffer = []
for key, value in values:
key_enc = force_bytes(key)
val_enc = force_bytes(value)
buffer.append(struct.pack('<H', len(key_enc)))
buffer.append(key_enc)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateheader(self, headerlist=[], http_s_obj=None):\n header = {}\n for headerparam in headerlist:\n key_value = headerparam.split(\":\", 1)\n if len(key_value) == 2:\n try:\n key = key_value[0]\n value = key_value[1].stri... | [
"0.61017483",
"0.57859564",
"0.57859564",
"0.5644042",
"0.5616887",
"0.5592618",
"0.5589547",
"0.55444163",
"0.5464243",
"0.5452265",
"0.5450181",
"0.5447638",
"0.53734666",
"0.5372025",
"0.5371413",
"0.53565687",
"0.53062934",
"0.5259966",
"0.5247004",
"0.5185051",
"0.517815... | 0.64058006 | 0 |
GETVOCABLIST reads the fixed vocabulary list in vocab.txt and returns a cell array of the words vocabList = GETVOCABLIST() reads the fixed vocabulary list in vocab.txt and returns a cell array of the words in vocabList. | def getVocabList():
vocab_list = []
with open('vocab.txt') as f_obj:
while True:
vocab_line = f_obj.readline()
if not vocab_line:
break
word = re.search(r'\t(\w+)', vocab_line).group(1)
vocab_list.append(word)
return vocab_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getVocabList():\n vocabList = pd.read_csv(os.path.join(folder, 'vocab.txt'),\n delimiter='\\t',\n names=['index', 'vocab'],\n index_col='index')\n return vocabList",
"def load_vocabulary(self):\n vocab_file = open(v... | [
"0.7075958",
"0.6563362",
"0.62386453",
"0.62297195",
"0.6216849",
"0.6168035",
"0.61426926",
"0.6140669",
"0.60911244",
"0.60910994",
"0.60533834",
"0.6049774",
"0.60286844",
"0.5981189",
"0.59723127",
"0.5971543",
"0.5952998",
"0.5952998",
"0.5948317",
"0.5947698",
"0.59433... | 0.7234663 | 0 |
A bpf which always returns a constant value | def const(value) -> core.Const:
return core.Const(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FO_Constant(value):\n return FO_Operation({(): value})",
"def _constant(name, value):\n\treturn push_aspect(name, lambda: value)",
"def __call__(self, val, tag=''):\n return self.constant(val, tag=tag)",
"def constant(value, name):\n\n disassembly.add_constant(value, name)",
"def test_constant... | [
"0.6069656",
"0.5451703",
"0.5350618",
"0.53337026",
"0.53274745",
"0.5310498",
"0.52960837",
"0.5213875",
"0.5211594",
"0.5193717",
"0.5181609",
"0.5159074",
"0.51065403",
"0.5092461",
"0.50884885",
"0.507941",
"0.50596386",
"0.50375867",
"0.5004285",
"0.49983937",
"0.492201... | 0.5522866 | 1 |
Generate a straight line with the given slope and offset This is the same as linear(0, offset, 1, slope) Example ```python >>> a = slope(0.5, 1) >>> a | def slope(slope:float, offset=0., bounds: tuple[float, float] = None) -> core.Slope:
return core.Slope(slope, offset, bounds=bounds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line(intercept, slope, x):\n return slope*x + intercept",
"def make_line(x = np.linspace(start = 0, stop = 50, num = 200), slope = 2, intercept = 0, noise = 3):\n \n return np.c_[x, slope * x + intercept + np.random.normal(loc = 0, scale = 3, size = len(x))]",
"def slope(x1, y1, x2, y2):\n retu... | [
"0.75668377",
"0.6972431",
"0.6577958",
"0.65691125",
"0.65565586",
"0.6550617",
"0.6550617",
"0.6510164",
"0.6491029",
"0.64422107",
"0.6410794",
"0.64024603",
"0.6373333",
"0.6360887",
"0.62985486",
"0.6250535",
"0.6135742",
"0.61144364",
"0.6102573",
"0.6096523",
"0.607209... | 0.80493134 | 0 |
Create a bpf blending two interpolation forms | def blendshape(shape0:str, shape1:str, mix, points) -> core.BpfInterface:
X, Y, kws = util.parseargs(*points)
a = makebpf(shape0, X, Y)
b = makebpf(shape1, X, Y)
return core.blend(a, b, mix) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cs4243_Lap_blend(A, B, mask):\n kernel = cs4243_gaussian_kernel(7, 1)\n blended_image = None\n ## your code here####\n \n lpyr_A = cs4243_lap_pyramid(cs4243_gauss_pyramid(A))\n lpyr_B = cs4243_lap_pyramid(cs4243_gauss_pyramid(B))\n gpyr_mask = cs4243_gauss_pyramid(mask)\n \n n = len(... | [
"0.63024664",
"0.62322485",
"0.62141496",
"0.6183072",
"0.61517406",
"0.6133155",
"0.6112801",
"0.5993833",
"0.59645236",
"0.5961193",
"0.59397745",
"0.592535",
"0.5909289",
"0.59005976",
"0.5823597",
"0.5816787",
"0.5806507",
"0.57124555",
"0.5686934",
"0.5679751",
"0.553416... | 0.6739267 | 0 |
Extract all intent filters from the Manifest | def get_intent_filers(apk):
# FIXME : not sure this fully reproduce Koodous filters
res = []
filters = apk.xml['AndroidManifest.xml'].findall(".//intent-filter")
for f in filters:
for ff in f.findall('.//action'):
filt = ff.get('{http://schemas.android.com/apk/res/android}name')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_app_manifests(self,sfilter = None):\n if sfilter:\n try:\n return filter(lambda app: app[\"developer\"] == sfilter[\"developer\"] and\n app[\"name\"] == sfilter[\"name\"] and\n app[\"version... | [
"0.63971984",
"0.6298969",
"0.60559106",
"0.5985283",
"0.58147806",
"0.575581",
"0.5662179",
"0.5576812",
"0.555099",
"0.5535033",
"0.5405882",
"0.5389935",
"0.5366802",
"0.5310268",
"0.5298104",
"0.52666205",
"0.5250125",
"0.52448076",
"0.52305675",
"0.5224118",
"0.5222767",... | 0.7598139 | 0 |
Extract permissions that are not default in Android | def extract_new_permissions(permissions):
res = []
for p in permissions:
if not p.startswith('android.permission') and not p.startswith('com.google') and not p.startswith('com.android'):
res.append(p)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_new_permissions(self, permissions):\n res = []\n for p in permissions:\n if p.startswith('android.permission'):\n continue\n if p.startswith('com.google'):\n continue\n if p.startswith('com.android'):\n continue... | [
"0.7572574",
"0.684293",
"0.6757529",
"0.6688526",
"0.66846716",
"0.66225046",
"0.66225046",
"0.6614443",
"0.65973693",
"0.6564902",
"0.6492609",
"0.64610565",
"0.64604527",
"0.63913196",
"0.63599986",
"0.6340323",
"0.6319321",
"0.6279732",
"0.6257591",
"0.6257591",
"0.625685... | 0.7735299 | 0 |
Convert x509 name to a string | def convert_x509_name(name):
types = {
'country_name': 'C',
'state_or_province_name': 'ST',
'locality_name': 'L',
'organization_name': 'O',
'organizational_unit_name': 'OU',
'common_name': 'CN',
'email_address': 'emailAddress'
}
return '/'.join(['{}={... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_certificate_name(cert_data) -> str:\r\n if cert_data is None:\r\n return None\r\n\r\n cert = x509.load_pem_x509_certificate(cert_data, default_backend())\r\n for fields in cert.subject:\r\n current = str(fields.oid)\r\n if \"commonName\" in current:\r\n... | [
"0.7533503",
"0.72779906",
"0.6930831",
"0.6704115",
"0.6575369",
"0.6316403",
"0.6300507",
"0.62367934",
"0.6066332",
"0.6047828",
"0.6027552",
"0.6016504",
"0.59839773",
"0.594749",
"0.59446615",
"0.59223944",
"0.58448434",
"0.58201015",
"0.57745653",
"0.57657427",
"0.56970... | 0.8349401 | 0 |
Draw a random setup from the set of types types_available after placing the flag somewhere in the last row of the board of the side of 'team', or behind the obstacle. | def draw_random_setup(types_available, team, game_dim):
nr_pieces = len(types_available)-1
types_available = [type_ for type_ in types_available if not type_ == 0]
if game_dim == 5:
row_offset = 2
elif game_dim == 7:
row_offset = 3
else:
row_offset = 4
setup_agent = np.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_with_random_tiles(self):\n for elem in [x[1] for x in self.tile_grid.values()]:\n self.view.remove(elem)\n tile_grid = {}\n # Fill the data matrix with random tile types\n while True: # Loop until we have a valid table (no imploding lines)\n for x in rang... | [
"0.5799348",
"0.5540068",
"0.55259854",
"0.5524947",
"0.54487205",
"0.5431358",
"0.5401177",
"0.5386302",
"0.5384066",
"0.5381447",
"0.5368631",
"0.536101",
"0.5360302",
"0.53390616",
"0.53009444",
"0.5299199",
"0.52803624",
"0.5273432",
"0.5270868",
"0.5254016",
"0.52395105"... | 0.80047303 | 0 |
Simulate num_simulations many games of the agent of type agent_type_0 against the agent of type agent_type_1. If setup_0 or setup_1 are provided respectively, then take the pieces setup from those. If show_game is True, the game will be printed by the internal function. | def simulation(game_, num_simulations, setup_0=None, setup_1=None, show_game=False):
blue_won = 0
blue_wins_bc_flag = 0
blue_wins_bc_noMovesLeft = 0
red_won = 0
red_wins_bc_flag = 0
red_wins_bc_noMovesLeft = 0
rounds_counter_per_game = []
rounds_counter_win_agent_0 = []
rounds_counte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runSimulation(num_robots, speed, width, height, min_coverage, num_trials,\n robot_type, visualize):\n #initialization of variables\n list_of_results = []\n \n #trial loop\n for i in range(num_trials):\n list_of_results.append(singleSimulation(num_robots, speed, width, hei... | [
"0.6379405",
"0.6128739",
"0.61141175",
"0.61141175",
"0.60873675",
"0.6055335",
"0.5968712",
"0.58148754",
"0.58123845",
"0.56971896",
"0.56512547",
"0.56495523",
"0.56320894",
"0.55994004",
"0.5556007",
"0.5548069",
"0.55038553",
"0.5484391",
"0.5457436",
"0.54455465",
"0.5... | 0.7941733 | 0 |
Check the cache queue for a cache update action and start a corresponding worker thread to complete the update | def manage_cache_tasks(self):
outstanding_threads = self._has_outstanding_threads()
try:
# Get a task from the cache queue, waiting less if we have active threads.
timeout = NONBLOCKING_TIMEOUT if outstanding_threads else BLOCKING_TIMEOUT
# Toggle between refresh and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _refresh_cache(self):\r\n if self._cache_refresh:\r\n Thread(target=self._cache_refresh).start()\r\n return \"Cache refresh in progress\"",
"def wait_for_all_cache_tasks(self):\n if self.is_server_process:\n self.update_queue.join()\n self.refresh_que... | [
"0.6876904",
"0.6332693",
"0.6127516",
"0.6033509",
"0.58651084",
"0.5840178",
"0.5817056",
"0.5768566",
"0.5764525",
"0.5750973",
"0.5737619",
"0.56771857",
"0.5642867",
"0.5633082",
"0.5600771",
"0.558422",
"0.55827755",
"0.55359495",
"0.552396",
"0.5476837",
"0.54533637",
... | 0.7454101 | 0 |
Add entries to the component cache for the runtime type and/or catalog of focus for this thread, and set the catalog state to 'updating'. | def prepare_cache_for_catalog(self, runtime_type: Optional[str] = None):
if self.action == "delete":
# On 'delete' the runtime_type parameter will be None and since catalog names
# are essentially unique across runtime types, we can break out of this loop
# on first occurrenc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n if self.action == \"delete\":\n # Check all runtime types in cache for an entry of the given name.\n # If found, remove only the components from this catalog\n for runtime_type in self._component_cache:\n if self.catalog.name in self._componen... | [
"0.6082837",
"0.5309497",
"0.5262068",
"0.51838136",
"0.51685834",
"0.5057052",
"0.50554544",
"0.50515133",
"0.49996442",
"0.49979347",
"0.49609727",
"0.49374864",
"0.4935867",
"0.48916453",
"0.48882973",
"0.48777506",
"0.48583716",
"0.48537374",
"0.4853518",
"0.4833407",
"0.... | 0.63692486 | 0 |
Determines if this process is a server (extension) process. | def _determine_server_process(emulate_server_app: bool, **kwargs) -> bool:
app_names = ["ServerApp", "ElyraApp"]
is_server_process = False
if "parent" in kwargs and kwargs["parent"].__class__.__name__ in app_names:
is_server_process = True
elif emulate_server_app: # Used in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ServerIsRunning( self ):\n return utils.ProcessIsRunning( self._gocode_handle )",
"def owserver_running():\n for proc in psutil.process_iter():\n if 'owserver' in proc.name():\n return True\n return False",
"def _checkTorcsServer(self):\n isRunning = False\n if sel... | [
"0.7501212",
"0.677049",
"0.6315507",
"0.6225383",
"0.6156547",
"0.61342263",
"0.6099082",
"0.6050925",
"0.6032327",
"0.60283303",
"0.60283303",
"0.5989453",
"0.59751815",
"0.5973232",
"0.59723526",
"0.59692734",
"0.5949517",
"0.593755",
"0.59129804",
"0.5900615",
"0.58858454... | 0.7859049 | 0 |
Triggers a refresh of all catalogs in the component cache. Raises RefreshInProgressError if a complete refresh is in progress. Note that we do not preclude nonserver processes from performing a complete refresh. In such cases, each of the catalog entries will be written to the manifest, which will be placed into the up... | def refresh(self):
if self.is_server_process and self.cache_manager.is_refreshing():
raise RefreshInProgressError()
catalogs = MetadataManager(schemaspace=ComponentCatalogs.COMPONENT_CATALOGS_SCHEMASPACE_ID).get_all()
for catalog in catalogs:
self._insert_request(self.ref... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_all(self) -> None:\n self._update_thread.force_refresh_folder(self.feed_cache)",
"def run(self):\n if self.action == \"delete\":\n # Check all runtime types in cache for an entry of the given name.\n # If found, remove only the components from this catalog\n ... | [
"0.58695596",
"0.585548",
"0.56707966",
"0.55678326",
"0.53448206",
"0.5331451",
"0.5325923",
"0.5271653",
"0.5264734",
"0.526373",
"0.525275",
"0.52445674",
"0.5241948",
"0.52326685",
"0.52040774",
"0.51769197",
"0.5171799",
"0.51635206",
"0.51635206",
"0.5158256",
"0.515187... | 0.8264543 | 0 |
Remove all existing manifest files in the Jupyter runtimes directory. | def _remove_all_manifest_files(self):
manifest_files = Path(self.manifest_dir).glob("**/elyra-component-manifest-*.json")
for file in manifest_files:
os.remove(str(file)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self) -> None:\n # remove all *.py and *.pyi files in the folder\n for wc in [\"*.py\", \"*.pyi\", \"modules.json\"]:\n for f in (self.package_path).rglob(wc):\n f.unlink()",
"def _clean_bins():\n rmtree(LIBS_DIR)\n rmtree(BINS_DIR)\n rmtree(HEADERS_DIR)... | [
"0.6405783",
"0.6322341",
"0.6262551",
"0.62561035",
"0.6247388",
"0.61493003",
"0.60215515",
"0.6019428",
"0.60155225",
"0.60044694",
"0.59351647",
"0.5930456",
"0.58913183",
"0.58589643",
"0.5837137",
"0.58304805",
"0.5794426",
"0.5790618",
"0.5757582",
"0.5753259",
"0.5740... | 0.7633034 | 0 |
Read and return the contents of a manifest file. If 'filename' is not provided, this process's manifest file will be read. | def _load_manifest(self, filename: Optional[str] = None) -> Dict[str, str]:
filename = filename or self.manifest_filename
if not os.path.isfile(filename):
self.log.debug(f"Manifest file '{filename}' doesn't exist and will be created.")
return {}
with open(filename, "r") a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manifest_from_file(file_name):\n in_file = open(file_name, 'rb')\n try:\n return read_file_manifest(in_file)\n finally:\n in_file.close()",
"def load_manifest(filename):\n\n data = manifest.load(filename)\n for field in manifest.validate(data):\n name = field.cfg or ''\n if nam... | [
"0.73697704",
"0.65815824",
"0.6555583",
"0.63321716",
"0.6208163",
"0.62070304",
"0.61636525",
"0.61461",
"0.60774523",
"0.6076865",
"0.6003955",
"0.5994013",
"0.59830374",
"0.59828806",
"0.5969498",
"0.5934474",
"0.5918152",
"0.5913478",
"0.58609563",
"0.5810454",
"0.580447... | 0.70324785 | 1 |
Update the manifest file with the given entry. | def update_manifest(self, filename: Optional[str] = None, manifest: Optional[Dict[str, str]] = None) -> None:
filename = filename or self.manifest_filename
manifest = manifest or {}
self.log.debug(f"Updating manifest '{manifest}' to file '{filename}'")
with open(filename, "w") as f:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_manifest(self, dst):\n # Read the current manifest into memory\n mpath = os.path.join(os.path.dirname(dst), \"manifest.json\")\n try:\n with open(mpath, 'r') as f:\n manifest = json.load(f)\n except IOError:\n manifest = {}\n\n name... | [
"0.69848335",
"0.6563885",
"0.6397998",
"0.6329147",
"0.6093439",
"0.60229206",
"0.6014666",
"0.5981316",
"0.58636606",
"0.57445526",
"0.5733751",
"0.5692679",
"0.5685172",
"0.56658876",
"0.5657464",
"0.5615135",
"0.5528297",
"0.54940873",
"0.54901737",
"0.54487157",
"0.54416... | 0.7094709 | 0 |
Block execution and wait for all tasks in the cache task update queue to complete. Primarily used for testing. | def wait_for_all_cache_tasks(self):
if self.is_server_process:
self.update_queue.join()
self.refresh_queue.join() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_completion(self):\r\n self.tasks.join()",
"def manage_cache_tasks(self):\n outstanding_threads = self._has_outstanding_threads()\n try:\n # Get a task from the cache queue, waiting less if we have active threads.\n timeout = NONBLOCKING_TIMEOUT if outstanding_t... | [
"0.67088807",
"0.66762435",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6636904",
"0.6408805",
"0.62951034",
"0.6279013",
"0.6244785",
"0.6238207",
"0.6215296",
"0.6209671",
"0.620684",
"0.6195017",
"0.618313",
... | 0.82350045 | 0 |
Retrieve all components from component catalog cache | def get_all_components(self, platform: RuntimeProcessorType) -> List[Component]:
components: List[Component] = []
catalogs = self._component_cache.get(platform.name, {})
for catalog_name, catalog_properties in catalogs.items():
components.extend(list(catalog_properties.get("componen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __components__():\n # Get the component registry of the active application.\n registry = context.app.component_registry\n # A shortcut: return cached components.\n if registry.components is not None:\n return registry.components\n # A list of `Component` subclasses... | [
"0.7058232",
"0.6596857",
"0.6531644",
"0.64999974",
"0.649992",
"0.6392556",
"0.63467246",
"0.6309984",
"0.6201707",
"0.6201707",
"0.6199261",
"0.6171362",
"0.6171362",
"0.615028",
"0.60671747",
"0.60305864",
"0.6011291",
"0.5958233",
"0.588494",
"0.58823764",
"0.5869009",
... | 0.6804353 | 1 |
Retrieve the component with a given component_id from component catalog cache | def get_component(self, platform: RuntimeProcessorType, component_id: str) -> Optional[Component]:
component: Optional[Component] = None
catalogs = self._component_cache.get(platform.name, {})
for catalog_name, catalog_properties in catalogs.items():
component = catalog_properties.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, id):\n pkg_key, component_key = id\n if pkg_key not in self.packages:\n raise Exception(\"Package not found while looking for id: %s \" % repr(id))\n p = self.packages[pkg_key]\n if component_key not in p.components:\n raise Exception(\"Component %s not found in package %s.\" % ... | [
"0.71200466",
"0.6680201",
"0.63620526",
"0.62793803",
"0.6266943",
"0.62591505",
"0.6183827",
"0.61024165",
"0.6063171",
"0.6012099",
"0.5972744",
"0.5962283",
"0.5925388",
"0.57999223",
"0.5796487",
"0.57649714",
"0.5720879",
"0.5697705",
"0.5692659",
"0.56475204",
"0.56320... | 0.6940762 | 1 |
Load the appropriate entrypoint class based on the schema name indicated in the ComponentCatalogMetadata instance and the file types associated with the component parser in use | def _load_catalog_reader_class(
self, catalog: ComponentCatalogMetadata, file_types: List[str]
) -> Optional[ComponentCatalogConnector]:
try:
catalog_reader = entrypoints.get_group_named("elyra.component.catalog_types").get(catalog.schema_name)
if not catalog_reader:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_component(self, name):\n cls = None\n if self.mapping and name in self.mapping:\n cls = self.mapping[name]\n elif \".\" in name:\n cls = self._import(*name.rsplit(\".\", 1))\n else:\n for base in self.bases:\n if self.module:\n ... | [
"0.5361574",
"0.51891816",
"0.51219964",
"0.5002335",
"0.4936164",
"0.48770025",
"0.48754284",
"0.48169455",
"0.48045355",
"0.47998667",
"0.4792753",
"0.4790735",
"0.4783852",
"0.4779774",
"0.4765397",
"0.47622862",
"0.4741482",
"0.4734167",
"0.4717581",
"0.47102895",
"0.4705... | 0.66268736 | 0 |
Read a component catalog and return a dictionary of components indexed by component_id. | def read_component_catalog(self, catalog: ComponentCatalogMetadata) -> Dict[str, Component]:
components: Dict[str, Component] = {}
# Ensure referenced runtime is available
if not PipelineProcessorRegistry.instance().is_valid_runtime_type(catalog.runtime_type.name):
return components... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getComponentsInfo(self):\n result = {}\n et = ElementTree()\n components = self.agentCompleteConfig.listComponents_() + \\\n self.agentCompleteConfig.listWebapps_()\n for comp in components:\n compConfig = getattr(self.agentCompleteConfig, comp)\n ... | [
"0.623686",
"0.6207056",
"0.61728287",
"0.6160309",
"0.582545",
"0.5813913",
"0.5714354",
"0.5708351",
"0.56794035",
"0.5587202",
"0.55474335",
"0.5506805",
"0.55003035",
"0.55003035",
"0.5471209",
"0.54471314",
"0.54157484",
"0.54140973",
"0.54133993",
"0.54089844",
"0.53381... | 0.746077 | 0 |
Loads the jinja template of the given name from the elyra/templates/components folder | def load_jinja_template(template_name: str) -> Template:
loader = PackageLoader("elyra", "templates/components")
template_env = Environment(loader=loader)
template_env.policies["json.dumps_kwargs"] = {"sort_keys": False} # prevent automatic key sort on 'tojson'
return template_env.get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_template(name, stdout = sys.stdout, stderr = sys.stderr):\n path = \"weblab\" + os.sep + \"admin\" + os.sep + \"config_templates\" + os.sep + name\n try:\n f = file(path, \"r\")\n template = f.read()\n f.close()\n except:\n print(\"Error: Could not load template file %... | [
"0.6956874",
"0.68111014",
"0.6743539",
"0.66488796",
"0.66392505",
"0.65723175",
"0.65490854",
"0.6514396",
"0.65135914",
"0.64929056",
"0.6446483",
"0.6420018",
"0.636116",
"0.63440937",
"0.6344021",
"0.6251424",
"0.6195191",
"0.614156",
"0.61414164",
"0.6114792",
"0.608360... | 0.7768754 | 0 |
Converts catalog components into appropriate canvas palette format | def to_canvas_palette(components: List[Component]) -> Dict:
template = ComponentCache.load_jinja_template("canvas_palette_template.jinja2")
# Define a fallback category for components with no given categories
fallback_category_name = "No Category"
# Convert the list of all components i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_palette(num_cls):\r\n\r\n palette = [0] * (num_cls * 3)\r\n palette[0:3] = (128, 64, 128) # 0: 'road'\r\n palette[3:6] = (244, 35, 232) # 1 'sidewalk'\r\n palette[6:9] = (70, 70, 70) # 2''building'\r\n palette[9:12] = (102, 102, 156) # 3 wall\r\n palette[12:15] = (190, 153, 153) # 4 ... | [
"0.58181363",
"0.570808",
"0.5683096",
"0.55874026",
"0.5540108",
"0.5537348",
"0.5497292",
"0.54908717",
"0.5364585",
"0.53578913",
"0.53442246",
"0.5329483",
"0.53077805",
"0.53018343",
"0.52809983",
"0.52728546",
"0.52368677",
"0.5234662",
"0.52242666",
"0.5224221",
"0.518... | 0.7037339 | 0 |
Converts catalog components into appropriate canvas properties format. If component_id is one of the generic set, generic template is rendered, otherwise, the runtimespecific property template is rendered. | def to_canvas_properties(component: Component) -> Dict:
if ComponentCache.get_generic_component(component.id) is not None:
template = ComponentCache.load_jinja_template("generic_properties_template.jinja2")
else:
template = ComponentCache.load_jinja_template("canvas_properties_te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_canvas_palette(components: List[Component]) -> Dict:\n template = ComponentCache.load_jinja_template(\"canvas_palette_template.jinja2\")\n\n # Define a fallback category for components with no given categories\n fallback_category_name = \"No Category\"\n\n # Convert the list of a... | [
"0.5503672",
"0.5410748",
"0.5173319",
"0.5002953",
"0.48757994",
"0.48636281",
"0.48524463",
"0.47206074",
"0.4712311",
"0.4712251",
"0.467162",
"0.46431145",
"0.46194717",
"0.4607115",
"0.45986682",
"0.45717648",
"0.4566872",
"0.4554476",
"0.45446584",
"0.4520944",
"0.45186... | 0.6668718 | 0 |
Fires when the component manifest file is modified. | def on_modified(self, event):
self.log.debug(f"ManifestFileChangeHandler: file '{event.src_path}' has been modified.")
manifest = self.component_cache._load_manifest(filename=event.src_path)
if manifest: # only update the manifest if there is work to do
for catalog, action in manife... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatch(self, event):\n if \"elyra-component-manifest\" in event.src_path:\n super().dispatch(event)",
"def on_modified(self, event):\n path = Path(event.src_path)\n if path.is_file() and path.suffix == '.json':\n self.load_configuration(path)\n self.hoo... | [
"0.6482664",
"0.6406745",
"0.6225922",
"0.616531",
"0.61129385",
"0.6017256",
"0.5964188",
"0.59581864",
"0.59235984",
"0.59042394",
"0.57900196",
"0.57052964",
"0.5688041",
"0.55982184",
"0.5592763",
"0.55649245",
"0.5550622",
"0.5505578",
"0.5395624",
"0.53847104",
"0.53380... | 0.7810466 | 0 |
Returns the common value of the arguments, if they are all equal. Otherwise, raises ValueError. | def common_value(*args):
if len(args) == 0:
raise ValueError("argument is empty")
x = args[0]
assert all(x == y for y in args[1:]), "no common value"
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _all_equal(arg):\n return arg.count(arg[0]) == len(arg)",
"def aeq(*args):\n arguments = (arg for arg in args)\n first = next(arguments)\n assert all(arg == first for arg in arguments), \\\n \"Not all arguments have the same value: \" + str(args)",
"def aeq(*args):\n arguments = (arg ... | [
"0.6246234",
"0.6216014",
"0.6216014",
"0.6216014",
"0.6216014",
"0.61963147",
"0.60523653",
"0.5993495",
"0.59091",
"0.56407857",
"0.56035984",
"0.5564881",
"0.5469389",
"0.54250026",
"0.53431237",
"0.524688",
"0.5243906",
"0.517713",
"0.5149153",
"0.5122689",
"0.5111839",
... | 0.84201837 | 0 |
Returns a randomlychosen output (as a column index) the system chooses when responding to a specific randomlychosen input (the probability distribution over the inputs can be given as an argument, but by default it is uniform). | def randoutput(self, input_p = None):
if input_p is None:
input_p = uniform_p(self.n_inputs())
input_ = np.random.choice(range(self.n_inputs()), p=input_p)
return np.random.choice(range(self.n_outputs()), p=self.matrix[input_, :]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comp_attack_column(self):\n column_hit = self.column_arry[-1]\n if column_hit == 10:\n column = random.randint(0, 9)\n return column\n else:\n attk_random = self.random_attk_int()\n if attk_random == 1:\n column = column_hit + 1\n ... | [
"0.6064536",
"0.6039813",
"0.59823877",
"0.58633626",
"0.5840016",
"0.5727009",
"0.5718813",
"0.57182163",
"0.5678928",
"0.559275",
"0.5545529",
"0.5537541",
"0.5483552",
"0.54714596",
"0.5465404",
"0.5459745",
"0.54591036",
"0.543485",
"0.542757",
"0.5416364",
"0.5415829",
... | 0.63760626 | 0 |
Generates a random ProductSystem. | def from_rand(self, n_input_meanings, n_signals, n_output_meanings):
return ProductSystem(System.from_rand(n_input_meanings, n_signals),
System.from_rand(n_signals, n_output_meanings)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_products(self = random.sample, name = random.choice(result), price = random.randint(5, 100), weight = random.randint(5, 100), \nflammability= random.uniform(0, 2.5)):\n return sample",
"def generate_products(num_products=30):\r\n products = []\r\n for i in range(num_products):\r\n na... | [
"0.64591074",
"0.6423393",
"0.6414964",
"0.63717693",
"0.6204677",
"0.6062808",
"0.6013743",
"0.59819967",
"0.5961276",
"0.5922137",
"0.5917656",
"0.5900207",
"0.58578897",
"0.5754532",
"0.5749165",
"0.5742516",
"0.566139",
"0.56353086",
"0.5604845",
"0.55722296",
"0.5565906"... | 0.6639632 | 0 |
The pair of entities can be thought of as a single inputoutput system parsing meanings; this method returns the System object representing that system. | def sys(self):
return System(np.dot(self.psys.matrix, self.rsys.matrix)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _interpret_system(\n self,\n system: Union[ProteinSystem, ProteinLigandComplex],\n ) -> Tuple[\n Union[oechem.OEGraphMol, None],\n Union[oechem.OEGraphMol, None],\n Union[oegrid.OESkewGrid, None]\n ]:\n from ..modeling.OEModeling import (\n rea... | [
"0.5836987",
"0.5682512",
"0.55238664",
"0.5499688",
"0.5478714",
"0.53468597",
"0.53303736",
"0.5318789",
"0.52553463",
"0.5249217",
"0.5233682",
"0.52215433",
"0.5212987",
"0.51447654",
"0.5144183",
"0.5131789",
"0.50756305",
"0.5044377",
"0.4966121",
"0.49657294",
"0.49643... | 0.60990137 | 0 |
Like the success_p function of System; 'success' is when the receiver outputs the same signal that was input to the producer, i.e. communication is successful. | def success_p(self, input_meaning_p = None):
return self.sys().success_p(input_meaning_p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success(self, result):\r\n raise NotImplementedError",
"def success(self, msg):\n print \"comm succeded\"\n return msg",
"def success(self, success):\n self._success = success",
"def success(cls, retval, retvalname='value'):\r\n if isinstance(retval, dict) and retvalnam... | [
"0.64074963",
"0.6382735",
"0.63219076",
"0.6246374",
"0.62062454",
"0.61051315",
"0.6057583",
"0.6032157",
"0.6023692",
"0.5879187",
"0.5796678",
"0.57748145",
"0.5759565",
"0.5758478",
"0.57374257",
"0.5709945",
"0.5708451",
"0.56804305",
"0.5661716",
"0.5624533",
"0.560915... | 0.6555954 | 0 |
Runs the randoutput method and returns True if the output meaning was the same as the input meaning (otherwise False). | def randsuccess(self, input_meaning_p = None):
assert(self.n_input_meanings() == self.n_output_meanings())
if input_meaning_p is None:
input_meaning_p = uniform_p(self.n_input_meanings())
input_meaning = np.random.choice(range(self.n_input_meanings()), p=input_meaning_p)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_output(self, output):\n return output == self.output",
"def evaluate_output(self, output: int) -> Callable[[str], bool]:\n assert 0 <= output < len(self.observations)\n return lambda out: self.observations(output).name == out",
"def check_output(output, expected_output):\n o ... | [
"0.7167138",
"0.6400009",
"0.63390064",
"0.6194593",
"0.61770433",
"0.61665374",
"0.60543954",
"0.6053292",
"0.6049021",
"0.60274327",
"0.59638923",
"0.5926674",
"0.5903524",
"0.5898594",
"0.5872902",
"0.58285093",
"0.5791255",
"0.579117",
"0.5735517",
"0.5708431",
"0.5690372... | 0.67948335 | 1 |
Generates a random probability distribution over input meanings, and a random ProductSystem using the rand_dyad classmethod. Then tests whether the success_p function gives the right probability of successful communication for this ProductSystem, by running the randsuccess method repeatedly and recording the cumulative... | def test_success_formula(n_meanings, n_signals, n_trials, n_runs):
input_meaning_p = rand_p(n_meanings)
print(input_meaning_p)
print()
dyad = ProductSystem.rand_dyad(n_meanings, n_signals)
print(dyad.psys.matrix)
print()
print(dyad.rsys.matrix)
print()
data = tuple(cummean(t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success_p_dist(n_trials, n_meanings, n_signals, input_meaning_p = None):\r\n if input_meaning_p is None:\r\n input_meaning_p = uniform_p(n_meanings)\r\n y = []\r\n for i in range(n_trials):\r\n dyad = ProductSystem.rand_dyad(n_meanings, n_signals)\r\n y.append(dyad.success_p(input... | [
"0.6866214",
"0.5831172",
"0.57206756",
"0.5639914",
"0.5639106",
"0.5616865",
"0.5613823",
"0.5602512",
"0.5594516",
"0.5582397",
"0.5574434",
"0.5570642",
"0.55330455",
"0.5500538",
"0.5494977",
"0.5492725",
"0.54851604",
"0.5433985",
"0.5391202",
"0.5381106",
"0.53668356",... | 0.7517009 | 0 |
Plots the distribution of success probability for ProductSystems randomly generated with the given parameters, and with the given distribution over input meanings. It can be seen for example that when input_meaning_p is uniform, the mean is simply 1/n_meanings (entirely independent of n_signals). | def success_p_dist(n_trials, n_meanings, n_signals, input_meaning_p = None):
if input_meaning_p is None:
input_meaning_p = uniform_p(n_meanings)
y = []
for i in range(n_trials):
dyad = ProductSystem.rand_dyad(n_meanings, n_signals)
y.append(dyad.success_p(input_meaning_p))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_distribution(self,show=True):\n\t\tk_vals,prob_vals = self.tuple_of_probabilities\n\t\t\n\t\tplt.figure(\"Probability distribution of Random Walk, theoretical\")\n\t\tplt.scatter(k_vals,prob_vals,s=4)\n\t\tplt.xlim((-self.n-1,self.n+1))\n\t\t\n\t\tplt.xlabel(\"x\\u2099 - Position after n jumps\")\n\t\tplt... | [
"0.6620169",
"0.6244728",
"0.61847967",
"0.61322683",
"0.60620314",
"0.5995032",
"0.5970597",
"0.5926881",
"0.5923823",
"0.589379",
"0.5889099",
"0.58436227",
"0.5792188",
"0.57902044",
"0.57831836",
"0.5777661",
"0.5777379",
"0.57543015",
"0.5735412",
"0.57296497",
"0.570425... | 0.6293933 | 1 |
Rect(left, top, width, height) > Rect Rect((left, top), (width, height)) > Rect Rect(object) > Rect | def __init__(self, *args):
if len(args) == 4:
# left, top, width, height
self.left, self.top, self.width, self.height = args
elif len(args) == 2:
# (left, top), (width, height)
self.left, self.top = args[0]
self.width, self.height = args[1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_06_two_args(self):\n r = Rectangle(7, 2)\n self.assertEqual(r.id, 1)\n self.assertEqual(r.width, 7)\n self.assertEqual(r.height, 2)\n self.assertEqual(r.x, 0)\n self.assertEqual(r.y, 0)",
"def test_07_three_args(self):\n r = Rectangle(7, 2, 10)\n s... | [
"0.6632328",
"0.64802325",
"0.64124537",
"0.6390327",
"0.6351573",
"0.6332371",
"0.6314574",
"0.62847567",
"0.6277828",
"0.61385894",
"0.6110654",
"0.60469544",
"0.6037325",
"0.60237294",
"0.6021254",
"0.5973531",
"0.59636545",
"0.595509",
"0.5943927",
"0.5925516",
"0.5925516... | 0.66299254 | 1 |
Returns the center x value of the rect | def centerx(self):
return self.left + self.width / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_x_position(self):\n return self.rect.x",
"def get_rect_center(rect):\n x, y, w, h = rect\n return x + w/2, y + h/2",
"def get_center_scr(self):\r\n return self.rect.center",
"def get_x(self):\n\t\treturn self._collision_rect.x + 14",
"def center(self):\n xc = (sel... | [
"0.8031844",
"0.7905196",
"0.77629286",
"0.745051",
"0.74357617",
"0.74212724",
"0.7397834",
"0.7281383",
"0.72525734",
"0.7204327",
"0.71400124",
"0.7095203",
"0.7095146",
"0.7087526",
"0.7083431",
"0.70678186",
"0.7064923",
"0.7060018",
"0.702804",
"0.70279485",
"0.70163614... | 0.833937 | 0 |
Returns a point (x, y) which is the midpoint of the top edge the rect. | def midtop(self):
return (self.centerx, self.top) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def midpoint(self) -> Tuple[int, int]:\n minx, miny, maxx, maxy = self.substrates.bounds\n return ((minx + maxx) // 2, (miny + maxy) // 2)",
"def getMidPoint(self):\n return p.Point((self.start.normalVector + self.end.normalVector)/2.0)",
"def get_pos(self):\n return self.rect.midto... | [
"0.76500976",
"0.7309252",
"0.725163",
"0.7170698",
"0.7047169",
"0.69002247",
"0.6897029",
"0.67588174",
"0.6724638",
"0.6661621",
"0.6647386",
"0.6606155",
"0.6597936",
"0.65815824",
"0.6506547",
"0.6495151",
"0.64475024",
"0.644593",
"0.64286613",
"0.6403866",
"0.63949263"... | 0.76629424 | 0 |
Returns a point (x, y) which is the midpoint of the left edge the rect. | def midleft(self):
return (self.left, self.centery) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rect_left(self):\n\treturn min(self.x, self.x + self.w)",
"def getMidPoint(self):\n return p.Point((self.start.normalVector + self.end.normalVector)/2.0)",
"def midpoint(self) -> Tuple[int, int]:\n minx, miny, maxx, maxy = self.substrates.bounds\n return ((minx + maxx) // 2, (miny + m... | [
"0.7517219",
"0.7243575",
"0.7218394",
"0.70709705",
"0.70709705",
"0.68680346",
"0.6736029",
"0.67191774",
"0.6678974",
"0.66577965",
"0.6645889",
"0.65988135",
"0.6579809",
"0.65635693",
"0.643486",
"0.6433358",
"0.6413653",
"0.63680094",
"0.6360517",
"0.6358098",
"0.635241... | 0.76932055 | 0 |
Returns a point (x, y) which is the midpoint of the bottom edge the rect. | def midbottom(self):
return (self.centerx, self.bottom) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def midpoint(self) -> Tuple[int, int]:\n minx, miny, maxx, maxy = self.substrates.bounds\n return ((minx + maxx) // 2, (miny + maxy) // 2)",
"def _rect_bottom(self):\n\treturn min(self.y, self.y + self.h)",
"def bottomLeftCorner(self):\n self._updateExtents()\n return (self._mMinX,s... | [
"0.7225014",
"0.71007353",
"0.70528626",
"0.70367455",
"0.70005757",
"0.6998103",
"0.6975342",
"0.67965275",
"0.67694247",
"0.6701562",
"0.6600726",
"0.6600726",
"0.65750843",
"0.6566296",
"0.6544031",
"0.6484949",
"0.6414438",
"0.63706785",
"0.6326723",
"0.6299827",
"0.62867... | 0.80408055 | 0 |
Returns a point (x, y) which is the midpoint of the right edge of the rect. | def midright(self):
return (self.right, self.centery) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def midpoint(self) -> Tuple[int, int]:\n minx, miny, maxx, maxy = self.substrates.bounds\n return ((minx + maxx) // 2, (miny + maxy) // 2)",
"def _rect_right(self):\n\treturn max(self.x, self.x + self.w)",
"def getMidPoint(self):\n return p.Point((self.start.normalVector + self.end.normalV... | [
"0.72387004",
"0.7190304",
"0.7009031",
"0.6783551",
"0.67242396",
"0.66471845",
"0.66471845",
"0.661838",
"0.6569062",
"0.65528",
"0.654266",
"0.6511605",
"0.6491345",
"0.6409926",
"0.64068615",
"0.6339525",
"0.63193333",
"0.62984693",
"0.6268774",
"0.62637895",
"0.6259858",... | 0.75244766 | 0 |
Iterate through supported mode/char combinations. | def iter_mode(n, obj='ndarray'):
for mode in cap[obj][MODE]:
for char in fmtdict[mode]:
yield randitems(n, obj, mode, char) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n return iter([v for k, v in sorted(self._modes.items())])",
"def modes(self):\n try:\n order = self._current_order\n except AttributeError:\n raise AttributeError('Cannot iterate over modes without iterating over orders!') from None\n mode = ... | [
"0.6249889",
"0.60778344",
"0.59459805",
"0.590278",
"0.5901733",
"0.5760481",
"0.5634657",
"0.5596808",
"0.5583998",
"0.5510182",
"0.5502217",
"0.5501133",
"0.54632974",
"0.54241824",
"0.5413422",
"0.54028744",
"0.53631246",
"0.5356655",
"0.53519946",
"0.5313822",
"0.5306434... | 0.6818856 | 1 |
Yield (format, items, item) for all possible modes and format characters plus one random compound format string. | def iter_format(nitems, testobj='ndarray'):
for t in iter_mode(nitems, testobj):
yield t
if testobj != 'ndarray':
return
yield struct_items(nitems, testobj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeNamesFromFormats(formats):\n i = getIter(formats)\n if not i:\n return\n\n try:\n c = 0\n item = i.next()\n while item:\n c = c +1\n name = 'c%s' % c\n if isinstance(item, str):\n yield name\n else:\n ... | [
"0.59636045",
"0.55950534",
"0.5526537",
"0.5526537",
"0.5512344",
"0.5512344",
"0.5500678",
"0.5500678",
"0.54459256",
"0.5404356",
"0.54026484",
"0.5386869",
"0.5325779",
"0.52617586",
"0.52564883",
"0.5248751",
"0.5190863",
"0.5118963",
"0.50866807",
"0.50587744",
"0.50531... | 0.64417255 | 1 |
Calculate strides of a contiguous array. Layout is 'C' or 'F' (Fortran). | def strides_from_shape(ndim, shape, itemsize, layout):
if ndim == 0:
return ()
if layout == 'C':
strides = list(shape[1:]) + [itemsize]
for i in range(ndim - 2, -1, -1):
strides[i] *= strides[i + 1]
else:
strides = [itemsize] + list(shape[:-1])
for i in ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strides_from_shape(ndim, shape, itemsize, layout):\n if ndim == 0:\n return ()\n if layout == 'C':\n strides = list(shape[1:]) + [itemsize]\n for i in range(ndim-2, -1, -1):\n strides[i] *= strides[i+1]\n else:\n strides = [itemsize] + list(shape[:-1])\n f... | [
"0.6674238",
"0.6667623",
"0.63901645",
"0.62995565",
"0.6209812",
"0.62079126",
"0.6108434",
"0.60595614",
"0.60080725",
"0.5996222",
"0.5996222",
"0.5860129",
"0.57919973",
"0.57440704",
"0.56975204",
"0.56885684",
"0.56631756",
"0.5634464",
"0.56175673",
"0.5605618",
"0.55... | 0.6671998 | 1 |
Compare the structure of llst[lslices] and rlst[rslices]. | def cmp_structure(llst, rlst, lslices, rslices):
lshape = slice_shape(llst, lslices)
rshape = slice_shape(rlst, rslices)
if len(lshape) != len(rshape):
return -1
for i in range(len(lshape)):
if lshape[i] != rshape[i]:
return -1
if lshape[i] == 0:
return 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmp_structure(llst, rlst, lslices, rslices):\n lshape = slice_shape(llst, lslices)\n rshape = slice_shape(rlst, rslices)\n if (len(lshape) != len(rshape)):\n return -1\n for i in range(len(lshape)):\n if lshape[i] != rshape[i]:\n return -1\n if lshape[i] == 0:\n ... | [
"0.80978125",
"0.5829969",
"0.5789966",
"0.57281804",
"0.570701",
"0.548118",
"0.5468567",
"0.5340575",
"0.53285724",
"0.5326908",
"0.52971095",
"0.52875507",
"0.52710307",
"0.5204913",
"0.51294273",
"0.508289",
"0.5026357",
"0.5012492",
"0.50023127",
"0.5000653",
"0.49907938... | 0.8108014 | 0 |
The structure 't' is overlapping if at least one memory location is visited twice while iterating through all possible tuples of indices. | def is_overlapping(t):
memlen, itemsize, ndim, shape, strides, offset = t
visited = 1 << memlen
for ind in indices(shape):
i = memory_index(ind, t)
bit = 1 << i
if visited & bit:
return True
visited |= bit
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_overlapping(t):\n memlen, itemsize, ndim, shape, strides, offset = t\n visited = 1<<memlen\n for ind in indices(shape):\n i = memory_index(ind, t)\n bit = 1<<i\n if visited & bit:\n return True\n visited |= bit\n return False",
"def listOfOverlappingTTPai... | [
"0.7153452",
"0.62313116",
"0.5419921",
"0.5372583",
"0.5271747",
"0.52387035",
"0.5173371",
"0.51701367",
"0.51511467",
"0.51245564",
"0.5054536",
"0.50453806",
"0.5040168",
"0.50393426",
"0.5034332",
"0.49903625",
"0.49665457",
"0.49559328",
"0.4951142",
"0.4949131",
"0.493... | 0.71437347 | 1 |
Create a random slice of len slicelen that fits into listlen. | def randslice_from_slicelen(slicelen, listlen):
maxstart = listlen - slicelen
start = randrange(maxstart + 1)
maxstep = (listlen - start) // slicelen if slicelen else 1
step = randrange(1, maxstep + 1)
stop = start + slicelen * step
s = slice(start, stop, step)
_, _, _, control = slice_indic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randslice_from_slicelen(slicelen, listlen):\n maxstart = listlen - slicelen\n start = randrange(maxstart+1)\n maxstep = (listlen - start) // slicelen if slicelen else 1\n step = randrange(1, maxstep+1)\n stop = start + slicelen * step\n s = slice(start, stop, step)\n _, _, _, control = sli... | [
"0.8386598",
"0.8022296",
"0.7148622",
"0.7131934",
"0.6567083",
"0.6412609",
"0.6211643",
"0.61631083",
"0.613346",
"0.6101639",
"0.6099712",
"0.6061299",
"0.60270053",
"0.60159683",
"0.5992975",
"0.59393466",
"0.592926",
"0.5924613",
"0.59234124",
"0.59072083",
"0.5882425",... | 0.8382608 | 1 |
Create two sets of slices for an array x with shape 'shape' such that shapeof(x[lslices]) == shapeof(x[rslices]). | def randslice_from_shape(ndim, shape):
lslices = [0] * ndim
rslices = [0] * ndim
for n in range(ndim):
l = shape[n]
slicelen = randrange(1, l + 1) if l > 0 else 0
lslices[n] = randslice_from_slicelen(slicelen, l)
rslices[n] = randslice_from_slicelen(slicelen, l)
return tu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randslice_from_shape(ndim, shape):\n lslices = [0] * ndim\n rslices = [0] * ndim\n for n in range(ndim):\n l = shape[n]\n slicelen = randrange(1, l+1) if l > 0 else 0\n lslices[n] = randslice_from_slicelen(slicelen, l)\n rslices[n] = randslice_from_slicelen(slicelen, l)\n ... | [
"0.6894566",
"0.6573922",
"0.64847517",
"0.64847517",
"0.6427743",
"0.64160067",
"0.64142555",
"0.63429934",
"0.63423526",
"0.63288146",
"0.6293118",
"0.62560296",
"0.62280154",
"0.61813617",
"0.59872895",
"0.5902308",
"0.5837056",
"0.5818695",
"0.57853127",
"0.57816154",
"0.... | 0.6904066 | 0 |
Return a list of random items for structure 't' with format 'fmtchar'. | def randitems_from_structure(fmt, t):
memlen, itemsize, _, _, _, _ = t
return gen_items(memlen // itemsize, '#' + fmt, 'numpy') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randitems_from_structure(fmt, t):\n memlen, itemsize, _, _, _, _ = t\n return gen_items(memlen//itemsize, '#'+fmt, 'numpy')",
"def gen_item(fmt, obj):\n mode, chars = fmt.split('#')\n x = []\n for c in chars:\n x.append(randrange_fmt(mode, c, obj))\n return x[0] if len(x) == 1 else t... | [
"0.743523",
"0.69968164",
"0.69968164",
"0.6158217",
"0.6158217",
"0.56768537",
"0.55988497",
"0.55988497",
"0.55495685",
"0.5540343",
"0.54579073",
"0.536578",
"0.535687",
"0.53133637",
"0.5218649",
"0.51368594",
"0.5075977",
"0.50701696",
"0.5047938",
"0.50477153",
"0.50288... | 0.75904536 | 0 |
Interpret the raw memory of 'exporter' as a list of items with size 'itemsize'. If shape=None, the new structure is assumed to be 1D with n itemsize = bytelen. If shape is given, the usual constraint for contiguous arrays prod(shape) itemsize = bytelen applies. On success, return (items, shape). If the constraints cann... | def cast_items(exporter, fmt, itemsize, shape=None):
bytelen = exporter.nbytes
if shape:
if prod(shape) * itemsize != bytelen:
return None, shape
elif shape == []:
if exporter.ndim == 0 or itemsize != bytelen:
return None, shape
else:
n, r = divmod(bytelen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast_items(exporter, fmt, itemsize, shape=None):\n bytelen = exporter.nbytes\n if shape:\n if prod(shape) * itemsize != bytelen:\n return None, shape\n elif shape == []:\n if exporter.ndim == 0 or itemsize != bytelen:\n return None, shape\n else:\n n, r = ... | [
"0.7727057",
"0.4954598",
"0.4824147",
"0.4800908",
"0.4739031",
"0.4712107",
"0.47060144",
"0.46961316",
"0.46703562",
"0.46703562",
"0.46703562",
"0.46703562",
"0.46573693",
"0.4640518",
"0.4593343",
"0.45195043",
"0.4501709",
"0.449512",
"0.44936705",
"0.4489558",
"0.44544... | 0.7749671 | 0 |
Generate random slice for a single dimension of length n. If zero=True, the slices may be empty, otherwise they will be nonempty. | def rslice(n, allow_empty=False):
minlen = 0 if allow_empty or n == 0 else 1
slicelen = randrange(minlen, n + 1)
return randslice_from_slicelen(slicelen, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rslice(n, allow_empty=False):\n minlen = 0 if allow_empty or n == 0 else 1\n slicelen = randrange(minlen, n+1)\n return randslice_from_slicelen(slicelen, n)",
"def get_slice(self, n):\n if n == 0:\n return slice(self._lo_atom, self._lo_atom + self._n_atoms)\n raise IndexErro... | [
"0.77199084",
"0.7018895",
"0.68136233",
"0.68136233",
"0.64119023",
"0.6384745",
"0.62981",
"0.6264033",
"0.61925167",
"0.61633945",
"0.6158656",
"0.615614",
"0.61386144",
"0.61261",
"0.6123165",
"0.60484874",
"0.5999658",
"0.59985995",
"0.59841186",
"0.5928469",
"0.592645",... | 0.77316195 | 0 |
Print ndarray for debugging. | def ndarray_print(nd):
try:
x = nd.tolist()
except (TypeError, NotImplementedError):
x = nd.tobytes()
if isinstance(nd, ndarray):
offset = nd.offset
flags = nd.flags
else:
offset = 'unknown'
flags = 'unknown'
print(
"ndarray(%s, shape=%s, strid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ndarray_print(nd):\n try:\n x = nd.tolist()\n except (TypeError, NotImplementedError):\n x = nd.tobytes()\n if isinstance(nd, ndarray):\n offset = nd.offset\n flags = nd.flags\n else:\n offset = 'unknown'\n flags = 'unknown'\n print(\"ndarray(%s, shape=%... | [
"0.7686053",
"0.68368405",
"0.6631245",
"0.6609683",
"0.65994364",
"0.65967774",
"0.6263622",
"0.62557095",
"0.62557095",
"0.62557095",
"0.62557095",
"0.6235029",
"0.6219768",
"0.6178411",
"0.61287254",
"0.6089198",
"0.6083977",
"0.60370946",
"0.60179627",
"0.6011618",
"0.598... | 0.7679877 | 1 |
Creates a new research group. The process of creating a new group requires a name. The name will be visible to participants of the study. Each research group is recognized by the participants of the study by means of a code. This code can be given manually, but it can also be generated randomly. | def create_research_group(self, name, code=None, description=None):
ResearchGroupRepository = get_repository('ResearchGroupRepository')
research_group = ResearchGroup(unit_id=self.id, code=code)
research_group.name = name
research_group.description=description
research_group.u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_group(self, name):\n\t\tdata = {\"name\":name}\n\t\tresponse = self.client.post(self._endpoint + \"/group\", content=data)\n\t\treturn Group(\n\t\t\tresponse.json['group_id'],\n\t\t\tself.user_id,\n\t\t\tself.site_id,\n\t\t\tdata=response.json\n\t\t)",
"def createGroup(self, name):\n new_group = ET... | [
"0.7631451",
"0.74209505",
"0.7270464",
"0.70967996",
"0.7086212",
"0.7078457",
"0.70375854",
"0.690792",
"0.68607086",
"0.6810042",
"0.6805589",
"0.68018395",
"0.6785249",
"0.6743896",
"0.66686916",
"0.66398335",
"0.6577481",
"0.6563361",
"0.6545581",
"0.6520852",
"0.6520852... | 0.80560404 | 0 |
Returns dictionaries with numerical and alphabetical ISO3 codes of all countries associated to a calibration region. Only contains countries that were affected by tropical cyclones between 1980 and 2017 according to EMDAT. | def get_countries_per_region(region='all'):
iso3n = {'NA1': [660, 28, 32, 533, 44, 52, 84, 60, 68, 132, 136,
152, 170, 188, 192, 212, 214, 218, 222, 238, 254,
308, 312, 320, 328, 332, 340, 388, 474, 484, 500,
558, 591, 600, 604,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_3letter(countries):\n url = URL(\"http://www.worldatlas.com/aatlas/ctycodes.htm\")\n html = url.download()\n dom = DOM(html)\n country_table = dom.by_tag('table.tableWrap')\n iso2_list = []\n iso3_list = []\n density_list = []\n\n for table in country_table:\n\n # Check if th... | [
"0.6693505",
"0.6442264",
"0.6434929",
"0.6373663",
"0.6347266",
"0.62879544",
"0.62832963",
"0.6151501",
"0.6148029",
"0.6129818",
"0.61217475",
"0.6008837",
"0.5993432",
"0.59486777",
"0.5905211",
"0.58826524",
"0.5858959",
"0.5848841",
"0.5817021",
"0.581479",
"0.58122736"... | 0.7045577 | 0 |
Returns list of failed_jobs and list of queued_jobs | def get_all_jobs():
fq = get_failed_queue(connection=conn)
job_data = {'queued_jobs': q.job_ids,
'failed_jobs': fq.job_ids}
return jsonify(job_data), 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_waiting_jobs(self):\n return []",
"def getFailedJobs(self):\n return self.__failedJobs",
"def _ls_waiting_jobs(self):\n \n jobs = [j for j in os.listdir(pjoin(self._jobsdir, \"00_waiting\")) if j.endswith(self._job_ext)]\n \n if self._job_filter:\n jobs ... | [
"0.7673165",
"0.729439",
"0.7151143",
"0.71381533",
"0.70219564",
"0.697404",
"0.6971113",
"0.69613254",
"0.6929969",
"0.68703556",
"0.68579084",
"0.6839582",
"0.6828979",
"0.6770599",
"0.6699452",
"0.66638",
"0.66388077",
"0.6578499",
"0.6571753",
"0.6571753",
"0.65546",
"... | 0.77690303 | 0 |
Synthesizes a new waveform from an existing wavetable, modifies last sample by averaging. | def karplus_strong(wavetable,nSamples):
samples = []
current_sample = 0
previous_value = 0
while len(samples) < nSamples:
wavetable[current_sample] = 0.5 * (wavetable[current_sample] + previous_value)
samples.append(wavetable[current_sample])
previous_value = samples[-1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def karplus_strong(wavetable, n_samples):\r\n samples = []\r\n current_sample = 0\r\n previous_value = 0\r\n while len(samples) < n_samples:\r\n wavetable[current_sample] = 0.5 * (wavetable[current_sample] + previous_value)\r\n samples.append(wavetable[current_sample])\r\n previous... | [
"0.6271071",
"0.5852042",
"0.57555866",
"0.56155145",
"0.5606625",
"0.5588599",
"0.55559814",
"0.5482329",
"0.54780155",
"0.54255253",
"0.541878",
"0.54015934",
"0.5395144",
"0.5356216",
"0.5349278",
"0.53260314",
"0.5207055",
"0.51885456",
"0.51621187",
"0.5160301",
"0.51579... | 0.63766307 | 0 |
Make sure that portal_classes exists | def test_01_CheckClassTool(self):
portal = self.portal
self.assertNotEqual(None,getattr(portal,'portal_classes',None))
self.commit()
# check if web UI works
portal_classes = portal.portal_classes
portal_classes.manage_viewDocumentList()
portal_classes.manage_viewPropertySheetList()
porta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_class_exists(self):\n\n self.assertTrue(hasattr(Account, self.klass_name))",
"def test_existe(self):\n\t\ttry:\n\t\t\tfrom DAS_core.models import Algo\n\t\texcept ImportError:\n\t\t\tself.fail('Classe Algo não existe!')",
"def deploy_class( self, target, type_name, fti ):\n write = self.... | [
"0.53774345",
"0.51280445",
"0.50186867",
"0.49392125",
"0.49174273",
"0.49015835",
"0.48458183",
"0.47867408",
"0.47851643",
"0.47115284",
"0.46889934",
"0.46678403",
"0.46626353",
"0.4632912",
"0.46316782",
"0.46226537",
"0.46139735",
"0.46076676",
"0.4581133",
"0.45805076",
... | 0.66639245 | 0 |
This tests checks that Documentation Helper works with propertysheets that define their categories using expressions. | def test_DocumentationHelperExpressionCategory(self):
from Products.ERP5Type.Core import DynamicCategoryProperty
from erp5.portal_type import Movement, Delivery
movement = Movement('dummy_movement').__of__(
Delivery('dummy_delivery').__of__(self.portal))
# This test relies on the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_extract_categories():\n pass",
"def test_schema_with_keywords_as_properties() -> None:\n soup = generate_case(\"with_keywords\")\n keywords = [\n \"default\",\n \"examples\",\n \"if\",\n \"then\",\n \"else\",\n \"anyOf\",\n \"allOf\",\n \"... | [
"0.60795856",
"0.59711784",
"0.58915657",
"0.58826786",
"0.57712066",
"0.56957185",
"0.56642175",
"0.564909",
"0.5631666",
"0.5598143",
"0.5526348",
"0.55044234",
"0.5482742",
"0.54043716",
"0.5330083",
"0.5322365",
"0.53221434",
"0.53104204",
"0.5306631",
"0.52514154",
"0.52... | 0.7291825 | 0 |
Returns ticker information for a specific symbol | def get_ticker(self, ticker_symbol):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_ticker(self, symbol: str, params={}):\n await self.load_markets()\n market = self.market(symbol)\n request = {\n 'symbol': market['id'],\n }\n response = await self.publicGetInstrument(self.extend(request, params))\n ticker = self.safe_value(resp... | [
"0.78603804",
"0.7758313",
"0.77317953",
"0.7673516",
"0.76512957",
"0.7537324",
"0.74595416",
"0.74571294",
"0.74185616",
"0.7411157",
"0.74107885",
"0.7337323",
"0.7282711",
"0.7149947",
"0.7087167",
"0.70546454",
"0.69366944",
"0.6935903",
"0.6910234",
"0.68530154",
"0.683... | 0.82886976 | 0 |
returns order book information for a specific ticker symbol | def get_order_book(self, tickerSymbol):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_ticker(self, symbol=''):\n params = {\n 'symbol': symbol,\n }\n return self._quote_get('ticker/bookTicker', params=params)",
"def get_ticker_book(self, symbol: Symbol):\n api_params = {\n \"symbol\": symbol.value\n }\n\n return self.request... | [
"0.81455857",
"0.8131528",
"0.7792051",
"0.738622",
"0.73515314",
"0.73360896",
"0.7012686",
"0.695943",
"0.6903387",
"0.6891515",
"0.6882886",
"0.68482375",
"0.6847495",
"0.6846191",
"0.68285894",
"0.68249434",
"0.67948323",
"0.67837065",
"0.6779166",
"0.6762778",
"0.6700178... | 0.8418663 | 0 |
creates a new wallet | def create_wallet(self, walletName):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_wallet(self, name, testnet=False):\n\t\tif name in list(self.wallets.keys()):\n\t\t\traise ValueError(f\"A wallet with the name '{name}' already exists\")\n\t\tw = Wallet(name, os.path.join(self.directory, name+\".json\"), self.bunkr_address, testnet)\n\t\tself.wallets[name] = w\n\t\treturn w",
"def c... | [
"0.7728691",
"0.7645546",
"0.74017274",
"0.71748984",
"0.70828825",
"0.70804906",
"0.70745426",
"0.6982063",
"0.69233996",
"0.690401",
"0.68713844",
"0.68614805",
"0.68131655",
"0.674367",
"0.6703419",
"0.66812265",
"0.6610821",
"0.6538225",
"0.63429326",
"0.62910056",
"0.624... | 0.8561778 | 0 |
returns a specific wallet by wallet id | def get_wallet(self, walletId):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_wallet(self, name):\n\t\treturn self.wallets[name]",
"def get_wallet(self, name):\n cmd = \"\"\" SELECT %s, %s, %s FROM %s \n WHERE %s = '%s'; \"\"\" %(COL_WALLETS_NAME,\n COL_WALLETS_PUB_KEY,\n ... | [
"0.7685199",
"0.6526179",
"0.6421603",
"0.60821086",
"0.6045026",
"0.6001108",
"0.5913738",
"0.5820807",
"0.578845",
"0.5772596",
"0.5763936",
"0.5741689",
"0.57395446",
"0.5667217",
"0.56473047",
"0.5631237",
"0.5595672",
"0.55946946",
"0.5569249",
"0.551072",
"0.5467637",
... | 0.8656911 | 0 |
returns the balance of a specific currency within a wallet | def get_wallet_balance(self, walletId, currency):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBalance(self, currency=''):\n\n if self.app.getExchange() == 'binance':\n if self.mode == 'live':\n model = BAuthAPI(self.app.getAPIKey(), self.app.getAPISecret())\n df = model.getAccount()\n if isinstance(df, pd.DataFrame):\n ... | [
"0.7852335",
"0.78425187",
"0.77898073",
"0.77060235",
"0.74482614",
"0.72229695",
"0.70222795",
"0.69157636",
"0.68902034",
"0.68884426",
"0.687906",
"0.6827744",
"0.68150514",
"0.6805584",
"0.6760362",
"0.67266095",
"0.6693744",
"0.66806483",
"0.6639499",
"0.6628088",
"0.66... | 0.8566594 | 0 |
returns a list of trades for a specific wallet results are paginated and limited to a maximum of 50 per request | def get_wallet_trades(self, walletId, filters={}):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_trades(self, symbol, limit=100):\n uri = \"/v3/trades\"\n params = {\n \"symbol\": symbol,\n \"limit\": limit\n }\n success, error = await self.request(\"GET\", uri, params)\n return success, error",
"def get_transactions():\n\n wallet = \... | [
"0.6731216",
"0.6282928",
"0.6250955",
"0.6204118",
"0.6151874",
"0.6113886",
"0.6096869",
"0.6058437",
"0.6016987",
"0.6013089",
"0.5983703",
"0.597755",
"0.5962768",
"0.59226096",
"0.5866819",
"0.584364",
"0.5842085",
"0.5841259",
"0.5808962",
"0.5775919",
"0.57513905",
"... | 0.715601 | 0 |
returns a list of orders for a wallet response will be paginated and limited to 50 items per response | def get_wallet_orders(self, walletId, filters={}):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_orders(self):\n return self._call_txtrader_api('query_orders', {})",
"def get_all_orders():",
"def get_all_orders(): \n data = order_obj.get_all_orders()\n return data",
"def get_all_orders():\n response = requests.get(\n settings.SHOPIFY_ORDERS_URL,\n auth=(settings.S... | [
"0.71169907",
"0.7110525",
"0.6960214",
"0.6934566",
"0.6841731",
"0.6807127",
"0.67992795",
"0.67735815",
"0.6703224",
"0.66973484",
"0.6666208",
"0.6579561",
"0.65551984",
"0.65550774",
"0.6521636",
"0.6460054",
"0.64496255",
"0.63238215",
"0.6322986",
"0.6293843",
"0.62667... | 0.7294534 | 0 |
creates a new limit order with a specific display amount (iceberg order) | def create_order_with_display(self, walletId, side, currency, amount, price, display, instrument):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_limit(self, price_limit):\n if self.price_limit is not None:\n return(order(self.symbol, -self.volume, style=LimitOrder(self.price_limit)))\n else:\n return",
"def place_limit_order(self, side, symbol, size, price, **kwargs):\n pass",
"def to_limit_order(s... | [
"0.6935492",
"0.5909779",
"0.58192116",
"0.57939625",
"0.57054144",
"0.5680742",
"0.55711776",
"0.5564312",
"0.55458647",
"0.5514782",
"0.5401939",
"0.53920233",
"0.53380656",
"0.53334963",
"0.53154343",
"0.5292036",
"0.52903724",
"0.5269442",
"0.5260938",
"0.524649",
"0.5242... | 0.6677763 | 1 |
cancels an order by order id | def cancel_order(self, walletId, orderId):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel(self, order_id):\n del self.__pending_orders[order_id]",
"def cancel_order(self, order_id: str):\n return self._call_txtrader_api('cancel_order', {'id': order_id})",
"def cancel_order(self, exchange, order_id):\n return self.ccxt.cancel_order(exchange, order_id)",
"def do_canc... | [
"0.7886926",
"0.7771369",
"0.7768115",
"0.7729761",
"0.7687791",
"0.7641673",
"0.7502705",
"0.7478574",
"0.74725676",
"0.733134",
"0.7282984",
"0.7212567",
"0.72104824",
"0.7196561",
"0.7165943",
"0.7117681",
"0.71050197",
"0.71039426",
"0.69047326",
"0.68984145",
"0.6885313"... | 0.79843706 | 0 |
Returns CADs and joined assessment data | def _get_bulk_cad_assessment_data(data):
# pylint: disable=too-many-locals
all_cads = db.session.query(
CAD,
all_models.Assessment.id,
all_models.Assessment.title,
all_models.Assessment.assessment_type,
all_models.Assessment.slug,
CAV.attribute_value,
CAV.attribute_object_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAcdcs(url, requests):\n acdcs = []\n for request in requests:\n name=request['id']\n #if a wrong or weird name\n if len(request['key'])<3:\n print request\n continue\n if 'ACDC' not in name:\n continue\n status=request['key']\n ... | [
"0.5760764",
"0.57193065",
"0.5685605",
"0.5670172",
"0.5644959",
"0.5521873",
"0.5435848",
"0.54345894",
"0.54301965",
"0.53913885",
"0.538099",
"0.5370903",
"0.5358886",
"0.53135127",
"0.5235593",
"0.52179354",
"0.52100855",
"0.5184517",
"0.51820374",
"0.5179295",
"0.516359... | 0.7123656 | 0 |
Call bulk complete job | def run_bulk_complete():
data = flask.request.json
parameters = {"data": data}
if _detect_files(data):
try:
gdrive.get_http_auth()
except gdrive.GdriveUnauthorized:
response = app.make_response(("auth", 401,
[("Content-Type", "text/html")]))
return re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_bulk(self, args):\n pass",
"def ExecuteBatchQueue(self):\n\t\tself.client.ExecuteBatch(self.batch_queue, 'https://www.google.com/m8/feeds/contacts/default/full/batch')\n\t\tself.ClearBatchQueue();",
"def complete_bulk(\n self,\n cache: DeferredCache[KT, VT],\n result: Dict[KT... | [
"0.7079095",
"0.6415702",
"0.61833334",
"0.6136382",
"0.6075964",
"0.6046644",
"0.6021936",
"0.6021726",
"0.5988993",
"0.59857816",
"0.59019566",
"0.58860904",
"0.5866364",
"0.5863739",
"0.5795183",
"0.5791518",
"0.5754818",
"0.5718038",
"0.5683675",
"0.56530243",
"0.5651987"... | 0.7564438 | 0 |
Call bulk verify job | def run_bulk_verify():
data = flask.request.json
parameters = {"data": data}
bg_task = background_task.create_task(
name="bulk_verify",
url=flask.url_for(bulk_verify.__name__),
queued_callback=bulk_verify,
parameters=parameters
)
db.session.commit()
return bg_task.make_response(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(self):\n self.logger.debug(\"Started verify\")\n jobs = []\n with db.within_session(self.config, self.logger) as session:\n jobs = session.query(\n Job.id, Job.file_path\n ).filter(Job.status == JobStatus.DONE)\n for job_id, file_path ... | [
"0.6720075",
"0.6682303",
"0.6468783",
"0.6262351",
"0.61376286",
"0.5955728",
"0.5869369",
"0.5861898",
"0.58433324",
"0.5837644",
"0.5836593",
"0.57137156",
"0.57011807",
"0.5656928",
"0.5633009",
"0.5630263",
"0.56249964",
"0.5550686",
"0.55351967",
"0.5533544",
"0.5525170... | 0.8012017 | 0 |
Save multiple copies of a figure on which axes is located with the most commonly used label combinations (or user supplied). | def savelabels(
fname: str = "",
ax: plt.Axes | None = None,
labels: list | None = None,
**kwargs,
):
if labels is None:
labels = [
("", ""),
("Preliminary", "pas"),
("Supplementary", "supp"),
("Work in Progress", "wip"),
]
if isins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hogg_savefig(prefix):\n for fn in [prefix + \".png\"]: # , prefix + \".pdf\"]:\n print \"saving \" + fn\n plt.savefig(fn)\n return None",
"def savefigure1(title, xlabel, ylabel, Y, labels, x, path_save_dir, type = \"linear\"):\n plt.figure(figsize = (10,8))\n plt.title(title)\n p... | [
"0.6350132",
"0.6260993",
"0.6197111",
"0.6191503",
"0.6170314",
"0.61094695",
"0.61077666",
"0.6071911",
"0.59721744",
"0.5910651",
"0.5904169",
"0.589379",
"0.5885587",
"0.58638483",
"0.58462965",
"0.5840445",
"0.5802337",
"0.5787703",
"0.5735204",
"0.57241803",
"0.57241803... | 0.6358126 | 0 |
This module finds corresponding runoff for each event in table df_events | def query_runoff(df_events, watershed, flume, df_rain):
# query all runoff records at selected flume
df_runRaw = query_DAP_runoff_rates(watershed, flume)
df_runRaw.runCode = df_runRaw.runCode.astype('int32')
df_runRaw = reduce_df_size(df_runRaw)
v(f'\n\nat flume{flume}:\n{len(df_runRaw)} runoff re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply(self, df_events):\n pass",
"def events(self, game_id: int) -> DataFrame[Any]:",
"def get_events(raw,event_id,offset=0):\r\n # extract time stamps from annotations\r\n timestamps = np.round(raw._annotations.onset*raw.info['sfreq']+offset).astype(int)\r\n assert np.all(timestamps < raw.... | [
"0.5748322",
"0.57144886",
"0.55991274",
"0.5579593",
"0.5531954",
"0.5496244",
"0.5468559",
"0.54090184",
"0.5358244",
"0.5308624",
"0.5286687",
"0.5271663",
"0.52494305",
"0.52436787",
"0.5229382",
"0.5169441",
"0.51639533",
"0.51450264",
"0.5132973",
"0.51306033",
"0.51272... | 0.65550363 | 0 |
align runoff elapsedTime based on firstRainStart calculate runoff volume/ rate and elapsedTime | def align_runoff_timeStamps(df_events, df_runoff):
df = pd.DataFrame()
for preName in df_events.preName.unique():
print(f'align runoff time stamps for event {preName}')
df_ = df_runoff[df_runoff.preName==preName].reset_index(drop=True)
if len(df_) > 1:
firstRainStart = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def align_rainfall_timeStamps(df0):\n\n df = pd.DataFrame()\n\n for preName in df0.preName.unique():\n\n print(f'align rainfall time stamps for event {preName}')\n\n df_pre = pd.DataFrame()\n\n for gauge in df0.gauge.unique():\n\n df_ = df0[(df0.preName==preName) & (df0.gauge=... | [
"0.6526323",
"0.59236485",
"0.59024507",
"0.58751476",
"0.5676522",
"0.5661514",
"0.56461394",
"0.55555403",
"0.5537185",
"0.5512149",
"0.5468423",
"0.5422588",
"0.53916734",
"0.5359967",
"0.53453577",
"0.5294358",
"0.5287564",
"0.5283864",
"0.5259966",
"0.52595323",
"0.52368... | 0.59759253 | 1 |
calculate elapsedTime based on the first rainStartTime calculate rainRate based on accDepth_DAP treat accDepth_DAP as the original measurements from rain gauge (not rate) calculate rainRate and they might be different from the rate from DAP database | def align_rainfall_timeStamps(df0):
df = pd.DataFrame()
for preName in df0.preName.unique():
print(f'align rainfall time stamps for event {preName}')
df_pre = pd.DataFrame()
for gauge in df0.gauge.unique():
df_ = df0[(df0.preName==preName) & (df0.gauge==gauge)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rrtime(self):\n if len(self.data.peaks):\n diff = ((self.data._masked[:-1] + self.data._masked[1:])\n / (2 * self.data.fs))\n return diff.compressed()",
"def ra_dec_calculate(self) -> dict:\n for sec in range(self.delta_time):\n if 0 < self.ra... | [
"0.5432386",
"0.52328086",
"0.51768696",
"0.51525265",
"0.5150645",
"0.5096807",
"0.50823",
"0.5001717",
"0.4944911",
"0.49364936",
"0.49303594",
"0.49172577",
"0.4902443",
"0.4893079",
"0.48878664",
"0.48768958",
"0.48706326",
"0.48587868",
"0.4838916",
"0.47926235",
"0.4792... | 0.5938804 | 0 |
new request with added headers | def add_headers(self, headers: Headers) -> 'Request':
return replace(self, headers={**self.headers, **headers}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, request):\n request.headers['Authorization'] = f'Token {self.token}'\n return request",
"def prepare_request(self, request):\r\n request = super(OpenStackApiSession, self).prepare_request(request)\r\n\r\n if not self._authenticating:\r\n request.headers.u... | [
"0.7145854",
"0.68151724",
"0.6461375",
"0.64191115",
"0.6331294",
"0.6330494",
"0.63175124",
"0.6306582",
"0.63058484",
"0.62810606",
"0.62717944",
"0.6213673",
"0.61926913",
"0.6174046",
"0.6164635",
"0.6164635",
"0.6155286",
"0.6126193",
"0.611144",
"0.6109326",
"0.6081064... | 0.7015091 | 1 |
new request with added url prefix | def add_prefix(self, prefix: str) -> 'Request':
return replace(self, url=prefix + self.url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_request(self, request):\n self.request = request\n site = get_current_site(request)\n if site.id > 1:\n prefix = \"_{0}\".format(site.id)\n self.request.urlconf = settings.ROOT_URLCONF + prefix",
"def get_prefix_url(request):",
"def preQuery(self):\n ... | [
"0.6477151",
"0.64046407",
"0.63772404",
"0.6298312",
"0.6177108",
"0.6159193",
"0.6141393",
"0.606293",
"0.60610163",
"0.600169",
"0.5991233",
"0.5954496",
"0.5852522",
"0.5842452",
"0.5812543",
"0.5803095",
"0.5729534",
"0.57173485",
"0.56708056",
"0.5661592",
"0.565153",
... | 0.7734129 | 0 |
new request with added params | def add_params(self, params: t.Mapping[str, str]) -> 'Request':
return replace(self, params={**self.params, **params}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newRequest(self):\n return Request( )",
"def build_request(input_id, method, params=None):\n request = {\"method\": method, \"id\": input_id}\n if params is not None:\n request[\"params\"] = params\n return request",
"def createRequest(self, **kwargs):\n for k,... | [
"0.7086695",
"0.70839065",
"0.70200723",
"0.69154435",
"0.6760896",
"0.66121113",
"0.63734776",
"0.6355967",
"0.62925065",
"0.62871957",
"0.6281109",
"0.62280893",
"0.62173194",
"0.6144183",
"0.61416066",
"0.61277694",
"0.6124601",
"0.6100068",
"0.6056791",
"0.60548115",
"0.6... | 0.7201312 | 0 |
new request with "basic" authentication | def add_basic_auth(self, credentials: t.Tuple[str, str]) -> 'Request':
username, password = credentials
encoded = b64encode(f'{username}:{password}'.encode('ascii'))
return self.add_headers({
'Authorization': f'Basic {encoded.decode("ascii")}'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basic_auth(user, password):\n return AuthToken(\"basic\", user, password)",
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def __init__(__self__, *,\n auth_type: pulumi.Input[str],\n username: pulumi.Input[... | [
"0.7194673",
"0.67385864",
"0.6613847",
"0.6601926",
"0.65919614",
"0.65387666",
"0.6505237",
"0.64942694",
"0.64724517",
"0.64498824",
"0.6448934",
"0.6444481",
"0.6431145",
"0.6406636",
"0.6401071",
"0.63408595",
"0.6322505",
"0.63128126",
"0.62457097",
"0.62346834",
"0.623... | 0.7480425 | 0 |
Calculates average, minimum and maximum of metrics parameters. The resulting data is sent to STDOUT | def output_data():
# Calculate average values
avgRequestLatency = 0 if len(requestLatencyValues) == 0 else \
sum(requestLatencyValues)/len(requestLatencyValues)
avgDbLatency = 0 if len(dbLatencyValues) == 0 else \
sum(dbLatencyValues)/len(dbLatencyValues)
avgCacheLatency = 0 if len(cache... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_avg():",
"def calculate(self):\n self.results['max'] = numpy.max(self.data)\n self.results['min'] = numpy.min(self.data)\n if self.type == 0:\n self.group_discrete_data()\n if self.type == 1:\n self.group_continuous_data()\n\n self.results['arith... | [
"0.65798646",
"0.6179972",
"0.60920435",
"0.6060811",
"0.59418815",
"0.5911781",
"0.5840751",
"0.57969624",
"0.573244",
"0.5599005",
"0.5584583",
"0.55808747",
"0.5571525",
"0.55686355",
"0.5541825",
"0.5539664",
"0.55186886",
"0.55182576",
"0.55130506",
"0.5512342",
"0.55069... | 0.62350345 | 1 |
Given a search space list, return an expanded search space list that includes negative directions | def generate_permutations(search_space):
expanded_ss = []
for sp in search_space:
new_se = generate_sign_permutation(sp)
expanded_ss.extend(new_se)
return expanded_ss | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alternate_pos_neg(num_list):\n\tpos = []\n\tneg = []\n\tres = []\n\n\tfor num in num_list:\n\t\tif num < 0:\n\t\t\tneg.append(num)\n\t\telse:\n\t\t\tpos.append(num)\n\n\ti = 0\n\tj = 0\n\n\twhile i < len(pos) or j < len(neg):\n\t\tif i < len(pos):\n\t\t\tres.append(pos[i])\n\t\tif j < len(neg):\n\t\t\tres.appe... | [
"0.550423",
"0.53602487",
"0.5196208",
"0.49958688",
"0.49188828",
"0.49109083",
"0.4907382",
"0.4907382",
"0.4907382",
"0.4907382",
"0.4907382",
"0.4907382",
"0.4907382",
"0.4907382",
"0.49058002",
"0.49058002",
"0.49058002",
"0.49058002",
"0.49058002",
"0.49058002",
"0.4905... | 0.5759162 | 0 |
Yield nodes in descending order. | def descending(self, x=None):
if x is None:
x = self.root
if x is not self.nil:
if x.right is not self.nil:
for y in self.descending(x.right):
yield y
yield x
if x.left is not self.nil:
for y in self.des... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_order(self):\n for node_data in self._post_order_helper(self._root):\n yield node_data",
"def ascend(self):\n node = self.parent\n while node:\n yield node\n node = node.parent",
"def __reversed__(self):\n if len(self) == 0:\n return\n\n # Cre... | [
"0.6864914",
"0.660879",
"0.6553952",
"0.6415333",
"0.6355616",
"0.6309595",
"0.6181089",
"0.61217636",
"0.607277",
"0.5988098",
"0.591854",
"0.5904996",
"0.5904596",
"0.59039015",
"0.58987355",
"0.5894788",
"0.5863905",
"0.5850456",
"0.57982355",
"0.57889086",
"0.5778526",
... | 0.6752017 | 1 |
Leftrotate the tree under node x. | def rotate_left(self, x=None):
if x is None:
x = self.root
assert x.right is not self.nil, "Cannot rotate any further left"
# Right node replaces x as the top node
y = x.right
# Move new top node's child under old top node.
x.right = y.left
if x.righ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_left(self, og_root):\r\n new_root = og_root.right\r\n og_root.right = new_root.left\r\n if new_root.left:\r\n new_root.left.parent = og_root\r\n new_root.parent = og_root.parent\r\n if og_root is self.root: # if our original root of the rotation is the tre... | [
"0.79157615",
"0.78381366",
"0.76984537",
"0.7614066",
"0.7600261",
"0.75376546",
"0.7511552",
"0.7416094",
"0.73643774",
"0.7325683",
"0.72307533",
"0.7230648",
"0.7041633",
"0.7040582",
"0.69988453",
"0.69572175",
"0.6934614",
"0.6882082",
"0.6835029",
"0.6818333",
"0.67571... | 0.84179527 | 0 |
Rightrotate the tree under node x. | def rotate_right(self, x=None):
if x is None:
x = self.root
assert x.left is not self.nil, "Cannot rotate any further right"
# Left node replaces x as the top node
y = x.left
# Move new top node's child under old top node.
x.left = y.right
if x.left ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_with_right_child(self, node):\n node.right = self.rotate_with_left_child(node.right)\n # double rotate to the left\n return self.rotate_with_right_child(node)",
"def rotate_with_right_child(self, node):\n temp = node\n # todo why the fuck i need temp?\n return_node = node.right\n ... | [
"0.7628521",
"0.75943077",
"0.7510121",
"0.742038",
"0.7366329",
"0.7341106",
"0.73247653",
"0.7276146",
"0.72076607",
"0.7126255",
"0.71257293",
"0.7124205",
"0.7109927",
"0.71011907",
"0.7056619",
"0.70498395",
"0.70308566",
"0.70234567",
"0.7012712",
"0.6971885",
"0.689212... | 0.8350318 | 0 |
Recursively update balance factors going up the tree. For a single insertion, factor = 1. For a single deletion, factor = 1. | def update(self, x, factor=0):
if x is self.nil:
return
if x.balance > 1 or x.balance < -1:
self.rebalance(x)
return
if x is self.root:
return
if x is x.parent.left:
x.parent.balance += factor
elif x is x.parent.right:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_balances(self, recursive=True):\n if self.node:\n if recursive:\n if self.node.left:\n self.node.left.update_balances()\n if self.node.right:\n self.node.right.update_balances()\n\n self.balance = self.node.... | [
"0.7114943",
"0.6488515",
"0.6434147",
"0.62561345",
"0.6224313",
"0.6212973",
"0.6092666",
"0.5940654",
"0.581709",
"0.58043826",
"0.5763958",
"0.57568693",
"0.5716241",
"0.56767696",
"0.5675978",
"0.5668895",
"0.56612366",
"0.564704",
"0.56425905",
"0.5569215",
"0.5566293",... | 0.7416797 | 0 |
Swap node with the smallest node in the right subtree. | def _swap_right(self, x):
y = self.minimum(x.right)
if x is y.parent:
x.parent, y.parent = y, x.parent
x.right, y.right = y.right, x
else:
x.parent, y.parent = y.parent, x.parent
x.right, y.right = y.right, x.right
x.parent.left = x
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_nodes(tree) -> None:\n if tree is None:\n raise ValueError('Empty tree')\n tmp = tree.left\n tree.left = tree.right\n tree.right = tmp",
"def delete_min(self):\n node = self.root \n if node is None:\n return \n # move to the leftmost \n while no... | [
"0.7324438",
"0.67315096",
"0.63112813",
"0.62305593",
"0.62209743",
"0.6135576",
"0.61194736",
"0.6054473",
"0.60118175",
"0.60117227",
"0.59994906",
"0.5998655",
"0.5998634",
"0.5990489",
"0.59838337",
"0.59796345",
"0.5977138",
"0.59554034",
"0.5910643",
"0.58893085",
"0.5... | 0.7686936 | 0 |
Returns the set of protocols which when combined in a workflow will yield the molar volume of a substance by reweighting cached data. | def _get_reweighting_protocols(id_suffix, gradient_replicator_id, data_replicator_id, replicator_id=None,
weight_by_mole_fraction=False, substance_reference=None, options=None):
if replicator_id is not None:
id_suffix = f'{id_suffix}_$({replicator_id})'
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protocols(self):\n return list(self.query(Protocol))",
"def _get_simulation_protocols(id_suffix, gradient_replicator_id, replicator_id=None, weight_by_mole_fraction=False,\n component_substance_reference=None, full_substance_reference=None, options=None):\n\n if rep... | [
"0.54899603",
"0.5423705",
"0.51128644",
"0.50020117",
"0.4925287",
"0.48651612",
"0.48622695",
"0.48384738",
"0.4797007",
"0.4785232",
"0.4785232",
"0.47777784",
"0.47763973",
"0.47625688",
"0.4719622",
"0.47192717",
"0.47112608",
"0.46366888",
"0.46180734",
"0.46037996",
"0... | 0.6349485 | 0 |
Returns system groups and users | def get_system_groups_and_users(host):
users = query("$.host.'{host}'.pam", host=host) or []
if isinstance(users, (str, unicode)):
users = users.replace(', ', ' ').replace(',', ' ').split(' ')
groups = [group[1:] for group in users if group and group.startswith("+")]
both = [group[1:] for group ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_groups(self, username):\n return []",
"def get_system_managers(only_name: bool = False) -> list[str]:\n\tHasRole = DocType(\"Has Role\")\n\tUser = DocType(\"User\")\n\n\tif only_name:\n\t\tfields = [User.name]\n\telse:\n\t\tfields = [User.full_name, User.name]\n\n\tsystem_managers = (\n\t\tfrappe.... | [
"0.67001593",
"0.669562",
"0.65539956",
"0.63845575",
"0.637509",
"0.6355268",
"0.6354115",
"0.635049",
"0.6310308",
"0.6302902",
"0.62869257",
"0.62774247",
"0.6277292",
"0.6256763",
"0.6251251",
"0.6237912",
"0.6228945",
"0.62287754",
"0.62163657",
"0.6161516",
"0.61081606"... | 0.74678093 | 0 |
Returns a list of services on the host | def get_services(host):
services = query("$.host.'{host}'.service", host=host)
return services | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_services(self):\r\n return get_service_list()",
"def list_services(ctx):\n pass",
"def services(self):\n return self.agent.http.get(\n lambda x: json.loads(x.body), '/v1/agent/services')",
"def get_service_list():\n service_dict = requests.get('http://consul... | [
"0.82029706",
"0.80577666",
"0.78521353",
"0.78275573",
"0.76788586",
"0.7619323",
"0.75906",
"0.7569603",
"0.7565902",
"0.7519041",
"0.7490017",
"0.745987",
"0.745464",
"0.74450487",
"0.7436154",
"0.7422885",
"0.74085695",
"0.7316116",
"0.73026794",
"0.72895956",
"0.72806096... | 0.8314367 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.