query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Toggle the mic output (un)mute mic | def speaker_toggle(self, emission, signal, source):
self.storage.call.mute_toggle() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mute_output_toggle(self):\n self._mute_toggle(self.pulse_core.Get(\"org.PulseAudio.Core1\", \"FallbackSink\"))",
"def mute_input_toggle(self):\n self._mute_toggle(self.pulse_core.Get(\"org.PulseAudio.Core1\", \"FallbackSource\"))",
"def handle_mic_unmute(_):\n loop.unmute()",
"def handle... | [
"0.8066267",
"0.727805",
"0.71628326",
"0.6953675",
"0.68161976",
"0.6781403",
"0.6756041",
"0.675276",
"0.6629703",
"0.6501688",
"0.64002997",
"0.63784355",
"0.63501537",
"0.63275814",
"0.62751156",
"0.62683904",
"0.62608665",
"0.62523144",
"0.6239259",
"0.621032",
"0.620891... | 0.7606264 | 1 |
Creates and initializes flask app. | def create_app(config_class=None):
app = Flask(__name__)
# Set up the proper app configurations based on the Flask environment or passed in config_class.
# Raises an exception if config_class is None and FLASK_ENV is not set.
environment = os.environ.get('FLASK_ENV')
if config_class is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app(self):\r\n self.app = Flask(__name__, instance_relative_config=True)\r\n\r\n # Init the secret key of the app -it is a must for flask to run\r\n self.app.config.from_mapping(\r\n SECRET_KEY='!ZNeverSayNever116Z!',\r\n MONGODB_SETTINGS= {'host': 'mongodb://l... | [
"0.85452795",
"0.8524006",
"0.8483392",
"0.84604436",
"0.8448938",
"0.8410629",
"0.83162904",
"0.8249251",
"0.82478195",
"0.824029",
"0.81743926",
"0.8160482",
"0.8152521",
"0.81443596",
"0.8139065",
"0.8139043",
"0.81346816",
"0.8121849",
"0.81182456",
"0.81014913",
"0.80837... | 0.0 | -1 |
r"""Initialise a new cosmology from the physical parameters. This uses the CMB relevant parameterisation that is commonly used. The dark energy density is calculated from the given parameters. | def init_physical(
ombh2=0.022161, omch2=0.11889, H0=67.77, omkh2=0.0, t0=2.726, nnu=3.046
):
h = H0 / 100.0
c = Cosmology()
c.omega_b = ombh2 / h ** 2
c.omega_c = omch2 / h ** 2
c.H0 = H0
rhoc = 3.0 * c.H() ** 2 * c_sl ** 2 / (8.0 * math.pi * G_n)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,cosmo=None, set_hinv=False):\n if cosmo is None: \n cp = CosmoParams(set_flat=True) \n else: \n cp = cosmo ... | [
"0.63952196",
"0.61827314",
"0.6016263",
"0.59597903",
"0.5940511",
"0.5898547",
"0.5872297",
"0.583614",
"0.581699",
"0.5790757",
"0.5776464",
"0.5757035",
"0.57305735",
"0.57302195",
"0.5728793",
"0.57286584",
"0.5722246",
"0.57181877",
"0.57063365",
"0.569889",
"0.5691673"... | 0.6686264 | 0 |
r"""The luminosity distance to redshift z. This routine is vectorized. | def luminosity_distance(self, z):
return self.proper_distance(z) * (1 + z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def luminosity_distance(self, z):\n da = self.angular_diameter_distance(z)\n dl = da*(1.+z)**2.\n return(dl)",
"def Luminosity_Distance(self, z):\n dl = (1 + z) * self.Comoving_Distance(z)\n return dl",
"def Luminosity_Distance_dimless(self, z):\n dl = (1 + z) * self.C... | [
"0.79278964",
"0.7798356",
"0.75086904",
"0.6878694",
"0.6640499",
"0.64590514",
"0.63060397",
"0.62948394",
"0.6230335",
"0.6054879",
"0.5883401",
"0.5830001",
"0.57934934",
"0.5703293",
"0.56915665",
"0.5675013",
"0.56322277",
"0.56094044",
"0.55899096",
"0.5586991",
"0.557... | 0.8201477 | 0 |
Compute sequence lengths for each batch element in a tensor using a binary mask. | def get_lengths_from_binary_sequence_mask(self, mask: torch.Tensor):
return mask.long().sum(-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lengths_from_binary_sequence_mask(mask: torch.Tensor):\n return mask.long().sum(-1)",
"def get_lengths_from_binary_sequence_mask(\n mask: torch.BoolTensor,\n) -> torch.LongTensor:\n return mask.sum(-1)",
"def length(sequence):\r\n populated = tf.sign(tf.abs(sequence))\r\n length = tf.cas... | [
"0.7909698",
"0.7882353",
"0.6812539",
"0.6645065",
"0.6404213",
"0.63116467",
"0.628978",
"0.61880934",
"0.6063069",
"0.6060494",
"0.6014021",
"0.5968722",
"0.593946",
"0.58760476",
"0.5818447",
"0.58059365",
"0.5749245",
"0.56792086",
"0.5635178",
"0.5570334",
"0.55680794",... | 0.7809736 | 2 |
Test that token is not created if user doesn`t exists | def test_create_token_no_user(self):
payload = {'email': 'test1@test.com', 'password': 'password'}
res = self.client.post(TOKEN_URL, payload)
self.assertNotIn('token', res.data)
self.assertEquals(res.status_code, status.HTTP_400_BAD_REQUEST) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_token_no_user(self):\n res = self.client.post(TOKEN_URL, self.mock_user)\n\n self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)\n self.assertNotIn('token', res.data)",
"def test_create_token_for_not_user(self):\n\n credentials = {'email': 'testuser@gmail.co... | [
"0.7856906",
"0.77536523",
"0.77330077",
"0.7648511",
"0.7579056",
"0.7545252",
"0.75082964",
"0.74734324",
"0.7413778",
"0.73526865",
"0.73489654",
"0.73449314",
"0.732971",
"0.73059464",
"0.72771466",
"0.7242528",
"0.72175646",
"0.7217404",
"0.7178604",
"0.7176463",
"0.7172... | 0.76987785 | 3 |
Test retrieving profile for logged user | def test_retrieve_profile_success(self):
res = self.client.get(ME_URL)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(res.data, {
'name': self.user.name,
'email': self.user.email,
'time_zone': 'Europe/Moscow'
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_profile(self):\n\n response = self.client.get(URL_ME)\n\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n\n # Check that the user object returns as expected. There is no need\n # (and it is not secure) to return a password to client side.\n self.ass... | [
"0.8034919",
"0.79708683",
"0.7885502",
"0.78722656",
"0.78630054",
"0.7850485",
"0.7841248",
"0.7811497",
"0.7809593",
"0.78094697",
"0.7796063",
"0.7733787",
"0.7718614",
"0.7688663",
"0.7685976",
"0.7667588",
"0.76559615",
"0.7568242",
"0.75580114",
"0.74441457",
"0.743025... | 0.76149094 | 17 |
replace spaces with %20 | def cleanUrl(url):
url_clean = url.replace(' ','%20')
""" add /index.html where necessary """
if (url[-1:]=='/'):
url_clean += 'index.html'
elif (url[-5:].find('.') == -1):
url_clean += '/index.html'
return url_clean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def urlify(w, length):\n return w.strip().replace(' ', '%20')",
"def urlify(board):\n return(board.replace(\" \",\"%20\"))",
"def make_url_safe(self, url):\n return url.replace(' ', '%20')\\\n .replace('(', '%28')\\\n .replace(')', '%29')\\\n .rep... | [
"0.747526",
"0.7397056",
"0.7385226",
"0.7369369",
"0.7166548",
"0.6731469",
"0.66903615",
"0.64442766",
"0.6324205",
"0.6253393",
"0.61330336",
"0.61279285",
"0.60966134",
"0.607538",
"0.60677725",
"0.6043515",
"0.6026315",
"0.6019534",
"0.59961283",
"0.5958039",
"0.59519595... | 0.0 | -1 |
Close and clean up source reader. Will be called when StreamBuffer stops or if an exception is raised during read and append loop. | def close(self) -> None:
self._data_read_thread_exit.set()
self._plc_raw_reader.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __del__(self):\n if self.reader is not None:\n self.reader.close()",
"def close(self):\n self._raw_stream.close()",
"def close(self):\n self.p.close(self.inStream)",
"def close(self):\n if self.closed:\n return\n self._stream.close()\n self._stream = None",
... | [
"0.6731178",
"0.6546805",
"0.63237774",
"0.63179237",
"0.627804",
"0.62592274",
"0.6205713",
"0.61669207",
"0.61302084",
"0.60671246",
"0.5996146",
"0.5967336",
"0.59638184",
"0.5956088",
"0.5949534",
"0.59438324",
"0.59171486",
"0.58929074",
"0.5887916",
"0.57966757",
"0.572... | 0.6441269 | 2 |
Convert XML derived dict to tf.Example proto. Notice that this function normalizes the bounding box coordinates provided by the raw data. | def dict_to_tf_example(data,
label_map_dict,
image_subdirectory,
ignore_difficult_instances=False):
img_path = os.path.join(image_subdirectory, data['filename'])
with tf.gfile.GFile(img_path, 'rb') as fid:
encoded_jpg = fid.read()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_raw_example(\n self,\n mode_dict: MutableMapping[str, Any],\n example: Mapping[str, Any]) -> ProcessedExample:\n img_path = example['image_path_or_name']\n base_name = os.path.basename(img_path)\n img_fobj = example.get('image_fobj', tf.io.gfile.GFile(img_path, 'rb'))\n img_... | [
"0.64853275",
"0.62820524",
"0.61581874",
"0.6119248",
"0.60627395",
"0.59382325",
"0.5928884",
"0.588166",
"0.58803463",
"0.5863715",
"0.58418375",
"0.5819398",
"0.58181757",
"0.578881",
"0.5782654",
"0.57494575",
"0.57492685",
"0.5719735",
"0.57126236",
"0.5693452",
"0.5693... | 0.5852231 | 10 |
Transform a Python dictionary object to the string format expected by Spec | def dictionarytoraw(dict):
data = ""
for key, val in dict.items():
if isinstance(val,dict):
for kkey, vval in iter(val.items()):
if kkey is None:
data += str(key) + NULL + str(vval) + NULL
else:
data += ''.join([str(key), ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_2_string(d):\n buff = io.StringIO()\n print_dictionary(d, output=buff)\n return buff.getvalue()",
"def _to_string(self) -> str:\n\n string_list = []\n for key, value in self.__dict__.items():\n if isinstance(value, dict):\n string_list.append(key)\n ... | [
"0.6936573",
"0.68353754",
"0.6636121",
"0.6621528",
"0.66060406",
"0.65788347",
"0.65639365",
"0.6415574",
"0.63642925",
"0.6269988",
"0.62683415",
"0.62228703",
"0.6196243",
"0.61843646",
"0.6159893",
"0.6137677",
"0.61336774",
"0.61224455",
"0.6096647",
"0.60770315",
"0.60... | 0.59703743 | 30 |
Return the string representing the data part of the message. | def sendingDataString(self, data, datatype):
rawstring = ''
if datatype in (ERROR, STRING, DOUBLE):
rawstring = str(data)
elif datatype == ASSOC:
rawstring = dictionarytoraw(data)
elif SpecArray.isArrayType(datatype):
rawstring = data.tostring()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toData(self):\n\n lines = []\n # 1. Request and protocol version\n lines.append(self.request + \" \" + BANNER)\n # 2. Request arguments\n lines.extend(['%s: %s' % (arg, self.args[arg]) for arg in self.args])\n # 3. End of message (double CR-LF)\n data = \"\\r\\n... | [
"0.7773438",
"0.7150623",
"0.7020451",
"0.6912867",
"0.6912867",
"0.68851477",
"0.68327284",
"0.6735287",
"0.66896284",
"0.6678881",
"0.6673185",
"0.6651609",
"0.66341513",
"0.6586051",
"0.6586051",
"0.6510055",
"0.6506211",
"0.6494798",
"0.6494798",
"0.6494798",
"0.6494798",... | 0.6789063 | 7 |
Constructor If called without arguments, message is supposed to be read from stream. Otherwise, the 'init' method is called with the specified arguments, for creating a message from arguments. | def __init__(self, *args, **kwargs):
SpecMessage.__init__(self, '<IiiiIIiiIII80s')
if len(args) > 0:
self.init(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, buf=None, *args, **kwargs):\n super(Message, self).__init__(buf, *args, **kwargs)\n self.__initialized = True",
"def __init__(self, message: str) -> None:\n self.message = message",
"def __init__(self, message=None):\n self.message = message",
"def __init__(self... | [
"0.77373403",
"0.72072816",
"0.71794885",
"0.71794885",
"0.71774596",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.7153903",
"0.71381134",
"0.70832187",
"0.70832187",
"0.70832187",
"0.70472133",
"0.701... | 0.66334254 | 40 |
Adds a lexical unit that part of this synset to the list of lexical units | def add_lexunit(self, unit):
self._lexunits.append(unit) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_units(self, units):\n units = self.model._get_units_obj(units)\n try:\n model_units = self.model.get_units_by_name(units.name)\n except KeyError:\n model_units = None\n if model_units:\n assert units.uniquify_tuple == model_units.uniquify_tuple\n... | [
"0.60551524",
"0.6053732",
"0.5924283",
"0.5544305",
"0.5539073",
"0.55372864",
"0.55254465",
"0.5516368",
"0.551075",
"0.55055135",
"0.54949015",
"0.5470546",
"0.5450033",
"0.54382974",
"0.543698",
"0.54336",
"0.54334307",
"0.54152876",
"0.54115933",
"0.54029685",
"0.5380608... | 0.780608 | 0 |
This method iterates recursively through the hyponyms of this synset to get all paths that connect this synset with a leaf node. A path is complete if it ends with a leaf node. All possible paths are returned. Each path is a list of nodes. | def hyponym_paths(self):
paths = []
hyponyms = self._direct_hyponyms
if self.is_leaf():
paths = [[self]]
for hyponym in hyponyms:
for ancestor_list in hyponym.hyponym_paths():
ancestor_list.append(self)
paths.append(ancestor_list)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hypernym_paths(self):\n paths = []\n hypernyms = self._direct_hypernyms\n if self.is_root():\n paths = [[self]]\n for hypernym in hypernyms:\n for ancestor_list in hypernym.hypernym_paths():\n ancestor_list.append(self)\n paths.app... | [
"0.7422237",
"0.65051013",
"0.63543946",
"0.62730676",
"0.626657",
"0.6222041",
"0.6086637",
"0.60478187",
"0.6000243",
"0.5959211",
"0.5935161",
"0.59281963",
"0.5876433",
"0.58762366",
"0.58679485",
"0.58576244",
"0.58576244",
"0.58333397",
"0.580117",
"0.5782998",
"0.57374... | 0.7799485 | 0 |
This returns the log of the mean of the notlogged data this version of the function requires a dense matrix, so might be memory hungry? But it is super fast | def exp_mean_dense(x):
# convert out of compressed sparse matrix
return np.log((np.sum(np.exp(x)-1)/x.shape[1]) + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_mean_exp(x, dim):\n return log_sum_exp(x, dim) - np.log(x.size(dim))",
"def exp_mean_sparse(x):\n # convert out of compressed sparse matrix\n return np.log((np.sum(x.expm1())/x.shape[1]) + 1)",
"def log_mean_exp(y):\n # init\n batch_size = y.size(0)\n sample_size = y.size(1)\n\n # ... | [
"0.70621765",
"0.6809297",
"0.6742798",
"0.6663161",
"0.6564605",
"0.65064085",
"0.6455784",
"0.63887745",
"0.6359034",
"0.62956625",
"0.6271695",
"0.6266449",
"0.62280035",
"0.6225644",
"0.6224636",
"0.6203908",
"0.6190347",
"0.6178793",
"0.61729896",
"0.6166792",
"0.615822"... | 0.67587495 | 2 |
Splits amount according to the shares dict | def split_amount(amount, shares, last_address):
total_shares = sum(shares.values())
# calculating amounts, int always rounds down:
amounts = {
address: share * amount // total_shares
for address, share in shares.items() if address != last_address
}
# dust goes to the last_address:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seperate_shareinfo(entry_split,entries,shareinfo):\n # Test if Stückelung wasn't recognized\n shareinfo['currency'] = entry_split\n shareinfo['amount'] = \"\"\n for idx, entry in enumerate(entries.split(\" \")[1:]):\n if entry == \"\":\n continue\n if entry[0].isdigit():\n ... | [
"0.6833782",
"0.6734144",
"0.6233229",
"0.6190128",
"0.6137208",
"0.5841906",
"0.5720234",
"0.5711589",
"0.56692106",
"0.5640182",
"0.55743253",
"0.5546221",
"0.5505224",
"0.5499333",
"0.5477827",
"0.5415766",
"0.53673935",
"0.53503126",
"0.5298688",
"0.5277851",
"0.52672994"... | 0.7375583 | 0 |
Initializes an user instance | def __init__(self, user):
if isinstance(user, dict):
# Every user must have these values
self.id = user['id']
self.name = user['first_name']
# These are optional
self.username = user.get('username', None)
self.last_name = user.get('last_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n create_user(app)\n get_all_user()",
"def user_init(self):\n pass",
"def initialize(self, *a, **kw):\n webapp2.RequestHandler.initialize(self, *a, **kw)\n uid = self.read_secure_cookie('user_id')\n self.user = uid and User.by_id(int(uid))",
"def initialize(self,... | [
"0.7244965",
"0.72124374",
"0.7170146",
"0.71537596",
"0.707521",
"0.7023502",
"0.70072836",
"0.6979637",
"0.6969571",
"0.6969103",
"0.6947331",
"0.68767965",
"0.68548805",
"0.6801345",
"0.66559297",
"0.65658927",
"0.65425",
"0.65213615",
"0.651309",
"0.6447022",
"0.6406627",... | 0.68878704 | 11 |
Returns True if n is prime. | def isprime(n):
if n == 1:
return False
if n == 2:
return True
if n == 3:
return True
if n % 2 == 0:
return False
if n % 3 == 0:
return False
i = 5
w = 2
while i * i <= n:
if n % i == 0:
return False
i += w
w ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n):\n\treturn is_prime(n)",
"def if_prime(cls, n):\n\n if (n <= 1):\n return False\n if (n <= 3):\n return True\n\n if (n % 2 == 0 or n % 3 == 0):\n return False\n\n i = 5\n while(i * i <=... | [
"0.8514796",
"0.85053056",
"0.8477928",
"0.84145856",
"0.8407615",
"0.84051764",
"0.8387878",
"0.83508223",
"0.83166903",
"0.8312641",
"0.8305638",
"0.8303322",
"0.83000225",
"0.8271",
"0.8247903",
"0.8247857",
"0.8245307",
"0.8236927",
"0.8229151",
"0.82214314",
"0.8210172",... | 0.7925613 | 53 |
Reshapes the data at most. | def forward(self, input=None):
if (input is not None) and (self.result is None):
self.result = self.node(input)
elif self.result is None:
raise ValueError("There must be some input or a previously calculated result")
return self.result.view(*self.G.d_out) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reshape(data):\n return K.reshape(x=data, shape=(K.shape(data)[0], 1, reshape_size))",
"def _data_reshape(self, data):\n data_offset = [int(size / 2) for size in data.shape[1:]]\n data_diff = [int(size / 2) for size in self.shape]\n data_diff_min = data_diff\n data_diff... | [
"0.7622886",
"0.73855644",
"0.6865512",
"0.6731449",
"0.66967636",
"0.66782326",
"0.66300786",
"0.6627189",
"0.66265833",
"0.6570942",
"0.6532213",
"0.65025",
"0.65007585",
"0.6497873",
"0.6483913",
"0.6457823",
"0.64163244",
"0.6345195",
"0.63281554",
"0.6301488",
"0.6236945... | 0.0 | -1 |
Takes a label (integer) and gives a embedding vector. | def forward(self, input=None):
if (input is not None) and (self.result is None):
self.result = self.drop(self.node(input))
# Pull the input from previous network layers
elif self.result is None:
in_result = []
for n in self.input:
in_result.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_to_embedding(sent, word_to_vec, seq_len, embedding_dim):\n embedding_vec = np.zeros((seq_len,embedding_dim))\n for i in range(min(len(sent),seq_len)):\n embedding_vec[i,:] = word_to_vec.get(sent[i])\n return embedding_vec",
"def labels2Vec(labels):\r\n global dict_words_n_vectors\... | [
"0.6532496",
"0.6502031",
"0.6319459",
"0.6212767",
"0.6208754",
"0.6138993",
"0.6136243",
"0.6121542",
"0.61211216",
"0.61024183",
"0.6090279",
"0.6061709",
"0.60195214",
"0.60132194",
"0.59999126",
"0.59952104",
"0.59864914",
"0.59500647",
"0.591279",
"0.58756846",
"0.58658... | 0.0 | -1 |
Takes 3d input and gives 3d output from recurrent layers. | def forward(self, input=None):
self._repackage()
if (input is not None) and (self.result is None):
if self.G.ntype == "lstm":
self.result, both = self.node(input, (self.hidden, self.state))
self.hidden, self.state = both
else:
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, input):\n return self.layers(input)",
"def get_output(self, prev_layers=None, **kwargs):\n if prev_layers is None:\n prev_layers = list()\n if self not in prev_layers:\n prev_layers += [self]\n incoming = self.incoming(prev_layers=prev_layer... | [
"0.6373839",
"0.6285802",
"0.62217426",
"0.618699",
"0.6131762",
"0.6108942",
"0.60621095",
"0.6044154",
"0.6041587",
"0.60261834",
"0.59697473",
"0.59620094",
"0.59096473",
"0.58994746",
"0.5890211",
"0.58814704",
"0.58787155",
"0.5850529",
"0.58421",
"0.58340603",
"0.581374... | 0.5584691 | 47 |
Create Rectangle should works properly | def test_construct(self):
rect = Rectangle(1, 2, 3, 4)
assert rect.ymin == 1
assert rect.xmin == 2
assert rect.ymax == 3
assert rect.xmax == 4
rect = Rectangle(-100, -50, -60, -25)
assert rect.ymin == -100
assert rect.xmin == -50
assert ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rectangle(xcenter, ycenter, width, height):\n x1, x2 = xcenter - width, xcenter + width\n y1, y2 = ycenter - height, ycenter + height\n return Shape([Point(x1, y1), Point(x1, y2), Point(x2, y2), Point(x2, y1)])",
"def test_rectangle_full_init(self):\n r2 = Rectangle(10, 2, 1, 3, 12)\n ... | [
"0.75161445",
"0.75066745",
"0.74981946",
"0.7460654",
"0.74284446",
"0.74284446",
"0.73873633",
"0.73571545",
"0.72350025",
"0.721613",
"0.7211104",
"0.71540064",
"0.7129443",
"0.706263",
"0.7053608",
"0.7037065",
"0.6890046",
"0.6878401",
"0.68750715",
"0.6873973",
"0.68692... | 0.7070902 | 13 |
Create Rectanle with invalid argumants should raise ValueError | def test_construct_with_invalid(self):
with pytest.raises(ValueError):
rect = Rectangle(300, 100, 500, 50) # xmin > xmax
with pytest.raises(ValueError):
rect = Rectangle(300, 100, 200, 500) # ymin > ymax
with pytest.raises(ValueError):
rect = Recta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_bounds(self):\n with pytest.raises(ValueError):\n Real(\"yolo\", \"norm\", 0, 2, low=+2, high=-2, shape=(4, 4))\n with pytest.raises(ValueError):\n Real(\"yolo\", \"norm\", 0, 2, low=+2, high=+2, shape=(4, 4))",
"def test_17_negative_ints(self):\n with self... | [
"0.6592457",
"0.642854",
"0.6408988",
"0.6350111",
"0.62996316",
"0.62801296",
"0.6191416",
"0.6190356",
"0.6157614",
"0.61277187",
"0.60498405",
"0.60302",
"0.5976198",
"0.59727985",
"0.59319925",
"0.5924095",
"0.59218925",
"0.5918343",
"0.58938265",
"0.5893404",
"0.58882815... | 0.7249291 | 0 |
Returns a queryset of the nodes currently associated with the sample. | def nodes(self):
return self._get_tree_queryset() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_nodes(self):\n query_nodes = []\n for node in self.nodes:\n if 'querynode' == node.get('infos').get('type'):\n query_nodes.append(node)\n return query_nodes",
"def getNodes(self):\n return self.__allNodes",
"def get_nodes(self):\n\n return ... | [
"0.6406302",
"0.61110187",
"0.6077181",
"0.6070868",
"0.60615706",
"0.60325384",
"0.60325384",
"0.60325384",
"0.60230476",
"0.6012783",
"0.5995669",
"0.5952224",
"0.5952224",
"0.5904378",
"0.58481956",
"0.58314383",
"0.578583",
"0.57762283",
"0.5760965",
"0.5700851",
"0.56826... | 0.7009298 | 0 |
Returns all of the leaf nodes of the tree as a list. | def leaf_nodes(self):
return self.nodes.filter(lft=models.F('rght') - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leafs(self) -> list:\n return self._leafs[:]",
"def list_of_nodes(tree):\n list_ = []\n if tree.left.is_leaf() and tree.right.is_leaf():\n list_.append(tree)\n return list_\n elif tree.left.is_leaf():\n list_.extend(list_of_nodes(tree.right))\n... | [
"0.83672225",
"0.8083395",
"0.8027317",
"0.76761544",
"0.76495415",
"0.7600962",
"0.7573438",
"0.7530191",
"0.75085807",
"0.7445919",
"0.736591",
"0.73657054",
"0.7359157",
"0.735502",
"0.7319668",
"0.7307305",
"0.7307029",
"0.7294855",
"0.71958345",
"0.71133345",
"0.7107463"... | 0.7769531 | 3 |
Returns the number of nodes in the tree including the root. | def node_count(self):
return self.process_tree.get_descendant_count() + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_count(self):\n return self._root.count()",
"def countNodes(self, root):\n\n\n if not root:\n return 0\n\n return 1+self.countNodes(root.left)+self.countNodes(root.right)",
"def count(self):\n return self.__tree.node_count",
"def count_nodes(self):\n if s... | [
"0.8757398",
"0.8528377",
"0.8497665",
"0.8439223",
"0.84229153",
"0.8314511",
"0.831333",
"0.8291999",
"0.82824135",
"0.8224706",
"0.820351",
"0.80985975",
"0.8073603",
"0.80503225",
"0.8043466",
"0.8043466",
"0.8023205",
"0.7930295",
"0.7928673",
"0.7924355",
"0.7912737",
... | 0.7773985 | 25 |
Get all nodes from the tree that have the specified process. | def get_nodes_for_process(self, uuid, clean=True):
if clean:
uuid = Process.strip_uuid(uuid)
return self._get_tree_queryset().filter(process__uuid_full__startswith=uuid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nodes_for_process_type(self, process_type):\n if not ProcessType.objects.filter(type=process_type).exists():\n raise ValueError('{} is not a valid process type'.format(process_type))\n\n return self._get_tree_queryset().filter(process__type_id=process_type)",
"def filter_process(... | [
"0.70144504",
"0.66335785",
"0.62922233",
"0.5932579",
"0.57972205",
"0.5690171",
"0.5633599",
"0.5568902",
"0.5567874",
"0.55014604",
"0.54867184",
"0.54830223",
"0.5449074",
"0.54370844",
"0.53813094",
"0.5343397",
"0.53061706",
"0.5292066",
"0.5291635",
"0.528982",
"0.5272... | 0.74077183 | 0 |
Should return a http error 404 and a message 'specified template does not exist'. | def test_get_template_not_found(self):
template_id = "foo"
rv = TEST_CLIENT.get(f"/templates/{template_id}")
result = rv.json()
expected = {
"message": "The specified template does not exist",
"code": "TemplateNotFound",
}
self.assertDictEqual(ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNonExistantTemplate(self):\n try:\n self.service.get_template(\"Non_Existant\")\n self.fail(\"No ServiceError raised by non-existant template\")\n except ServiceError as ex:\n self.assertEqual(\n ex.message,\n \"There is no templa... | [
"0.8201116",
"0.8021696",
"0.7956505",
"0.79333884",
"0.7875378",
"0.7814681",
"0.7746407",
"0.76908815",
"0.7687622",
"0.75513756",
"0.7548562",
"0.75406986",
"0.7494457",
"0.7468443",
"0.7465183",
"0.7465183",
"0.7441508",
"0.743449",
"0.7427313",
"0.7424917",
"0.7410876",
... | 0.8741455 | 0 |
Should return a http error 404 and a message 'specified template does not exist'. | def test_update_template_not_found(self):
template_id = "foo"
rv = TEST_CLIENT.patch(f"/templates/{template_id}", json={})
result = rv.json()
expected = {
"message": "The specified template does not exist",
"code": "TemplateNotFound",
}
self.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_template_not_found(self):\n template_id = \"foo\"\n\n rv = TEST_CLIENT.get(f\"/templates/{template_id}\")\n result = rv.json()\n\n expected = {\n \"message\": \"The specified template does not exist\",\n \"code\": \"TemplateNotFound\",\n }\n ... | [
"0.8741455",
"0.8201116",
"0.8021696",
"0.7956505",
"0.79333884",
"0.7814681",
"0.7746407",
"0.76908815",
"0.7687622",
"0.75513756",
"0.7548562",
"0.75406986",
"0.7494457",
"0.7468443",
"0.7465183",
"0.7465183",
"0.7441508",
"0.743449",
"0.7427313",
"0.7424917",
"0.7410876",
... | 0.7875378 | 5 |
Should return a http error 404 and a message 'specified template does not exist'. | def test_delete_template_not_found(self):
template_id = "unk"
rv = TEST_CLIENT.delete(f"/templates/{template_id}")
result = rv.json()
expected = {
"message": "The specified template does not exist",
"code": "TemplateNotFound",
}
self.assertDictEq... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_template_not_found(self):\n template_id = \"foo\"\n\n rv = TEST_CLIENT.get(f\"/templates/{template_id}\")\n result = rv.json()\n\n expected = {\n \"message\": \"The specified template does not exist\",\n \"code\": \"TemplateNotFound\",\n }\n ... | [
"0.8741283",
"0.8202523",
"0.80220366",
"0.7955503",
"0.7934539",
"0.78754866",
"0.7813631",
"0.7689857",
"0.76870793",
"0.7550237",
"0.75474787",
"0.7539923",
"0.74933916",
"0.74672675",
"0.74641067",
"0.74641067",
"0.74405396",
"0.74334157",
"0.74267185",
"0.7423984",
"0.74... | 0.77468604 | 7 |
Get the coordinates of the cell that pt = (x,y) falls in. | def get_cell_coords(pt):
return int(pt[0] // a), int(pt[1] // a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cell_coords(self, pt):\n\n\t return int(pt[0] // self.a), int(pt[1] // self.a)",
"def get_xy(self, x, y):\r\n\t\treturn self.grid[y, x]",
"def cell_index(self, coord):\n\n for x in range(len(self.cell_x)):\n if coord[0] >= self.cell_x[x] and coord[0] <= self.cell_x[x] + self.cell_s... | [
"0.8275171",
"0.7619234",
"0.7504589",
"0.73647934",
"0.7238733",
"0.7114471",
"0.7106591",
"0.6987829",
"0.69733703",
"0.69653416",
"0.69414",
"0.6889359",
"0.6862875",
"0.6858249",
"0.68545693",
"0.6846717",
"0.68415534",
"0.6824136",
"0.6803303",
"0.67963445",
"0.6751741",... | 0.8010507 | 1 |
Return the superoperator Lindblad term of the Lindblad operator `C` Return ``SPre(C) SPost(C.adjoint()) (1/2) santi_commutator(C.adjoint()C)``. These are the superoperators | def lindblad(C):
if is_scalar(C):
return ZeroSuperOperator
return SPre(C) * SPost(C.adjoint()) - (sympyOne / 2) * anti_commutator(
C.adjoint() * C
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neg__(self):\n return type(self)(self.parent(), self._simplify(-self._express))",
"def seepage_from_superoperator(U):\n if U.type=='oper':\n sump = 0\n for i_list in [[0,2],[1,2],[2,0],[2,1],[2,2]]:\n for j_list in [[0,2],[1,2],[2,0],[2,1],[2,2]]:\n bra_i =... | [
"0.5604684",
"0.54941183",
"0.5458069",
"0.54444814",
"0.52984166",
"0.52971745",
"0.52864414",
"0.5285542",
"0.5270501",
"0.5242228",
"0.5215609",
"0.5205951",
"0.5193834",
"0.51228446",
"0.51023436",
"0.5061484",
"0.50338817",
"0.5018532",
"0.5006617",
"0.49908182",
"0.4980... | 0.75950086 | 0 |
r"""Return the Liouvillian superoperator associated with `H` and `Ls` | def liouvillian(H, Ls=None):
if Ls is None:
Ls = []
elif isinstance(Ls, Matrix):
Ls = Ls.matrix.ravel().tolist()
summands = [
-I * commutator(H),
]
summands.extend([lindblad(L) for L in Ls])
return SuperOperatorPlus.create(*summands) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seepage_from_superoperator(U):\n if U.type=='oper':\n sump = 0\n for i_list in [[0,2],[1,2],[2,0],[2,1],[2,2]]:\n for j_list in [[0,2],[1,2],[2,0],[2,1],[2,2]]:\n bra_i = qtp.tensor(qtp.ket([i_list[0]], dim=[3]),\n qtp.ket([i_list[1]]... | [
"0.66157997",
"0.6448992",
"0.6081125",
"0.6070775",
"0.5854614",
"0.558322",
"0.552592",
"0.5465405",
"0.5462971",
"0.52896434",
"0.5233691",
"0.5229577",
"0.5228568",
"0.52004325",
"0.5197161",
"0.51892775",
"0.5182485",
"0.51797944",
"0.51164424",
"0.5114397",
"0.51095915"... | 0.57781404 | 5 |
Return a list of all nodes in the graph. | def nodes(self):
return list(self.keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nodes(self):\n\n return list(self.graph.nodes)",
"def get_node_list(self):\n return [[node] for node in self.graph.nodes]",
"def nodes(self):\n nodes = list()\n for node in self._nodes:\n if isinstance(node, Graph):\n nodes += node.nodes\n ... | [
"0.8472086",
"0.8338669",
"0.83107734",
"0.83003837",
"0.82076037",
"0.82002985",
"0.8135488",
"0.81194836",
"0.8071171",
"0.80481184",
"0.8026572",
"0.7999312",
"0.79447746",
"0.7841381",
"0.7841381",
"0.7815081",
"0.77605134",
"0.7730046",
"0.77066123",
"0.7670032",
"0.7667... | 0.7293438 | 41 |
Add a new edge to the graph. connecting the node containing 'val1' and the node containing 'val2'. If either val1 or val2 are not already present in the graph, they should be added. If an edge already exists, overwrite it. | def add_edge(self, val1, val2, weight=0):
self.setdefault(val1, {})
self.setdefault(val2, {})
if val2 not in self[val1]:
self[val1][val2] = weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, val1, val2):\n if val1 not in self._g:\n self.add_node(val1)\n if val2 not in self._g:\n self.add_node(val2)\n if val2 == val1:\n raise ValueError('Cannot have a self-referential edge.')\n if val2 in self._g[val1]:\n self._g... | [
"0.8606805",
"0.8387147",
"0.763467",
"0.74387056",
"0.7204296",
"0.7203375",
"0.71598744",
"0.71544975",
"0.7053013",
"0.7027295",
"0.70252305",
"0.7019469",
"0.70174515",
"0.69757086",
"0.69120944",
"0.6901864",
"0.6885757",
"0.6885566",
"0.68544376",
"0.6847653",
"0.681570... | 0.77042204 | 2 |
True if node containing 'val' is in the graph, False if not. | def has_node(self, val):
return val in self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_node(self, val):\n return val in self._g",
"def contain(graph, value):\n for node in graph:\n if node.value == value:\n return True\n\n return False",
"def exists(self, val):\n if val == self.val:\n return True\n if val < self.val and self.left:\n... | [
"0.8717857",
"0.75156194",
"0.71927726",
"0.70918417",
"0.7081533",
"0.674753",
"0.67297935",
"0.66340816",
"0.66089153",
"0.6538612",
"0.6538612",
"0.65146697",
"0.63801897",
"0.6296466",
"0.6280682",
"0.62758595",
"0.62709814",
"0.6250638",
"0.6247763",
"0.62336236",
"0.623... | 0.8466136 | 2 |
Return the list of all nodes connected to the node containing. 'Val' by edges; raises an error if val is not in the graph. | def neighbors(self, val):
if val in self:
return list(self[val].keys())
else:
raise ValueError('Value not in graph') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbors(self, val):\n if val in self._g:\n return self._g[val]\n else:\n raise ValueError('Node not in graph')",
"def nodes(self):\n\n return list(set(self._graph.keys() + [x for x in itertools.chain.from_iterable(self._graph.values())]))",
"def get_neighbours(s... | [
"0.6591919",
"0.6460177",
"0.62699753",
"0.61977684",
"0.6159545",
"0.6147275",
"0.6131371",
"0.6077147",
"0.6045097",
"0.6038219",
"0.6025909",
"0.6000624",
"0.59691715",
"0.59526867",
"0.5949424",
"0.5930631",
"0.5928426",
"0.58593196",
"0.58513683",
"0.58118176",
"0.577738... | 0.6982369 | 0 |
Determine if two elements from gates' matrices are equal. This is to be used in __eq__ method when comparing matrices elementwise. | def _are_matrix_elements_equal(element, another_element):
difference = sympy.N(sympy.expand(element) - sympy.expand(another_element))
try:
return np.allclose(
float(sympy.re(difference)) + 1j * float(sympy.im(difference)), 0
)
except TypeError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_equal(self, g, a, b):\n return self.matrix[a][b] == g[a][b]",
"def is_equal(self, a, b):\n return a.X[0] == b.X[0]",
"def IsEqual(*args, **kwargs):\n return _gdi_.GraphicsMatrix_IsEqual(*args, **kwargs)",
"def __eq__(self, other):\n return np.all(self.grid == other.grid) an... | [
"0.8073091",
"0.773882",
"0.76414824",
"0.75366604",
"0.7464264",
"0.74062115",
"0.7390346",
"0.7357049",
"0.73563695",
"0.72895056",
"0.72576296",
"0.7208506",
"0.7165344",
"0.71389234",
"0.71205527",
"0.7108382",
"0.707198",
"0.70695335",
"0.7069317",
"0.7058517",
"0.704872... | 0.74924386 | 4 |
Yield successive nsized chunks from l. | def batches(l, n):
for i in xrange(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038751",
"0.7924752",
"0.7923082",
"0.78850657",
"0.78771824",
"0.7815519",
"0.77652335",
"0.775546",
"0.77440816",
"0.77313656",
"0.77284646",
"0.77244157",
"0.770246",
"0.76888484",
"0.76888484",
"0.766384",
"0.7656689",
"0.7655605",
"0.7655605",
"0.76455575",
"0.764555... | 0.0 | -1 |
Returns the message encapsulated in a resilient_circuits.StatusMessage object | def status_message(message):
return StatusMessage(message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_message(self) -> str:\n return pulumi.get(self, \"status_message\")",
"def status_message(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"status_message\")",
"def status_message(self) -> Optional[str]:\n return pulumi.get(self, \"status_message\")",
"def getMessage():... | [
"0.7362105",
"0.7279062",
"0.7173974",
"0.7146777",
"0.7031653",
"0.69117224",
"0.69117224",
"0.68954086",
"0.6873813",
"0.6873813",
"0.68346554",
"0.68346554",
"0.68234783",
"0.68154335",
"0.6803702",
"0.67414486",
"0.67414486",
"0.67414486",
"0.67414486",
"0.67414486",
"0.6... | 0.72227 | 2 |
Returns True if at least one of the digits of k is a 7, False otherwise. >>> has_seven(3) False >>> has_seven(7) True >>> has_seven(2734) True >>> has_seven(2634) False >>> has_seven(734) True >>> has_seven(7777) True | def has_seven(k):
if k % 10 == 7:
return True
else:
if k<10:
return False
return has_seven(k//10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_seven(k):\n\tif k % 10 == 7:\n\t\treturn True\n\telif k < 10:\n\t\treturn False\n\telse:\n\t\treturn has_seven(k // 10)",
"def has_seven(k):\n if k == 0:\n return False\n else:\n if k%10 == 7:\n return True\n return has_seven(k//10)",
"def has_seven(k):\n if k %... | [
"0.89323646",
"0.8716972",
"0.86909974",
"0.86909974",
"0.86909974",
"0.6201881",
"0.58182603",
"0.5787132",
"0.5744597",
"0.5732898",
"0.55541635",
"0.55484676",
"0.5536399",
"0.5535901",
"0.5501019",
"0.54364717",
"0.5353493",
"0.5331975",
"0.533103",
"0.53261024",
"0.53200... | 0.870721 | 2 |
load requirements from a pip requirements file | def parse_requirements(filename):
lines = (line.strip() for line in open(filename))
return [line.strip() for line in lines if line and not line.strip().startswith("#")] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_requirements():\n reqs_path = path.join('.', 'requirements.txt')\n with open(reqs_path, 'r') as f:\n requirements = [line.rstrip() for line in f]\n return requirements",
"def parse_requirements_from_pipfile():\n lineiter = (line.strip() for line in open('Pipfile'))\n requirements_p... | [
"0.7206639",
"0.7191491",
"0.7187297",
"0.7138445",
"0.7138277",
"0.70911366",
"0.70401156",
"0.70233893",
"0.70084476",
"0.69288045",
"0.6917543",
"0.69035953",
"0.69035953",
"0.6900558",
"0.6823832",
"0.6820074",
"0.6802556",
"0.67198455",
"0.6716624",
"0.6715886",
"0.66736... | 0.0 | -1 |
Call the method 'init_app' to register the extensions in the flask.Flask object passed as parameter. | def register_extensions(app):
app = extensions.create_admin(app)
extensions.db.init_app(app)
extensions.jwt.init_app(app) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_app(app):\n app.load_extension(__name__)",
"def init_extensions(app: Flask):\n\n global celery\n celery = make_celery(app)\n csrf.init_app(app)\n db.init_app(app)\n lm.init_app(app)\n mail.init_app(app)\n migrate.init_app(app, db)",
"def register_extensions(app):\n bcrypt.in... | [
"0.8419003",
"0.8123265",
"0.78876823",
"0.78860533",
"0.7876395",
"0.7791846",
"0.77611125",
"0.7569908",
"0.7517068",
"0.7115238",
"0.70913905",
"0.7017221",
"0.7005334",
"0.69883406",
"0.69103885",
"0.6856983",
"0.6853611",
"0.68268174",
"0.68209267",
"0.681811",
"0.675095... | 0.7511938 | 9 |
Load tokens from yaml file path | def load_tokens(tokens_fp):
with open(tokens_fp, "r") as tokens:
tokens = yaml.safe_load(tokens)
return tokens | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_token():\n with open(\"config.yaml\") as f:\n config = yaml.load(f, Loader=yaml.FullLoader)\n return config[\"token\"]",
"def LoadYaml(path):\n #NOTE(g): Import is done here, instead of the top of the file, to not require this module if it is not used\n import yaml\n \n fp = None\n try... | [
"0.71427613",
"0.65120596",
"0.6455739",
"0.6424273",
"0.63995874",
"0.6386262",
"0.6367284",
"0.6352151",
"0.63420117",
"0.6313702",
"0.6280708",
"0.6266853",
"0.6261813",
"0.6243691",
"0.62433827",
"0.6242728",
"0.6218907",
"0.6200927",
"0.62001157",
"0.61915505",
"0.618853... | 0.7585266 | 0 |
Get random index and token from token_key of n_pairs. | def get_idx_tok(seq_len, token_dict, token_key, n_pairs):
return [
(
random.choices(range(seq_len), k=1)[0],
random.choices(token_dict[token_key], k=1)[0],
)
for _ in range(n_pairs)
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tokens(seq_len, token_dict, token_key, n_tokens):\n return random.choices(token_dict[token_key], k=n_tokens)",
"def generate_token(self, prev_tokens=None):\n n = self._n\n prev_tokens = prev_tokens or ()\n\n assert len(prev_tokens) == n - 1\n\n probs = self._sorted_probs[pr... | [
"0.7295682",
"0.6243557",
"0.62268186",
"0.6065969",
"0.60341203",
"0.60270005",
"0.5956013",
"0.5918126",
"0.58158475",
"0.5652525",
"0.5610012",
"0.55383086",
"0.55345184",
"0.55214816",
"0.5520364",
"0.54750067",
"0.54639715",
"0.5460754",
"0.5436094",
"0.5425711",
"0.5410... | 0.8430134 | 0 |
Get random list of tokens. | def get_tokens(seq_len, token_dict, token_key, n_tokens):
return random.choices(token_dict[token_key], k=n_tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tokens(self) -> List[str]:\n return self.tokens",
"def tokens(self):\n # type: () -> List[Token]\n return self._tokens",
"def getTokens(self):\n list = []\n for i in range(self.startIdx, self.endIdx + 1):\n token = self.sentence[i]\n list.append(token)\n... | [
"0.70490056",
"0.66292953",
"0.65045255",
"0.6496137",
"0.64705616",
"0.64627004",
"0.6452341",
"0.6452341",
"0.6452341",
"0.64327866",
"0.63970196",
"0.63891554",
"0.6357141",
"0.63449967",
"0.63168806",
"0.62767035",
"0.62677866",
"0.6198683",
"0.61903507",
"0.61640286",
"0... | 0.70597094 | 0 |
Generate a simple toy dataset. | def get_simple_dataset(seq_len, uid_len, uid_colname, count_dict, tokens):
cat_lst = []
if "n_ppp_adverse" in count_dict:
ppp = get_sequences(
adverse=1,
helper=1,
unhelper=0,
seq_len=seq_len,
label=1,
uid_len=uid_len,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autogen_dataset():\n return TabularDataset.autogen('tests/data/dummy_tabular/train.csv',\n seed=42,\n sep=',')",
"def create_data_bunch(data, test=False):\r\n examples = [t[0] for t in data if t[0]]\r\n target = np.zeros((len(data),),... | [
"0.6893019",
"0.6851491",
"0.6676897",
"0.66609156",
"0.65895075",
"0.6586603",
"0.6567052",
"0.6552706",
"0.654943",
"0.651481",
"0.65125936",
"0.640397",
"0.6397541",
"0.63666123",
"0.6334864",
"0.632577",
"0.6286122",
"0.6271696",
"0.6265446",
"0.625999",
"0.62585014",
"... | 0.0 | -1 |
Serve the index HTML | def algebra742live(lti=lti):
user = db.session.query(User).filter_by(lti_user_id=lti.name).first()
if user:
return render_template(ROOMS[0].template)
else:
form = UserInfoForm()
return render_template('GetUserInfo.html', lti=lti, form=form) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n single = os.path.join(\n os.path.dirname(os.path.abspath(__file__)),\n 'index.html')\n return serve_file(single)",
"def index():\n return render_template('index.html'), 200",
"def index():\n\n return render_template(\"index.html\"), 200",
"def inde... | [
"0.8685354",
"0.85523725",
"0.84890985",
"0.8468328",
"0.8451884",
"0.82966554",
"0.8292779",
"0.82886124",
"0.82686514",
"0.82686514",
"0.82643247",
"0.82445365",
"0.82445365",
"0.8232638",
"0.8232638",
"0.8232638",
"0.8232638",
"0.8232638",
"0.8232638",
"0.8232638",
"0.8232... | 0.0 | -1 |
Raise a ValueError if an array has multiple attributes | def assert_single_attribute(array):
if len(array.att_names) > 1:
raise ValueError("Array must have a single attribute: %s" % array.name)
return array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_common(ndarray, name):\n\tvalidate_ndarray(ndarray,(np.float, np.int), (2,) , name)",
"def _validate_array(t):\n basetype = t.type\n if is_array(basetype):\n raise ArrayOfArrayError(t)\n validate(basetype)",
"def validate_array_arg(array_arg: List[str], arg_name: str, arg_options: ... | [
"0.68142027",
"0.645691",
"0.61964995",
"0.61891514",
"0.61605674",
"0.6159394",
"0.6040362",
"0.603997",
"0.60162383",
"0.59871244",
"0.5964127",
"0.59607434",
"0.58659923",
"0.58625484",
"0.5862297",
"0.58392847",
"0.58179355",
"0.57899946",
"0.57829016",
"0.57665306",
"0.5... | 0.69431514 | 0 |
Coerce arrays into the same shape if possible, or raise a ValueError | def as_same_dimension(*arrays):
ndim = arrays[0].ndim
for a in arrays:
if a.ndim == ndim:
continue
# XXX could try broadcasting here
raise ValueError("Invalid array dimensions: %s vs %s" % (ndim, a.ndim))
return arrays | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_and_transform_input(self, data):\n if isinstance(data, list):\n if np.array(data).shape == (len(data),):\n if len(data) == 1:\n data = np.array(data).reshape(1, 1)\n data = np.array(data).reshape(len(data), 1)\n else:\n ... | [
"0.6480889",
"0.6465306",
"0.64563537",
"0.63950306",
"0.6394052",
"0.63755566",
"0.6365454",
"0.63610464",
"0.6266464",
"0.62661624",
"0.6243125",
"0.6243125",
"0.621831",
"0.61841834",
"0.6150108",
"0.61400056",
"0.6132569",
"0.5925925",
"0.59137213",
"0.591158",
"0.5899492... | 0.60694075 | 17 |
Return an array shape, even if the array is unbound. If the array is unbound, the shape is guaranteed to contain the data | def coerced_shape(array):
if array.shape is not None:
return array.shape
r = array.eval().dimensions().project('low', 'high').toarray()
shp = tuple(np.maximum(r['high'] - r['low'] + 1, 0))
return shp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shape(self,squeeze=True):\n return np.shape(self.getData(squeeze=squeeze))",
"def shape(self):\n\n self._check_assigned()\n\n if (\n self.lazy\n and self.transformer is not None\n and hasattr(self.transformer, \"get_transformed_shape\")\n ):\n ... | [
"0.6846602",
"0.6791698",
"0.6767298",
"0.67537344",
"0.6657868",
"0.66476953",
"0.6590128",
"0.6478428",
"0.646469",
"0.6462793",
"0.6430986",
"0.6411982",
"0.63831025",
"0.63279676",
"0.63279676",
"0.63279676",
"0.63185173",
"0.6310806",
"0.63008183",
"0.63008183",
"0.63008... | 0.65767586 | 7 |
Add dummy dimensions as needed to an array, so that it is at least ndimensional. | def right_dimension_pad(array, n):
if array.ndim >= n:
return array
nadd = n - array.ndim
atts = [_new_attribute_label('_dim%i' % i, array) for i in range(nadd)]
apply_args = [x for item in enumerate(atts) for x in item[::-1]]
ds = array.datashape.copy()
ds.dim_low = list(ds.dim_low) +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_dummy_batch_dim(x):\n return x.view(1, x.size()[0], x.size()[1], x.size()[2])",
"def _expand(x, ndim, axis=0):\n while F.rank(x) < ndim:\n x = F.expand_dims(x, axis)\n return x",
"def expand_dims(array):\n return array[np.newaxis, np.newaxis, ...]",
"def nd_expand_dims(x, n=1, befo... | [
"0.69711435",
"0.6289555",
"0.626369",
"0.62120557",
"0.6187597",
"0.6177333",
"0.61354893",
"0.6106649",
"0.60983765",
"0.5934457",
"0.5933046",
"0.59297705",
"0.5927637",
"0.589074",
"0.5861947",
"0.585611",
"0.5836829",
"0.5809025",
"0.57942003",
"0.5784004",
"0.5776339",
... | 0.5432618 | 47 |
Add dummy dimensions as needed to an array, so that it is at least ndimensional. | def left_dimension_pad(array, n):
if array.ndim >= n:
return array
nadd = n - array.ndim
atts = [_new_attribute_label('_dim%i' % i, array) for i in range(nadd)]
apply_args = [x for item in enumerate(atts) for x in item[::-1]]
ds = array.datashape.copy()
ds.dim_low = ([0] * nadd) + list(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_dummy_batch_dim(x):\n return x.view(1, x.size()[0], x.size()[1], x.size()[2])",
"def _expand(x, ndim, axis=0):\n while F.rank(x) < ndim:\n x = F.expand_dims(x, axis)\n return x",
"def expand_dims(array):\n return array[np.newaxis, np.newaxis, ...]",
"def nd_expand_dims(x, n=1, befo... | [
"0.6969795",
"0.62897974",
"0.6265098",
"0.6213611",
"0.61877656",
"0.6175816",
"0.61347055",
"0.6105191",
"0.6095881",
"0.5935124",
"0.593115",
"0.5927859",
"0.5927647",
"0.58896315",
"0.58607846",
"0.58557487",
"0.58357376",
"0.58073485",
"0.57940704",
"0.57841676",
"0.5777... | 0.5717845 | 22 |
Run method to start the Thread | def run(self):
for _ in range(self.num_iteration):
self.move()
time.sleep(self.speed)
if not self.is_running:
break | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n self.thread = threading.Thread(target=self._main)\n self.thread.start()\n self.running = True",
"def start_thread(self):\n self.stop_thread()\n self.running = True\n self.run_thread = threading.Thread(target=self.run, daemon=True)\n self.run_threa... | [
"0.81871223",
"0.79976916",
"0.7915911",
"0.7914365",
"0.77208835",
"0.77002895",
"0.7636529",
"0.76164496",
"0.7615356",
"0.75891584",
"0.7519211",
"0.75181556",
"0.7499789",
"0.7455604",
"0.7312862",
"0.72716194",
"0.7267445",
"0.7267445",
"0.72599614",
"0.7255353",
"0.7175... | 0.0 | -1 |
returns the UTC offset of the current user or None, if not logged in | def shn_user_utc_offset():
if auth.is_logged_in():
return db(db.auth_user.id == session.auth.user.id).select(db.auth_user.utc_offset, limitby=(0, 1)).first().utc_offset
else:
try:
offset = db().select(db.s3_setting.utc_offset, limitby=(0, 1)).first().utc_offset
except:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_utc_offset():\n timedelta = datetime.datetime.now() - datetime.datetime.utcnow()\n # XXX: `return -time.timezone`?\n return timedelta.total_seconds()",
"def get_timezone():\n localTimezone = request.args.get('timezone')\n if localTimezone in pytz.all_timezones:\n return localTimezon... | [
"0.7235937",
"0.6507789",
"0.6406071",
"0.6197284",
"0.6137172",
"0.6127582",
"0.6127582",
"0.6125625",
"0.6113585",
"0.6096486",
"0.60768145",
"0.60034406",
"0.59995973",
"0.5990449",
"0.5939147",
"0.5925929",
"0.5900606",
"0.5869681",
"0.58428746",
"0.5806712",
"0.5803286",... | 0.81071174 | 0 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(RobotStateRTMsg, self).__init__(*args, **kwds)
# message fields cannot be None, assign default values for those that are
if self.time is None:
self.time = 0.
if self.q_target is None:
self.q_target = []
if self.q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.77950615",
"0.7721642",
"0.7721642",
"0.7688074",
"0.7627341",
"0.7565248",
"0.74413425",
"0.74183315",
"0.73526335",
"0.7309278",
"0.7281199",
"0.72392416",
"0.7228342",
"0.7225894",
"0.7225894",
"0.7220378",
"0.7213045",
"0.7213045",
"0.7213045",
"0.7213045",
"0.7213045"... | 0.0 | -1 |
Initializes a new MinHeap DO NOT CHANGE THIS METHOD IN ANY WAY | def __init__(self, start_heap=None):
self.heap = DynamicArray()
# populate MH with initial values (if provided)
# before using this feature, implement add() method
if start_heap:
for node in start_heap:
self.add(node) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n # Initialize a new binary min heap to store the items\n self.heap = MinHeap()",
"def __init__(self, start_heap=None):\n self.heap = DynamicArray()\n\n # populate MinHeap with initial values\n if start_heap:\n for node in start_heap:\n ... | [
"0.81102544",
"0.7927081",
"0.7638438",
"0.7586296",
"0.7536302",
"0.7512964",
"0.7489935",
"0.74239755",
"0.73951316",
"0.7392049",
"0.73760784",
"0.73196924",
"0.7230348",
"0.7217382",
"0.72097415",
"0.7163924",
"0.71604306",
"0.7148502",
"0.7135269",
"0.7135269",
"0.713526... | 0.70922065 | 22 |
Return True if no elements in the heap, False otherwise DO NOT CHANGE THIS METHOD IN ANY WAY | def is_empty(self) -> bool:
return self.heap.length() == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty(heap):\n return size(heap) == 0",
"def empty(self):\n return 0 >= len(self._heap)",
"def is_empty(self):\n return len(self.__heap) == 0",
"def is_empty(self):\n return not bool(self._heap)",
"def is_empty(self):\n return self.heap_size <= 0",
"def is_empty(self):\... | [
"0.8376278",
"0.80944407",
"0.7983365",
"0.7968602",
"0.7909276",
"0.7542171",
"0.74225754",
"0.734104",
"0.7321196",
"0.6971609",
"0.69104576",
"0.68850213",
"0.6884418",
"0.68811506",
"0.68744683",
"0.6844022",
"0.6831663",
"0.6777573",
"0.6776539",
"0.6773411",
"0.6770908"... | 0.79376173 | 5 |
Add a new element to heap and perculate it down | def add(self, node: object) -> None:
end_index=self.heap.length()
parent_index=((end_index-1)//2)
if end_index==0:
self.heap.append(node)
else:
self.heap.append(node)
while self.heap.get_at_index(end_index)<self.heap.get_at_index(parent_index):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heappush(heap, item):\n heap.append(item)\n _siftdown(heap, 0, len(heap)-1)",
"def heappush(heap, item):\n pass",
"def heappush(heap, item):\n heap.append(item)\n Heap.siftdown(heap, 0, len(heap) - 1)",
"def put(self, element):\n self.heap.append(element)\n # sift up ... | [
"0.78720164",
"0.7870332",
"0.7848792",
"0.7752735",
"0.76961213",
"0.7650148",
"0.7617099",
"0.75450814",
"0.75425875",
"0.753416",
"0.7508013",
"0.7471515",
"0.7463439",
"0.74573076",
"0.7446066",
"0.73714477",
"0.7343224",
"0.7341097",
"0.733858",
"0.7328739",
"0.7287592",... | 0.7376098 | 15 |
Return the top of the minheap if empty return None | def get_min(self) -> object:
if self.is_empty()==True:
return None
return self.heap.get_at_index(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findmin(self):\n return self.heap[0] if len(self.heap) > 0 else None",
"def top(self):\n if len(self.heap) > 0:\n return self.heap[0]\n\n return None",
"def top(self):\n if len(self.heap) > 0:\n return self.heap[0]\n\n return None",
"def front(self... | [
"0.821921",
"0.8129737",
"0.8129737",
"0.79857814",
"0.7739567",
"0.7688953",
"0.7654788",
"0.7599694",
"0.7552742",
"0.7400108",
"0.7361829",
"0.7348604",
"0.73331416",
"0.72914875",
"0.726739",
"0.72481143",
"0.7197485",
"0.71349806",
"0.71264505",
"0.7076966",
"0.7065882",... | 0.8175796 | 1 |
Find the minumum index between two or one or No children. If No children returns None | def find_min_child(self,index1, index2):
try:
min1=self.heap.get_at_index(index1)
except:
min1=None
try:
min2 = self.heap.get_at_index(index2)
except:
min2 = None
if min1==None and min2==None:
return None
elif m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_child(self, index):\n if self.empty():\n return None\n if self._has_left(index):\n left = self._left(index)\n small_child = left\n if self._has_right(index):\n right = self._right(index)\n if self._data[right] < self._d... | [
"0.726821",
"0.70535606",
"0.6950649",
"0.6872264",
"0.68576646",
"0.6833978",
"0.6797497",
"0.6748043",
"0.6725259",
"0.66480803",
"0.6611291",
"0.6568514",
"0.6528594",
"0.65031785",
"0.6483043",
"0.6478143",
"0.6473378",
"0.6462083",
"0.6430465",
"0.64082557",
"0.6395964",... | 0.74338174 | 0 |
Helper function for build heap | def build_heap_helper(self, current):
if current==-1:
return
parent_index=current
min_child=self.find_min_child((parent_index * 2)+1,(parent_index * 2) + 2)
while min_child!=None:
if self.heap.get_at_index(parent_index)<self.heap.get_at_index(min_child):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_heap(data):\n size = len(data)\n for i in range(size//2, -1,-1):\n shiftDown(data, i)",
"def build_heap(arr):\n for i in range(len(arr)-1, -1, -1):\n down_heapify(arr, len(arr), i)",
"def heapify(x):\n pass",
"def build_heap(arr):\n for i in range((len(arr)//2), -1, -1)... | [
"0.8021066",
"0.799351",
"0.797472",
"0.7963422",
"0.7931183",
"0.79122627",
"0.78444237",
"0.7613649",
"0.7384708",
"0.73826665",
"0.736335",
"0.73522353",
"0.7345245",
"0.73390645",
"0.73335224",
"0.7285605",
"0.7207387",
"0.71976316",
"0.7187377",
"0.7167342",
"0.7167342",... | 0.6781146 | 51 |
Invalid Post should not redirect | def test_post(self):
self.assertEqual(200, self.resp.status_code) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_invalid(self):\n self.post_data['name'] = ''\n response = self._post()\n self.assertEquals(self.model.objects.count(), 0)\n self.assertEquals(response.status_code, 200)\n self.assertTemplateUsed(response, self.template_name)\n self.assertTrue('form' in respon... | [
"0.7081821",
"0.7000336",
"0.6909538",
"0.68235576",
"0.67811555",
"0.67154366",
"0.66632116",
"0.6583473",
"0.6551985",
"0.65508556",
"0.65191156",
"0.65137386",
"0.6511875",
"0.6500711",
"0.64963454",
"0.6489908",
"0.6479309",
"0.6477767",
"0.6476861",
"0.64455557",
"0.6442... | 0.0 | -1 |
Determine the position of the last numeric type character in a string. | def last_numeric_char(self, s):
keep = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '.'}
i = 0
not_done = True
while not_done:
if s[i] in keep:
i += 1
else:
not_done = False
if i >= len(s):
no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_number(s:str):\n array = re.findall(r'[0-9]+', s)\n if array.__len__() is 0:\n return -1\n return int(array[-1])",
"def _afterpoint(string):\n if _isnumber(string) or _isnumber_with_thousands_separator(string):\n if _isint(string):\n return -1\n else:\n ... | [
"0.746705",
"0.74052715",
"0.63275355",
"0.5900891",
"0.5883295",
"0.56339395",
"0.5601899",
"0.5597857",
"0.5596761",
"0.55881476",
"0.55680317",
"0.55602795",
"0.5547871",
"0.55259115",
"0.5523133",
"0.55198866",
"0.54571825",
"0.54560095",
"0.5445202",
"0.54442734",
"0.544... | 0.75252575 | 0 |
isLeft is true if it is a left rotation | def rotate(self,isLeft,node):
parent = node.parent
parentLeft = False
if parent != None and parent.left == node:
parentLeft = True
finalNode = node.right
if isLeft:
finalNode = node.right
oldLeft = finalNode.left
finalNode.left = no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startRotatingLeft(self,event):\n self.isRotatingLeft=True",
"def isLeft(self):\n return self.left",
"def rotate_left(self):\n if self.change_valid(dr=-1):\n self.rotate = (self.rotate-1)%4",
"def rotate_left_right(self):\n\t\treturn",
"def rotate_right_left(self):\n\t\tr... | [
"0.76729333",
"0.74126786",
"0.7173786",
"0.7159334",
"0.7138698",
"0.7134321",
"0.7127134",
"0.71151084",
"0.6965492",
"0.6887838",
"0.68622553",
"0.6817497",
"0.6817486",
"0.680325",
"0.6800991",
"0.6793223",
"0.67802763",
"0.67352176",
"0.67311877",
"0.668339",
"0.6675778"... | 0.61995023 | 48 |
Scale unit vectors to Z=unity; build FOV sides | def setup_localxyzs(self):
self.localxyzs = [sp.vscl(1.0/v[2],v) for v in self.uvlclxyzs]
self.fovsides = list()
lastxyz = self.localxyzs[-1]
for xyz in self.localxyzs:
self.fovsides.append(FOVSIDE(xyz,lastxyz))
lastxyz = xyz | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uv(vec):\n return vec / sqrt(dot(vec, vec))",
"def surfcut_points(**kwargs):\n npoints = kwargs.get( 'npoints', 240 )\n origin = kwargs.get( 'origin', vec3(0.,0.,0.)) \n normal = kwargs.get( 'normal', (np.pi/2., 0.) ) \n lims0 = kwargs.get( 'lims0', (-50., 50.) ) \n lims1 = kwargs.g... | [
"0.6463911",
"0.59198433",
"0.58021253",
"0.5769475",
"0.5721622",
"0.5700551",
"0.5693246",
"0.56921417",
"0.5665923",
"0.56577814",
"0.56494594",
"0.56465554",
"0.56436545",
"0.5607606",
"0.55910677",
"0.5575756",
"0.5559132",
"0.5534522",
"0.5534375",
"0.552748",
"0.552090... | 0.6554574 | 0 |
Scale observer velocity in the inertial frame (J2000 or ICRS) by the reciprocal of speed of light. The resulting vector can be added to unit vectors, or subtracted, to correct for stellar aberration. N.B. Stellar aberration correction is not yet implemented | def setup_stellar_aberration(self,observer_velocity_xyz):
self.v_for_stellar_aberr = sp.vscl(recip_clight,observer_velocity_xyz) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scaleTemperature(self):\n if self.currentTemp > 100.0 or self.currentTemp < 80.0:\n print(\"Rescaling velocities...\")\n for atom in range(0, self.numAtoms):\n self.atoms[atom].vx *= math.sqrt(self.temp/self.currentTemp)\n self.atoms[atom].vy *= math.s... | [
"0.60662025",
"0.605431",
"0.60036767",
"0.5973538",
"0.5959217",
"0.5907451",
"0.58928233",
"0.5876859",
"0.58722633",
"0.58391166",
"0.57901967",
"0.57874024",
"0.5787146",
"0.5757551",
"0.57506126",
"0.574746",
"0.5744059",
"0.5735033",
"0.5732672",
"0.569169",
"0.56734324... | 0.5463022 | 43 |
Is this side to the right of the vector argument v, with Z=unity, or does this side pass over the vector; exclude the maximum y of this side. | def right_of(self,v):
x,y = v[0:2]
if y < self.ylo: return False
if y >= self.yhi: return False
if x > self.xhi: return False
if x > ((y * self.m) + self.b): return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right (x):\n\n return Sinary(side(x.v,0))",
"def isOnInteriorSide(self, v):\n n = self.normalVect()\n return n.dotProduct(vector(self.vertices[0]) - vector(v)) > 0",
"def is_vertical(self):\n return self.slope == float(\"+inf\")",
"def is_collided_vertical(self):\n # boun... | [
"0.6458465",
"0.6015575",
"0.596416",
"0.5810247",
"0.5767788",
"0.57629657",
"0.5744676",
"0.57361627",
"0.5719245",
"0.5693986",
"0.56901187",
"0.5663075",
"0.56552845",
"0.56443095",
"0.5642051",
"0.5642051",
"0.55842423",
"0.5567654",
"0.5554976",
"0.55539495",
"0.5541316... | 0.6619748 | 0 |
I is normal distribution integral from inf to x | def example2(N, x):
X = np.random.randn(N)
I_estm = np.mean([0 if s>=x else 1 for s in X])
print("simulation estimate:", I_estm)
print("true value: ", norm.cdf(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integral_generator(yi, mi, vi, yi_m):\n def f(fi_star):\n #exponent = np.exp(-(1./(2*vi))*np.square(mi-fi_star))\n #from GPy.util.misc import safe_exp\n #exponent = safe_exp(exponent)\n #res = safe_exp(self.logpdf(fi_star, yi, yi_m))*expone... | [
"0.68295634",
"0.65704775",
"0.655522",
"0.6491513",
"0.643708",
"0.6410075",
"0.62702954",
"0.62040675",
"0.6160205",
"0.6160205",
"0.61594796",
"0.61475116",
"0.6125183",
"0.6112249",
"0.61106324",
"0.61097336",
"0.6038832",
"0.60224235",
"0.59947735",
"0.59759116",
"0.5966... | 0.5553721 | 90 |
Convert a healpix component_type object to a point component_type. Multiply by the pixel area and optionally convert to Jy. This effectively treats diffuse pixels as unresolved point sources by integrating over the pixel area. Whether or not this is a good assumption depends on the nside and the resolution of the teles... | def healpix_to_point(
self, to_jy=True, run_check=True, check_extra=True, run_check_acceptability=True
):
if self.component_type != "healpix":
raise ValueError(
"This method can only be called if component_type is 'healpix'."
)
try:
import... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _point_to_healpix(\n self, to_k=True, run_check=True, check_extra=True, run_check_acceptability=True\n ):\n if (\n self.component_type != \"point\"\n or self.nside is None\n or self.hpx_inds is None\n or self.hpx_order is None\n ):\n ... | [
"0.5127937",
"0.5002298",
"0.4930781",
"0.48469242",
"0.4836677",
"0.4817874",
"0.47951376",
"0.47827953",
"0.47627622",
"0.47310948",
"0.46713084",
"0.46195674",
"0.4587737",
"0.4583776",
"0.4581509",
"0.45701343",
"0.45461267",
"0.4543837",
"0.45360982",
"0.45268637",
"0.45... | 0.5977815 | 0 |
Get the path to the data | def get_repository_data():
return get_path(get_repository_dir(), 'data') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n return self._data_file",
"def data_path(self):\n raise NotImplementedError",
"def dataPath(self):\n return ''",
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def get_data_path():\n\t... | [
"0.8647245",
"0.86116946",
"0.84613854",
"0.8424446",
"0.83875954",
"0.8314632",
"0.81026804",
"0.79134333",
"0.78372663",
"0.77591395",
"0.76801246",
"0.76063985",
"0.75899416",
"0.75493073",
"0.7539609",
"0.7532704",
"0.7504534",
"0.7450742",
"0.7449613",
"0.73702765",
"0.7... | 0.7265833 | 34 |
Get the path to the latex directory | def get_repository_latex():
return get_path(get_repository_dir(), 'latex') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf_path() -> Path:\n return Path(__file__).parent / 'data' / 'ocr.pdf'",
"def get_html_theme_path():\n cur_dir = path.abspath(path.dirname(path.dirname(__file__)))\n return cur_dir",
"def rst_path(self):\n return Path(self.dir_path, self.index_file + \".rst\").abspath",
"def get_reposito... | [
"0.6996405",
"0.63381064",
"0.6252254",
"0.61662763",
"0.6156468",
"0.6140375",
"0.61115396",
"0.61087906",
"0.60359514",
"0.6003975",
"0.5955318",
"0.5932517",
"0.59262174",
"0.591661",
"0.59151834",
"0.5913625",
"0.5898697",
"0.58961016",
"0.58828765",
"0.58749473",
"0.5869... | 0.73446274 | 0 |
Chunk up a list of items | def chunk_list(items, chunk_size=25):
start = 0
for end in range(chunk_size, len(items) + chunk_size, chunk_size):
chunk = items[start:end]
start = end
yield chunk | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(item_list, n_items):\n for i in range(0, len(item_list), n_items):\n yield item_list[i : i + n_items]",
"def split_chunks(item_list, num_items_in_list):\n for item in range(0, len(item_list), num_items_in_list):\n # Create an index range for item_list of num_items_in_list i... | [
"0.821057",
"0.8010264",
"0.79643106",
"0.7787986",
"0.7784484",
"0.7767749",
"0.76466465",
"0.75978553",
"0.75934786",
"0.7579813",
"0.7483308",
"0.744119",
"0.74259806",
"0.74220103",
"0.74026865",
"0.73680586",
"0.73579895",
"0.7352973",
"0.7342875",
"0.7319974",
"0.728333... | 0.80896586 | 1 |
Sets the start of this MolecularLocation. | def start(self, start):
if start is None:
raise ValueError("Invalid value for `start`, must not be `None`") # noqa: E501
if start is not None and start < 0: # noqa: E501
raise ValueError("Invalid value for `start`, must be a value greater than or equal to `0`") # noqa: E501
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_start(self, start_line):\n self.__start_line = start_line",
"def _set_start(self, coordinates):\n self._start = coordinates",
"def start(self, start: pos.Pos) -> None:\n self.__start = start",
"def setStart(self, *args):\n return _libsbml.LineSegment_setStart(self, *args)"... | [
"0.77682066",
"0.75922024",
"0.75444",
"0.74842614",
"0.7300423",
"0.72246486",
"0.72246486",
"0.72246486",
"0.72246486",
"0.6944823",
"0.69433314",
"0.68229556",
"0.6782505",
"0.6709949",
"0.6703286",
"0.6552599",
"0.65284353",
"0.6441619",
"0.6441619",
"0.6441619",
"0.64416... | 0.64505345 | 17 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, MolecularLocation):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088463",
"0.8088463",
"0.80553037",
"0.7983272",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
"0.7966844",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Returns a central crop for the specified size of an image. | def central_crop(image, crop_size):
with tf.variable_scope('CentralCrop'):
target_width, target_height = crop_size
image_height, image_width = tf.shape(image)[0], tf.shape(image)[1]
assert_op1 = tf.Assert(
tf.greater_equal(image_height, target_height),
['image... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _central_crop(image, crop_size):\r\n shape = tf.shape(input=image)\r\n height, width = shape[0], shape[1]\r\n\r\n amount_to_be_cropped_h = (height - crop_size[0])\r\n crop_top = amount_to_be_cropped_h // 2\r\n amount_to_be_cropped_w = (width - crop_size[1])\r\n crop_left = amount_to_be_croppe... | [
"0.77718234",
"0.75201434",
"0.74777675",
"0.746495",
"0.73952633",
"0.7302425",
"0.72671986",
"0.72339755",
"0.7224375",
"0.7146129",
"0.71335214",
"0.71233594",
"0.7108425",
"0.7011101",
"0.70108217",
"0.6931412",
"0.6847312",
"0.68183243",
"0.68002045",
"0.6780886",
"0.671... | 0.7879414 | 0 |
Node constructor A node data object | def __init__(self, p=None, l=None, r=None, d=None):
self.parent = p
self.left = l
self.right = r
self.data = d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data, node):\n self.data = data\n self.node = node",
"def __init__(self, data, node):\n self.data = data\n self.node = node # This is the data structure which holds the data for this node, e.g. lat, lon, etc.",
"def __init__(self):\n self.node = None\n ... | [
"0.8630294",
"0.8213249",
"0.80684876",
"0.76269317",
"0.76221865",
"0.755696",
"0.755696",
"0.74443734",
"0.74327767",
"0.7412797",
"0.73595417",
"0.735478",
"0.734892",
"0.7282429",
"0.7250602",
"0.7219047",
"0.71794254",
"0.7137113",
"0.71167076",
"0.70764214",
"0.70729595... | 0.0 | -1 |
Data constructor A list of values assigned to object's attributes | def __init__(self, val1, val2):
self.a1 = val1
self.a2 = val2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data):\n # loop through data\n for x in data:\n # create pitches list if attribute name is pitches\n if x == 'pitches':\n self.pitches = []\n for y in data[x]:\n self.pitches.append(Pitch(y))\n else:\... | [
"0.6776637",
"0.67460704",
"0.6720386",
"0.6679947",
"0.66144055",
"0.66077894",
"0.6607623",
"0.65949",
"0.6575372",
"0.6542007",
"0.6536759",
"0.65347445",
"0.6527079",
"0.6510175",
"0.64976746",
"0.6478579",
"0.6454469",
"0.64413464",
"0.6435857",
"0.6434245",
"0.64259815"... | 0.59268916 | 100 |
Return the argmax over the Q values | def act(self, q_values, *args, **kwargs):
return np.array([np.argmax(q_values)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_q_argmax(self):\n self.cur_head = self._sess.run(self.ucb_net._P_argmax,\n {self.state_ph: self.state,\n self.ucb_A_ph: self.ucb_A,\n self.ucb_b_ph: self.ucb_b})[0]\n x = self._sess.run(self._... | [
"0.79589105",
"0.7455329",
"0.7177335",
"0.716488",
"0.7096171",
"0.70615786",
"0.69575363",
"0.68467575",
"0.6819715",
"0.6806031",
"0.6788897",
"0.6746189",
"0.6725206",
"0.6720967",
"0.66745734",
"0.66498977",
"0.66177636",
"0.6602889",
"0.65944433",
"0.659224",
"0.6581768... | 0.7935174 | 1 |
Sample an action from a Gaussian distribution with the predicted mean. | def act(self, mean, *args, **kwargs):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self, args):\n mean, stddev = args\n dist = tfp.distributions.Normal(loc=mean, scale=stddev)\n action = dist.sample(1)\n action = K.clip(action,\n self.env.action_space.low[0],\n self.env.action_space.high[0])\n return acti... | [
"0.6960811",
"0.6824122",
"0.66926885",
"0.6673003",
"0.65869033",
"0.656521",
"0.65417546",
"0.6523377",
"0.6517124",
"0.6481544",
"0.64731497",
"0.64699954",
"0.64670193",
"0.64302975",
"0.64125437",
"0.6383714",
"0.63717735",
"0.6348251",
"0.6346594",
"0.63103276",
"0.6268... | 0.5795867 | 77 |
Instantiate the Gaussian policy. | def __init__(self, start_epsilon, end_epsilon, decay_steps, decay_schedule='const',
min_action=None, max_action=None):
self.min_action = min_action
self.max_action = max_action
self.epsilon_updater = common.ParameterUpdater(
start_epsilon, end_epsilon, decay_steps, d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, sigmas, start=None):\n Proposal.GaussianProposal.__init__(self, unpackage(sigmas), start)",
"def gaussian_prior(self):\n self.prior = sps.multivariate_normal(self.m0,self.S0)",
"def _create_init_gp(self):\n reg_X = np.concatenate((self.pre_eval_points, self.history.query_poi... | [
"0.66172713",
"0.6473374",
"0.63083845",
"0.6251704",
"0.6093418",
"0.6090153",
"0.6080946",
"0.60236067",
"0.5934487",
"0.591734",
"0.59074265",
"0.58959746",
"0.58629864",
"0.5855779",
"0.58185846",
"0.57879174",
"0.5784295",
"0.577392",
"0.57544553",
"0.5754428",
"0.575417... | 0.0 | -1 |
The name of the reactor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reactor_id(self):\n return self.__reactor_id",
"def test_name(self):\n c = EventLoop(lambda: FakeReactor(), lambda f, g: None)\n\n @c.run_in_reactor\n def some_name():\n pass\n\n self.assertEqual(some_name.__name__, \"some_name\")",
"def name(self):\n re... | [
"0.7184927",
"0.6717763",
"0.66173404",
"0.65065867",
"0.65065867",
"0.6476128",
"0.6349755",
"0.6349755",
"0.6349755",
"0.6349755",
"0.6349755",
"0.6349755",
"0.6349755",
"0.63461167",
"0.63319916",
"0.6315429",
"0.6315429",
"0.6315429",
"0.6315429",
"0.6315429",
"0.6315429"... | 0.0 | -1 |
The density of the fluid in the reactor [kg/m^3]. | def density(self):
return _cantera.reactor_density(self.__reactor_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n return (1e-3*self.molar_mass) * self.pressure / (gas_constant * self.temperature) # kg/m^3",
"def electron_density_per_m3(self):\n return self.electron_density * 1e6",
"def _density(self):\n fraction = np.array([0.]+[m.value for m in self.fraction])\n # TODO: ha... | [
"0.818683",
"0.76020765",
"0.7559003",
"0.749608",
"0.7491871",
"0.7491871",
"0.7491871",
"0.7479063",
"0.7328322",
"0.7197849",
"0.71568424",
"0.70913225",
"0.7023295",
"0.6987508",
"0.6953821",
"0.6926116",
"0.6926116",
"0.68770057",
"0.68655664",
"0.6847457",
"0.68361074",... | 0.8080355 | 1 |
The mass fraction of species s, specified either by name or index number. >>> y1 = r.massFraction(7) ___0.02 >>> y2 = r.massFraction('CH3O') ___0.02 | def massFraction(self, s):
if type(s) == types.StringType:
kk = self._contents.speciesIndex(s)
else:
kk = s
return _cantera.reactor_massFraction(self.__reactor_id, kk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def massFraction(self, species):\n k = self.speciesIndex(species)\n return _cantera.phase_massfraction(self._phase_id,k)",
"def massFractions(self, species = None):\n y = _cantera.phase_getarray(self._phase_id,21)\n return self.selectSpecies(y, species)",
"def massFractions(self):\n... | [
"0.7743062",
"0.73519343",
"0.72839075",
"0.68483424",
"0.6575884",
"0.65118426",
"0.646749",
"0.62767494",
"0.61607987",
"0.6129931",
"0.61222875",
"0.6093286",
"0.60050243",
"0.59821045",
"0.59699965",
"0.59532815",
"0.59503585",
"0.5887114",
"0.5871935",
"0.58382773",
"0.5... | 0.82255644 | 0 |
Return an array of the species mass fractions. | def massFractions(self):
nsp = self._contents.nSpecies()
y = zeros(nsp,'d')
for k in range(nsp):
y[k] = self.massFraction(k)
return y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def massFractions(self, species = None):\n y = _cantera.phase_getarray(self._phase_id,21)\n return self.selectSpecies(y, species)",
"def massFraction(self, species):\n k = self.speciesIndex(species)\n return _cantera.phase_massfraction(self._phase_id,k)",
"def moleFractions(self, sp... | [
"0.8205905",
"0.7388184",
"0.72683173",
"0.69506633",
"0.66317695",
"0.64604557",
"0.64396274",
"0.6254437",
"0.6252561",
"0.62450284",
"0.6182931",
"0.6164036",
"0.6069755",
"0.6067782",
"0.59794134",
"0.59480405",
"0.5944606",
"0.5920388",
"0.5920388",
"0.5886868",
"0.58405... | 0.86272925 | 0 |
The name specified when initially constructed. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name = None):\n self._name = name",
"def __init__(self, name):\n self._name = name",
"def __init__(self, name):\n self._name = name",
"def name(self, name):\n pass",
"def __init__(self, name):\n self._name = name\n pass",
"def __init__(self, na... | [
"0.8099982",
"0.80871195",
"0.80871195",
"0.8087063",
"0.8071083",
"0.7975904",
"0.79081786",
"0.7907479",
"0.78962106",
"0.78407943",
"0.78253275",
"0.78127617",
"0.7808901",
"0.7805997",
"0.7805997",
"0.7805997",
"0.7805997",
"0.7805997",
"0.7805997",
"0.7805997",
"0.780599... | 0.0 | -1 |
The wall area (m^2). | def area(self):
return _cantera.wall_area(self.__wall_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n\t\treturn self.height * self.height",
"def area(self):\n area = 0\n\n for room in self.rooms:\n area += room.polygon.area()\n\n for wall in self.walls:\n area += wall.polygon.area()\n\n return area",
"def area(self):\n\t\treturn self.width * s... | [
"0.72917974",
"0.7275804",
"0.72728664",
"0.7266446",
"0.72301364",
"0.7187178",
"0.7187178",
"0.7184693",
"0.7182397",
"0.7177845",
"0.7175258",
"0.7173317",
"0.7173317",
"0.7173317",
"0.71632415",
"0.7150705",
"0.7130878",
"0.7130878",
"0.7130878",
"0.7130878",
"0.7130878",... | 0.8031802 | 0 |
Set the relative and absolute error tolerances used in integrating the reactor equations. | def setTolerances(self, rtol = 1.0e-9,
atol = 1.0e-20, rtolsens= -1.0, atolsens = -1.0):
_cantera.reactornet_setTolerances(self.__reactornet_id, rtol, atol)
_cantera.reactornet_setSensitivityTolerances(self.__reactornet_id, rtolsens, atolsens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_tolerances(self, atol=None, rtol=None, maxiter=None):\n atol = self.atol if atol is None else atol\n rtol = self.rtol if rtol is None else rtol\n maxiter = self.maxiter if maxiter is None else maxiter\n # BUG: PETSc misses rtol requirement by ~10-20X -> Report to petsc4py\n ... | [
"0.7158792",
"0.69586426",
"0.6500547",
"0.6349474",
"0.6269998",
"0.6230118",
"0.61364615",
"0.60424495",
"0.5932808",
"0.58228296",
"0.57946295",
"0.5760862",
"0.575831",
"0.57442653",
"0.5717488",
"0.57131505",
"0.5696014",
"0.56331676",
"0.55733985",
"0.54787797",
"0.5463... | 0.67821777 | 2 |
Return the list of reactors in the network. | def reactors(self):
return self._reactors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actors(self):\n return self._actors",
"def _list_reactions(self, reaction_node):\n reactions = [reaction_node]\n curr_rxn = reaction_node\n products = self._product_nodes(reaction_node)\n while products[0] is not self.root:\n curr_rxn = next(self.graph.predecesso... | [
"0.6769732",
"0.6487706",
"0.6314013",
"0.62579024",
"0.62069416",
"0.6131083",
"0.6131083",
"0.6131083",
"0.6131083",
"0.5970601",
"0.592833",
"0.5921623",
"0.5921623",
"0.58861923",
"0.5838287",
"0.5804067",
"0.57927185",
"0.5784432",
"0.5743117",
"0.5713695",
"0.56690997",... | 0.79283595 | 0 |
Create and return a gRPC channel object. | def create_channel(
cls,
host: str = "clouddeploy.googleapis.com",
credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs,
) -> ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grpc_channel(self) -> grpc.Channel:\n # Sanity check: Only create a new channel if we do not already\n # have one.\n if not hasattr(self, \"_grpc_channel\"):\n self._grpc_channel = self.create_channel(\n self._host, credentials=self._credentials\n )\n\n... | [
"0.76726127",
"0.7287777",
"0.724973",
"0.71410984",
"0.71410984",
"0.7112775",
"0.70493317",
"0.6943139",
"0.68606234",
"0.6772209",
"0.67028666",
"0.6642572",
"0.662686",
"0.6605209",
"0.6479314",
"0.6206986",
"0.6115825",
"0.6110168",
"0.608392",
"0.6048783",
"0.6014445",
... | 0.66935563 | 11 |
Return the channel designed to connect to this service. | def grpc_channel(self) -> grpc.Channel:
return self._grpc_channel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_channel(self):\n if self.channel is None or not self.channel.is_open:\n if not self.connection.is_open:\n self.connection = CONNECTION_MANAGER.get_connection(self.connection_name)\n self.channel = self.connection.channel()\n return self.channel",
"def ch... | [
"0.82963324",
"0.80489576",
"0.8003835",
"0.78035873",
"0.7663182",
"0.7663182",
"0.7652607",
"0.76489896",
"0.74305207",
"0.72599155",
"0.72599155",
"0.72072446",
"0.6971863",
"0.68524957",
"0.6778563",
"0.6759073",
"0.67335385",
"0.66539884",
"0.66149175",
"0.6613948",
"0.6... | 0.7423489 | 9 |
r"""Return a callable for the get config method over gRPC. Gets the configuration for a location. | def get_config(
self,
) -> Callable[[cloud_deploy.GetConfigRequest], cloud_deploy.Config]:
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(location):\n import urlparse # urlparse\n if urlparse.urlparse(location).scheme:\n if location.endswith('.git'):\n return get_config_from_remote_git(location)\n elif location.endswith('.zip'):\n return get_config_from_remote_zip(location)\n else:\... | [
"0.6723193",
"0.6610465",
"0.6533603",
"0.64110726",
"0.64110726",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"0.632539",
"... | 0.7103817 | 0 |
r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. | def get_iam_policy(
self,
) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_access_policy_output(access_policy_id: Optional[pulumi.Input[str]] = None,\n opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetAccessPolicyResult]:\n ...",
"def get_policy(usage_id):\r\n return policy.get(policy_key(usage_id), {})",
"def post... | [
"0.6326554",
"0.627488",
"0.6211524",
"0.6186148",
"0.6183484",
"0.6183484",
"0.6148085",
"0.60955864",
"0.6040781",
"0.5995597",
"0.5982858",
"0.5982858",
"0.5958672",
"0.5947325",
"0.5947325",
"0.59076893",
"0.59028107",
"0.58988273",
"0.5890648",
"0.58865625",
"0.5882375",... | 0.78044355 | 0 |
Compute 'Scaled Dot Product Attention' | def attention(self, query, key, value, mask=None, dropout=None):
scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(self.d_k)
if mask is not None:
scores = scores.masked_fill(mask == 0, -1000000000.0)
p_attn = torch.softmax(scores, dim=-1)
if dropout is not None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scaled_dot_product_attention(q, k, v, mask):\n matmul_qk = tf.matmul(q, k, transpose_b=True) # [..., q_len, kv_len]\n # scale matmul_qk\n dk = tf.cast(tf.shape(k)[-1], tf.float32)\n scaled_attention_logits = matmul_qk / tf.sqrt(dk)\n # print(\"scaled_attention_logits\", tf.nn.top_k(scaled_atten... | [
"0.6741155",
"0.66337067",
"0.6571944",
"0.65150666",
"0.6506159",
"0.65043765",
"0.65037763",
"0.65037763",
"0.64900655",
"0.6464614",
"0.6410581",
"0.63864654",
"0.63760495",
"0.62910765",
"0.6101237",
"0.6056868",
"0.60146934",
"0.5985043",
"0.5952964",
"0.5942924",
"0.592... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Supersim.V1.FleetInstance {}>".format(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Supersim.V1.FleetContext {}>".format(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76001465",
"0.757194",
"0.7228986",
"0.7215887",
"0.71939564",
"0.714225",
"0.7140649",
"0.71357155",
"0.7134081",
"0.7134081",
"0.7130201",
"0.71034807",
"0.7075018",
"0.70679307",
"0.706735",
"0.706735",
"0.706735",
"0.706735",
"0.706735",
"0.703001",
"0.7019043",
"0.7... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Supersim.V1.FleetPage>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Supersim.V1.FleetList>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76001465",
"0.757194",
"0.7228986",
"0.7215887",
"0.71939564",
"0.714225",
"0.7140649",
"0.71357155",
"0.7134081",
"0.7134081",
"0.7130201",
"0.71034807",
"0.7075018",
"0.70679307",
"0.706735",
"0.706735",
"0.706735",
"0.706735",
"0.706735",
"0.703001",
"0.7019043",
"0.7... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.