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
Compute sequence lengths for each batch element in a tensor using a binary mask.
def get_lengths_from_binary_sequence_mask(mask: torch.Tensor): return mask.long().sum(-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lengths_from_binary_sequence_mask(\n mask: torch.BoolTensor,\n) -> torch.LongTensor:\n return mask.sum(-1)", "def get_lengths_from_binary_sequence_mask(self, mask: torch.Tensor):\n return mask.long().sum(-1)", "def length(sequence):\r\n populated = tf.sign(tf.abs(sequence))\r\n lengt...
[ "0.7882264", "0.7809273", "0.6811649", "0.66445816", "0.64034766", "0.6310454", "0.62911236", "0.61880827", "0.606136", "0.6060825", "0.60130227", "0.5968252", "0.5941716", "0.58749974", "0.58191395", "0.5808333", "0.5747515", "0.5680931", "0.56371975", "0.55695957", "0.55666...
0.7909949
0
``torch.nn.functional.log_softmax(vector)`` does not work if some elements of ``vector`` should be masked. This performs a log_softmax on just the nonmasked portions of ``vector``. Passing ``None`` in for the mask is also acceptable; you'll just get a regular log_softmax. We assume that both ``vector`` and ``mask`` (if...
def masked_log_softmax(vector, mask): if mask is not None: mask = mask.float() vector = vector + mask.log() return torch.nn.functional.log_softmax(vector)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def masked_log_softmax(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1) -> torch.Tensor:\n if mask is not None:\n mask = mask.float()\n while mask.dim() < vector.dim():\n mask = mask.unsqueeze(1)\n # vector + mask.log() is an easy way to zero out masked elements in logspa...
[ "0.8610911", "0.8188039", "0.7166855", "0.67613995", "0.66536164", "0.66536164", "0.65114474", "0.6430716", "0.6390452", "0.6381591", "0.6311668", "0.6271854", "0.6221283", "0.619346", "0.614264", "0.6085324", "0.6083745", "0.5994769", "0.58857626", "0.58724594", "0.5842682",...
0.88869876
0
Compute the path for a git_info cache file related to a given directory. >>> info_filename('foo', 'foo', '') 'info.json' >>> info_filename('foo/bar/baz', 'foo', 'xyzzy') 'xyzzy/infobarbaz.json'
def info_filename(directory, install_path, cache_path): path = directory if path.startswith(install_path): path = path[len(install_path):] return os.path.join(cache_path, 'info%s.json' % path.replace('/', '-'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _cachefilename(self, cachedir):\n\n return cachedir / \"filename\"", "def _get_cache_filename(name, filename):\n filename = os.path.abspath(filename)[1:]\n home_folder = os.path.expanduser('~')\n base_cache_dir = os.path.join(home_folder, '.git-lint', 'cache')\n\n return os.path.join(base_...
[ "0.6028605", "0.5937027", "0.57996154", "0.5649608", "0.5625687", "0.56097734", "0.5597825", "0.5569786", "0.555389", "0.55506986", "0.554297", "0.5530308", "0.5516758", "0.5509555", "0.5507355", "0.5499917", "0.5490301", "0.5453425", "0.54521376", "0.5389314", "0.53779745", ...
0.73675203
0
Make sure there aren't more than max_tags.
def clean_tags(location, max_tags): git = '/usr/bin/git' ensure_dir(location) with utils.cd(location): cmd = [ git, 'for-each-ref', '--sort=taggerdate', '--format=%(refname)', 'refs/tags' ] tags = subprocess.check_output(cm...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maxlen(self):\n \n return reduce(max, list(map(len, self.tags)))", "def too_few_tags(request):\n if request.method == 'POST':\n form = forms.EventEditTagsForm(request.POST)\n if form.is_valid():\n event = get_object_or_404(Event, id=form.cleaned_data['event_id'])\n ...
[ "0.66492766", "0.65344244", "0.63388747", "0.6137362", "0.59207255", "0.59129035", "0.5900259", "0.5881636", "0.5881636", "0.5861361", "0.57586586", "0.56939876", "0.5678228", "0.56726843", "0.5672559", "0.5658105", "0.56495273", "0.56231064", "0.55499345", "0.553957", "0.553...
0.56738126
13
Return ndarray normalized by length, i.e. Euclidean norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, axis=1) >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0v0, axis=2)),...
def unit_vector(data, axis=None, out=None): if out is None: data = numpy.array(data, dtype=numpy.float64, copy=True) if data.ndim == 1: data /= math.sqrt(numpy.dot(data, data)) return data else: if out is not data: out[:] = numpy.array(data, co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unit_vector(data, axis=None, out=None):\n if out is None:\n data = np.array(data, dtype=np.float64, copy=True)\n if data.ndim == 1:\n data /= math.sqrt(np.dot(data, data))\n return data\n else:\n if out is not data:\n out[:] = np.array(data, copy=Fals...
[ "0.8290531", "0.8270573", "0.8076325", "0.788217", "0.7717261", "0.74218553", "0.7393939", "0.73234904", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72324944", "0.72294974", "0....
0.8274973
1
Return matrix to rotate about axis defined by point and direction. >>> R = rotation_matrix(math.pi/2, [0, 0, 1], [1, 0, 0]) >>> numpy.allclose(numpy.dot(R, [0, 0, 0, 1]), [1, 1, 0, 1]) True >>> angle = (random.random() 0.5) (2math.pi) >>> direc = numpy.random.random(3) 0.5 >>> point = numpy.random.random(3) 0.5 >>> R0 ...
def axisangle2matrix(angle, direction, point=None): sina = math.sin(angle) cosa = math.cos(angle) direction = unit_vector(direction[:3]) # rotation matrix around unit vector R = numpy.diag([cosa, cosa, cosa]) R += numpy.outer(direction, direction) * (1.0 - cosa) direction *= sina ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotation_matrix(angle, direction, point=None):\n sina = math.sin(angle)\n cosa = math.cos(angle)\n direction = unit_vector(direction[:3])\n # rotation matrix around unit vector\n R = np.array(((cosa, 0.0, 0.0),\n (0.0, cosa, 0.0),\n (0.0, 0.0, cosa)), ...
[ "0.8308042", "0.8293115", "0.82603717", "0.7068822", "0.70132005", "0.6986211", "0.6984109", "0.6972318", "0.6963251", "0.6869955", "0.6831005", "0.6787215", "0.67703694", "0.67436063", "0.66769284", "0.66701114", "0.66599727", "0.6657853", "0.6655027", "0.66358215", "0.66318...
0.7685783
3
Return quaternion from rotation matrix. If isprecise is True, the input matrix is assumed to be a precise rotation matrix and a faster algorithm is used. >>> q = quaternion_from_matrix(numpy.identity(4), True) >>> numpy.allclose(q, [1, 0, 0, 0]) True >>> q = quaternion_from_matrix(numpy.diag([1, 1, 1, 1])) >>> numpy.al...
def matrix2quaternion(matrix, isprecise=False): M = numpy.array(matrix, dtype=numpy.float64, copy=False)[:4, :4] if isprecise: q = numpy.empty((4, )) t = numpy.trace(M) if t > M[3, 3]: q[0] = t q[3] = M[1, 0] - M[0, 1] q[2] = M[0, 2] - M[2, 0] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quaternion_from_matrix(matrix, isprecise=False):\r\n M = numpy.array(matrix, dtype=numpy.float64, copy=False)[:4, :4]\r\n if isprecise:\r\n q = numpy.empty((4, ))\r\n t = numpy.trace(M)\r\n if t > M[3, 3]:\r\n q[0] = t\r\n q[3] = M[1, 0] - M[0, 1]\r\n ...
[ "0.80575997", "0.6987518", "0.6893308", "0.68884116", "0.68413407", "0.67808294", "0.6684644", "0.6603249", "0.651913", "0.6358592", "0.62227494", "0.6149119", "0.6142952", "0.61374974", "0.6078684", "0.59324473", "0.57647574", "0.570771", "0.5697673", "0.562712", "0.5568865"...
0.75175977
1
Return translation vector from translation matrix. >>> v0 = numpy.random.random(3) 0.5 >>> v1 = translation_from_matrix(translation_matrix(v0)) >>> numpy.allclose(v0, v1) True
def translation_from_matrix(matrix): return numpy.array(matrix, copy=False)[:3, 3].copy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_translation_matrix(translation_vector):\r\n T = torch.zeros(translation_vector.shape[0], 4, 4).to(device=translation_vector.device)\r\n\r\n t = translation_vector.contiguous().view(-1, 3, 1)\r\n\r\n T[:, 0, 0] = 1\r\n T[:, 1, 1] = 1\r\n T[:, 2, 2] = 1\r\n T[:, 3, 3] = 1\r\n T[:, :3, 3,...
[ "0.7055211", "0.66092604", "0.65775156", "0.6541816", "0.6521263", "0.6483276", "0.6326393", "0.6259159", "0.62497634", "0.61845416", "0.6177389", "0.6055303", "0.60518944", "0.5968436", "0.5933856", "0.5927472", "0.59188664", "0.5918372", "0.59109616", "0.5889519", "0.588925...
0.7460081
0
Return homogeneous rotation matrix from quaternion. >>> M = quaternion_matrix([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(M, rotation_matrix(0.123, [1, 0, 0])) True >>> M = quaternion_matrix([1, 0, 0, 0]) >>> numpy.allclose(M, numpy.identity(4)) True >>> M = quaternion_matrix([0, 1, 0, 0]) >>> numpy.allclose(M, ...
def quaternion_matrix(quaternion): q = numpy.array(quaternion, dtype=numpy.float64, copy=True) n = numpy.dot(q, q) if n < _EPS: return numpy.identity(4) q *= math.sqrt(2.0 / n) q = numpy.outer(q, q) return numpy.array([ [1.0-q[2, 2]-q[3, 3], q[1, 2]-q[3, 0], q[1, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quaternion_matrix(quaternion):\n q = np.array(quaternion, dtype=np.float64, copy=True)\n n = np.dot(q, q)\n if n < _EPS:\n return np.identity(4)\n q *= math.sqrt(2.0 / n)\n q = np.outer(q, q)\n return np.array([\n [1.0-q[2, 2]-q[3, 3], q[1, 2]-q[3, 0], q[1, 3]+q[2, 0], 0...
[ "0.81262285", "0.77498937", "0.7736601", "0.76753336", "0.7632361", "0.7474626", "0.73542523", "0.7351921", "0.7347321", "0.7301515", "0.72976035", "0.72916156", "0.72043765", "0.71664226", "0.7165577", "0.7159346", "0.712398", "0.69947636", "0.69908386", "0.6887744", "0.6811...
0.81762314
0
Return quaternion from rotation matrix. If isprecise is True, the input matrix is assumed to be a precise rotation matrix and a faster algorithm is used. >>> q = quaternion_from_matrix(numpy.identity(4), True) >>> numpy.allclose(q, [1, 0, 0, 0]) True >>> q = quaternion_from_matrix(numpy.diag([1, 1, 1, 1])) >>> numpy.al...
def quaternion_from_matrix(matrix, isprecise=False): M = numpy.array(matrix, dtype=numpy.float64, copy=False)[:4, :4] if isprecise: q = numpy.empty((4, )) t = numpy.trace(M) if t > M[3, 3]: q[0] = t q[3] = M[1, 0] - M[0, 1] q[2] = M[0, 2] - M[2...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matrix2quaternion(matrix, isprecise=False):\r\n M = numpy.array(matrix, dtype=numpy.float64, copy=False)[:4, :4]\r\n if isprecise:\r\n q = numpy.empty((4, ))\r\n t = numpy.trace(M)\r\n if t > M[3, 3]:\r\n q[0] = t\r\n q[3] = M[1, 0] - M[0, 1]\r\n q[2]...
[ "0.75175977", "0.6987518", "0.6893308", "0.68884116", "0.68413407", "0.67808294", "0.6684644", "0.6603249", "0.651913", "0.6358592", "0.62227494", "0.6149119", "0.6142952", "0.61374974", "0.6078684", "0.59324473", "0.57647574", "0.570771", "0.5697673", "0.562712", "0.5568865"...
0.80575997
0
Return True if two quaternions are equal.
def is_same_quaternion(q0, q1): q0 = numpy.array(q0) q1 = numpy.array(q1) return numpy.allclose(q0, q1) or numpy.allclose(q0, -q1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n if isinstance(other, Quaternion):\n return self.__real == other.__real and (self.__img == other.__img).all()\n return False", "def test_equality_with_quat(self):\n quat = Quat(1, 2, 3, 4)\n self.assertEqual(quat, Quat(1, 2, 3, 4))", "def __equal...
[ "0.7583597", "0.72831035", "0.7072646", "0.6711779", "0.6574817", "0.65317", "0.65287095", "0.64501816", "0.64491796", "0.64237165", "0.6364926", "0.6339932", "0.6289985", "0.6289691", "0.6263706", "0.625672", "0.6205036", "0.6199863", "0.6130328", "0.6121531", "0.61177653", ...
0.82035464
0
Generate a random string of fixed length
def randomString(stringLength=10): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(stringLength))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))", "def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",...
[ "0.86810505", "0.8573398", "0.8549153", "0.85291016", "0.852194", "0.84337574", "0.8433061", "0.84165514", "0.8411733", "0.8390179", "0.8346973", "0.8344882", "0.8341727", "0.83356076", "0.8323762", "0.82998705", "0.8290879", "0.82825434", "0.82822", "0.8281794", "0.82652897"...
0.77623934
92
Get the user currently logged in. Returns
def get_current_user_route(): response_object = {'status': 'success'} user = current_user if user.get_id() is not None: admin_role = False user_role = models.UserRoles.query.filter( models.UserRoles.user_id == user.id).first() if user_role and user_role.role_id == 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_logged_in_user(self):\n return self.session_mgr.get_logged_in_user()", "def current_user(self):\n user_dict = self.auth.get_user_by_session()\n return self.auth.store.user_model.get_by_id(user_dict['user_id'])", "def get_current_user(self):\n return self.get_secure_cookie(\"user\")"...
[ "0.8767683", "0.8670571", "0.86552584", "0.8470696", "0.84529823", "0.8390968", "0.8289352", "0.8212612", "0.8174645", "0.8130501", "0.8130501", "0.8107743", "0.8097765", "0.8084371", "0.8082905", "0.80739975", "0.80739975", "0.80739975", "0.8073993", "0.805309", "0.8040876",...
0.0
-1
Check if the specified filename is valid to be uploaded and not harmful.
def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower( ) in flask.current_app.config['ALLOWED_EXTENSIONS']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_filename_safe(filename: str) -> bool:\n allowed_format = \"|\".join(FileStoreManager.ALL_FORMAT) # png|svg|jpg\n regex = f\"[a-zA-Z0-9][a-zA-Z0-9_()-\\.]*\\.({allowed_format})$\"\n return re.match(regex, filename) is not None", "def valid_filename(filename):\n if filename in IGNORE...
[ "0.8134955", "0.7977593", "0.7930854", "0.7827486", "0.77778286", "0.7691593", "0.76521325", "0.7599943", "0.75628257", "0.7523988", "0.74836457", "0.7476992", "0.74701464", "0.7434088", "0.7420723", "0.7420723", "0.7420723", "0.7420723", "0.7420723", "0.7420723", "0.7415682"...
0.68299824
63
Get the projects belonging to the current user. Returns
def get_projects(): if current_user.get_id() is None: return with database.engine.begin() as connection: result = connection.execute(select( [models.projects.c.project_id, models.projects.c.name, models.projects.c.path, models.projects.c.creation_date, models.projects.c.user_id, func...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_for(user):\n return Project.objects.filter(\n user_group__members=user\n ).distinct()", "def get_projects(self):\n return self.http_call(\"get\", url=f\"{self.base_url}/projects\").json()", "def get_projects_of_user(self, user_id):\n res = self.conn.cursor().execu...
[ "0.79247385", "0.7852957", "0.78366923", "0.7641969", "0.7608876", "0.754447", "0.7533854", "0.7435337", "0.7384129", "0.73512715", "0.7330887", "0.7293063", "0.7259015", "0.7250967", "0.72378296", "0.7236866", "0.7230432", "0.72070366", "0.72002923", "0.71815515", "0.7177385...
0.8384203
0
Make a DataFrame from a BeautifulSoup `table` element. Returns a DataFrame whose columns are the `th` contents if present, otherwise the first row's `td` contents, and whose data are the remaining `td` items converted using maybe_convert.
def table_to_dataframe(table): ths = table.find_all('th') trs = table.find_all('tr') if ths: columns = [th.text.strip() for th in ths] else: columns = [td.text.strip() for td in trs[0]] trs = trs[1:] _logger.debug(f'Creating DataFrame with columns {columns}') data = [[ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def table_to_data_frame(table):\n nr = table.rowCount()\n nc = table.columnCount()\n\n if nr == 0:\n return None\n\n idx_labels = []\n for i in range(nr):\n item = table.verticalHeaderItem(i)\n if item is not None:\n idx_labels.append(item.text().replace(' ', ''))\n ...
[ "0.70743644", "0.6959615", "0.6689998", "0.6485569", "0.61409247", "0.59254473", "0.58435845", "0.5609926", "0.55973357", "0.55677766", "0.55064714", "0.55055195", "0.54777896", "0.54197305", "0.54075485", "0.5351048", "0.5338707", "0.5303496", "0.530042", "0.5263195", "0.525...
0.80500674
0
Opens a file browser depending on the system.
def open_sync_folder(self): if platform.system() == 'Darwin': subprocess.call(['open', '--', self.sync_dir]) elif platform.system() == 'Linux': subprocess.call(['gnome-open', self.sync_dir]) elif platform.system() == 'Windows': subprocess.call(['explorer', sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_file_browser(path):\n if sys.platform == 'win32':\n #subprocess.Popen(['start', path], shell=True)\n os.startfile(path)\n\n elif sys.platform == 'darwin':\n subprocess.Popen(['open', path])\n\n else:\n try:\n subprocess.Popen(['xdg-open', path])\n exc...
[ "0.77961284", "0.7574786", "0.7339383", "0.7183447", "0.68746704", "0.6856208", "0.68285185", "0.6784354", "0.6772225", "0.6768073", "0.67483926", "0.6700895", "0.66996014", "0.668011", "0.66394436", "0.662891", "0.6605536", "0.6495348", "0.64636713", "0.64368325", "0.6395059...
0.0
-1
Return if the string is a url.
def is_url(string): try: urlparse(string) return True except: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_url(string):\n return \"http\" in string", "def _is_url(s: str) -> bool:\n\n return urlparse(s).netloc != \"\"", "def __isUrl(self, url):\n if type(url)==str:\n return url.startswith('http://') or url.startswith('https://')\n return False", "def is_url(val):\n res = ...
[ "0.88902646", "0.8453106", "0.82887113", "0.7996636", "0.7933351", "0.79173577", "0.7883935", "0.7783624", "0.777046", "0.77529097", "0.7725525", "0.76535094", "0.76413417", "0.7572489", "0.7475691", "0.73300666", "0.727667", "0.72640604", "0.7245608", "0.7245038", "0.7221225...
0.8706504
1
Assuming TxHxWxC dimensions on the tensor, will normalize over the H,W dimensions. Use this before the activation layer.
def BatchNorm(inputs, epsilon=1e-3, suffix=''): # Create scale + sx hift. Exclude batch dimension. stat_shape = inputs.get_shape().as_list() scale = tf.get_variable('scale' + suffix, initializer=tf.ones(stat_shape[3])) shift = tf.get_variable('shift' + suffix, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize(w: torch.Tensor):\n\n if w.dim() > 1:\n return _matrix(w)\n\n return _vector(w)", "def normalize_weights(w, dims=(0,), bias=1e-5):\n with tf.name_scope('normalization'):\n return w / (tf.sqrt(tf.reduce_sum(tf.square(w), dims, keep_dims=True) + bias))", "def normalize_parame...
[ "0.7092934", "0.680095", "0.66938764", "0.6608311", "0.6543793", "0.6522797", "0.65008134", "0.6447466", "0.64333284", "0.64056337", "0.6383174", "0.630553", "0.6294856", "0.62843823", "0.62604946", "0.6259418", "0.6226762", "0.6226762", "0.6220959", "0.62134135", "0.6149984"...
0.0
-1
Formats the duration in a human format
def get_formatted_duration(self, prev_time): duration = time() - prev_time if duration < 60: unit = 's' elif duration < 3600: duration /= 60 unit = 'm' else: duration /= 3600 unit = 'h' return self.format_num(duration) +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_display_duration(self):\n duration = self.duration\n return '%dmn' % duration if duration < 60 else '%dh%dmn' % (duration / 60, duration % 60)", "def format_duration(duration: int) -> str:\n assert duration > 0, \"`duration` must be nonzero number.\"\n\n hours = duration / 3600\n ...
[ "0.77669686", "0.76068306", "0.7535577", "0.720885", "0.7177113", "0.7174686", "0.71304053", "0.7109951", "0.7020978", "0.7000697", "0.6985772", "0.6946493", "0.67987305", "0.677966", "0.6778", "0.6722786", "0.6717019", "0.66937435", "0.6693559", "0.6684677", "0.66644955", ...
0.7279261
3
Sets up the compositor nodes for the ambient occlusion (AO) effect.
def comp_add_ao(self): scene = self.set_as_active() scene.use_nodes = True tree = scene.node_tree tree.nodes.clear() # creating the nodes node_rlayer = tree.nodes.new('CompositorNodeRLayers') node_rlayer.location = -300, 100 node_rlayer.scene = scene ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_up_all_ao(self):\n self.set_as_active()\n \n # sets up ambient occlusion lighting\n self.set_up_world_ao()\n self.comp_add_ao()", "def set_up_world_ao(self):\n scene = self.set_as_active()\n new_world = bpy.context.blend_data.worlds.new('World of Wireframe...
[ "0.7553021", "0.6401904", "0.5988711", "0.53755695", "0.53438663", "0.52935785", "0.52915996", "0.5218304", "0.5217991", "0.52040046", "0.519018", "0.51827013", "0.51460063", "0.5142392", "0.51252884", "0.5103902", "0.5100563", "0.50920296", "0.5072815", "0.50706446", "0.5069...
0.66313845
1
Strips spaces from the given lines, skipping empty lines.
def _strip_lines(lines): for line in lines: stripped = line.strip() if stripped: yield stripped
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_excess_white_space(lines: str):\n two_plus_white_space = r\"\\s{2,}\"\n return re.sub(two_plus_white_space, \"\", lines)", "def _strip(lines: Sequence[str]) -> Sequence[str]:\n lines = [i.rstrip() for i in lines]\n return lines", "def clean_lines(lines):\n _lines = []\n for l in li...
[ "0.7591515", "0.7119102", "0.70392126", "0.6786671", "0.6586437", "0.6567677", "0.654912", "0.6541707", "0.64734006", "0.64608246", "0.637591", "0.6373358", "0.6365933", "0.63484496", "0.63175637", "0.6306828", "0.6294437", "0.62861365", "0.62393093", "0.6232841", "0.6159538"...
0.72036695
1
Returns true iff a and b are already assumed to be equal. Otherwise adds an equivalence of a and b to the set and returns false.
def _are_assumed_equal(a, b, assumed_equivs): # Are we just assuming that the two are equal? equiv = (id(a), id(b)) if equiv in assumed_equivs: return True # If we see these two again assume they're equal. If they're not then the # traversal will detect it. assumed_equivs.add(equiv) return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_equivalent(self, a, b):\n assert set(a) == set(b)\n for key in a:\n assert self.is_equal(a[key], b[key])", "def is_equal(self, a, b):\n return a is b", "def is_equal(self, a, b):\n return a == b", "def check_equivalent(self, a, b):\n assert len(a) == le...
[ "0.73745716", "0.7294457", "0.7017389", "0.68406826", "0.68237925", "0.6721873", "0.66242605", "0.6558427", "0.6537712", "0.6533564", "0.65290856", "0.6425641", "0.6341114", "0.6306723", "0.6301434", "0.62947357", "0.62782955", "0.6251529", "0.62153476", "0.62068325", "0.6150...
0.7310512
1
Sets the current limit
def set_current_limit(self, value): function_string = 'I' + self.output + ' ' + str(value) return self.scpi_comm(function_string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def limit(self, limit):\n self._limit = limit", "def limit(self, limit):\n\n self._limit = limit", "def limit(self, limit):\n\n self._limit = limit", "def limit(self, limit):\n\n self._limit = limit", "def limit(self, limit):\n self._evaluated = False\n self._limit = limit...
[ "0.8321238", "0.82901835", "0.82901835", "0.82901835", "0.8274691", "0.80368996", "0.80291593", "0.7988913", "0.79629344", "0.78597677", "0.77753043", "0.76638585", "0.7580955", "0.75547415", "0.75515777", "0.75448334", "0.7306402", "0.7241701", "0.72257584", "0.71677834", "0...
0.7232335
18
Sets the voltage step size
def set_voltage_stepsize(self, value): function_string = 'DELTAV' + self.output + ' ' + str(value) return self.scpi_comm(function_string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_step_size(self, step_size):\r\n # Max step size for each unit is based on one byte of SIGNED data -> range = 2**8 / 2 = 128\r\n # if step_size < 12.8:\r\n # if self._current_units != 'A':\r\n # self.set_units('A')\r\n # time.sleep(1)\r\n # s...
[ "0.74010175", "0.6986717", "0.66157603", "0.65916836", "0.65386975", "0.6495294", "0.6421655", "0.6403729", "0.6382267", "0.6366617", "0.6095966", "0.60946834", "0.6023813", "0.59866464", "0.5980038", "0.5955805", "0.5909388", "0.5865058", "0.5854622", "0.5840859", "0.5815582...
0.80560005
0
Sets the current step size
def set_current_stepsize(self, value): function_string = 'DELTAI' + self.output + ' ' + str(value) return self.scpi_comm(function_string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_step_size(self):\n self.setSingleStep(10 ** self.step_exponent)\n self.update_format_string()", "def set_step_size(self, step_size):\r\n # Max step size for each unit is based on one byte of SIGNED data -> range = 2**8 / 2 = 128\r\n # if step_size < 12.8:\r\n # i...
[ "0.81042665", "0.7881661", "0.75044477", "0.7100057", "0.70118666", "0.7010279", "0.6990207", "0.68298715", "0.6808383", "0.6667335", "0.66461796", "0.6632997", "0.66171646", "0.6609318", "0.65944636", "0.65802324", "0.6556569", "0.6497378", "0.643514", "0.6338649", "0.633864...
0.74792796
3
Check that boundary notes for both lines are valid.
def __validate_boundary_notes(self) -> None: if not self.cantus_firmus[0].scale_element.is_from_tonic_triad: raise ValueError( f"{self.cantus_firmus[0].scale_element.note} is not " f"a tonic triad member for {self.tonic}-{self.scale_type}; " f"therefor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanity_check(left_line, right_line):\n\n # check horizontal separation distance\n if abs(right_line.line_base_pos - left_line.line_base_pos) > 4.0:\n #print(\"Line base positions too far from each other\")\n return False\n\n # check lines are roughly parallel\n ...
[ "0.66337883", "0.6215919", "0.5968808", "0.59490865", "0.59386504", "0.5933262", "0.5902461", "0.589344", "0.58844423", "0.5836618", "0.5818493", "0.57827437", "0.57767904", "0.5740488", "0.5728311", "0.5720174", "0.5716834", "0.57141846", "0.57128435", "0.56548643", "0.55735...
0.67237383
0
Sets the x_request_id of this CreateMyActionTemplateResponse.
def x_request_id(self, x_request_id): self._x_request_id = x_request_id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setRequestId(self, reqid) :\n self.request_id = reqid", "def request_id(self, request_id):\n\n self._request_id = request_id", "def request_id(self, request_id):\n\n self._request_id = request_id", "def request_id(self, request_id):\n\n self._request_id = request_id", "def x...
[ "0.67833334", "0.66909575", "0.66909575", "0.66909575", "0.60023355", "0.5821035", "0.5695752", "0.5624176", "0.55492365", "0.5536636", "0.541821", "0.53684855", "0.5245515", "0.51234245", "0.5038494", "0.5027814", "0.49535102", "0.49246117", "0.48825893", "0.48513824", "0.48...
0.70036757
0
Gets the content_length of this CreateMyActionTemplateResponse.
def content_length(self): return self._content_length
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content_len(self):\n return self.header('CONTENT-LENGTH')", "def content_size(self):\n return self._content_size", "def content_length(self):\n # If none, there is nothing we can do, the server didn't have\n # a response.\n return self._expected_size", "def content_leng...
[ "0.7467367", "0.70747304", "0.70571107", "0.6723362", "0.6611068", "0.6522878", "0.64492947", "0.64433664", "0.63768405", "0.63518995", "0.6272273", "0.6163749", "0.59781665", "0.59537405", "0.5899055", "0.5856133", "0.58092296", "0.58092296", "0.58092296", "0.5785959", "0.57...
0.76046646
0
Gets the date of this CreateMyActionTemplateResponse.
def date(self): return self._date
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date(self):\n return self.status.created_at", "def date(self):\n return DateTime(self.created)", "def date_created(self) -> str:\n return pulumi.get(self, \"date_created\")", "def date_created(self):\n return self._date_created", "def date_created(self):\n return self...
[ "0.69656146", "0.6920944", "0.688368", "0.686152", "0.686152", "0.686152", "0.68401223", "0.68401223", "0.68401223", "0.68401223", "0.6817057", "0.6774727", "0.6774727", "0.6774727", "0.6711103", "0.6711103", "0.6709678", "0.66994154", "0.65454465", "0.6524678", "0.65212625",...
0.6666414
19
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, CreateMyActionTemplateResponse): 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.80885184", "0.80885184", "0.805514", "0.7983044", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", "0.7966715", ...
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
Return an attributes dictionary.
def attributes(self): return { 'parameters': { 'coef_': self.model.coef_.tolist(), 'intercept_': self.model.intercept_.tolist(), 'n_iter': self.model.n_iter_.tolist() } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attributes(self) -> Dict[str, str]:\n pass", "def get_attributes(self):\n return dict(self.attributes) # return the attributes", "def get_attributes(self):\n return dict(self.attributes) # return the attributes", "def get_attributes(self):\n return dict(self.attributes) ...
[ "0.8691341", "0.85366255", "0.85366255", "0.85366255", "0.8314095", "0.83012086", "0.80281276", "0.8004489", "0.79481703", "0.78277653", "0.7804881", "0.7784176", "0.7774848", "0.7731459", "0.7668717", "0.76554936", "0.76542026", "0.7653588", "0.75857204", "0.7583654", "0.755...
0.0
-1
Return an attributes dictionary.
def attributes(self): params = self.model.param_array return {'parameters': params}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attributes(self) -> Dict[str, str]:\n pass", "def get_attributes(self):\n return dict(self.attributes) # return the attributes", "def get_attributes(self):\n return dict(self.attributes) # return the attributes", "def get_attributes(self):\n return dict(self.attributes) ...
[ "0.8691341", "0.85366255", "0.85366255", "0.85366255", "0.8314095", "0.83012086", "0.80281276", "0.8004489", "0.79481703", "0.78277653", "0.7804881", "0.7784176", "0.7774848", "0.7731459", "0.7668717", "0.76554936", "0.76542026", "0.7653588", "0.75857204", "0.7583654", "0.755...
0.0
-1
Is n an even integer.
def is_even(n): # Convert the integer value to binary value. # Check if the last char is '0' for even and '1' for odd. if int(bin(n)[-1]): # print('%d is NOT an even number' % n) return False # print('%d is a even number' % n) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_even(n):\r\n return n%2==0", "def is_even(n: int) -> bool:\r\n if n % 2 == 0:\r\n return True\r\n else:\r\n return False", "def is_even(n):\n return n % 2 == 0", "def even(n):\n return n % 2 == 0", "def is_even(n):\n return not n & 1", "def is_even(number: int) -> b...
[ "0.9042097", "0.90372825", "0.8982246", "0.8708808", "0.8526921", "0.852319", "0.84857464", "0.8482472", "0.8424361", "0.8401079", "0.83886355", "0.83465195", "0.8279159", "0.82593", "0.820209", "0.80524474", "0.8028825", "0.79502183", "0.7950106", "0.7927966", "0.7923726", ...
0.8766311
3
Return package version as listed in `__version__` in `init.py`.
def get_version(package): init_py = open(os.path.join(package, '__init__.py')).read() return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_version_from_package() -> str:\n path = join(dirname(__file__), \"__init__.py\")\n path = normpath(abspath(path))\n with open(path) as f:\n for line in f:\n if line.startswith(\"__version__\"):\n token, version = line.split(\" = \", 1)\n version = ve...
[ "0.84893894", "0.83908445", "0.83863354", "0.8380136", "0.8379423", "0.83694756", "0.83582735", "0.8357903", "0.835638", "0.8078477", "0.7975143", "0.7938866", "0.78928864", "0.78928864", "0.78928864", "0.78029025", "0.7722147", "0.7697877", "0.7694654", "0.7689602", "0.76594...
0.8370828
7
Create a post for the user
def create_post(self: User, content: str, is_public: bool, circles: List[Circle], reshareable: bool, reshared_from: Optional[Post], media_list: List[Media], mentioned_users: List[User], is_update_avatar: bool) \ -> Union[Post, bool]: if not content and not media_list: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_post():\n\n #Get prompt id\n prompt_id = request.form.get('prompt_id')\n\n # Get post text\n post_text = request.form.get('user_post')\n\n # Create post timestamp\n created_at = datetime.now()\n user_facing_date = created_at.strftime(\"%B %d, %Y\")\n\n # Save post and related dat...
[ "0.8171881", "0.80254686", "0.8018321", "0.76414037", "0.7498425", "0.74868053", "0.748617", "0.74788165", "0.74700993", "0.74521244", "0.74062985", "0.73776734", "0.73619854", "0.73497707", "0.73335177", "0.7326628", "0.72624403", "0.7256988", "0.71878636", "0.7161349", "0.7...
0.0
-1
Whether the user owns a post
def owns_post(self, post): return self.id == post.author.id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sees_post(self, post, context_home_or_profile):\n if owns_post(self, post):\n return True\n if context_home_or_profile and post.author not in self.followings:\n return False\n if post.is_public:\n return True\n else:\n for circle in post.circles:\n circle = ge...
[ "0.744853", "0.74311835", "0.74311835", "0.74311835", "0.7402557", "0.74022806", "0.7215938", "0.7215938", "0.6950199", "0.6780304", "0.6770366", "0.67641425", "0.67641425", "0.67386174", "0.6709183", "0.66811544", "0.6656178", "0.6655809", "0.6645435", "0.6630842", "0.655009...
0.8664601
0
Whether the user can see a post
def sees_post(self, post, context_home_or_profile): if owns_post(self, post): return True if context_home_or_profile and post.author not in self.followings: return False if post.is_public: return True else: for circle in post.circles: circle = get_in_circle_ca...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_view_post(user):\n #only students and admins may use the search, submitForm functions\n return (not bool(user.is_staff) or user.is_superuser)", "def can_view(self, user):\r\n return True", "def can_be_viewed_by(self,user):\n return True", "def is_post_authorised(self, params):\n ...
[ "0.8148385", "0.7721121", "0.76107174", "0.7346776", "0.7345456", "0.72343075", "0.72244954", "0.72244954", "0.72244954", "0.7208309", "0.7117419", "0.7098061", "0.7043158", "0.70406187", "0.7021062", "0.699753", "0.6980933", "0.69795537", "0.6974857", "0.69651085", "0.695663...
0.72803503
5
All posts that are visible to the user on home, reverse chronologically ordered
def retrieves_posts_on_home(self: User, from_id: Optional[str]) -> List[Post]: def _filter_post(p): return sees_post(self, p, context_home_or_profile=True) return get_page( mongoengine_model=Post, extra_query_args={}, extra_filter_func=_filter_post, from_id=from_id, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self):\n\t\treturn Post.objects.order_by('-pub_date')[:5]", "def visible_posts_for(user):\n own = Post.objects.filter(author=user)\n public = Post.objects.filter(circles=PUBLIC_CIRCLE)\n my_circle = Post.objects.filter(circles__owner=user.pk)\n in_circle = Post.objects.filter(circles...
[ "0.6940597", "0.68756944", "0.68317795", "0.68317795", "0.6824538", "0.67645997", "0.67563367", "0.67563367", "0.6688261", "0.66720176", "0.6627604", "0.6600208", "0.6599614", "0.6551504", "0.6550618", "0.655056", "0.65177244", "0.64343196", "0.6411758", "0.6401439", "0.63752...
0.69338363
1
All posts that are visible to the user on home since the to_id Post, reverse chronologically ordered
def poll_latest_posts_on_home(self: User, to_id: str) -> List[Post]: def _filter_post(p): return sees_post(self, p, context_home_or_profile=True) return poll_latest( mongoengine_model=Post, extra_query_args={}, extra_filter_func=_filter_post, to_id=to_id )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieves_posts_on_home(self: User, from_id: Optional[str]) -> List[Post]:\n def _filter_post(p):\n return sees_post(self, p, context_home_or_profile=True)\n\n return get_page(\n mongoengine_model=Post,\n extra_query_args={},\n extra_filter_func=_filter_post,\n from_id=...
[ "0.6913278", "0.6483228", "0.63389397", "0.6312018", "0.6312018", "0.63101375", "0.62469035", "0.62469035", "0.619697", "0.61919415", "0.6168661", "0.61675084", "0.61165303", "0.61018896", "0.6085419", "0.60774714", "0.6037695", "0.60189027", "0.596115", "0.5926781", "0.58968...
0.72919524
0
All posts that are visible to the user on a certain user's profile
def retrieves_posts_on_profile(self, profile_user, from_id): def _filter_post(p): return sees_post(self, p, context_home_or_profile=False) return get_page( mongoengine_model=Post, extra_query_args={ 'author': profile_user }, extra_filter_func=_filter_post, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visible_posts_for(user):\n own = Post.objects.filter(author=user)\n public = Post.objects.filter(circles=PUBLIC_CIRCLE)\n my_circle = Post.objects.filter(circles__owner=user.pk)\n in_circle = Post.objects.filter(circles__members=user.pk)\n return own | public | my_circle | in_circle", "def get...
[ "0.7978445", "0.7545996", "0.7061533", "0.67809623", "0.67631847", "0.66391176", "0.66337824", "0.6610011", "0.6549047", "0.6419027", "0.6313623", "0.62293255", "0.6013442", "0.6009355", "0.6000801", "0.59888965", "0.59676474", "0.59676474", "0.5961858", "0.59599984", "0.5959...
0.6993194
3
Test that CachedJob successfully pulls a new job off the queue.
def test_cachedjob_waits_for_new_job_pre_existing_job(uncached_job): # Setup cached_job = uncached_job initial_job_key = cached_job.current_job_id # Execute cached_job.wait_for_new_job(sleep=2) final_job_key = cached_job.current_job_id # Verify assert initial_job_key == None asser...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cachedjob_removes_job_from_queue(preload_queue_html_data):\n\n # Setup\n queue = preload_queue_html_data\n cached_job = CachedJob(queue=queue)\n expected = queue.pending_jobs\n\n # Execute\n cached_job.wait_for_new_job(sleep=1)\n actual = queue.pending_jobs\n\n assert expected != a...
[ "0.75305635", "0.7472608", "0.67290395", "0.67157555", "0.66919106", "0.6556907", "0.6521149", "0.6440725", "0.64277846", "0.6427092", "0.640635", "0.63999295", "0.63964766", "0.6358329", "0.6349282", "0.6345201", "0.6291425", "0.62903845", "0.62840563", "0.6279245", "0.62693...
0.7506504
1
Helper method to filter zeros
def filter_zeros(X): noNonzeros = np.count_nonzero(X, axis=1) mask = np.where(noNonzeros > 0) return X[mask[0], :]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trim_zeros(filt, trim='fb'):\n first = 0\n trim = trim.upper()\n if 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last =...
[ "0.7372922", "0.6986495", "0.69664484", "0.6919017", "0.667525", "0.66309685", "0.6627707", "0.65701836", "0.65390766", "0.6512598", "0.6507188", "0.6469427", "0.64438885", "0.64154685", "0.64014983", "0.63911945", "0.6358381", "0.6327979", "0.6321019", "0.6312708", "0.626767...
0.79219
0
Method that creates ad saves a scatter plot of targets vs predictions
def diff_plot(targets, predictions, filename, remove_outliers=False): if remove_outliers: indices = np.where(np.logical_not(np.logical_or(np.abs(predictions) > 10 * np.abs(targets), np.abs(predictions) < np.abs(targets) / 10.0))) targets = targets[indices] predictions = predictions[indices] if targets.shape[0]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_predictions(self):\n\n plt.title(\"Targets vs. Predictions\")\n plt.plot(self.T, label=\"Targets\")\n plt.plot(self.Y, label=\"Predictions\")\n plt.xlabel(\"Sample number\")\n plt.legend()\n plt.show()", "def plot_scatter(self):\n if Trainer.y_pred is Non...
[ "0.68067914", "0.6621742", "0.6469675", "0.63705885", "0.63519365", "0.6291138", "0.6274391", "0.625966", "0.6237554", "0.62050825", "0.6184564", "0.616188", "0.6116308", "0.61088634", "0.6106604", "0.60800415", "0.6079421", "0.606093", "0.60474885", "0.60470647", "0.59905577...
0.5891136
31
Method that creates and saves a loss plot
def loss_plot(train_loss, val_loss, filename): plt.plot(train_loss) plt.plot(val_loss) plt.ylabel('Loss') plt.xlabel('Epochs') plt.legend(['Train', 'Val'], loc='upper right') plt.savefig(filename) plt.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_plot(fname, x, y, xlabel, ylabel, title):\n # plot details\n loss_fig = plt.figure(1)\n plt.plot(x, y, \"r-\", label=\"Train Loss\")\n plt.xlabel(xlabel)\n plt.ylabel(ylabel)\n plt.grid(True, which=\"major\", axis=\"both\", color=\"k\", ls=\"dotted\", lw=\"1.0\")\n plt.grid(True, whic...
[ "0.75160754", "0.749208", "0.745585", "0.7427943", "0.72732055", "0.72103786", "0.7102361", "0.7089162", "0.7088583", "0.70800287", "0.703225", "0.69586986", "0.69477695", "0.69418275", "0.6909596", "0.6907716", "0.6902135", "0.6880678", "0.68515563", "0.68074274", "0.6796291...
0.76856
0
return the reward you get for taking action in state and landing on next_state
def get_reward(self, state, action, next_state): assert action in self.get_possible_actions(state), "cannot do action %s from state %s" % (action, state) return self._rewards.get(state, {}).get(action, {}).get(next_state, 0.0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_reward(self, state, action, next_state):\n assert action in self.get_possible_actions(\n state), \"cannot do action %s from state %s\" % (action, state)\n x, y = self.__state_to_xy(next_state)\n reward = -1\n if MAP[y][x] == 'G':\n reward = 1\n elif ...
[ "0.82261556", "0.81532186", "0.81191283", "0.80854607", "0.7950593", "0.7912813", "0.76754266", "0.758897", "0.7516153", "0.7505192", "0.74610573", "0.74253654", "0.7378642", "0.73715734", "0.73450774", "0.732586", "0.7314139", "0.7307842", "0.72925115", "0.72748286", "0.7268...
0.80786586
4
Create an instance of resnet18 model.
def resnet18(pretrained: bool = False, include_top: bool = False, freeze: bool = False): model = torchvision.models.resnet18(pretrained=pretrained) if freeze: set_parameter_requires_grad(model, "fc") if not include_top: output_size = model.fc.in_features model.fc = nn.Identity() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resnet18(pretrained=False):\n model = ResNet(BasicBlock, [2, 2, 2, 2])\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet18']))\n return model", "def resnet18(pretrained=False, **kwargs):\n model = ResNet(BasicBlock, [2, 2, 2, 2], **kwargs)\n if pretrained:\n...
[ "0.7190707", "0.7189109", "0.718525", "0.7150241", "0.71493405", "0.71493405", "0.71493405", "0.71493405", "0.71493405", "0.71299523", "0.71299523", "0.71299523", "0.68781275", "0.6776572", "0.674288", "0.6593779", "0.6567251", "0.6540599", "0.6462289", "0.6460179", "0.645439...
0.5910857
43
Create an instance of resnet34 model.
def resnet34(pretrained: bool = False, include_top: bool = False, freeze: bool = False): model = torchvision.models.resnet34(pretrained) if freeze: set_parameter_requires_grad(model, "fc") if not include_top: output_size = model.fc.in_features model.fc = nn.Identity() return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resnet34(pretrained=False, **kwargs):\n model = ResNet(BasicBlock, [3, 4, 6, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet34']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model", "def resnet34(pretrained=False):\n model = Res...
[ "0.71733284", "0.71322113", "0.7104207", "0.7104207", "0.7104207", "0.7085304", "0.7085304", "0.7085304", "0.7015601", "0.69973624", "0.6687334", "0.66197246", "0.6576784", "0.6571027", "0.65692157", "0.65682685", "0.65431243", "0.6496377", "0.64932436", "0.6469556", "0.64695...
0.60638666
49
Create an instance of resnet50 model.
def resnet50(pretrained: bool = False, include_top: bool = False, freeze: bool = False): model = torchvision.models.resnet50(pretrained) if freeze: set_parameter_requires_grad(model, "fc") if not include_top: output_size = model.fc.in_features model.fc = nn.Identity() return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resnet50(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 4, 6, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet50']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model", "def resnet50(num_classes, pretrained=False, **kw...
[ "0.7491255", "0.7459228", "0.7459228", "0.7443011", "0.7391149", "0.7391149", "0.7391149", "0.7391149", "0.73873913", "0.7364894", "0.72902673", "0.72902673", "0.71849746", "0.713451", "0.7132072", "0.71030587", "0.7002115", "0.69583905", "0.6952049", "0.6925259", "0.6786604"...
0.64491814
27
Returns a 3x3 rotation matrix suitable for rotating sets of x,y,z coordinates. Uses a lefthanded coordinate system where roll is about the x axis, pitch about the y and yaw about the z, so a positive rotation will be clockwise when looking in the direction of the axis. Rotation uses a zyx convention, applying yaw, then...
def matrix(self): # apply yaw, then pitch, then roll return Matrix(( ( 1, 0, 0 ), ( 0, math.cos(self.roll.val), -math.sin(self.roll.val) ), ( 0, math.sin(self.roll.val), math.cos(self.roll.val) ) ))* Matrix(( ( math.cos(self.pitch.val), 0, math.sin(self.pitch.val) ), ( 0, 1, 0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotation_matrix3(angle_x=0, angle_y=0, angle_z=0):\n if angle_x != 0:\n c, s = cos(angle_x), sin(angle_x)\n r = np.array([[1, 0, 0], [0, c, -s], [0, s, c]])\n else:\n r = np.identity(3)\n\n if angle_y != 0:\n c, s = cos(angle_y), sin(angle_y)\n r = r.dot(np.array([[c...
[ "0.7357334", "0.7195169", "0.71853185", "0.70431185", "0.7036197", "0.69560766", "0.6854448", "0.68434334", "0.68110555", "0.67951244", "0.67819315", "0.6733962", "0.66828233", "0.66702914", "0.6658833", "0.6648444", "0.66378057", "0.66324025", "0.6603489", "0.6593149", "0.65...
0.6223156
43
Rotate the vector by the given Angle or radian value. Uses a righthand coordinate system so positive angle will rotate clockwise where the x axis points right and the y axis points down.
def rotate(self, angle): if not isinstance(angle, Angle): angle = Angle(angle) return angle.matrix() * self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate(self, angle):\n n, a = Vector.polar([self.x, self.y])\n a += angle\n self.x = n * cos(a)\n self.y = n * sin(a)", "def rotate_rad(self, angle):\n self.beam_angle += angle\n self.xy = rotate(self.xy, angle)\n self.angle += angle", "def rotate(self, angl...
[ "0.7565612", "0.74042964", "0.7335221", "0.71442616", "0.7030003", "0.6990324", "0.6938393", "0.6890339", "0.6878105", "0.6836883", "0.68090975", "0.68008786", "0.67596817", "0.6745591", "0.6742673", "0.67157465", "0.67037725", "0.66894025", "0.6688393", "0.66857123", "0.6626...
0.62797076
53
Rotate the vector by the given Rotation or (roll,pitch,yaw) value, about the given Vector3d or (x,y,z) point. Uses a righthanded coordinate system so a positive angle will result in a clockwise rotation when looking in the axis direction.
def rotate_about(self, rotation, point): if not isinstance(point,Vector3d): point = Vector3d(*point) return (self - point).rotate(rotation) + point
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate(self, x=0, y=0, z=0):\n\t\tquaternion = R.from_euler('xyz', [x, y, z], degrees=True)\n\t\trotation_matrix = np.array(quaternion.as_matrix())\n\t\trotation_matrix = np.pad(rotation_matrix, [(0, 1), (0, 1)], mode='constant')\n\t\trotation_matrix[3,3] = 1\n\n\t\tself.matrix = np.matmul(self.matrix, rotatio...
[ "0.69152033", "0.68399537", "0.6737186", "0.6638122", "0.6622648", "0.6577238", "0.6522625", "0.6515174", "0.64878714", "0.6475635", "0.64649767", "0.6396809", "0.6384067", "0.63669896", "0.6361012", "0.6349359", "0.63389134", "0.63048863", "0.62898755", "0.6265561", "0.62418...
0.724603
0
Scurve function. sigmoid(0) is almost 0 and sigmoid(1) is almost 1, with an Sshaped curve in between.
def sigmoid(x): return 1.0/(1.0+math.exp(-(x-0.5)*12.0))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid(x):\n s = 1 / (1 + np.exp(-x))\n return s", "def sigmoid(x):\n\n s = 1 / (1 + np.exp(-x))\n\n return s", "def sigmoid(x):\r\n return 1 / (1 + np.exp(-x))", "def sigmoid(x):\n return 1 / (1 + exp(-x))", "def sigmoid(x):\n return 1 / (1 + exp(-x))", "def sigmoid(x):\r\n ...
[ "0.72954875", "0.72953516", "0.72104937", "0.72006434", "0.72006434", "0.71796805", "0.71754813", "0.7160047", "0.7155375", "0.7133799", "0.7133799", "0.7133799", "0.7133799", "0.7133799", "0.7133799", "0.7131177", "0.71307576", "0.7124751", "0.7121753", "0.71146137", "0.7109...
0.69284
38
Return True if this Rectangle overlaps the given Rectangle rect.
def intersects(self, rect): return ( rect.right >= self.left and rect.left < self.right and rect.bottom >= self.top and rect.top < self.bottom )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _rect_intersects(self, rect):\n\tb = (self.left() > rect.right() or \n\t\tself.right() < rect.left() or \n\t\tself.top() < rect.bottom() or \n\t\tself.bottom() > rect.top())\n\treturn not b", "def intersect(self, rectangle):\n return self.contains(rectangle.corner) or rectangle.contains(self.corner)",...
[ "0.7900632", "0.7253098", "0.7141259", "0.70272446", "0.7010724", "0.69642925", "0.6955739", "0.6927011", "0.68506116", "0.68051285", "0.6750947", "0.673739", "0.6706012", "0.6672882", "0.66449225", "0.6591029", "0.6576501", "0.65428793", "0.6425972", "0.64139944", "0.6379404...
0.78974867
1
Returns a new Cuboid representing the area where this Cuboid and cuboid overlap, or None if they do not overlap
def intersection(self, cuboid): if not self.intersects(cuboid): return None else: in_back = max(self.back, cuboid.back) in_front = min(self.front, cuboid.front) in_left = max(self.left, cuboid.left) in_right = min(self.right, cuboid.right) in_top = max(self.top, cuboid.top) in_bottom = min(self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def area(self) -> float:\n return cross3(self.b.position - self.a.position,\n self.c.position - self.a.position).length() / 2.0", "def get_overlap(c1, c2):\n width = max(0, min(c1['right'], c2['right']) - max(c1['left'], c2['left']))\n height = max(0, min(c1['bottom'], c2['botto...
[ "0.5901651", "0.5880152", "0.5621607", "0.5593558", "0.55018955", "0.54630864", "0.54491454", "0.53871244", "0.5375547", "0.53748024", "0.5336974", "0.529725", "0.529725", "0.52953035", "0.5287891", "0.52822596", "0.5274854", "0.52742153", "0.5268218", "0.5263978", "0.5253315...
0.6980924
0
utility function to determine if `state` is inside the map.
def in_bounds(state, map_shape): return 0 <= state[0] < map_shape[0] and 0 <= state[1] < map_shape[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_in_state(location, state_regions):\n flag=0\n for each in state_regions:\n if is_in_region(location,each)==True:\n flag=1\n if flag==1:\n return True\n else:\n return False", "def _in_zone(hass, zone_entity_id, state):\n if not state or None in (state.attribu...
[ "0.70241916", "0.68012166", "0.6617356", "0.65669984", "0.6528462", "0.6515131", "0.6467506", "0.643944", "0.63602877", "0.6293549", "0.6195699", "0.61497766", "0.61497766", "0.6148276", "0.6117941", "0.61067396", "0.61002874", "0.60384387", "0.6023801", "0.60072947", "0.6004...
0.70303535
0
initialize all utilities to zero, or to the rewards for final states
def init_utils(map_shape, rewards): utilities = np.zeros(map_shape) utilities[final_arr] = rewards[final_arr] return utilities
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\r\n\t\tself.player_selected_actions = np.zeros((self.num_actions,), int)\r\n\t\tself.player_reward = np.zeros((self.num_timesteps,))\r\n\t\tself.player_optimum = np.zeros_like(self.player_reward, dtype=int)", "def reset_initial_values(self):\n #### TODO: move reset conditions to /sim\n ...
[ "0.67180055", "0.65808296", "0.6494542", "0.6473988", "0.6422013", "0.62698835", "0.6266514", "0.62233114", "0.622042", "0.62164927", "0.6204542", "0.61860895", "0.6162239", "0.61486644", "0.6148441", "0.61084527", "0.60743886", "0.6046238", "0.6045933", "0.60425496", "0.6040...
0.6082651
16
Name of this column.
def Name(self): return self.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_name(self):\n return self.col_name", "def columnName(self):\n return self.__column", "def column_name(self) -> Optional[str]:\n return pulumi.get(self, \"column_name\")", "def column_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"column_name\")", "def colum...
[ "0.86722624", "0.83100283", "0.8080886", "0.7886318", "0.7886318", "0.76383203", "0.7508606", "0.7473399", "0.7471107", "0.7429538", "0.74181193", "0.74181193", "0.7396328", "0.73807406", "0.7361718", "0.73601365", "0.7355124", "0.7355124", "0.7355124", "0.7355124", "0.735508...
0.0
-1
Checks that all the columns have same the number of rows.
def _validate_cardinality(self, columns): cards = [len(c.data) for c in columns] c = np.unique(cards) assert len(c) == 1, c return c[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_row(row):\n \n if len(row) != _ncols:\n raise ValueError(\"Row contains {0} columns, expected {1}!\\n\\n{2}\\n\".format(len(row), _ncols, row))", "def test_row_from_columns_has_errors(self):\n errors_on_separate_row = True\n field_setup = None\n error_names = ['first',...
[ "0.6821837", "0.67747664", "0.6656312", "0.6631516", "0.6624145", "0.6610161", "0.6568613", "0.6561385", "0.6526123", "0.65234196", "0.6501377", "0.64836305", "0.64554477", "0.64515525", "0.6447409", "0.64200896", "0.634507", "0.63309884", "0.63238245", "0.63177013", "0.63044...
0.6474992
12
Name of this table.
def Name(self): return self.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self):\n if self.table:\n return \"{}.{}\".format(self.table, self.field_name)\n return self.field_name", "def table_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"table_name\")", "def table(self):\n return self._table_name", "def get_table_name(...
[ "0.83553594", "0.82960325", "0.82196283", "0.818861", "0.8100748", "0.8073954", "0.80549634", "0.80549634", "0.80549634", "0.79258406", "0.79065734", "0.772197", "0.7672439", "0.7597051", "0.7411029", "0.7320582", "0.7320582", "0.7320582", "0.7320582", "0.7320582", "0.7320582...
0.0
-1
Returns index of column with the specified name.
def ColumnIndex(self, name): assert name in self.name_to_index return self.name_to_index[name]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def column_index(self, column_name: str) -> int:\n return self._column_indices[column_name]", "def get_column_index(self, colName):\n\t\treturn self._columns[colName]", "def find_index_column(sheet, name, num):\n for idx in range(1, 26):\n if sheet[chr(idx + 64) + str(num)].value == name:\n ...
[ "0.8369732", "0.82278687", "0.761645", "0.7615155", "0.7539434", "0.7366718", "0.7331785", "0.72998846", "0.72762024", "0.723955", "0.70934033", "0.70155704", "0.6988663", "0.68562555", "0.6850019", "0.67143756", "0.6681335", "0.6671047", "0.66369", "0.6603488", "0.6582341", ...
0.8385383
0
Transforms data values into integers using a Column's vocab.
def Discretize(col, data=None): # pd.Categorical() does not allow categories be passed in an array # containing np.nan. It makes it a special case to return code -1 # for NaN values. start_t = time.perf_counter() if data is None: data = col.data # pd.isnull returns true for both np.na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cat_to_num(self):\n\n for col in self.conf_dict:\n indexer = StringIndexer(inputCol=col, outputCol=\"{}_indexed\".format(col))\n self.df = indexer.fit(self.df).transform(self.df)", "def map_to_num(column, cats, vals):\r\n map_dict = {cats[i]:vals[i] for i in range(len(cats))}\...
[ "0.6557428", "0.6237392", "0.62307775", "0.5941076", "0.59282935", "0.5890161", "0.57835364", "0.5714869", "0.5678335", "0.5601424", "0.5580078", "0.5572222", "0.5572222", "0.55695844", "0.5484704", "0.54815674", "0.54464734", "0.5438957", "0.54063886", "0.5402412", "0.537616...
0.0
-1
Given a variable name, retrieves a handle on the tensorflow Variable.
def get_variable_by_name(var_name): global_vars = ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES) def _filter_fn(item): try: return var_name == item.op.name except AttributeError: # Collection items without operation are ignored. return False candidate_vars = list(filter(_filter_fn,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_variable(self, variable_name):\n with self._graph.as_default():\n return self._sess.run(self._get_tensor_by_name(variable_name))", "def _get_existing_variable(name):\n try:\n op = tf.get_default_graph().get_operation_by_name(name)\n except KeyError:\n return None\n\n # Among all cases (p...
[ "0.73991674", "0.69605136", "0.64867485", "0.6293598", "0.6174583", "0.6113733", "0.61042607", "0.6102446", "0.60988647", "0.60611856", "0.60356635", "0.6009104", "0.6006974", "0.5997929", "0.5994218", "0.59811825", "0.5980368", "0.59383166", "0.5938176", "0.5934079", "0.5914...
0.61206
5
Creates a gradpassthrough op with the forward behavior provided in f. Use this function to wrap any op, maintaining its behavior in the forward pass, but replacing the original op in the backward graph with an identity.
def grad_pass_through(f): @custom_gradient def _grad_pass_through_op(*args, **kwargs): def grad(*args, **kwargs): variables = kwargs.get("variables") if variables is not None: # Variables involved in the wrapped op will not receive gradients. return args, [None] * len(variables) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_gradient(f=None):\n\n if f is None:\n return lambda f: custom_gradient(f=f)\n\n @Bind.decorator\n def decorated(wrapped, args, kwargs):\n \"\"\"Decorated function with custom gradient.\"\"\"\n if context.executing_eagerly():\n return _eager_mode_decorator(wrapped, args, kwargs)\n els...
[ "0.60289764", "0.58720404", "0.5712203", "0.56250596", "0.55644006", "0.55220485", "0.55114216", "0.5494046", "0.5375402", "0.53342724", "0.5306879", "0.5296591", "0.5280722", "0.5205133", "0.51920694", "0.517611", "0.5135707", "0.510767", "0.5103577", "0.509574", "0.509574",...
0.6999448
0
Compute the horizontal unit vector in the plane normal to the incident beam direction. Note that it is assumed here that the incident beam is perpendicular to the gravity vector.
def cyl_x_unit_vector(gravity: sc.Variable, incident_beam: sc.Variable) -> sc.Variable: v_x = sc.cross(incident_beam, gravity) return v_x / sc.norm(v_x)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNormalVector(self):\n vector = self.unit_vector\n vector.rotate(math.pi / 2)\n return vector", "def PlaneNormalVector(h, k, l):\r\n vec = np.array([h, k, l])\r\n return vec/np.linalg.norm(vec)", "def normal(self) -> Vec:\n return abs(self.up_axis.cross(self.forward()))"...
[ "0.6586124", "0.64079964", "0.6270185", "0.6256552", "0.6215722", "0.6205256", "0.6175257", "0.6175257", "0.6175257", "0.6121776", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", "0.6107919", ...
0.72170377
0
Compute the vertical unit vector in the plane normal to the incident beam direction. Note that it is assumed here that the incident beam is perpendicular to the gravity vector.
def cyl_y_unit_vector(gravity: sc.Variable) -> sc.Variable: v_y = -gravity return v_y / sc.norm(v_y)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_vertical_velocity(self):\n # Note: again we make use of the automatically added 'grid' attribute, and the stored coef_w attribute.\n # Here we arbitrarily set the vertical velocity to increase in the\n # y-direction (not very realistic).\n return self.coef_w[0] * self.grid.y[No...
[ "0.6781418", "0.65646875", "0.6471634", "0.6417735", "0.6339692", "0.6317502", "0.63147146", "0.6313796", "0.63110274", "0.6266843", "0.6239492", "0.62369084", "0.62340444", "0.62127006", "0.6190836", "0.61745906", "0.6122614", "0.61107427", "0.6102718", "0.6080016", "0.60731...
0.7192715
0
Compute the horizontal x coordinate perpendicular to the incident beam direction. Note that it is assumed here that the incident beam is perpendicular to the gravity vector.
def cylindrical_x( cyl_x_unit_vector: sc.Variable, scattered_beam: sc.Variable ) -> sc.Variable: return sc.dot(scattered_beam, cyl_x_unit_vector)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cyl_x_unit_vector(gravity: sc.Variable, incident_beam: sc.Variable) -> sc.Variable:\n v_x = sc.cross(incident_beam, gravity)\n return v_x / sc.norm(v_x)", "def Distance_traveled_in_the_x_direction(i_vy , g , i_h, i_vx ):\n t= (i_vy + math.sqrt(math.pow(-i_vy,2) -4*(.5*g)*(-i_h)))/g\n return float...
[ "0.68176794", "0.60537624", "0.6002913", "0.5936071", "0.58247143", "0.5809991", "0.5771408", "0.57610536", "0.5757527", "0.572173", "0.5707807", "0.56985384", "0.56943285", "0.56574106", "0.5635309", "0.56308925", "0.56137705", "0.5594236", "0.5592444", "0.5521306", "0.55180...
0.5580814
19
Compute the vertical y coordinate perpendicular to the incident beam direction. Note that it is assumed here that the incident beam is perpendicular to the gravity vector.
def cylindrical_y( cyl_y_unit_vector: sc.Variable, scattered_beam: sc.Variable ) -> sc.Variable: return sc.dot(scattered_beam, cyl_y_unit_vector)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_vertical_velocity(self):\n # Note: again we make use of the automatically added 'grid' attribute, and the stored coef_w attribute.\n # Here we arbitrarily set the vertical velocity to increase in the\n # y-direction (not very realistic).\n return self.coef_w[0] * self.grid.y[No...
[ "0.6973278", "0.69652474", "0.65846395", "0.6493674", "0.6448111", "0.6437988", "0.6431983", "0.6405434", "0.6252892", "0.6203439", "0.6154504", "0.6146603", "0.6086901", "0.6057522", "0.6052666", "0.6043423", "0.60369897", "0.59715694", "0.5933397", "0.5911489", "0.58906084"...
0.62282175
9
Round a datetime object to a multiple of a timedelta
def roundTime(dt=None, dateDelta=datetime.timedelta(minutes=1)): roundTo = dateDelta.total_seconds() if dt == None : dt = datetime.datetime.now() seconds = (dt - dt.min).seconds # // is a floor division, not a comment on following line: rounding = (seconds+roundTo/2) // roundTo * roundTo retur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datetime_round(dt, period, start=None):\n result = datetime_mod(dt, period, start)\n if abs(dt - result) >= period // 2:\n result += period\n return result", "def round_timedelta(td, period):\n\n period_seconds = period.total_seconds()\n half_period_seconds = period_seconds / 2\n rem...
[ "0.68981403", "0.68552595", "0.65706146", "0.6420372", "0.64072424", "0.6403435", "0.6342599", "0.63149107", "0.62943363", "0.6240979", "0.6233253", "0.6167185", "0.61668456", "0.6109091", "0.60548645", "0.6045999", "0.5956489", "0.59173924", "0.57935774", "0.5697111", "0.563...
0.68266994
2
All initial values are set to zero until initalized using the initialize() method which reads in data using the ModelParameterDictionary and sets the random variables according to their respective distribution
def __init__(self): self.shape_parameter = 0.0 """Shape parameter describes the skew of the Weibull distribution. If shape < 3.5, data skews left. If shape == 3.5, data is normal. If shape > 3.5, data skews right. """ self.scale_paramte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_parameters(self):\n stdv = 1. / math.sqrt(self.weight.data.size(1))\n self.weight.data.uniform_(-stdv, stdv)\n if self.bias is not None:\n self.bias.data.uniform_(-stdv, stdv)", "def reset_parameters(self):\n logger.info('===== Initialize %s with normal distributio...
[ "0.7266492", "0.72575974", "0.7135072", "0.70894074", "0.70770675", "0.7074035", "0.70233995", "0.6937692", "0.6937692", "0.6928661", "0.6890951", "0.6881885", "0.68689823", "0.6864337", "0.68554384", "0.68550956", "0.67966956", "0.679371", "0.67881876", "0.6738923", "0.66983...
0.0
-1
Build index.html for cherrypy Render the template and return the html file to be delivered to the browser
def index(self, action=None, item_id=None, item_path=None, reload=None): item = self.plugin.get_sh().return_item(item_path) tmpl = self.tplenv.get_template('index.html') # add values to be passed to the Jinja2 template eg: tmpl.render(p=self.plugin, interface=interface, ...) return tmpl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n return render_template('index.html')", "def main():\n return render_template('index.html')", "def index():\n # Render template\n return render_template('index.html')", "def get_index():\n return render_template('index.html')", "def index():\n return render_template(\"index.h...
[ "0.78007984", "0.78007984", "0.772002", "0.77079576", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76367", "0.76118773", "0.76118773", "...
0.0
-1
Takes an `etree.Element` and a tag name to search for and retrieves the text attribute from any of the parent element's direct children. Returns a simple `str` if only a single element is found, or a list if multiple elements with the same tag. Ignores element attributes, returning only the text.
def get_text(parent, tag, plural = False): text = None for item in parent.findall(tag): t = item.text if not text: if plural: text = [t] else: text = t elif isinstance(text, list): text.append(t) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_element_text(self, element):\n text = ''\n if element.text is not None:\n text = text + element.text\n for child in element.getchildren():\n text = text + self._get_element_text(child)\n if element.tail is not None:\n text = text + element.tail\n return text", "def _text_of...
[ "0.708323", "0.69239", "0.63163096", "0.62998754", "0.6188424", "0.6187285", "0.61542684", "0.6121271", "0.61170256", "0.6115291", "0.6100374", "0.6097478", "0.59545386", "0.5946928", "0.5942928", "0.5920667", "0.5902594", "0.58992714", "0.58896804", "0.5870991", "0.58676594"...
0.7001072
1
Takes either a `str` or a filelike object and passes back a tuple containing (md5sum, filesize) The file is streamed as 1Mb chunks so should work for large files. Filelike object must support `seek()`
def get_md5(data): if hasattr(data, "read") and hasattr(data, 'seek'): data.seek(0) m = md5() chunk = data.read(1024*1024) # 1Mb f_size = 0 while(chunk): f_size += len(chunk) m.update(chunk) chunk = data.read(1024*1024) data.seek(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def md5sum(fname):\n\tdef read_chunks(fh):\n\t\tfh.seek(0)\n\t\tchunk = fh.read(8096)\n\t\twhile chunk:\n\t\t\tyield chunk\n\t\t\tchunk = fh.read(8096)\n\t\telse: #最后要将游标放回文件开头\n\t\t\tfh.seek(0)\n\n\tm = hashlib.md5()\n\tif isinstance(fname, str) and os.path.exists(fname):\n\t\tfh = open(fname, \"rb\")\n\t\tfor ch...
[ "0.72915167", "0.7128833", "0.7114593", "0.6996359", "0.69749075", "0.690541", "0.6870545", "0.68620884", "0.68549144", "0.6790323", "0.67039245", "0.6700344", "0.66730016", "0.66488886", "0.664635", "0.66294765", "0.66204536", "0.66172457", "0.6614622", "0.65947324", "0.6583...
0.7766328
0
Find the lowest and highest corner of a Rectangle
def min_max_coord(self, coord): coordinate = [] minx = min(coord[0][0], coord[1][0], coord[2][0], coord[3][0]) maxx = max(coord[0][0], coord[1][0], coord[2][0], coord[3][0]) miny = min(coord[0][1], coord[1][1], coord[2][1], coord[3][1]) maxy = max(coord[0][1], coord[1][1], coord[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bounds(self):\n occupied_locations = self.board.keys()\n min_x = min(p[0] for p in occupied_locations)\n max_x = max(p[0] for p in occupied_locations)\n min_y = min(p[1] for p in occupied_locations)\n max_y = max(p[1] for p in occupied_locations)\n return ((min_x, max_x), (min_y, max_y))"...
[ "0.70099235", "0.6966278", "0.69182146", "0.6906904", "0.6845326", "0.6845326", "0.6845203", "0.6843669", "0.6808552", "0.6735146", "0.67064345", "0.6695514", "0.6657198", "0.6650735", "0.6601418", "0.6587032", "0.6586924", "0.6584988", "0.656769", "0.65573394", "0.6541586", ...
0.0
-1
Sets the direction based on the previous direction we came from.
def get_inertia(self,p0,p1): # direction (index) of movement if p0.x!=p1.x: return 0 elif p0.y!=p1.y: return 1 else: # z direction return 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_direction(self, new_dir):\n self.__direction = new_dir", "def set_direction(self, dir):\n if dir == 0:\n self.direction = [0, -1]\n elif dir == 1:\n self.direction = [1, 0]\n elif dir == 2:\n self.direction = [0, 1]\n elif dir == 3:\n ...
[ "0.7746206", "0.74156153", "0.73931086", "0.7099428", "0.70471", "0.7042119", "0.6937615", "0.6913319", "0.68935573", "0.6785674", "0.6760073", "0.67295766", "0.6670327", "0.6652412", "0.6633178", "0.6598327", "0.6579291", "0.6508445", "0.64998657", "0.6496158", "0.64562744",...
0.0
-1
This returns how many disconnected pin components there are.
def num_pin_components(self, pin_name): return len(self.pin_groups[pin_name])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected_component_lengths(self):\n return [len(x) for x in nx.connected_components(self.return_undirected())]", "def _num_conn_comp(graph):\n\n return nx.number_connected_components(graph)", "def num_complementary_regions(self):\n g = self._get_puncturefinder_graph()\n # retur...
[ "0.7562491", "0.7416879", "0.74096906", "0.7112288", "0.70458215", "0.6966993", "0.6843206", "0.6829814", "0.669162", "0.66499", "0.6648658", "0.662687", "0.66004586", "0.65740275", "0.6518938", "0.6518938", "0.6479624", "0.6471631", "0.6465076", "0.64430714", "0.6425476", ...
0.6883167
6
Generate a compact, deterministic representation of the current configuration. This is saved in the job log and used by `check_digest` in subsequent jobs to determine if the configuration changed the operation needs to be rerun. The default implementation calculates a SHA1 digest of the values of the inputs that where ...
def save_digest(self, task: "TaskView") -> dict: # XXX user definition should be able to exclude inputs from digest # XXX might throw AttributeError inputs = task._resolved_inputs # type: ignore # sensitive values are always redacted so no point in including them in the digest ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config_md5():\r\n all_opts = sorted([c for c in _config_var_list if c.in_c_key],\r\n key=lambda cv: cv.fullname)\r\n return theano.gof.cc.hash_from_code('\\n'.join(\r\n ['%s = %s' % (cv.fullname, cv.__get__()) for cv in all_opts]))", "def config_digest(reques...
[ "0.6685994", "0.6470806", "0.6313638", "0.60796064", "0.60220957", "0.5973646", "0.5896773", "0.5826914", "0.58026105", "0.5748865", "0.56577724", "0.5544629", "0.5531141", "0.5519635", "0.54824924", "0.54590297", "0.54039544", "0.53428143", "0.5333673", "0.53077894", "0.5289...
0.5606275
11
Collect any environment variables set by the connections returned by ``_get_connections()``.
def _find_relationship_env_vars(self) -> dict: env = {} for rel in self.connections.by_type(): # only one per connection type env.update(rel.merge_props(find_env_vars, True)) return env
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def env_vars(self):\n return _untag_env_vars(self._tagged_env_vars, build=False)", "def _get_env(self):\n env = {}\n for k, v in os.environ.items():\n k = k.decode() if isinstance(k, bytes) else k\n v = v.decode() if isinstance(v, bytes) else v\n env[k] = v\n...
[ "0.75786704", "0.73192704", "0.7294009", "0.7288282", "0.7230704", "0.71848536", "0.7143984", "0.7135728", "0.6995262", "0.69538516", "0.69390166", "0.6859071", "0.68553215", "0.68553215", "0.68553215", "0.68553215", "0.6850144", "0.6827602", "0.6808371", "0.6806571", "0.6801...
0.67573607
28
Return a dictionary of environment variables applicable to this task.
def get_environment(self, addOnly: bool, env: Optional[dict] = None) -> dict: if env is None: env = self.target.environ # build rules by order of preference (last overrides first): # 1. ensemble's environment # 2. variables set by connections # 3. operation's environ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task_variables(self, for_env=False):\n the_vars = {}\n task_role = self.get_task_role()\n if task_role is not None:\n the_vars = {k:v.get_value(task_role)\n for k, v in task_role.get_visible_vars().items()\n if not for_env or (for_en...
[ "0.79889476", "0.79296094", "0.79296094", "0.79296094", "0.79296094", "0.77215135", "0.7709666", "0.7623945", "0.76088065", "0.7565515", "0.7516029", "0.74899375", "0.747397", "0.738796", "0.73447275", "0.7319002", "0.7284174", "0.72819114", "0.7251188", "0.7219336", "0.72193...
0.0
-1
Find a relationship that this task can use to connect to the given instance. First look for relationship between the task's target instance and the given instance. If none is found, see if there a default connection of the given type.
def find_connection( ctx: RefContext, target: NodeInstance, relation: str = "tosca.relationships.ConnectsTo", ) -> Optional[RelationshipInstance]: connection = cast( Optional[RelationshipInstance], Ref( f"$OPERATION_HOST::.requirements::*[.type...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_related_instance(self,\n related_instance_class: Union[Type[NetworkInstance],\n Type[VnfInstance]],\n relationship_related_to_type: str) -> Iterator[\\\n ...
[ "0.59339", "0.56424", "0.53664076", "0.53402746", "0.51648915", "0.5110103", "0.50956404", "0.5043712", "0.50315577", "0.50175565", "0.5004465", "0.49936703", "0.4992888", "0.49702263", "0.49190623", "0.4916863", "0.48906094", "0.4877163", "0.48642722", "0.4845273", "0.484159...
0.75019854
0
Get the front element.
def peek(self) -> int: if self.input_stack is None and self.output_stack is None: return None else: for i in range(0, len(self.input_stack)): self.output_stack.append(self.input_stack.pop()) return self.output_stack[-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getFront(self):\n\t\tfront = self.queue[self.front]\n\t\treturn front\n\t\tpass", "def getFront(self):\n if not self.isEmpty():\n return self._data[0]\n else:\n return -1", "def front(self):\n return self.queue[0] if not self.empty() else None", "def peek_front(...
[ "0.82009244", "0.79261875", "0.7852642", "0.7791182", "0.77886623", "0.75723046", "0.752337", "0.7510604", "0.7478953", "0.7379256", "0.7379256", "0.734284", "0.7323573", "0.7320296", "0.7291721", "0.72772557", "0.7269801", "0.72657627", "0.7253295", "0.72355044", "0.72213495...
0.0
-1
Returns whether the queue is empty.
def empty(self) -> bool: if len(self.input_stack)==0 and len(self.output_stack)==0: return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_empty(self):\n return len(self.the_queue) == 0", "def is_empty(self):\n return len(self.__queue) > 0", "def is_empty(self):\n return len(self.queue) == 0", "def is_empty(self):\n return len(self.queue) == 0", "def is_empty(self):\n return self.queue == []", "def ...
[ "0.9270249", "0.92506766", "0.923635", "0.923635", "0.9155843", "0.9098441", "0.9095006", "0.90922606", "0.90731245", "0.9053733", "0.89205354", "0.89137155", "0.8877591", "0.88436323", "0.88436323", "0.8835949", "0.88038146", "0.8758203", "0.87577534", "0.87310195", "0.86462...
0.0
-1
Returns true if the given point is inside this button
def wasClicked(self, point): p1 = self.rect.getP1() p2 = self.rect.getP2() if (p1.getX() <= point.getX() <= p2.getX() and p1.getY() <= point.getY() <= p2.getY()): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contains_point(self, point) -> bool:\n return (self.pos.x <= point[0] <= self.pos.x + self.size.x and\n self.pos.y <= point[1] <= self.pos.y + self.size.y and\n self.visible)", "def is_point_in(self, point):\n return (self.upperleft[0] <= point[0] <= self.upperrigh...
[ "0.79296035", "0.7822236", "0.7822236", "0.7712401", "0.75957394", "0.74614006", "0.74614006", "0.741993", "0.7331815", "0.7317757", "0.72606695", "0.7237214", "0.72198933", "0.7199678", "0.71970654", "0.71909785", "0.717014", "0.7138743", "0.7118173", "0.7117486", "0.7098508...
0.8225055
0
Returns YUV space channels representation of matrix in BGR space.
def bgr_to_yuv_channels(matrix): yuv_matrix = cv2.cvtColor(matrix, cv2.COLOR_BGR2YUV) return cv2.split(yuv_matrix)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def yuv2bgr(tens: Tensor) -> Tensor:\n if not _is_yuv_image(tens):\n raise ValueError(\n f\"Tensor of shape 3 expected. Found shape {len(tens.shape)}. \"\n \"This function converts an YUV Tensor to its BGR counterpart\"\n )\n\n img = cv.cvtColor(tens, YUV2BGR)\n return ...
[ "0.64366806", "0.620075", "0.61821824", "0.6044535", "0.6017581", "0.598009", "0.59576815", "0.59331363", "0.5860556", "0.58582824", "0.58398837", "0.58302945", "0.581686", "0.57962024", "0.57512003", "0.5739474", "0.57268625", "0.569926", "0.5697993", "0.5661303", "0.5659381...
0.73302835
0
Gets the id of this Status. internal id of status, gets created by system
def id(self) -> int: return self._id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id(self):\n return self.status.id", "def get_id(self):\n\n\t\treturn self.__id", "def id_str(self):\n return self.status.id_str", "def _get_id(self):\n return self.id", "def get_id(self) -> int:\n return self.id", "def get_id(self) -> int:\n return self.id", "def ...
[ "0.8748242", "0.76359236", "0.7608475", "0.75984716", "0.7597968", "0.7597968", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", "0.7562605", ...
0.7407735
48
Sets the id of this Status. internal id of status, gets created by system
def id(self, id: int): self._id = id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id_status(self, id_status):\n self._id_status = id_status", "def set_id(self, id):\n self.__id = id", "def SetId(self, id):\n self.id = int(id)", "def set_id(self, id):\n self.data['id'] = id", "def set_id(self, id_):\n\n self.id_ = id_", "def set_id(self, id):\n ...
[ "0.8006725", "0.78805274", "0.78672", "0.7821201", "0.77638435", "0.7698021", "0.74709046", "0.74706274", "0.74706274", "0.74706274", "0.74706274", "0.74706274", "0.7432048", "0.7432048", "0.7432048", "0.7432048", "0.7432048", "0.7432048", "0.7432048", "0.7432048", "0.7432048...
0.7441295
17
Gets the owner of this Status. owner of status to differentiate between status by customer and internal status
def owner(self) -> str: return self._owner
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def owner(self):\n return Organization.objects.get(id=self.owner_id)", "def getOwner(self):\r\n return self.owner", "def get_owner(self):\n return self.__owner", "def getOwner(self):\n return self.__owner", "def getOwner(self):\n return self.__owner", "def owner(self):\...
[ "0.78331643", "0.75774986", "0.75078976", "0.7406867", "0.7406867", "0.73850465", "0.732142", "0.73034054", "0.72378296", "0.7222642", "0.7222642", "0.7222642", "0.7222642", "0.7222642", "0.7215669", "0.7117884", "0.70322865", "0.6974363", "0.69516927", "0.69516927", "0.69288...
0.6942482
20
Sets the owner of this Status. owner of status to differentiate between status by customer and internal status
def owner(self, owner: str): self._owner = owner
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_owner(self, owner):\n self.__owner = owner", "def owner(self, owner):\n self._owner = owner", "def owner(self, owner):\n self._owner = owner", "def owner(self, owner):\n self._owner = owner", "def owner(self, owner):\n self._owner = owner", "def owner(self, owne...
[ "0.7791753", "0.7501731", "0.7501731", "0.7501731", "0.7501731", "0.7465591", "0.7465591", "0.7465591", "0.7465591", "0.74589896", "0.7186712", "0.7162466", "0.70594513", "0.6971625", "0.6949899", "0.6931628", "0.681902", "0.68009835", "0.67739826", "0.6531717", "0.63323855",...
0.7466008
5
Gets the status of this Status. name of status, for example \"planned\", \"staffed\", \"finished\"
def status(self) -> str: return self._status
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status(self):\n return STATUS[self.fields['status']]", "def status(self):\n return status_dict[self._get_property_(self.STATUS).upper()]", "def status(self):\n return self.get(self._names[\"status\"])", "def _get_status(self):\n return u'%s' % (self.get_status_display())", "...
[ "0.7622136", "0.7493074", "0.74834335", "0.74323434", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", "0.73027474", ...
0.6979568
58
Convert the string into a list of bits.
def string_to_bit_array(text): array = list() for char in text: bin_val = bin_value(char, 8) # Get value of char in one byte array.extend([int(x) for x in list(bin_val)]) # Add the bits to the list return array
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _string_to_bitlist(self, data):\n l = len(data) * 8\n result = [0] * l\n pos = 0\n for ch in data:\n i = 7\n while i >= 0:\n # bit-wise operation\n if ch & (1 << i) != 0:\n result[pos] = 1\n else:\...
[ "0.8705171", "0.79383844", "0.76609385", "0.74345416", "0.74090487", "0.7159752", "0.66168106", "0.6612349", "0.6490972", "0.6336382", "0.6332502", "0.6269086", "0.6269086", "0.62167823", "0.6194286", "0.6165127", "0.6096438", "0.604556", "0.6036077", "0.6034268", "0.6026799"...
0.7396606
5
Split into lists each of size 'n'.
def split_into_n(s, n): return [s[k:k + n] for k in range(0, len(s), n)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_list_into_sublists_of_size_n(lst, n):\n return [lst[i : i + n] for i in range(0, len(lst), n)]", "def split(a, n):\n k, m = divmod(len(a), n)\n ret = [a[i*k+min(i, m):(i+1)*k+min(i+1, m)] for i in range(n)]\n return ret", "def split(a, n):\n n = min(n, len(a))\n k, m = divmod(len(a)...
[ "0.8492814", "0.82600695", "0.81925404", "0.80970645", "0.806114", "0.80475175", "0.8017348", "0.7996203", "0.7986872", "0.7981534", "0.7926774", "0.78881973", "0.7882007", "0.78756535", "0.77767855", "0.7770877", "0.77567947", "0.7732476", "0.7728437", "0.77138394", "0.77114...
0.78935957
11
Shift a list of the given value.
def shift(self, g, d, n): return g[n:] + g[:n], d[n:] + d[:n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_elements(self, shifts):\n for _ in range(shifts):\n # get the current tail of the list\n old_tail = self.get_tail()\n # delete the current tail\n self.remove_tail()\n # place the current tail in the beginning of the list, with that all elem...
[ "0.69929963", "0.68658006", "0.6525571", "0.64629936", "0.6391682", "0.6306096", "0.62911296", "0.6063079", "0.60278183", "0.5991653", "0.5982575", "0.598211", "0.59734744", "0.59643704", "0.59581316", "0.5942577", "0.5936857", "0.5919769", "0.5909025", "0.5903117", "0.589335...
0.0
-1
method to check if all rows have the same class attribute
def allRowsWithSameClass(self, data, structure): classIndex = structure['class']['index'] for value in structure['class']['values']: newData = list(filter(lambda x: x[classIndex] == value, data)) if len(newData) == len(data): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_same_class(instances):\n # assumption: instances is not empty and class label is at index -1\n first_label = instances[0][-1]\n for instance in instances:\n if instance[-1] != first_label:\n return False \n return True # if we get here, all instance labels matched the first la...
[ "0.6725636", "0.64604634", "0.6213739", "0.6189229", "0.610799", "0.5885866", "0.58502835", "0.5818962", "0.5630929", "0.56233495", "0.5543786", "0.55361366", "0.54942226", "0.54910564", "0.54899174", "0.5483627", "0.5481766", "0.5464791", "0.5459607", "0.54580736", "0.544749...
0.77054113
0
Saved the weights of the trained model and the training history.
def save_mlp_trained_model(model, training_history, save_dir, train_num): model.save_weights(save_dir + '/{}_bottleneck_fc_model.h5'.format(train_num)) history_dict = training_history.history save = save_dir + '/{}_bottleneck_history.json'.format(train_num) json.dump(history_dict,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model(self):\n save_folder = os.path.join(self.log_path, \"models\", \"weights_{}\".format(self.epoch))\n if not os.path.exists(save_folder):\n os.makedirs(save_folder)\n\n for model_name, model in self.models.items():\n print(\"MODEL NAME = {}\".format(model_nam...
[ "0.75609285", "0.74589366", "0.7383465", "0.7349716", "0.73417634", "0.72641754", "0.72444755", "0.72266394", "0.7197186", "0.7180464", "0.7180464", "0.71789545", "0.7170924", "0.715443", "0.7097848", "0.70726484", "0.7072484", "0.7049579", "0.70365846", "0.699106", "0.696990...
0.6915722
25
Saved the weights of the trained model and the training history.
def save_cnn_trained_model(model, training_history, save_dir, train_num): # Save the model training history history_dict = training_history.history history_save = save_dir + '/{}_cnn_history.json'.format(train_num) json.dump(history_dict, open(history_save, 'w')) # Save the model weights weights...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model(self):\n save_folder = os.path.join(self.log_path, \"models\", \"weights_{}\".format(self.epoch))\n if not os.path.exists(save_folder):\n os.makedirs(save_folder)\n\n for model_name, model in self.models.items():\n print(\"MODEL NAME = {}\".format(model_nam...
[ "0.7559289", "0.74588996", "0.73830515", "0.73482215", "0.73400486", "0.7263889", "0.7242855", "0.7226794", "0.7195693", "0.7180372", "0.7180372", "0.7177778", "0.7169525", "0.7155429", "0.70979387", "0.707155", "0.7071525", "0.7047838", "0.7036099", "0.69899577", "0.6970225"...
0.0
-1
Controller for the app home page.
def home(request): variable_options = [('Total Precipitation(mm)', 'APCP_surface'), ('Convective Available Potential Energy(J/kg)', 'CAPE_surface'), ('Dew Point Temperature(C)', 'DPT_2maboveground'), ('Geopotential Height(m)','HGT_500mb'), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home():\n payload = manager.get_payload()\n return render_template('index.html', payload=payload)", "def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)", "def home(self, *args, **kwargs):\n pass", "def home(request):\n\treturn r...
[ "0.78027886", "0.7685395", "0.7654384", "0.7584396", "0.7558254", "0.7547364", "0.7488385", "0.7459023", "0.7447416", "0.73899287", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7383182", ...
0.0
-1
Controller for the app home page.
def leaf(request): variable_options = [('Total Precipitation(mm)', 'APCP_surface'), ('Convective Available Potential Energy(J/kg)', 'CAPE_surface'), ('Dew Point Temperature(C)', 'DPT_2maboveground'), ('Geopotential Height(m)','HGT_500mb'), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home():\n payload = manager.get_payload()\n return render_template('index.html', payload=payload)", "def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)", "def home(self, *args, **kwargs):\n pass", "def home(request):\n\treturn r...
[ "0.78027886", "0.7685395", "0.7654384", "0.7584396", "0.7558254", "0.7547364", "0.7488385", "0.7459023", "0.7447416", "0.73899287", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7388719", "0.7383182", ...
0.0
-1
Returns the MSE of predictions at the last time step; used when the following m time steps are predicted at every time step, because only predictions made at the final time step will be useful for evaluation
def last_time_step_mse(y_true, y_pred): return keras.metrics.mean_squared_error(y_true[:,-1],y_pred[:,-1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mse(predicted, actual):\n diff = predicted - actual\n return np.average(diff * diff, axis=0)", "def mse(observed, predicted):\n return np.sqrt(np.mean((observed - predicted)**2))", "def mse(real, predicted):\n # Calculate the mse\n N = len(real)\n mse = (1 / N) * np.sum((real - predicted)...
[ "0.71316", "0.7100399", "0.7061553", "0.6948985", "0.6923322", "0.6923322", "0.6873936", "0.6820049", "0.6744909", "0.67235965", "0.6657408", "0.6657408", "0.6648754", "0.66374433", "0.66078264", "0.65740746", "0.652141", "0.6506477", "0.648369", "0.6480953", "0.6477491", "...
0.7884475
0
Compute this dask collection. This turns a lazy Dask collection into its inmemory equivalent. For example a Dask array turns into a NumPy array and a Dask dataframe turns into a Pandas dataframe. The entire dataset must fit into memory before calling this operation.
def compute(self, **kwargs: Any) -> Any: raise NotImplementedError("Inheriting class must implement this method.")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataset(self):\n with self._lock:\n if self._dataset is None:\n if isinstance(self._orig_dataset, DaskLazyIndexer):\n self._orig_dataset = self._orig_dataset.dataset\n dataset = dask_getitem(self._orig_dataset, self.keep)\n for t...
[ "0.62944055", "0.6272045", "0.6272045", "0.5916003", "0.5809786", "0.5763698", "0.57008344", "0.5635369", "0.56326306", "0.5630112", "0.55906826", "0.55441046", "0.5534288", "0.5533714", "0.55092674", "0.5422051", "0.54218036", "0.540819", "0.5382995", "0.53784823", "0.537222...
0.0
-1