query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
r""" Transposition (i,j) in the vector v
def swap2(d, n, v, i, j): for a in range(n): for k in range(d): if k == i or k == j: continue x = a*d*d + d*i + k y = a*d*d + d*j + k v[x], v[y] = v[y], v[x] x = a*d*d + d*k + i y = a*d*d + d*k + j v[x], v[y] = v[y], v[x] x = a*d*d + d*i + i y = a*d*d + d*j + j v[x], v[y] = v[y], v[x] x = a*d*d + d*j + i y = a*d*d + d*i + j v[x], v[y] = v[y], v[x]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transpose():", "def transpose(m):\n\n pass", "def transp(lon, z, v):\n\tdx = np.diff(lon, axis=1) * 111 * 1000 # valid only for low latitudes!!!\n\taux = dx[:,0]; aux.shape = (np.size(aux), 1)\n\tdx = np.concatenate( (dx, aux), axis=1) \n\n\tdz = np.diff(z, axis=0)\n\taux = dz[0,:]; aux.shape = (1, np...
[ "0.66814506", "0.6551252", "0.65357876", "0.6345111", "0.63199097", "0.6183269", "0.6159493", "0.6156704", "0.61289173", "0.6096206", "0.6076558", "0.6074613", "0.6038157", "0.6010176", "0.60027725", "0.5979507", "0.5971244", "0.5955453", "0.59221447", "0.5877151", "0.5875646...
0.0
-1
r""" permutation (i,j,k) in the vector v
def swap3(d, n, v, i, j, k): for a in range(n): for m in range(d): if m == i or m == j or m == k: continue x = a*d*d + d*i + m y = a*d*d + d*j + m z = a*d*d + d*k + m v[x],v[y],v[z] = v[z],v[x],v[y] x = a*d*d + d*m + i y = a*d*d + d*m + j z = a*d*d + d*m + k v[x],v[y],v[z] = v[z],v[x],v[y] x = a*d*d + d*i + i y = a*d*d + d*j + j z = a*d*d + d*k + k v[x],v[y],v[z] = v[z],v[x],v[y] x = a*d*d + d*i + j y = a*d*d + d*j + k z = a*d*d + d*k + i v[x],v[y],v[z] = v[z],v[x],v[y] x = a*d*d + d*i + k y = a*d*d + d*j + i z = a*d*d + d*k + j v[x],v[y],v[z] = v[z],v[x],v[y]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tuple_permutation(v,P):\r\n u = []\r\n w = list(v)[:]\r\n test = True\r\n for i in range(len(v)):\r\n if ((isinstance(v[i], int) == True) or (isinstance(v[i], str) == True)):\r\n if (v[i] in P):\r\n w[i] = P(v[i])\r\n else:\r\n u.append(tuple_permu...
[ "0.6331758", "0.62894833", "0.6197115", "0.6137187", "0.6044073", "0.6019328", "0.5991224", "0.5982989", "0.5912814", "0.5890045", "0.58892596", "0.5880598", "0.5838851", "0.5801919", "0.5771089", "0.57405615", "0.56747866", "0.56370187", "0.56347495", "0.5619772", "0.5605379...
0.5475577
39
r""" Perform a cyclic swap on the vertices. This is used in multiplication of symbolic upper matrices. Currently it is suboptimal but on the other hand, this cost much less than whatever convex hull computation.
def vertex_cyclic_swap(nvars, l, i): if i == 0 or not l: return l ll = [] F = l[0].parent() for v in l: assert not v[-i:] ll.append(F(tuple(v[-i:]) + tuple(v[:-i]))) for v in ll: v.set_immutable() return tuple(ll)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vertex_swap(d, n, l, i1, i2, j1, j2):\n if i1 == i2 and j1 == j2:\n return l\n if i1 == j1:\n # (i1,i1) -> (i2,i2)\n assert i2 == j2\n def swap(v):\n swap2(d, n, v, i1, i2)\n elif i1 == i2:\n # (i,j1) -> (i,j2)\n def swap(v):\n swap2(d, n...
[ "0.6700525", "0.6548219", "0.62071115", "0.619347", "0.6155958", "0.61089027", "0.6073555", "0.6059136", "0.6011071", "0.59793395", "0.5920292", "0.591253", "0.59060276", "0.5894991", "0.58805555", "0.5820859", "0.5787564", "0.5771385", "0.57236433", "0.57217413", "0.5709025"...
0.6623225
1
Creates a dashboard of plots for time steps, potential, kintetic, and total energy
def create_dashboard(h, t, k, p): plt.style.use('seaborn') # Initialize the dashboard fig = plt.figure(figsize=(20, 8)) ax1 = fig.add_subplot(2, 2, 1) ax2 = fig.add_subplot(2, 2, 2) ax3 = fig.add_subplot(2, 2, 3) ax4 = fig.add_subplot(2, 2, 4) # Create individual graphs dt_line, = ax1.plot(h, lw=3, c='k') total_line, = ax2.plot(t, lw=3, c='#d62728') k_line, = ax3.plot(k, lw=3, c='#1f77b4') p_line = ax4.plot(p, lw=3, c='#2ca02c') ax1.set_title(r'Variation in $\Delta t$') ax1.set_ylabel(r'$\Delta t$') ax2.set_title(r'Total Energy over Time') ax2.set_ylabel('Total Energy') ax3.set_title('Kinetic Energy over Time') ax3.set_ylabel('Kinetic Energy') ax3.set_xlabel('Time Steps') ax4.set_title('Potential Energy over Time') ax4.set_ylabel('Potential Energy') ax4.set_xlabel('Time Steps') plt.show() """im = ax[0, 0].imshow(model.lattice, cmap='Greys', vmin=-1, vmax=1) energy_line, = ax[0, 1].plot([], [], lw=3) mag_line, = ax[1, 0].plot([], [], lw=3) heat_line, = ax[1, 1].plot([], [], lw=3) susceptibility_line, = ax[2, 0].plot([], [], lw=3) acceptance_line, = ax[2, 1].plot([], [], lw=3)"""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_vanHove_dt(comp,conn,start,step_size,steps):\n \n (fin,) = conn.execute(\"select fout from comps where comp_key = ?\",comp).fetchone()\n (max_step,) = conn.execute(\"select max_step from vanHove_prams where comp_key = ?\",comp).fetchone()\n Fin = h5py.File(fin,'r')\n g = Fin[fd('vanHove...
[ "0.64270926", "0.641641", "0.63471955", "0.633336", "0.6203229", "0.6157202", "0.6156514", "0.60662705", "0.60575175", "0.60480624", "0.6023913", "0.5948977", "0.5948531", "0.5910911", "0.589686", "0.5895649", "0.58862346", "0.58814776", "0.5880334", "0.58726776", "0.58645946...
0.77813894
0
[input > 32_channel > 64_channel] (lrelu, lrelu) one residual, with spatial conv1 and conv2 [64_channel > 128_channel > 256_channel] (lrelu, lrelu) one residual, with spatial conv3 and conv4 [256_channel > 512_channel] (no activation) conv5 = weighted_pooled after residual(should halve channels now)
def network_modified(input): up6 = upsample_and_concat( conv5, conv4, 256, 512 , 'up_conv1' ) conv6=slim.conv2d(up6, 256,[3,3], rate=1, activation_fn=lrelu,scope='g_conv6_1') conv6=slim.conv2d(conv6,256,[3,3], rate=1, activation_fn=lrelu,scope='g_conv6_2') up7 = upsample_and_concat( conv6, conv3, 128, 256 , 'up_conv2' ) conv7=slim.conv2d(up7, 128,[3,3], rate=1, activation_fn=lrelu,scope='g_conv7_1') conv7=slim.conv2d(conv7,128,[3,3], rate=1, activation_fn=lrelu,scope='g_conv7_2') up8 = upsample_and_concat( conv7, conv2, 64, 128 , 'up_conv3') conv8=slim.conv2d(up8, 64,[3,3], rate=1, activation_fn=lrelu,scope='g_conv8_1') conv8=slim.conv2d(conv8,64,[3,3], rate=1, activation_fn=lrelu,scope='g_conv8_2') up9 = upsample_and_concat( conv8, conv1, 32, 64 , 'up_conv4') conv9=slim.conv2d(up9, 32,[3,3], rate=1, activation_fn=lrelu,scope='g_conv9_1') conv9=slim.conv2d(conv9,32,[3,3], rate=1, activation_fn=lrelu,scope='g_conv9_2') conv10=slim.conv2d(conv9,12,[1,1], rate=1, activation_fn=None, scope='g_conv10') out = tf.depth_to_space(conv10,2) return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv_relu_pool_forward(x, w, b, conv_param, pool_param):\n a, conv_cache = conv_forward_fast(x, w, b, conv_param)\n s, relu_cache = relu_forward(a)\n out, pool_cache = max_pool_forward_fast(s, pool_param)\n cache = (conv_cache, relu_cache, pool_cache)\n return out, cache", "def conv_relu_pool_...
[ "0.7122538", "0.7122538", "0.6950416", "0.6885206", "0.6869267", "0.6830916", "0.6811857", "0.6751886", "0.67322737", "0.6657507", "0.6656693", "0.66494304", "0.663799", "0.66285485", "0.66139823", "0.66124654", "0.6612394", "0.66063386", "0.6571061", "0.65616673", "0.6557849...
0.61448115
82
Creates a new user profile object
def create_user(self, email, name, password=None): if not email: raise ValueError("Users must have an email address") email = self.normalize_email(email) user = self.model(email = email, name = name) user.set_password(password) user.save(using = self._db) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user_profile(instance, created, **_):\n if created:\n Profile.objects.create(user=instance)", "def createUserProfile(user):\n MyProfile.objects.get_or_create(user=user)", "def create_profile(username):\n user = User.objects.create(username=username)\n return Profile.objects.create...
[ "0.8367903", "0.81304103", "0.81051487", "0.8098728", "0.8076744", "0.8076744", "0.8076744", "0.805672", "0.8050523", "0.80482244", "0.8038606", "0.800379", "0.7968006", "0.79638684", "0.7961977", "0.79449934", "0.7897795", "0.78840756", "0.7868318", "0.786531", "0.7865149", ...
0.0
-1
Creates and saves a new superuser with given details
def create_superuser(self, email, name, password): user = self.create_user(email, name, password) user.is_superuser = True user.is_staff = True user.save(using=self._db) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_superuser(self, su_id, first_name, last_name, email, phone_number, password):\n user = self.create_user(\n su_id,\n first_name,\n last_name,\n email,\n phone_number,\n password=password,\n )\n user.is_admin = True\n ...
[ "0.7452185", "0.7432198", "0.7297633", "0.7279892", "0.72240347", "0.7219963", "0.7207689", "0.71808976", "0.7158941", "0.71064526", "0.7101526", "0.70998144", "0.7079699", "0.7065048", "0.70579106", "0.70458865", "0.7034362", "0.7034056", "0.70265925", "0.70232207", "0.70158...
0.0
-1
Used to get a users full name
def get_full_name(self): return self.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_full_name(self):\n full_name = '%s %s' % (self.user.first_name.strip(), self.user.last_name.strip())\n if len(full_name.strip()) == 0:\n full_name = self.user.username\n return full_name.strip()", "def get_full_name(self):\n full_name = f'{self.first_name} {self.las...
[ "0.8447406", "0.84173375", "0.840863", "0.840863", "0.8322008", "0.83157456", "0.8233342", "0.8191648", "0.81704843", "0.80976194", "0.8085201", "0.8049897", "0.80166596", "0.8014928", "0.8014928", "0.80035484", "0.7998611", "0.79971266", "0.79911834", "0.79884243", "0.798031...
0.0
-1
Used to get the users short name
def get_short_name(self): return self.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_short_name(self):\n return self.username", "def get_short_name(self):\n return self.username", "def get_short_name(self):\n return self.username", "def get_short_name(self):\n # The user is identified by their email address\n return self.first_name", "def get_shor...
[ "0.8692162", "0.8692162", "0.8692162", "0.8419169", "0.835935", "0.8267483", "0.8214984", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0.8179056", "0...
0.73236275
60
Django uses this when it needs to convert the object into a string
def __str__(self): return self.email
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return str(self.obj)", "def str_(object_):\n return str(object_)", "def u(obj):\n return obj if isinstance(obj, str) else str(obj)", "def __str__(self):\n return str(self.__dict__['_obj'])", "def format_item(self,obj):\n return unicode(obj)", ...
[ "0.7571222", "0.74968106", "0.7390877", "0.73628175", "0.73334724", "0.7276389", "0.7255745", "0.7255745", "0.7237711", "0.72124106", "0.71872014", "0.7185711", "0.71037436", "0.71037436", "0.71037436", "0.7084364", "0.7082783", "0.7033254", "0.7020016", "0.69618905", "0.6961...
0.0
-1
Return the model as a string.
def __str__(self): return self.status_text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def model_info(self) -> str:\n return self._model_info(self.model).decode(\"utf-8\")", "def get_cpo_model_string(self):\n # Build string\n self._build_cpo_model_string()\n\n # Publish model\n self....
[ "0.80334365", "0.7646696", "0.7642632", "0.7509533", "0.74480665", "0.74480665", "0.74373275", "0.74339825", "0.74090093", "0.7385252", "0.73606116", "0.730152", "0.7259204", "0.72199345", "0.7141298", "0.7138032", "0.7135251", "0.7126956", "0.7084482", "0.7061448", "0.704482...
0.0
-1
Simplifies display of description of the object
def __unicode__(self): return self.title
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def description(self):", "def description():", "def __str__(self):\n return str(self.description)[:10]", "def Description(self) -> str:", "def Description(self) -> str:", "def __str__(self):\n return \"{0} : {1}\".format(self.name, self.description)", "def description(self):\n pass...
[ "0.80118245", "0.7948067", "0.77770305", "0.77731", "0.77731", "0.7686482", "0.7643417", "0.7643417", "0.763395", "0.7609585", "0.75963145", "0.75963145", "0.7564732", "0.7494345", "0.74726653", "0.74393976", "0.738546", "0.7361387", "0.7352297", "0.7344379", "0.73168623", ...
0.0
-1
returns as a string
def __unicode__(self): return unicode(self.user)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_str(self) -> str:", "def toString():", "def to_string(self):\r\n return self.__str__()", "def toString(self) -> unicode:\n ...", "def toString(self) -> unicode:\n ...", "def safeToString():", "def toString(self) -> str:\n raise NotImplementedError", "def get_string(...
[ "0.8379665", "0.81285405", "0.7657668", "0.7572911", "0.7572911", "0.75156456", "0.7466699", "0.74074817", "0.7362591", "0.72081953", "0.72052455", "0.72052455", "0.72052455", "0.71933657", "0.7128041", "0.71150506", "0.7070591", "0.7048586", "0.70474184", "0.7038429", "0.701...
0.0
-1
Download and unpack the Zenodo minted data for the current stitches distribution.
def fetch_zenodo(self): # full path to the stitches root directory where the example dir will be stored if self.data_dir is None: data_directory = pkg_resources.resource_filename('stitches', 'data') else: data_directory = self.data_dir # build needed subdirectories if they do not already exist tas_data_path = os.path.join(data_directory, "tas-data") temp_data_path = os.path.join(data_directory, "temp-data") if not os.path.exists(tas_data_path): os.mkdir(tas_data_path) if not os.path.exists(temp_data_path): os.mkdir(temp_data_path) # get the current version of stitches that is installed current_version = pkg_resources.get_distribution('stitches').version try: data_link = InstallPackageData.DATA_VERSION_URLS[current_version] except KeyError: msg = f"Link to data missing for current version: {current_version}. Using default version: {InstallPackageData.DEFAULT_VERSION}" data_link = InstallPackageData.DEFAULT_VERSION print(msg) # retrieve content from URL print("Downloading example data for stitches version {}. This may take a few minutes...".format(current_version)) response = requests.get(data_link) with zipfile.ZipFile(BytesIO(response.content)) as zipped: # extract each file in the zipped dir to the project for f in zipped.namelist(): extension = os.path.splitext(f)[-1] # Extract only the csv and nc files if all([len(extension) > 0, extension in (".csv", ".nc")]): basename = os.path.basename(f) # Check to see if tas-data is in the file path if "tas-data" in f: basename = os.path.join("tas-data", basename) out_file = os.path.join(data_directory, basename) # extract to a temporary directory to be able to only keep the file out of the dir structure with tempfile.TemporaryDirectory() as tdir: # extract file to temporary directory zipped.extract(f, tdir) # construct temporary file full path with name tfile = os.path.join(tdir, f) print(f"Unzipped: {out_file}") # transfer only the file sans the parent directory to the data package shutil.copy(tfile, out_file)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_zenodo(self):\n\n # retrieve content from URL\n try:\n logging.info(f\"Downloading example data from {self.url}\")\n r = requests.get(self.url, stream=True)\n with io.BytesIO() as stream:\n with tqdm.wrapattr(\n stream,\n ...
[ "0.66224813", "0.63485897", "0.6268055", "0.6250528", "0.60906255", "0.6000069", "0.59467095", "0.5897437", "0.5875298", "0.5873493", "0.5796746", "0.5769636", "0.57534075", "0.57515734", "0.5747376", "0.5746502", "0.5727455", "0.5726162", "0.5718221", "0.57016945", "0.569462...
0.7480389
0
Download and unpack Zenodominted stitches package data that matches the current installed stitches distribution.
def install_package_data(data_dir: str = None): zen = InstallPackageData(data_dir=data_dir) zen.fetch_zenodo()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_zenodo(self):\n\n # full path to the stitches root directory where the example dir will be stored\n if self.data_dir is None:\n data_directory = pkg_resources.resource_filename('stitches', 'data')\n else:\n data_directory = self.data_dir\n\n # build neede...
[ "0.76543707", "0.60858387", "0.6030473", "0.6029866", "0.5999589", "0.5853508", "0.57119447", "0.5664164", "0.5609213", "0.5573679", "0.55025905", "0.54998595", "0.54737514", "0.54679334", "0.5459293", "0.5448745", "0.5415353", "0.54141283", "0.5396013", "0.53918666", "0.5384...
0.52912843
29
Get all morbidities by war name.
def get_morbidities_for_war_era(): war_era_name = request.args.get('warEra') if not war_era_name: raise BadRequestError("warEra parameter is missing") return datasources_service.get_morbidities_for_war_era(war_era_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_war_eras():\n return datasources_service.get_war_eras()", "def get_movies(self):\n worlds = ['cinemaworld',\n 'filmworld']\n\n pool = Pool(2)\n movies_world = pool.map(self.get_movies_list, worlds)\n pool.close()\n pool.join()\n\n for m_world ...
[ "0.530085", "0.5216914", "0.52164996", "0.52158", "0.512819", "0.5046316", "0.49238253", "0.48991495", "0.48724052", "0.4854176", "0.48369068", "0.47993955", "0.4775364", "0.47421068", "0.47291753", "0.46694636", "0.4650255", "0.46441507", "0.46405992", "0.46394694", "0.46272...
0.69981116
0
Get list of all war eras.
def get_war_eras(): return datasources_service.get_war_eras()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ewriters():\n return dict(_ewriters)", "def get_morbidities_for_war_era():\n war_era_name = request.args.get('warEra')\n if not war_era_name:\n raise BadRequestError(\"warEra parameter is missing\")\n return datasources_service.get_morbidities_for_war_era(war_era_name)", "def list_shelve...
[ "0.5828334", "0.5808068", "0.57432085", "0.5644334", "0.56183976", "0.5573372", "0.5563877", "0.55565184", "0.55515826", "0.55351365", "0.55152845", "0.55032134", "0.54578054", "0.54362935", "0.54297596", "0.5429045", "0.5412836", "0.54041094", "0.5400069", "0.5393652", "0.53...
0.7025474
0
Create the request client instance.
def __init__(self, **kwargs): self.__kwargs = kwargs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_client(self, context):\n return Client(self.settings['client_routing'], context=context)", "def create_client(self) -> None:\n pass", "def create_client(self) -> None:\n self._client = discovery.build('ml', 'v1')", "def client_setup(self):\n self.client = Client()", "def _clien...
[ "0.7219166", "0.716613", "0.70292443", "0.6970843", "0.65893507", "0.65696806", "0.6560892", "0.65602523", "0.65598226", "0.65531236", "0.65434104", "0.65080535", "0.6499727", "0.64700776", "0.6468287", "0.64645094", "0.64377755", "0.6397173", "0.636765", "0.63654023", "0.635...
0.0
-1
Get the withdraw records of an account.
def get_deposit_withdraw(self, op_type: 'str', currency: 'str' = None, from_id: 'int' = None, size: 'int' = None, direct: 'str' = None) -> list: check_should_not_none(op_type, "operate type") params = { "currency": currency, "type": op_type, "from": from_id, "direct": direct, "size": size } from huobi.service.wallet.get_deposit_withdraw import GetDepositWithdrawService return GetDepositWithdrawService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def withdraws(self, asset=None, timestamp=None):\n\t\tif self._session:\n\t\t\tdata = {}\n\t\t\tif asset:\n\t\t\t\tdata['asset'] = asset\n\t\t\tif timestamp:\n\t\t\t\tdata['startTime'] = int(timestamp*1000)\n\n\t\t\tresult = self._session.get_withdraw_history(**data)\n\n\t\t\tif result and result.get('success'):\n...
[ "0.6707817", "0.62090015", "0.61132365", "0.59777224", "0.586913", "0.5829058", "0.58250797", "0.5786732", "0.572243", "0.56471694", "0.56391835", "0.558515", "0.5583775", "0.55779237", "0.5575182", "0.5569372", "0.5547758", "0.55422384", "0.55409026", "0.550295", "0.5485568"...
0.0
-1
Submit a request to withdraw some asset from an account.
def post_create_withdraw(self, address: 'str', amount: 'float', currency: 'str', fee: 'float', chain: 'str' = None, address_tag: 'str' = None) -> int: check_symbol(currency) check_should_not_none(address, "address") check_should_not_none(amount, "amount") check_should_not_none(fee, "fee") params = { "currency": currency, "address": address, "amount": amount, "fee": fee, "chain": chain, "addr-tag": address_tag } from huobi.service.wallet.post_create_withdraw import PostCreateWithdrawService return PostCreateWithdrawService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def withdraw(self, asset: Asset, address: str, amount: float,\n receive_window: Optional[int] = None):\n api_params = {\n 'asset': asset.value,\n 'address': address,\n 'amount': amount,\n 'timestamp': get_current_time_milliseconds()\n }\n\n ...
[ "0.6766613", "0.6515961", "0.6493949", "0.6168783", "0.61496735", "0.60446924", "0.58922", "0.5787488", "0.5744847", "0.56431615", "0.5603435", "0.54944474", "0.5494445", "0.548808", "0.547827", "0.5470316", "0.54234326", "0.5407679", "0.53537494", "0.5329677", "0.5327134", ...
0.0
-1
Cancel an withdraw request.
def post_cancel_withdraw(self, withdraw_id: 'int') -> int: params = { "withdraw-id": withdraw_id } from huobi.service.wallet.post_cancel_withdraw import PostCancelWithdrawService return PostCancelWithdrawService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Cancel(self, request, global_params=None):\n config = self.GetMethodConfig('Cancel')\n return self._RunMethod(\n config, request, global_params=global_params)", "def Cancel(self, request, global_params=None):\n config = self.GetMethodConfig('Cancel')\n return self._RunMethod(\n ...
[ "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055", "0.66425055"...
0.6858336
0
Get deposit address of corresponding chain, for a specific crypto currency (except IOTA)
def get_account_deposit_address(self, currency: 'str') -> list: check_should_not_none(currency, "currency") params = { "currency": currency } from huobi.service.wallet.get_account_deposit_address import GetAccountDepositAddressService return GetAccountDepositAddressService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_deposit_address(self, currency):\n return self.__call__('balance', \"getdepositaddress\", \n {\"currencyname\": currency})", "def generate_deposit_address(self, currency):\n return self.__call__('balance', \"generatedepositaddress\", \n ...
[ "0.773913", "0.72328436", "0.7039697", "0.6727295", "0.6697329", "0.6667728", "0.65922564", "0.6322239", "0.6310505", "0.6198878", "0.57645744", "0.57568973", "0.5751982", "0.5747228", "0.5672455", "0.55680877", "0.5531586", "0.5513636", "0.550136", "0.54769146", "0.5449721",...
0.6650143
6
Get the withdraw quota for currencies
def get_account_withdraw_quota(self, currency: 'str') -> list: check_should_not_none(currency, "currency") params = { "currency": currency, } from huobi.service.wallet.get_account_withdraw_quota import GetAccountWithdrawQuotaService return GetAccountWithdrawQuotaService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options_to_withdraw(self, amount):\n counter = PaperMoneyCounter() # aux class\n options = [] # options to withdraw\n remaining_cash = 0 # aux var\n\n if (amount % 20 == 0 or amount % 50 == 0) and (amount <= 1000): # is it allowed to withdraw?\n # prioritizing 100-dollar ...
[ "0.63382167", "0.62305385", "0.6179834", "0.60655946", "0.5956213", "0.5947808", "0.59429044", "0.58825815", "0.58773303", "0.5864017", "0.58567953", "0.58432806", "0.5827308", "0.5814937", "0.57675916", "0.57590467", "0.5756222", "0.57123595", "0.5685044", "0.5678759", "0.56...
0.6826426
0
Parent get sub user depoist history.
def get_sub_user_deposit_history(self, sub_uid: 'int', currency: 'str' = None, start_time: 'int' = None, end_time: 'int' = None, sort: 'str' = None, limit: 'int' = None, from_id: 'int' = None) -> DepositHistory: check_should_not_none(sub_uid, "sub_uid") params = { "subUid": sub_uid, "currency": currency, "startTime": start_time, "endTime": end_time, "sort": sort, "limit": limit, "fromId": from_id } from huobi.service.wallet.get_sub_user_deposit_history import GetSubUserDepositHistoryService return GetSubUserDepositHistoryService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_history(self, user):\n return History.objects(user=user).order_by('-created_at').first()", "def user_history(self):\n self.query_1 = \"SELECT * FROM orders WHERE user_id=%s\"\n self.input_1 = (self.user_id,) \n self.event = \"user_history\"\n self.message = \"Order his...
[ "0.61068934", "0.6100039", "0.60115993", "0.59361994", "0.59344065", "0.58696795", "0.5844484", "0.5742806", "0.571162", "0.5664033", "0.56583655", "0.56562835", "0.5651735", "0.56295484", "0.5605254", "0.5565101", "0.55631995", "0.55622804", "0.55606115", "0.54985034", "0.54...
0.61268777
0
Parent get sub user deposit address
def get_sub_user_deposit_address(self, sub_uid: 'int', currency: 'str') -> list: check_should_not_none(sub_uid, "subUid") check_should_not_none(currency, "currency") params = { "subUid": sub_uid, "currency": currency } from huobi.service.wallet.get_sub_user_deposit_address import GetSubUserDepositAddressService return GetSubUserDepositAddressService(params).request(**self.__kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAddress(user):", "def address1(self, instance):\r\n return instance.user.profile.address1", "def deposit_address(self):\n response = self.query('deposit_address')\n return response", "def address2(self, instance):\r\n return instance.user.profile.address2", "def get_depos...
[ "0.6647167", "0.6165405", "0.61530155", "0.5871263", "0.5798319", "0.57832575", "0.5712461", "0.5691261", "0.5627003", "0.55536985", "0.5515165", "0.5496232", "0.54191124", "0.5402566", "0.5397947", "0.5349834", "0.53110534", "0.52480906", "0.5225322", "0.5217574", "0.5213821...
0.58459884
4
Add an obstacle to the map
def add_obstacle(self, obstacle_to_add): if self.obstacles.size != 0: self.obstacles = np.hstack((self.obstacles, obstacle_to_add)) else: self.obstacles = np.array([obstacle_to_add])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_obstacle(self, x, y):\n self.BOARD[y][x].traversable = False\n self.board_array[y][x] = 1", "def add_obstacle(self, x, y):\n self.BOARD[y][x].traversable = False\n self.board_array[y][x] = 1", "def add_obstacle(self, *points: Tuple[float, float]):\n self.obstacles.app...
[ "0.75989723", "0.75989723", "0.7295586", "0.7156997", "0.6637772", "0.65937614", "0.6447093", "0.6407341", "0.6341093", "0.6300385", "0.6247986", "0.6215138", "0.61860317", "0.60853684", "0.6058344", "0.6036493", "0.60249126", "0.60026395", "0.5975957", "0.59466404", "0.59013...
0.78030485
0
Add a waypoint to the drone
def add_waypoint(self, waypoint): self.drone.add_waypoint(waypoint)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def waypoint_add_rel(self):\n pass", "def waypoint_add_global(self):\n pass", "def create_waypoint(self, waypoint):\n connection = self.__create_connection()\n try:\n waypoint_list = list(waypoint)\n key = self.__compound_key(waypoint)\n waypoint_lis...
[ "0.75902", "0.7147039", "0.6792248", "0.62503475", "0.6224604", "0.6080674", "0.60524154", "0.6044039", "0.603555", "0.60317796", "0.5964286", "0.5918597", "0.58790517", "0.5873767", "0.58673775", "0.5866497", "0.585557", "0.5817661", "0.58173054", "0.57790995", "0.5753916", ...
0.8948917
0
Set the drone's location in the map
def set_drone_position(self, new_point): self.drone.set_drone_position(new_point)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def m_location_set(self, x: int, y: int):\n pass", "def set_location(self, location_set):", "def set_location(self, lat, long):\n self._data['loc'] = [lat, long]", "def location(self, value: 'Point'):\n self.geometry.location = value", "def set_location(self, location):\n self.locat...
[ "0.6776562", "0.67337173", "0.6717304", "0.66437644", "0.66012245", "0.65962243", "0.65886664", "0.6457518", "0.643699", "0.63909936", "0.62847275", "0.6281692", "0.6220761", "0.6214897", "0.60538673", "0.60247016", "0.6005318", "0.5934853", "0.5927787", "0.5925752", "0.59109...
0.6822219
0
Reset the obstacles' positions within the map (should be called when map is refreshed to clean the array)
def reset_obstacles(self): self.obstacles = np.array([])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.obstacles = []\n self._tick = 0", "def recreate_obstacles(self):\n self.board_matrix = np.full(Dimension.board_size(), 1)\n self.obstacles = self.create_obstacles()", "def reset(self) -> None:\n self.map = []\n for col in range(self.width):\n ...
[ "0.80095875", "0.7382117", "0.72062683", "0.7101044", "0.7061013", "0.70536333", "0.7010583", "0.6989404", "0.69813454", "0.69743735", "0.6880206", "0.68602246", "0.6838129", "0.6808036", "0.67923963", "0.6767282", "0.67519385", "0.67181975", "0.67109746", "0.6702349", "0.669...
0.84130687
0
Return True if drone should avoid obstacle and False if not
def is_obstacle_in_path(self): for obstacle in self.obstacles.tolist(): print("obstacle.get_point():", obstacle.get_point()) dist_to_obstacle = VectorMath.get_vector_magnitude(np.subtract(obstacle.get_point(), self.drone.get_point())) if dist_to_obstacle < obstacle.get_radius() + Constants.DETECTION_THRESHOLD: if isinstance(obstacle, StationaryObstacle): paths = self.generate_possible_paths(obstacle) if len(paths) != 0: return True, np.array(paths) elif isinstance(obstacle, MovingObstacle): pass return False, None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _detect_obstacles(self):\n def _distance(point, line_point1, line_point2):\n \"\"\"calcuate the distance between a point and a line\"\"\"\n vec1 = line_point1 - point\n vec2 = line_point2 - point\n distance = np.abs(np.cross(vec1,vec2)) / np.linalg.norm(line_p...
[ "0.6633492", "0.64835197", "0.6468089", "0.64078575", "0.63262063", "0.63250136", "0.6243122", "0.62322724", "0.6221644", "0.61202383", "0.6082648", "0.6052843", "0.6038652", "0.6014081", "0.60019505", "0.599128", "0.5978446", "0.5961467", "0.59569794", "0.5955709", "0.594354...
0.5899829
26
Generate possible paths around the passed obstacle
def generate_possible_paths(self, obstacle): if self.does_uav_intersect_obstacle_vertically(obstacle, self.drone.get_point(), self.drone.get_waypoint_holder().get_current_waypoint()): if self.does_path_intersect_obstacle_2d(obstacle, self.drone.get_point(), self.drone.get_waypoint_holder().get_current_waypoint()): new_attempt_pos_points = [ [obstacle.get_point()[0] + obstacle.get_radius(), obstacle.get_point()[1] + obstacle.get_radius(), self.drone.get_point()[2]], [obstacle.get_point()[0] - obstacle.get_radius(), obstacle.get_point()[1] - obstacle.get_radius(), self.drone.get_point()[2]], [obstacle.get_point()[0] + obstacle.get_radius(), obstacle.get_point()[1] - obstacle.get_radius(), self.drone.get_point()[2]], [obstacle.get_point()[0] - obstacle.get_radius(), obstacle.get_point()[1] + obstacle.get_radius(), self.drone.get_point()[2]], [obstacle.get_point()[0], obstacle.get_point()[1] + obstacle.get_radius(), obstacle.get_height() + (Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS * 2)], [obstacle.get_point()[0], obstacle.get_point()[1] - obstacle.get_radius(), obstacle.get_height() + (Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS * 2)], [obstacle.get_point()[0] + obstacle.get_radius(), obstacle.get_point()[1], obstacle.get_height() + (Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS * 2)], [obstacle.get_point()[0] - obstacle.get_radius(), obstacle.get_point()[1], obstacle.get_height() + (Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS * 2)] ] new_paths = [] for new_pos_point in new_attempt_pos_points: if not self.does_path_intersect_obstacle_3d(obstacle, self.drone.get_point(), new_pos_point) and self.flight_boundary.is_point_in_bounds(new_pos_point): for recursive_new_pos_point in new_attempt_pos_points: if self.flight_boundary.is_point_in_bounds(recursive_new_pos_point) and abs(recursive_new_pos_point[2] - new_pos_point[2]) < 5: if recursive_new_pos_point[0] != new_pos_point[0] or recursive_new_pos_point[1] != new_pos_point[1]: if not self.does_path_intersect_obstacle_3d(obstacle, new_pos_point, recursive_new_pos_point) and not self.does_path_intersect_obstacle_3d(obstacle, recursive_new_pos_point, self.drone.get_waypoint_holder().get_current_waypoint()): new_paths.append([new_pos_point, recursive_new_pos_point]) # Uncomment for DEBUGGING ONLY for path in new_paths: print("Point:", str(path)) return new_paths return []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_path(self, start_point: Pos, end_point: Pos, obstacles: list) -> list:\n pass", "def drawpath(self,obstacles):\n for i in obstacles:\n self.distance_map[i[0],i[1]]=44\n print(\"Distance map\")\n print(self.distance_map)\n for i in self.footprint:\n ...
[ "0.7479054", "0.6964157", "0.6800724", "0.6652429", "0.65608233", "0.6515328", "0.6502793", "0.64869034", "0.64225703", "0.63867986", "0.62653744", "0.6237662", "0.61990416", "0.61127084", "0.61037284", "0.60940355", "0.6085445", "0.6071979", "0.6071137", "0.6048148", "0.6047...
0.82060087
0
Determine if the UAV intersects an obstacle on the verticle axis
def does_uav_intersect_obstacle_vertically(self, obstacle, drone_point, waypoint): if isinstance(obstacle, StationaryObstacle): if drone_point[2] < obstacle.height + Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inside_obstacle(point, obstacle):\r\n for obs in obstacle:\r\n if point[0] > obs[0][0] and point[0] < obs[0][2] and point[1] > obs[1][0] and point[1] < obs[1][2]:\r\n return 1\r\n return 0", "def inside_obstacle(point, obstacle):\r\n for obs in obstacle:\r\n if point[0] > ob...
[ "0.66017944", "0.66017944", "0.65201724", "0.6504722", "0.6439276", "0.6425067", "0.638491", "0.6364111", "0.63495326", "0.6324251", "0.6221943", "0.6213708", "0.6208691", "0.61606497", "0.6156494", "0.6152293", "0.6147638", "0.6138719", "0.6131911", "0.6120432", "0.6107103",...
0.71816885
0
Determine if the vector between a UAV's position and the current waypoint intersect an obstacle.
def does_path_intersect_obstacle_2d(self, obstacle, uav_point, waypoint): drone_point = uav_point[:-1] waypoint = waypoint[:-1] obstacle_point = obstacle.get_point()[:-1] waypoint_vector = np.subtract(waypoint, drone_point) obstacle_vector = np.subtract(obstacle_point, drone_point) obstacle_vector_magnitude = VectorMath.get_vector_magnitude(obstacle_vector) rejection_vector = VectorMath.get_vector_rejection(obstacle_vector, waypoint_vector) rejection_vector_magnitude = VectorMath.get_vector_magnitude(rejection_vector) # Uncomment for DEBUGGING ONLY print("Waypoint Vector: " + str(waypoint_vector)) print("Obstacle Vector: " + str(obstacle_vector)) print("Rejection Vector: " + str(rejection_vector)) print("Rejection Vector Magnitude: " + str(rejection_vector_magnitude)) print("Obstacle Radius: " + str(obstacle.get_radius())) print("Distance From Obstacle: " + str(VectorMath.get_vector_magnitude(np.subtract(uav_point, obstacle.get_point())))) if self.is_obstacle_in_path_of_drone(obstacle_vector, waypoint_vector): return rejection_vector_magnitude < obstacle.get_radius() return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def does_uav_intersect_obstacle_vertically(self, obstacle, drone_point, waypoint):\n if isinstance(obstacle, StationaryObstacle):\n if drone_point[2] < obstacle.height + Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS:\n return True\n\n return False", "def inside_obstacle(poin...
[ "0.7454063", "0.7005391", "0.7005391", "0.69903654", "0.6773237", "0.66110426", "0.6502717", "0.6439229", "0.64051235", "0.6336705", "0.6297145", "0.6216562", "0.621584", "0.6154906", "0.61373097", "0.6084647", "0.6082654", "0.6072066", "0.60683346", "0.60457075", "0.6034389"...
0.7407062
1
Determine if the vector between a UAV's position and the current waypoint intersect an obstacle.
def does_path_intersect_obstacle_3d(self, obstacle, drone_point, waypoint): waypoint_vector = np.subtract(waypoint, drone_point) obstacle_vector = np.subtract(obstacle.get_point(), drone_point) obstacle_vector_magnitude = VectorMath.get_vector_magnitude(obstacle_vector) rejection_vector = VectorMath.get_vector_rejection(obstacle_vector, waypoint_vector) rejection_vector_magnitude = VectorMath.get_vector_magnitude(rejection_vector) # Uncomment for DEBUGGING ONLY print("Waypoint Vector: " + str(waypoint_vector)) print("Obstacle Vector: " + str(obstacle_vector)) print("Rejection Vector: " + str(rejection_vector)) print("Rejection Vector Magnitude: " + str(rejection_vector_magnitude)) print("Obstacle Radius: " + str(obstacle.get_radius())) print("Distance From Obstacle: " + str(VectorMath.get_vector_magnitude(np.subtract(drone_point, obstacle.get_point())))) if self.is_obstacle_in_path_of_drone(obstacle_vector, waypoint_vector): return rejection_vector_magnitude < Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def does_uav_intersect_obstacle_vertically(self, obstacle, drone_point, waypoint):\n if isinstance(obstacle, StationaryObstacle):\n if drone_point[2] < obstacle.height + Constants.STATIONARY_OBSTACLE_SAFETY_RADIUS:\n return True\n\n return False", "def does_path_intersect_...
[ "0.7454063", "0.7407062", "0.7005391", "0.7005391", "0.69903654", "0.6773237", "0.6502717", "0.6439229", "0.64051235", "0.6336705", "0.6297145", "0.6216562", "0.621584", "0.6154906", "0.61373097", "0.6084647", "0.6082654", "0.6072066", "0.60683346", "0.60457075", "0.6034389",...
0.66110426
6
Looks at the signs of the components of the vectors to determine if the direction of the obstacle is in the same direction as the waypoint (quadrants)
def is_obstacle_in_path_of_drone(self, obstacle_vector, waypoint_vector): obstacle_list = obstacle_vector.tolist() waypoint_list = waypoint_vector.tolist() for index in range(len(obstacle_list)): if all(item > 0 for item in [-1.0 * obstacle_list[index], waypoint_vector[index]]) or all(item < 0 for item in [-1.0 * obstacle_list[index], waypoint_vector[index]]): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __check_direction(self, vector, coordinate):\n inverse_vector = -vector[0], -vector[1]\n # Calculate hits to direction\n hits = self.__direction(vector,1,coordinate)\n if hits == 5:\n return True\n # After reaching the end, add hits towards the opposite direction\n...
[ "0.7193433", "0.65259945", "0.6495801", "0.6493202", "0.6424737", "0.6406378", "0.640443", "0.64031774", "0.6398309", "0.6398309", "0.6398309", "0.62759835", "0.6256729", "0.62326354", "0.6192946", "0.6183871", "0.6148293", "0.61077344", "0.6098693", "0.6095345", "0.60564905"...
0.72141993
0
Return the shortest path from the paths provided. This function assumes that the paths are possible waypoints calculated from the is_obstacle_in_path() function
def get_min_path(self, paths): shortest_path = paths[0] shortest_distance = self.get_path_distance(paths[0]) for path in paths[1:]: distance = self.get_path_distance(path) if distance < shortest_distance: shortest_path = path shortest_distance = distance return shortest_path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_path(env, service, paths):\n for idp, path in enumerate(paths):\n if is_path_free(env.topology, path, service.number_units):\n return True, idp\n return False, env.k_paths # returns false and an index out of bounds if no path is available", "def constructShortestPath(self):\r...
[ "0.7273277", "0.70496786", "0.69742703", "0.6943726", "0.68671346", "0.6855859", "0.68451226", "0.68320864", "0.6805442", "0.67743856", "0.6726081", "0.6716487", "0.6714552", "0.670571", "0.669246", "0.66918075", "0.665236", "0.66394556", "0.6638905", "0.6598199", "0.6593292"...
0.81187457
0
Get the path distance from drone point to path points to current waypoint. It will find the distance of a nlength path
def get_path_distance(self, path): distance = VectorMath.get_magnitude(self.drone.get_point(), path[0]) for index in range(len(path[:-1])): distance += VectorMath.get_magnitude(path[index], path[index + 1]) distance += VectorMath.get_magnitude(path[-1], self.drone.get_waypoint_holder().get_current_waypoint()) if abs(self.drone.get_point()[2] - path[0][2]) > 1: distance *= Constants.VERTICAL_PATH_WEIGHTING_MULTIPLE return distance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance_to_current_waypoint(self):\n next_waypoint = self.vehicle.commands.next\n if next_waypoint == 1:\n return None\n mission_item = self.vehicle.commands[next_waypoint]\n lat = mission_item.x\n lon = mission_item.y\n alt = mission_item.z\n waypoi...
[ "0.7367824", "0.71563923", "0.7043922", "0.6508495", "0.64370704", "0.64057875", "0.63992316", "0.6391346", "0.6376828", "0.6344942", "0.6311526", "0.6288452", "0.625014", "0.6223638", "0.61669296", "0.61589134", "0.6145705", "0.6145705", "0.61372155", "0.613306", "0.6127435"...
0.7029971
3
Return the obstacles in the map
def get_obstacles(self): return self.obstacles
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getObstacles(self):\r\n ausgabeObstacle = self.globalObstaclesList + self.globalHardObstaclesList\r\n self.globalObstaclesList = []\r\n return(ausgabeObstacle)", "def obstacles(self):\r\n\r\n #Radious arround the head\r\n limit_sight = self.snake_sight\r\n head = sel...
[ "0.7732808", "0.76378906", "0.7601713", "0.7597489", "0.74278224", "0.7182941", "0.70999545", "0.7085734", "0.70508057", "0.69266826", "0.68817693", "0.68608207", "0.66608745", "0.66440624", "0.6596019", "0.6556084", "0.6540522", "0.6464882", "0.6458014", "0.6457657", "0.6408...
0.83878875
0
Return True if the UAV has reached the current waypoint and false if not
def has_uav_reached_current_waypoint(self): return self.drone.has_reached_waypoint()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_reached_waypoint_goal(self):\n return self.control_instance.check_reached_waypoint_goal()", "def update(self):\n\n # If the agent has already reached the\n # last waypoint it doesn't need to update\n if self.finished:\n return True\n\n # Skip if the proxy d...
[ "0.7815707", "0.7180824", "0.70038074", "0.69606185", "0.694313", "0.6907562", "0.6907562", "0.6904402", "0.68095386", "0.6806599", "0.6785689", "0.67554694", "0.6742048", "0.67407054", "0.66793656", "0.66658723", "0.65675145", "0.6564974", "0.6496703", "0.648724", "0.6471804...
0.864633
0
Hook to be invoked before the test method has been executed. May perform expensive setup here.
def before_test(self, func, *args, **kwargs): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_run_tests(cls):\n pass", "def do_before(self):\r\n pass", "def beforeTest(self, test):\n self.setupLoghandler()", "def before(self) -> None:\n pass", "def startTestHook(self):", "def setUp(self):\n # use self.attribute to keep anything which needs to be acces...
[ "0.80520755", "0.7866928", "0.76243114", "0.76155716", "0.749539", "0.74885553", "0.7474587", "0.74741113", "0.73961705", "0.7393307", "0.7393307", "0.73867905", "0.7364386", "0.7364033", "0.73517734", "0.7307922", "0.7301422", "0.7300426", "0.7297788", "0.7283322", "0.726435...
0.8013997
1
Hook to be invoked after the test method has been executed. May perform additional cleanup required by the command here.
def after_test(self, func, *args, **kwargs): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def teardown(self) -> None:", "def teardown(self) -> None:", "def teardown(self) -> None:", "def teardown(self):", "def teardown(self):", "def teardown(self):", "def teardown(self):\n pass", "def teardown(self):\n pass", "def teardown(self):\n pass", "def after_test(self, tes...
[ "0.7715716", "0.7715716", "0.7715716", "0.76030385", "0.76030385", "0.76030385", "0.7553543", "0.7553543", "0.7553543", "0.75292295", "0.7514933", "0.7465234", "0.7465234", "0.74545705", "0.7450483", "0.74478006", "0.74094987", "0.7409005", "0.7381039", "0.7332953", "0.733295...
0.74189425
16
Executes the command once with the response of the active
def execute(self, response): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do(self, line): \n self.interface.onecmd(line)", "def run_cmd(self):\r\n self.run = True", "def _sendingCommand(self): \n\n while True:\n self.tello.send_command('command') \n time.sleep(5)", "def do_command(command):\n send_command(command)\...
[ "0.6571192", "0.6366622", "0.63558435", "0.63473594", "0.6232847", "0.6113608", "0.60568047", "0.60522336", "0.5991149", "0.59650344", "0.5937013", "0.5937013", "0.5937013", "0.5937013", "0.5937013", "0.5937013", "0.59077984", "0.5870947", "0.58543557", "0.5847925", "0.581675...
0.578565
22
Whether the command is scoped only for the current request or the whole test method. Requestspecific commands will be executed once per request, testspecific commands only once per test.
def has_request_scope(self): return self.request_scope
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def class_level_setup(self, request):\n\n if data_reader.get_data(request.function.__name__, \"Runmode\") != \"Y\":\n pytest.skip(\"Excluded from current execution run.\")", "def class_level_setup(self, request):\n test_name = request.function.__name__\n if data_reader.get_data(te...
[ "0.5562551", "0.5516768", "0.5430572", "0.539855", "0.5351005", "0.5274069", "0.52571267", "0.5246556", "0.52220726", "0.5220322", "0.5207937", "0.52079004", "0.52006286", "0.51645637", "0.51614296", "0.51251787", "0.51241505", "0.51203376", "0.5114063", "0.5096146", "0.50909...
0.50144213
23
Generates fixture objects from the given response and stores them in the applicationspecific cache.
def execute(self, response): if not has_request_context: return self._fallback_fixture_names() try: app = self.auto_fixture.app # Create response fixture fixture = Fixture.from_response(response, app, self.response_name) self.auto_fixture.add_fixture(fixture) # Create request fixture if request.data: fixture = Fixture.from_request(request, app, self.request_name) self.auto_fixture.add_fixture(fixture) except TypeError: # pragma: no cover warnings.warn("Could not create fixture for unsupported mime type") return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_response():\n return load_fixture(\"smhi.json\", DOMAIN)", "def fixture_retrieved():\n from aiida.plugins import DataFactory\n from aiida_logger.tests import TEST_DIR\n\n retrieved = DataFactory('folder')()\n retrieved.put_object_from_tree(path=os.path.join(TEST_DIR, 'input_files'))\n\n ...
[ "0.6123618", "0.5608524", "0.56062853", "0.5596069", "0.55481315", "0.5504589", "0.5498172", "0.5480052", "0.5423372", "0.5308721", "0.52908236", "0.5271301", "0.52630156", "0.525457", "0.5245118", "0.52290255", "0.52251756", "0.5215446", "0.5191281", "0.51741076", "0.5172798...
0.6490722
0
Falls back to the default fixture names if no names could be determined up to this point.
def _fallback_fixture_names(self): if not self.request_name or not self.response_name: warnings.warn( "No name was specified for the recorded fixture. Falling " "back to default names.") if not self.request_name: self.request_name = __default_names__[0] if not self.response_name: self.response_name = __default_names__[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_fixtures():\n languages()\n words()", "def fixtures():", "def _find_fixtures(self, start_dir):\r\n fixtures = []\r\n def _find(arg, dirname, names):\r\n if (dirname.endswith('fixtures')) and (dirname.find('unit_test')==-1):\r\n for name in names:\r\n ...
[ "0.62607694", "0.6084847", "0.59035265", "0.58864886", "0.5782445", "0.56454164", "0.5598075", "0.5590924", "0.55757374", "0.55625635", "0.5513001", "0.5497023", "0.54902035", "0.5441633", "0.5436192", "0.5364549", "0.536005", "0.535958", "0.53501177", "0.5234277", "0.521221"...
0.7567539
0
Starting a subprocess should be possible.
async def test_subprocess(event_loop): proc = await asyncio.subprocess.create_subprocess_exec( sys.executable, '--version', stdout=asyncio.subprocess.PIPE, loop=event_loop) await proc.communicate()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Start(self):\n\n\n\n assert not self._process, 'Start() can only be called once'\n self._process = subprocess.Popen(self._args)", "def run_subprocess(cmd):\n subprocess.Popen(cmd, stdin =subprocess.PIPE,\n stderr=subprocess.PIPE,\n stdout=subprocess....
[ "0.7211386", "0.6982913", "0.6917975", "0.6912684", "0.6888676", "0.6845422", "0.65411717", "0.65263665", "0.648128", "0.6467744", "0.6461761", "0.64219886", "0.6418295", "0.64087766", "0.63941157", "0.6381634", "0.63771", "0.6374373", "0.63405687", "0.633077", "0.6330121", ...
0.57605875
76
Starting a subprocess should be possible.
async def test_subprocess_forbid(event_loop): proc = await asyncio.subprocess.create_subprocess_exec( sys.executable, '--version', stdout=asyncio.subprocess.PIPE, loop=event_loop) await proc.communicate()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Start(self):\n\n\n\n assert not self._process, 'Start() can only be called once'\n self._process = subprocess.Popen(self._args)", "def run_subprocess(cmd):\n subprocess.Popen(cmd, stdin =subprocess.PIPE,\n stderr=subprocess.PIPE,\n stdout=subprocess....
[ "0.7211386", "0.6982913", "0.6917975", "0.6912684", "0.6888676", "0.6845422", "0.65411717", "0.65263665", "0.648128", "0.6467744", "0.6461761", "0.64219886", "0.6418295", "0.64087766", "0.63941157", "0.6381634", "0.63771", "0.6374373", "0.63405687", "0.633077", "0.6330121", ...
0.57060796
83
Apply the orthonormalization explicit topic analysis method
def main(): if len(sys.argv) != 5: exit("Usage: python oneta.py train-corpus test-corpus kernel-size output") w1Words = dict() w2Words = dict() W1 = 0 W2 = 0 D1 = int(sys.argv[3]) sys.stderr.write("First scan of training data\n") J = 0 # Read through the corpus to decided which words are in the dense set and which in the sparse set corpus = open(sys.argv[1],"r") for line in corpus: tokens = word_tokenize(line) for token in tokens: tk_decoded = token.decode("utf-8") if J < D1 and tk_decoded not in w1Words: w1Words[tk_decoded] = W1 W1 += 1 elif J >= D1 and tk_decoded not in w2Words: w2Words[tk_decoded] = W2 W2 += 1 J += 1 corpus.close() D2 = J - D1 # Partition the corpus into a L-shaped matrix sys.stderr.write("Building matrices") At = lil_matrix((D1,W1)) B = lil_matrix((W1,D2)) Ct = lil_matrix((D2,W2)) corpus = open(sys.argv[1],"r") j = 0 for line in corpus: sys.stderr.write(".") tokens = word_tokenize(line) docsq = 0. for token in tokens: tk_decoded = token.decode("utf-8") if j < D1: # tk_decoded in w1words tkId = w1Words[tk_decoded] docsq += (At[j,tkId]+1)**2 - (At[j,tkId])**2 At[j,tkId] += 1. elif tk_decoded in w1Words: tkId = w1Words[tk_decoded] docsq += (B[tkId,j-D1]+1)**2 - (B[tkId,j-D1])**2 B[tkId,j-D1] += 1. else: tkId = w2Words[tk_decoded] docsq += (Ct[j-D1,tkId]+1)**2 - (Ct[j-D1,tkId])**2 Ct[j-D1,tkId] += 1. if j < D1: At[j,:] /= math.sqrt(docsq) else: for w in range(0,W1): B[w,j-D1] /= math.sqrt(docsq) Ct[j-D1,:] /= math.sqrt(docsq) j += 1 sys.stderr.write("\nBuild Cn\n") Cn = zeros((D2,1)) Ct = Ct.tocsr() for i in range(0,D2): v = ((Ct[i,:] * Ct[i,:].transpose())[0,0]) if v == 0: Cn[i,0] = 1. else: Cn[i,0] = v # Building real matrices sys.stderr.write("Calculating ATA\n") ATA = (At * At.transpose()).todense() # D1 x D1 At = At.tocsr() B = B.tocsc() sys.stderr.write("Solve inverse\n") ATAi = linalg.inv(ATA) # The real calculation is that if we have input vector [ d_1 d_2 ] ^ T # We yield [ (A^T * A)^-1 * A^T ( d1^T - B * (C^T * d2 / Cn) ) (C^T * d2 / Cn) sys.stderr.write("Calculating projected vectors\n") out = open(sys.argv[4],"w") testDocs = open(sys.argv[2],"r") for testDoc in testDocs: sys.stderr.write(".") corpus = open(sys.argv[1],"r") d1 = zeros((W1,1)) d2 = zeros((W2,1)) tokens = word_tokenize(testDoc) for token in tokens: tk_decoded = token.decode("utf-8") if tk_decoded in w1Words: d1[w1Words[tk_decoded],0] += 1 elif tk_decoded in w2Words: d2[w2Words[tk_decoded],0] += 1 norm = sqrt(sum(d1**2) + sum(d2**2)) d1 /= norm d2 /= norm v2 = (Ct * d2) / Cn v1 = ATAi * (At * (d1 - B * v2)) for j in range(0,D1+D2): out.write(str(j) + " ") out.write("||| ") for j in range(0,D1): out.write(str(v1[j,0]) + " ") for j in range(0,D2): out.write(str(v2[j,0]) + " ") out.write("\n") out.flush() out.close() sys.stderr.write("\n")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform(self, corpus: Corpus):\n assert 'stem_tokens' in next(corpus.iter_utterances()).meta\n counter = 1\n for utt in corpus.iter_utterances():\n if utt.meta['valid']:\n utt.meta['analysis'] = lexicon.analyze(utt.text,categories=self.categories)\n ...
[ "0.55906874", "0.55814046", "0.5555375", "0.55358505", "0.5529263", "0.5498415", "0.54653543", "0.5456407", "0.53456396", "0.5337148", "0.5316981", "0.5269533", "0.52625924", "0.52604556", "0.5249314", "0.5231671", "0.5213493", "0.5205622", "0.519339", "0.51790893", "0.517141...
0.0
-1
Generate ics from days.
def generate_ics(days: Sequence[dict], filename: Text) -> None: cal = Calendar() cal.add("X-WR-CALNAME", "中国法定节假日") cal.add("X-WR-CALDESC", "中国法定节假日数据,自动每日抓取国务院公告。") cal.add("VERSION", "2.0") cal.add("METHOD", "PUBLISH") cal.add("CLASS", "PUBLIC") cal.add_component(_create_timezone()) days = sorted(days, key=lambda x: x["date"]) for fr, to in _iter_date_ranges(days): start = _cast_date(fr["date"]) end = _cast_date(to["date"]) + datetime.timedelta(days=1) name = fr["name"] + "假期" if not fr["isOffDay"]: name = "上班(补" + name + ")" cal.add_component(_create_event(name, start, end)) with open(filename, "wb") as f: f.write(cal.to_ical())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_ics(events, config):\n\n # Create the Calendar\n calendar = icalendar.Calendar()\n calendar.add('prodid', config.calendar_prodid)\n calendar.add('version', '2.0')\n calendar.add('method', 'publish')\n\n for event_data in events:\n # Create the event\n event = icalendar....
[ "0.6347691", "0.6087289", "0.6072295", "0.59718066", "0.57362044", "0.5708821", "0.56834716", "0.5679318", "0.5669046", "0.56072843", "0.5576914", "0.557137", "0.557137", "0.553295", "0.54978454", "0.5415384", "0.5413129", "0.53640497", "0.5288981", "0.52658474", "0.52517194"...
0.78284
0
Get user profile Fetches from the user collection by using the user's email as key.
def get_user_profile(email): # GET # NOTE: This method previously called LCS with director credentials in order to retrieve the user's name # We will update TeamRU to store names along with our user objects, saving the need to call LCS again user_profile = coll("users").find_one({"_id": email}) if not user_profile: return {"message": "User not found"}, 404 user_profile["user_id"] = user_profile.pop("_id") return user_profile, 200
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getProfileFromUser(self):\n # Make sure user is authenticated\n user = endpoints.get_current_user()\n if not user:\n raise endpoints.UnauthorizedException('Authorization required')\n # Get Profile from datastore\n user_id = user.email()\n p_key = ndb.Key(Pr...
[ "0.74857944", "0.7336757", "0.7331344", "0.7298807", "0.72768545", "0.72726756", "0.71711785", "0.7168781", "0.7130947", "0.71272796", "0.70798576", "0.70757645", "0.7041153", "0.6998165", "0.6979574", "0.6948253", "0.69294655", "0.69286436", "0.69207954", "0.6915467", "0.688...
0.8088444
0
Endpoint to get multiple user profiles at once
def get_user_profiles(args): # GET limit = args.get("limit", type=int) if args.get("limit") else 0 # NOTE checks if the string value of hasateam is equal to "true" because HTTP protocol only passes strings hasateam = args.get("hasateam", "").lower() == "true" if hasateam: users = list(coll("users").find({"hasateam": hasateam}).limit(limit)) else: users = list(coll("users").find({}).limit(limit)) for user in users: user["user_id"] = user.pop("_id") return {"user_profiles": users}, 200
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_list(request):\n if request.method == 'GET':\n user_info = UserData.objects.all()\n serializer = UserProfileSerializer(user_info, many=True)\n return JSONResponse(serializer.data)\n else:\n return JSONResponse('Using wrong api.', status=404)", "def getUserProfile(reques...
[ "0.7123131", "0.7092195", "0.67327285", "0.66832435", "0.6620146", "0.6597439", "0.6545158", "0.65444624", "0.6516381", "0.6486743", "0.6464873", "0.64039516", "0.6396808", "0.63603383", "0.63488567", "0.6325813", "0.63202125", "0.63083386", "0.62850004", "0.62842536", "0.627...
0.69456804
2
Create user profile Creates a new user profile from the user email, skills, prizes, and other fields.
def create_user_profile(email, **kwargs): # POST user_exists = coll("users").find_one({"_id": email}) if user_exists: return {"message": "User already exists"}, 400 # NOTE Doesn't make sense for a person to have prizes only a team should have this coll("users").insert_one( { "_id": email, "skills": kwargs["skills"], "prizes": kwargs["prizes"], "bio": kwargs["bio"], "github": kwargs["github"], "interests": kwargs["interests"], "seriousness": kwargs["seriousness"], "team_id": "", "hasateam": False, } ) return {"message": "User profile successfully created"}, 201
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(self, data):\n # Make User\n username = data['email'].split(\"@\")[0]\n user = User.objects.create_user(**data, username=username, is_verified=False, is_client=True)\n Profile.objects.create(user=user)\n send_confirmation_email.delay(user_pk=user.pk)\n return us...
[ "0.75975007", "0.74751395", "0.7427103", "0.73537993", "0.7324293", "0.7319972", "0.7295748", "0.7285775", "0.7275217", "0.7270615", "0.7237489", "0.72268796", "0.72268796", "0.72268796", "0.7216276", "0.7180537", "0.716592", "0.7164825", "0.71644413", "0.7159965", "0.7144012...
0.8317838
0
Update user profile Update a user profile with new parameters.
def update_user_profile(email, **kwargs): # PUT user = coll("users").find_one({"_id": email}) if not user: return {"message": "User not found"}, 404 coll("users").update_one({"_id": email}, {"$set": kwargs}) return {"message": "User profile successfully updated"}, 200
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_update_profile():\n \n if 'userid' and 'email' not in request.forms:\n return {'status':'Failure','message':'User Id is missing,please try with correct data.'}\n \n data = user_obj.user_update_profile(request.forms)\n return data", "def update_profile():\n logger.debug(\"enterin...
[ "0.8154847", "0.7868579", "0.7719946", "0.77043855", "0.7689022", "0.7664817", "0.7529994", "0.75082785", "0.7425593", "0.7420964", "0.73797953", "0.7358667", "0.73411655", "0.7204369", "0.71413976", "0.71375716", "0.70822394", "0.7041348", "0.70147234", "0.6986787", "0.69684...
0.7519383
7
Add a channel to watch. Gif attachments that break mobile clients will be removed in these channels.
async def watch(self, ctx, channel: discord.TextChannel): channel_list = await self.config.guild(ctx.guild).watching() if channel.id not in channel_list: channel_list.append(channel.id) await self.config.guild(ctx.guild).watching.set(channel_list) await ctx.send(f"{self.bot.get_channel(channel.id).mention} will have bad gifs removed.")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addChannel(self, channel):\n c = SubElement(self.root, 'channel')\n self.setattr(c, 'id', channel['id'])\n\n # Display Name\n for display_name in channel['display-name']:\n dn = SubElement(c, 'display-name')\n self.settext(dn, display_name)\n\n # Icon\n ...
[ "0.7233943", "0.72161865", "0.7117447", "0.6998894", "0.69869983", "0.6717073", "0.6696119", "0.66698676", "0.6659829", "0.6645461", "0.66428185", "0.66339123", "0.66172534", "0.6603776", "0.63936055", "0.6305807", "0.6265757", "0.6263904", "0.6182621", "0.60905236", "0.60528...
0.71405834
2
List the channels being watched.
async def watchlist(self, ctx): channel_list = await self.config.guild(ctx.guild).watching() msg = "Bad gifs will be removed in:\n" for channel in channel_list: channel_obj = self.bot.get_channel(channel) if channel_obj is None: # Catch deleted/unexisting channels continue msg += f"{channel_obj.mention}\n" await ctx.send(msg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _channels_list(self):\n result = self.slack.api_call(\"channels.list\")\n\n if not result.get(\"ok\"):\n logging.error(result['error'])\n return None\n\n return result['channels']", "def get_channels(self):\n return self.channels", "def channels(self):\n ...
[ "0.79604846", "0.77818024", "0.7657704", "0.76543194", "0.76405656", "0.75859505", "0.7379902", "0.7354642", "0.7337159", "0.73244745", "0.73033804", "0.7295559", "0.72613245", "0.7203369", "0.7156832", "0.7063657", "0.7061825", "0.7007366", "0.6981566", "0.6963767", "0.69260...
0.6865468
23
Remove a channel from the watch list.
async def unwatch(self, ctx, channel: discord.TextChannel): channel_list = await self.config.guild(ctx.guild).watching() if channel.id in channel_list: channel_list.remove(channel.id) else: return await ctx.send("Channel is not being watched.") await self.config.guild(ctx.guild).watching.set(channel_list) await ctx.send(f"{self.bot.get_channel(channel.id).mention} will not have bad gifs removed.")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_channel(self, channel):\n self._channels.pop(channel.fileno, None)\n\n try:\n self._poller.remove(channel.fileno, channel._events)\n except (IOError, OSError):\n log.exception(\"Error while removing %r.\" % channel)", "def remove(self, irc, msg, args, channel...
[ "0.78963095", "0.73827446", "0.7304483", "0.72998226", "0.7257182", "0.7189836", "0.7003809", "0.6930595", "0.6920038", "0.68613374", "0.68129927", "0.65488666", "0.6515532", "0.64504415", "0.6387552", "0.6373514", "0.63086313", "0.62170106", "0.61841017", "0.60812473", "0.60...
0.7280058
4
Resolver should be able to produce a value for a given key. If key doesn't exist, should return None.
def resolve(self, key: str) -> Optional[Any]: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(self, key: str) -> Optional[Any]:\n return self.dict.get(key)", "def get(self, key: K)-> Optional[V]:\n return self._func(key)", "def lookup(self, key):\n n = self.find(key)\n if n:\n return n.value\n else:\n return False", "def _get(self, ...
[ "0.7909129", "0.6813241", "0.67681676", "0.66341573", "0.64758044", "0.6463813", "0.64607257", "0.6392654", "0.6385483", "0.63703537", "0.63212407", "0.6292602", "0.6284046", "0.62764496", "0.619645", "0.6181006", "0.617452", "0.614984", "0.6148691", "0.6125853", "0.61204463"...
0.75538653
1
Return all values available in the resolver.
def values(self) -> Dict[str, Any]: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValues(self):\n return self.__get('values')", "def get_values(self):\n \n return []", "def _values(self):\n return self.__values", "def get_values(self):\n raise NotImplementedError(\"Abstract method not implemented.\")", "def values(self):\r\n return self._...
[ "0.71192074", "0.71074104", "0.7013543", "0.6938158", "0.68647885", "0.6794239", "0.6794239", "0.6765329", "0.6765329", "0.6765329", "0.6765329", "0.67555463", "0.67555463", "0.6741106", "0.6719452", "0.67193747", "0.66979545", "0.668874", "0.66784626", "0.667716", "0.6666213...
0.0
-1
Resolver should be able to produce a value for a given key. If key doesn't exist, should return None.
def resolve(self, key: str) -> Optional[Any]: return environ.get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(self, key: str) -> Optional[Any]:\n return self.dict.get(key)", "def resolve(self, key: str) -> Optional[Any]:\n pass", "def get(self, key: K)-> Optional[V]:\n return self._func(key)", "def lookup(self, key):\n n = self.find(key)\n if n:\n return n.va...
[ "0.7909129", "0.75538653", "0.6813241", "0.67681676", "0.66341573", "0.64758044", "0.6463813", "0.64607257", "0.6392654", "0.6385483", "0.63703537", "0.63212407", "0.6292602", "0.6284046", "0.62764496", "0.619645", "0.6181006", "0.617452", "0.614984", "0.6148691", "0.6125853"...
0.59762084
42
Resolver should be able to produce a value for a given key. If key doesn't exist, should return None.
def resolve(self, key: str) -> Optional[Any]: return self.dict.get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(self, key: str) -> Optional[Any]:\n pass", "def get(self, key: K)-> Optional[V]:\n return self._func(key)", "def lookup(self, key):\n n = self.find(key)\n if n:\n return n.value\n else:\n return False", "def _get(self, key):\n try:\n...
[ "0.75538653", "0.6813241", "0.67681676", "0.66341573", "0.64758044", "0.6463813", "0.64607257", "0.6392654", "0.6385483", "0.63703537", "0.63212407", "0.6292602", "0.6284046", "0.62764496", "0.619645", "0.6181006", "0.617452", "0.614984", "0.6148691", "0.6125853", "0.61204463...
0.7909129
0
Return all values available in the resolver.
def values(self) -> Dict[str, Any]: return self.dict.copy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValues(self):\n return self.__get('values')", "def get_values(self):\n \n return []", "def _values(self):\n return self.__values", "def get_values(self):\n raise NotImplementedError(\"Abstract method not implemented.\")", "def values(self):\r\n return self._...
[ "0.71192074", "0.71074104", "0.7013543", "0.6938158", "0.68647885", "0.6794239", "0.6794239", "0.6765329", "0.6765329", "0.6765329", "0.6765329", "0.67555463", "0.67555463", "0.6741106", "0.6719452", "0.67193747", "0.66979545", "0.668874", "0.66784626", "0.667716", "0.6666213...
0.0
-1
run a command, returning output. raise an exception if it fails.
def run_or_die(command): (status, stdio) = commands.getstatusoutput(command) if status != 0: raise Exception("command '%s' failed with exit status %d and output '%s'" % (command, status, stdio)) return stdio
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(command):\n\n out = \"\"\n try:\n out = str(subprocess.check_output(command,\n shell=True,\n universal_newlines=True))\n except subprocess.CalledProcessError as e:\n raise RuntimeError(\n 'Fa...
[ "0.7624283", "0.74565816", "0.7429833", "0.7369673", "0.7366693", "0.7308195", "0.72908425", "0.72728914", "0.72698665", "0.72682434", "0.724774", "0.7206386", "0.72033876", "0.7180701", "0.7153353", "0.71275276", "0.71244043", "0.71204966", "0.71131384", "0.7102511", "0.7098...
0.70195824
31
Determines the number of files each node will process in scatter gather environment
def number_of_files_per_node(files, number_of_nodes): files_per_node = float(len(files))/float(number_of_nodes) if files_per_node > 0.: return int(math.floor(files_per_node)) else: return int(math.ceil(files_per_node))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fileCount(self):\n pass", "def countDataSize(self,filename):\n \n d = h5py.File(filename,'r')\n features = d['spectrometer/features'][:]\n select = self.selectData(features.astype(float), self.ifeature, d)\n N = len(features[select])\n d.close()\n\n N =...
[ "0.6732709", "0.6647272", "0.6646703", "0.65596217", "0.655924", "0.6545861", "0.65446675", "0.6479833", "0.64772725", "0.6464439", "0.6455599", "0.6446589", "0.6436676", "0.641191", "0.6406125", "0.6391951", "0.636867", "0.6327254", "0.63119394", "0.63079107", "0.62990075", ...
0.7106992
0
Organizes all files to be distributed across all nodes of scatter gather equally based on total file size to process
def distribute_files_by_size(file_sizes, dx_file_objects, number_of_nodes): files_per_node = number_of_files_per_node(file_sizes, number_of_nodes) sorted_file_sizes = sorted(file_sizes.items(), key=operator.itemgetter(1)) job_idx = 1 jobs_object = {} for file_name, file_size in sorted_file_sizes: if job_idx > number_of_nodes: job_idx = 1 try: jobs_object[job_idx].append(dx_file_objects[file_name]) except KeyError: jobs_object[job_idx] = [dx_file_objects[file_name]] job_idx += 1 return jobs_object
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _distribute_files(self, distribution='one'):\n for k, files in self.file_lists.items():\n self.idle[k] = False\n if distribution.lower() == 'single':\n self.distribution_comms[k] = None\n if self.comm.rank >= 1:\n self.local_file_lis...
[ "0.66015565", "0.6507331", "0.59870154", "0.5919278", "0.5917296", "0.58891445", "0.5861876", "0.5806694", "0.5750406", "0.57269675", "0.57239187", "0.5673634", "0.567278", "0.5663586", "0.56529", "0.5636067", "0.5622266", "0.5600914", "0.5597496", "0.5590672", "0.5590012", ...
0.6488863
2
Load parameters from SSM Parameter Store.
def load_params(namespace: str, env: str) -> dict: config = {} path = f"/{namespace}/{env}/" ssm = boto3.client("ssm") more = None args = {"Path": path, "Recursive": True, "WithDecryption": True} while more is not False: if more: args["NextToken"] = more params = ssm.get_parameters_by_path(**args) for param in params["Parameters"]: key = param["Name"].split("/")[3] config[key] = param["Value"] more = params.get("NextToken", False) return config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_parameter_store_config(config):\n parameter_store = config\n ps_keys = list(parameter_store.keys())\n ssm = boto3.client('ssm')\n LOGGER.info(f\"Loading configurations from Parameter Store for {config}\")\n for ps_key in ps_keys:\n ps_name = parameter_store[ps_key]\n result = s...
[ "0.67715704", "0.6456362", "0.63223475", "0.62987643", "0.62267524", "0.6217192", "0.6191533", "0.61013824", "0.59506804", "0.5887682", "0.58793163", "0.587145", "0.5848228", "0.5811435", "0.57710826", "0.57590187", "0.5749164", "0.56775564", "0.56462854", "0.5638049", "0.556...
0.51215804
52
Send a request to Slack and validate the response
def slack_request(url: str, headers: dict, data: dict) -> dict: logger.debug(f'\nSending request to Slack API using {url}') response = requests.post(url=url, headers=headers, data=data) if response.status_code != 200: logger.error(f'Got status {r.status_code} while trying to post to the slack url {url}.') # todo: check for error details, since their reponse format is not always consistent then converting to json # doesn't work all the time. #data = response.json() #if not data['ok']: # logger.error(f"Got the following errors back from slack: {data}") return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_slackWH_send_good(get_slackwebhook, capsys):\n s = get_slackwebhook\n s.send()\n out, err = capsys.readouterr()\n assert \"Message sent\" in out", "def __call(self, headers, method, data):\n url = 'https://slack.com/api/'+method\n req = requests.post(\n url=url,\n ...
[ "0.67223775", "0.66398156", "0.6534951", "0.6358252", "0.6333655", "0.62352383", "0.6171377", "0.6148408", "0.6085096", "0.6081135", "0.60650325", "0.6040874", "0.6038498", "0.60302174", "0.59917426", "0.59649956", "0.59637076", "0.5943963", "0.59014314", "0.58998", "0.588938...
0.72009796
0
Create a report about stale branches for a list of repositories.
def check_stale_branches(event: dict, context) -> dict: ssm_parameters = load_params('dev_tools', 'dev') if 'jira_statuses_for_task_completion' in ssm_parameters and ssm_parameters['jira_statuses_for_task_completion']: jira_statuses_for_task_completion = ssm_parameters['jira_statuses_for_task_completion'] else: jira_statuses_for_task_completion = ('Resolved', 'Closed') repository_names = ssm_parameters['github_repository_names'] github_repository_names = repository_names.split(',') jira_oauth_dict = { 'access_token': ssm_parameters['jira_access_token'], 'access_token_secret': ssm_parameters['jira_access_token_secret'], 'consumer_key': ssm_parameters['jira_consumer_key'], 'key_cert': ssm_parameters['jira_private_key'] } auth_jira = JIRA(ssm_parameters['jira_url'], oauth=jira_oauth_dict) # Github authentication setup g = Github(ssm_parameters['github_access_token']) # Look for stale branches for all the specified repos total_stale_branches = 0 general_report = '' author_count = defaultdict(int) for repo_name in github_repository_names: logger.debug(f'\nChecking repo: {repo_name}') try: repo = g.get_repo(f"{ssm_parameters['github_account']}/{repo_name}") except GithubException: logger.error(f"Github repository '{ssm_parameters['github_account']}/{repo_name}' not found!") continue repo_report = '' # confirm the name for the main develop branch main_develop_branch = 'develop' try: _ = repo.get_branch('develop') except GithubException: main_develop_branch = 'master' logger.debug('Develop branch not found, using master as the main develop branch.') continue branches = repo.get_branches() for branch in branches: # only check feature and hotfix branches if not branch.name.startswith('feature/') and not branch.name.startswith('hotfix/'): continue # compare the branch against the main develop branch try: comparison = repo.compare(main_develop_branch, branch.name) except GithubException as error: logger.error(f'GithubException: Error while trying to compare {main_develop_branch} and {branch.name}.') logger.error(f'GithubException: {error}.') if comparison.behind_by == 0: # the branch is up to date, nothing to do continue # try to get the jira ticket number from the branch name ticket = None result = re.search(r'feature/(?P<ticket>[a-zA-Z]+-[0-9]+).*', branch.name) if result: ticket = result.groupdict()['ticket'].upper() try: issue = auth_jira.issue(ticket) except jira_exceptions.JIRAError: logger.debug(f"The ticket {ticket} specified in the branch name doesn't exist in Jira.") if issue and issue.fields.status.name not in jira_statuses_for_task_completion: # the issue hasn't been marked as resolved in jira, so the branch may still be needed continue author = branch.commit.author.login if branch.commit.author else 'unknown' author_count[author] += 1 repo_report += f'Branch: {branch.name}\nComparison status: {comparison.status}\nAuthor: {author}\n' if ticket: repo_report += f'Ticket status: "{issue.fields.status.name}\n' repo_report += '\n' total_stale_branches += 1 if repo_report: general_report += f'Repo: {repo_name}, develop branch name: {main_develop_branch}\n{repo_report}' if total_stale_branches: count_by_author = '' for author, count in sorted(author_count.items(), key=operator.itemgetter(1), reverse=True): count_by_author += f'{author}: {count}\n' report_overview = f'Current number of stale branches: {total_stale_branches}\n\n'\ f'Count by author:\n{count_by_author}\n' report_details = f'Details:\n\n{general_report}' _ = slack_request(url=ssm_parameters['slack_webhook_url'], headers={'Content-type': 'application/json', 'Authorization': f"Bearer {ssm_parameters['slack_access_token']}"}, data=json.dumps({'text': report_overview}) ) _ = slack_request(url='https://slack.com/api/files.upload', headers={'Content-type': 'application/x-www-form-urlencoded'}, data={'token': ssm_parameters['slack_access_token'], 'channels': 'GE8NS0FT5', 'content': report_details, 'title': 'Stale branches details'} )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stale_pr_branches(config, args):\n repo = config.repo\n for pr in repo.pull_requests(state=\"closed\"):\n if pr.head.repo == pr.base.repo and repo.branch(pr.head.ref):\n yield {\n \"html_url\": pr.html_url,\n \"base_branch\": pr.base.ref,\n \"head_branch\": pr.head.ref,\n }"...
[ "0.71542406", "0.57429", "0.5712632", "0.5642177", "0.55806303", "0.5520008", "0.54752177", "0.54629207", "0.5433732", "0.5424115", "0.53311217", "0.5299445", "0.5283825", "0.52417576", "0.5239561", "0.5191586", "0.5190831", "0.51559097", "0.5126341", "0.512589", "0.50958616"...
0.72896576
0
Wrap function in setter
def evaluate_wrapper(func): @wraps(func) def wrapper(self, blackboard): if self.state == EvaluationState.ready: self.on_enter() state = func(self, blackboard) self.state = state if state != EvaluationState.running: self.on_exit() return state return wrapper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setter(self):\n def decorator(func):\n self._setf = func\n return self\n return decorator", "def setter(self, func):\n if not isinstance(func, (classmethod, staticmethod)):\n func = classmethod(func)\n self.fset = func\n return self", "def...
[ "0.84098685", "0.7812984", "0.77397096", "0.7689164", "0.69597083", "0.6959586", "0.69246805", "0.6809191", "0.67956316", "0.6794793", "0.67877066", "0.67604524", "0.6759456", "0.6755358", "0.67432415", "0.6720239", "0.66899675", "0.66600424", "0.6644266", "0.6640938", "0.664...
0.0
-1
Evaluate the node state
def evaluate(self, blackboard): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self, state):\n abstract", "def evaluate(self) :\n for inp in self.inStates :\n if inp.getState() == 1 : return 1\n return 0", "def evaluate_node(self):\n # p, v = np.random.random(225).astype(np.float16), np.random.random()\n socket = zmq.Context().so...
[ "0.7793834", "0.7214056", "0.71922576", "0.70654464", "0.698469", "0.6897534", "0.6870111", "0.67943263", "0.6491411", "0.6490257", "0.6447222", "0.62859714", "0.62780833", "0.62673026", "0.6194209", "0.6178528", "0.61736", "0.61736", "0.615123", "0.6134387", "0.6047522", "...
0.0
-1
Reset this node's (and its children's) state to ready
def reset(self): self.state = EvaluationState.ready for child in self.children: if hasattr(child, "reset"): child.reset()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n for c in self.children:\n c.reset()\n self.marked = False", "def reset_tree(self):\n self.root = None\n self.action = None\n self.dist_probability = None", "def reset(self):\n self.children.clear()", "def reset(self):\r\n self...
[ "0.7023482", "0.6967508", "0.6964375", "0.670918", "0.67040575", "0.6657348", "0.65749437", "0.65516037", "0.65334755", "0.64151716", "0.6284906", "0.62482226", "0.62395614", "0.61377215", "0.61206025", "0.6064591", "0.604821", "0.6045733", "0.60326046", "0.6019434", "0.59808...
0.75797325
0
Evaluates the node's (and its children's) state.
def evaluate(self, blackboard): success = EvaluationState.success state = success for child in self.children: state = child.__call__(blackboard) if state != success: break return state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self, tree):\n\t\tpass", "def evaluate(self, state):\n abstract", "def evaluate_node(self):\n # p, v = np.random.random(225).astype(np.float16), np.random.random()\n socket = zmq.Context().socket(zmq.DEALER)\n socket.setsockopt_string(zmq.IDENTITY, self.player_id)\n ...
[ "0.7153151", "0.6905958", "0.65348285", "0.6446776", "0.63490057", "0.62762874", "0.6272428", "0.6272428", "0.62597114", "0.62265426", "0.6199221", "0.61362064", "0.60104877", "0.59859467", "0.5944751", "0.5939889", "0.5925841", "0.58773786", "0.57595444", "0.57158136", "0.56...
0.6596801
2
Evaluates the node's (and its children's) state. Returns success if any node succeeds, else failure.
def evaluate(self, blackboard): success = EvaluationState.success for child in self.children: state = child.__call__(blackboard) if state == success: return success return EvaluationState.failure
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self, blackboard):\n success = EvaluationState.success\n\n state = success\n for child in self.children:\n state = child.__call__(blackboard)\n\n if state != success:\n break\n\n return state", "def evaluate(self, tree):\n\t\tpass", ...
[ "0.71742636", "0.6537723", "0.6279385", "0.6106426", "0.6106426", "0.60549605", "0.60402316", "0.60212874", "0.5946995", "0.58815885", "0.58076704", "0.5800487", "0.57829833", "0.5762511", "0.56892544", "0.56854844", "0.56838524", "0.5680494", "0.56597567", "0.56062233", "0.5...
0.6946291
1
imports 'catalog', and creates a pandas.DataFrame containing the columns specified in 'params'. 'catalog' is expected to be in the .csv format.
def import_data(catalog='xmatch_TGAS_Simbad.csv', params=None, nrows=None, delimiter=','): print "Loading %s and creating DataFrame.." % catalog df_imported = pd.read_csv(catalog, delimiter=delimiter, header=0, usecols=params, nrows=nrows) print "..Done\n----------" return df_imported
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_catalog(self):\n self.catalog = pd.read_csv(self.catalog_path, \n index_col=0, parse_dates=True)\n self.unique_years = self.catalog.index.year.unique()\n return", "def loadData(catalog):\n return controller.loadData(catalog)", "def loadData(catalog):\n return cont...
[ "0.6171639", "0.5896814", "0.5896814", "0.58639306", "0.58639306", "0.58639306", "0.58639306", "0.58639306", "0.5844626", "0.57802", "0.5761707", "0.5757528", "0.5681903", "0.56408125", "0.5618386", "0.5584293", "0.5555248", "0.5497467", "0.5468997", "0.54676163", "0.54645765...
0.75542295
0
Open a table fits file and convert it to a pandas dataframe.
def import_fits(fitsfile='tgasptyc.fits'): if isfile(fitsfile): print "Opening %s.." % fitsfile table = Table.read(fitsfile) pandas_df = table.to_pandas() else: print "%s not found. Exiting." % fitsfile sys.exit() print "Converting table to pandas_df.." print "..Done" return pandas_df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def df_from_fits(filename, i=1):\n return pd.DataFrame.from_records(fitsio.FITS(filename)[i].read().byteswap().newbyteorder())", "def load_fits_table(fname):\n\treturn fits.open(fname)[1].data", "def load_fits(path: str, ncols: int, nonames: bool) -> DataFrame:\n assert not nonames\n\n from astropy.ta...
[ "0.72136354", "0.70939803", "0.6888955", "0.6693443", "0.65260655", "0.64546525", "0.64119506", "0.6292741", "0.60741687", "0.6048607", "0.59836", "0.59633166", "0.5962561", "0.5943778", "0.59254146", "0.5899131", "0.5885488", "0.586403", "0.57661194", "0.5747174", "0.5743360...
0.7552445
0
creates a new column 'tycho2_id' in the tycho2 catalog. This is for comparison with the TGAS catalog.
def create_tycho_id(tycho2df): tycho2df['tycho2_id'] = tycho2df.TYC1.astype(str).str.cat(tycho2df.TYC2.astype(str), sep='-')\ .str.cat(tycho2df.TYC3.astype(str), sep='-') tycho2df = tycho2df.rename(columns={'HIP': 'hip'}) return tycho2df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_idx2id(self, id2idx = None):\n if id2idx is None:\n return {v:k for k, v in self.id2idx.items()}\n return {v:k for k, v in id2idx.items()}", "def getMcc2Id(self):\n return self._base.getMcc2Id()", "def get_col2id( self, ratios_standardized, db ):\n\t\tcol_info_collection...
[ "0.50282025", "0.50220966", "0.5005243", "0.49620757", "0.49583018", "0.4915321", "0.4880197", "0.4807147", "0.4807147", "0.4807147", "0.4807147", "0.47635424", "0.47528297", "0.46979147", "0.4659034", "0.4647828", "0.45996457", "0.45982006", "0.4572538", "0.456453", "0.45589...
0.7335801
0
select data with relative parallax error less than 'cutoff', add absolute magnitude columns for plotting. If catalog is not None, the cutoff on BV will not be applied (ensures initial variable stars DataFrame is not constrained in magnitudes)
def data_process(df_toprocess=None, cutoff=0.2, bv_cutoff=0.15, catalog=None): print "Selecting objects.." df_toprocess['sigma_pi/pi'] = df_toprocess.loc[:, 'parallax_error'].astype(float) / df_toprocess.loc[:, 'parallax']\ .astype(float) print "..Done\nCutoff at relative parallax error of %s\n----------" % cutoff # only take objects with relative parallax error < cutoff df_toprocess = df_toprocess.loc[df_toprocess.loc[:, 'parallax'] / df_toprocess.loc[:, 'parallax_error'] > 1. / cutoff] print catalog if catalog is None: print "Replacing whitespace with nan" df_toprocess = df_toprocess.replace(' ', np.nan) # some cells are ' ' instead of nan print "Converting BTmag and VTmag to floats.." df_toprocess.BTmag = df_toprocess.BTmag.astype(float) df_toprocess.VTmag = df_toprocess.VTmag.astype(float) # Some values are NaN: print "Removing objects with missing BT or VT measurements.." df_toprocess = df_toprocess[df_toprocess.BTmag.notnull()] df_toprocess = df_toprocess[df_toprocess.VTmag.notnull()] print "Computing B-V and M_V.." df_toprocess['B_V'] = df_toprocess.BTmag - df_toprocess.VTmag df_toprocess['M_V'] = df_toprocess.VTmag - 5. * (np.log10(1000. / df_toprocess.parallax) - 1.) print "Converting sigma BT and sigma VT to float.." df_toprocess.e_BTmag = df_toprocess.e_BTmag.astype(float) df_toprocess.e_VTmag = df_toprocess.e_VTmag.astype(float) print "Computing sigma B-V.." df_toprocess['e_B_V'] = np.sqrt(df_toprocess.e_BTmag.pow(2)+df_toprocess.e_VTmag.pow(2)) print "Applying selection on sigma BT-VT < %s.." % bv_cutoff df_toprocess = df_toprocess[df_toprocess.e_B_V < bv_cutoff] if catalog == 'xmatch_TGAS_Simbad.csv': df_toprocess = df_toprocess.loc[(df_toprocess['J'] < 11.) & (df_toprocess['K'] < 11.)] print "min in J: %s" % np.max(df_toprocess['J']) print "max in J: %s" % np.min(df_toprocess['J']) df_toprocess.insert(10, 'B_V', df_toprocess.loc[:, 'B'] - df_toprocess.loc[:, 'V']) df_toprocess.insert(10, 'J_K', df_toprocess.loc[:, 'J'] - df_toprocess.loc[:, 'K']) df_toprocess.insert(10, 'M_G', df_toprocess.loc[:, 'phot_g_mean_mag'] - 5. * (np.log10(1000. / df_toprocess.loc[:, 'parallax']) - 1.)) df_toprocess.insert(10, 'M_J', df_toprocess.loc[:, 'J'] - 5. * (np.log10(1000. / df_toprocess.loc[:, 'parallax']) - 1.)) df_toprocess.insert(10, 'M_K', df_toprocess.loc[:, 'K'] - 5. * (np.log10(1000. / df_toprocess.loc[:, 'parallax']) - 1.)) if catalog == 'xmatch_TGAS_VSX.csv': df_toprocess = df_toprocess[df_toprocess.V == 0] print "%s objects selected" % len(df_toprocess) print "..Done\n----------" return df_toprocess
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def localize_red_clump(star_catalog,close_cat_idx,log):\n\n def select_within_range(mags, colours, mag_min, mag_max, col_min, col_max):\n \"\"\"Function to identify the set of array indices with values\n between the range indicated\"\"\"\n\n idx1 = np.where(colours >= col_min)[0]\n i...
[ "0.5334454", "0.5270723", "0.526012", "0.5255001", "0.51794606", "0.51098704", "0.50803125", "0.5008346", "0.49690634", "0.49599707", "0.49506727", "0.49429023", "0.49181986", "0.49170044", "0.4914409", "0.48817256", "0.4856762", "0.48513559", "0.48380238", "0.48282054", "0.4...
0.5875681
0
load and unpickle a pickled pandas.DataFrame 'pkl_file'. Should not use pickles because of version compatibility issues.
def get_pickle(get_file='simbad_mag_errors.pkl'): print "Opening %s and unpickling the DataFrame.." % get_file with open(get_file, 'r') as opened_file: df_unpickled = cPickle.load(opened_file) print "..Done" return df_unpickled
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_pkl(file_name):\n with open(file_name) as fp:\n data = pkl.load(fp)\n return data", "def load_pickle(args):\n with open(args.pickle_name, 'rb') as fh:\n datum = pickle.load(fh)\n\n df = pd.DataFrame.from_dict(datum['labels'])\n\n return df", "def load_pickle_data(filename)...
[ "0.7040217", "0.7036856", "0.6931901", "0.68135583", "0.6794832", "0.6742458", "0.67017835", "0.6617142", "0.655173", "0.65279627", "0.6512124", "0.630458", "0.6266877", "0.6249877", "0.6215119", "0.6211559", "0.6184485", "0.61801195", "0.61761963", "0.61551476", "0.61521256"...
0.67094475
6
add two pandas.DataFrames together on columns 'hip' and 'tycho2_id' columns.
def merge_df(merge_on_df, merge_with_df, merge_column=None): if merge_column is None: merge_column = ['hip', 'tycho2_id'] merge_on_df = merge_on_df.merge(merge_on_df, merge_with_df, on=merge_column) return merge_on_df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __add__(self, other):\n\n if not isinstance(other, Photons):\n raise ValueError('Can only add a Photons object to another Photons object.')\n\n # don't want to modify what is being added\n other = other.copy()\n\n # make column units consistent with self\n other.ma...
[ "0.553466", "0.54892987", "0.54729784", "0.53718424", "0.53287685", "0.5248236", "0.5239626", "0.5215545", "0.5187559", "0.5185057", "0.51510555", "0.5100996", "0.50776625", "0.5064464", "0.5058133", "0.50135696", "0.50105774", "0.5002041", "0.4988571", "0.49817595", "0.49551...
0.51093644
11
plot the background stars (HR diagram). The plot is a 2d histogram, for better readability. Only bins with at least 10 stars a shown.
def plot_hr_diag(hr_df, x='B_V', y='M_V', cutoff=0.2, bvcutoff=0.05): plt.figure(figsize=(11., 10.)) print "Plotting background stars.." plt.set_cmap('gray_r') plt.hist2d(hr_df[x].tolist(), hr_df[y].tolist(), (200, 200), norm=LogNorm(), cmin=10) plt.axis([-0.2, 2.35, -3., 7.]) plt.gca().invert_yaxis() plt.xlabel(r'$BT-VT$ (mag)') plt.ylabel(r'$M_{VT}$ (mag)') # Plotting M_{VT} plt.title(r'$\sigma_\pi / \pi < %s, \sigma_{BT-VT}< %s$ mag' % (cutoff, bvcutoff)) print "..Done" return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_histogram(img):\n rgb_hist = rgb_histogram(img)\n plt.figure()\n for color, hist in rgb_hist.items():\n plt.plot(hist, color=color)\n plt.xlim([0, 256])", "def plot_hist(self):\n labels = [self.get_class_str(action, obj)\n for (action, obj, subj, rec, beg, ...
[ "0.5921788", "0.5898935", "0.586834", "0.586834", "0.586834", "0.5814485", "0.575388", "0.5714343", "0.5698721", "0.56886125", "0.5656541", "0.5636839", "0.56319624", "0.5586074", "0.55594313", "0.5537156", "0.54848033", "0.54779595", "0.5466038", "0.54587734", "0.5457407", ...
0.66867584
0
Parent function of get_variable_stars. Sequencially select 'variableTypes' variable stars and plot them on the HR diagram.
def plot_variable_stars(variablesdf, variabletype=None, x='B_V', y='M_V'): if variabletype is None: variabletype = ['CEP', 'BCEP', 'BCEPS', 'DSCT', 'SR', 'SRA', 'SRB', 'SRC', 'SRD', 'RR', 'RRAB', 'RRC', 'GDOR', 'SPB', 'M', 'LPV', 'roAp'] markers = ['^', 'D', 'D', 'v', 's', 'D', 'D', 'D', 'D', 's', 'D', 'D', 'D', 'o', 'p', 'o', 'o'] colors = ['k', 'k', 'k', '#00c000', 'r', 'r', 'r', 'r', 'r', 'm', 'm', 'm', '#00c0ff', (1, .7, 0), 'w', 'w', 'r'] sizes = [50, 40, 40, 40, 50, 40, 40, 40, 40, 50, 50, 50, 40, 40, 45, 40, 40] labels = ['', "BCEP, BCEPS", '', 'DSCT', 'SR', "SRA, SRB, SRC, SRD", '', '', '', 'RR', "RRAB, RRC", '', 'GDOR', 'SPB', '', 'LPV', 'roAp'] for i in range(len(variabletype)): if i in [2, 6, 7, 8, 11]: my_label = None else: my_label = "%s" % labels[i] plt.scatter(variablesdf[x].loc[variablesdf.loc[:, 'Type'] == variabletype[i]], variablesdf[y] .loc[variablesdf.loc[:, 'Type'] == variabletype[i]], facecolor=colors[i], marker=markers[i], s=sizes[i], label=my_label, edgecolor='k') print "plotting %s as %s%s" % (variabletype[i], colors[i], markers[i]) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_variable_stars(df_data, df_variables_names, variabletype=None):\n if variabletype is None:\n variabletype = ['CEP', 'BCEP', 'BCEPS', 'DSCT', 'SR', 'SRA', 'SRB', 'SRC', 'SRD', 'RR', 'RRAB', 'RRC',\n 'GDOR', 'SPB', 'M', 'LPV']\n\n print \"Selecting variable stars..\"\n ...
[ "0.6919843", "0.5500659", "0.5284528", "0.5282017", "0.49810436", "0.49508908", "0.49358875", "0.47995615", "0.47526926", "0.4750297", "0.4654779", "0.4653055", "0.46524152", "0.46244058", "0.46109277", "0.45994213", "0.45680085", "0.45665252", "0.45277017", "0.4504224", "0.4...
0.76934016
0
Child function fo plot_variable_stars. Process the DataFrame to select only stars marked as 'var_type' variable stars.
def get_variable_stars(df_data, df_variables_names, variabletype=None): if variabletype is None: variabletype = ['CEP', 'BCEP', 'BCEPS', 'DSCT', 'SR', 'SRA', 'SRB', 'SRC', 'SRD', 'RR', 'RRAB', 'RRC', 'GDOR', 'SPB', 'M', 'LPV'] print "Selecting variable stars.." # create a string "var_type" of variabletype separated by or ('|'). # var_type = "|".join(variabletype) # check if var_type is contained in Type (any or all, partial or not) # are_variables = df_variables_names[df_variables_names.Type.str.contains(var_type) == True] # fails with "is True" # are_variables.Type = are_variables.Type.str.replace(".*BCEP.*", "BCEP") # rename all types containing 'BCEP' are_variables = df_variables_names[df_variables_names.Type.isin(variabletype)] types_df = are_variables[['hip', 'tycho2_id', 'source_id', 'Type', 'Name']] print "..Done" print "Preparing subselection of initial DataFrame.." print "..Making Hipparcos list.." hip_list = are_variables.hip.tolist() hip_list = np.array(hip_list) hip_list = hip_list[~np.isnan(hip_list)] # remove the nans hip_list = list(hip_list) print "..Making Tycho2 list.." tycho2_list = are_variables.tycho2_id.tolist() tycho2_list = np.array(tycho2_list) tycho2_list = tycho2_list[tycho2_list != 'nan'] # tycho2 is str tycho2_list = list(tycho2_list) print "..Done\n----------" print "Getting Hipparcos and Tycho variable objects.." hip_objects = df_data[df_data.hip.isin(hip_list)] hip_objects = pd.merge(hip_objects, types_df, on='hip', how='inner') if 'tycho2_id_y' in hip_objects.columns: hip_objects = hip_objects.drop('tycho2_id_y', axis=1) hip_objects = hip_objects.rename(columns={'hip_x': 'hip', 'tycho2_id_x': 'tycho2_id'}) tycho_objects = df_data[df_data.tycho2_id.isin(tycho2_list)] tycho_objects = pd.merge(tycho_objects, types_df, on='tycho2_id', how='inner') if 'hip_y' in tycho_objects.columns: tycho_objects = tycho_objects.drop('hip_y', axis=1) tycho_objects = tycho_objects.rename(columns={'hip_x': 'hip', 'tycho2_id_x': 'tycho2_id'}) print "..Done\n----------" print "Getting roAp stars from file.." # roAP_names.csv contains tycho2_id names of roAp stars with open('roAP/roAP_names.csv') as roAP_file: roap_objects_list = roAP_file.readlines() roap_objects_list = [line.rstrip() for line in roap_objects_list] roap_objects = df_data[df_data.tycho2_id.isin(roap_objects_list)] column_number = len(roap_objects.columns) roap_objects.insert(column_number, 'Type', 'roAp') print "..Done\n----------" variable_df = pd.concat([hip_objects, tycho_objects, roap_objects], axis=0, ignore_index=True) variable_df.source_id = variable_df.source_id.fillna(-9999).astype(int) return variable_df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_variable_stars(variablesdf, variabletype=None, x='B_V', y='M_V'):\n if variabletype is None:\n variabletype = ['CEP', 'BCEP', 'BCEPS', 'DSCT', 'SR', 'SRA', 'SRB', 'SRC', 'SRD', 'RR', 'RRAB', 'RRC', 'GDOR',\n 'SPB', 'M', 'LPV', 'roAp']\n markers = ['^', 'D', 'D', 'v', 's...
[ "0.7149481", "0.53572685", "0.49779034", "0.49217516", "0.4668608", "0.46611875", "0.46530828", "0.46240893", "0.46187612", "0.45908424", "0.4562476", "0.45395714", "0.4536326", "0.45301196", "0.4524316", "0.4492281", "0.4465708", "0.44525927", "0.4432995", "0.44032437", "0.4...
0.72028685
0
added a Variability flag check in data_process, where only CONFIRMED variables are now kept drop misclassified objects, like SR stars on the Main Sequence, optical binaries, etc.
def remove_misclassified_objects(data_frame): misclassified_objects = ['7720-1455-1', '7911-499-1', # Mira '8990-3504-1', '899-471-1', # SRs with very poor light curves '6430-88-1', # SV For, obsolete measurement is p=91d, newer is p=16h '9017-396-1', '7676-2953-1', '8296-3303-1', # SR '2365-2764-1', '4109-638-1', '2058-56-1', # Cepheids '3642-2459-1', '3999-1391-1', '2607-1448-1', # Cepheids '3655-469-1', '1476-148-1', '1233-531-1', # RR Lyrae '3029-738-1', '6863-1255-1', '6954-1236-1', '9380-420-1' # RR Lyrae '6192-461-1', # DSCT '2550-686-1', '4992-357-1', '9380-420-1', '8562-728-1', '6567-2007-1', '6040-2003-1', # RR '2553-1108-1', '4851-2441-1', '8962-577-1', '3135-132-1', '8976-3674-1', '3136-437-1', '1506-618-1', '7046-1715-1', '3140-3046-1', '2000-162-1', '6210-755-1', '3547-1807-1', '8836-935-1', '3033-273-1', '7606-437-1', '3049-180-1', '9198-1862-1', '8192-626-1', '7703-1577-1', '8594-433-1', '6833-280-1', '9270-1803-1', '8153-376-1', '8169-431-1', '3086-1770-1', '6472-1634-1', '9321-795-1', '2664-351-1', '2426-162-1' # roAp star that has no reference ] dsct = data_frame[(data_frame.Type == 'DSCT') & (data_frame.B_V > 0.4) & (data_frame.M_V > 2.5)].tycho2_id.tolist() dsct2 = data_frame[(data_frame.Type == 'DSCT') & (data_frame.B_V > 0.25) & (data_frame.M_V > 3.)].tycho2_id.tolist() print "Dropping objects DSCT: %s %s" % (dsct, dsct2) data_frame = data_frame.drop(data_frame[data_frame.tycho2_id.isin(dsct)].index) data_frame = data_frame.drop(data_frame[data_frame.tycho2_id.isin(dsct2)].index) print "Dropping objects: %s" % misclassified_objects data_frame = data_frame.drop(data_frame[data_frame.tycho2_id.isin(misclassified_objects)].index) print "..Done\n----------" return data_frame
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def control_variation(df, outDir, features_to_analyse, \n variables_to_analyse=[\"date_yyyymmdd\"], \n remove_outliers=True, \n p_value_threshold=0.05, \n PCs_to_keep=10):\n \n # Record non-data columns before dropping...
[ "0.5850183", "0.56285363", "0.562465", "0.55599266", "0.5522764", "0.5506512", "0.5470186", "0.5469287", "0.54548407", "0.5453748", "0.5453382", "0.54242575", "0.5410281", "0.53945994", "0.53779036", "0.5369179", "0.5358951", "0.5341739", "0.53268266", "0.531534", "0.5304359"...
0.0
-1
compute the dereddened values of BV and M_V for the six Cepheids in our sample (parallax cutoff = 0.25 and BV error < 0.1).
def deredden_cepheids(df_variables): extinction_coefficients = {'2365-2764-1': np.array([0.2622, 0.844]), '4109-638-1': np.array([0.0524, 0.1576]), '2058-56-1': np.array([0.0751, 0.248]), '3642-2459-1': np.array([0.1907, 0.608]), '3999-1391-1': np.array([0.3911, 1.2480]), '2607-1448-1': np.array([0.0430, 0.1310])} print "Dereddening Cepheids:" for tyc in extinction_coefficients.keys(): print "%s.." % tyc b_minus_v = df_variables[df_variables.tycho2_id == tyc].B_V m_v = df_variables[df_variables.tycho2_id == tyc].M_V extinc = extinction_coefficients[tyc] df_variables.set_value(df_variables.tycho2_id == tyc, 'B_V', b_minus_v - extinc[0]) df_variables.set_value(df_variables.tycho2_id == tyc, 'M_V', m_v - extinc[1]) print "..Done\n----------" return df_variables
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deredden(EBV,filt):\n conversion_data = ascii.read(datapath+\"/stellar_param_data/sf11.txt\")\n assert filt in conversion_data[\"filter\"], (filt, conversion_data[\"filter\"])\n return EBV * float(conversion_data[\"AB_EBV\"][np.where(conversion_data[\"filter\"]==filt)[0]])", "def get_debiet_inlaatdu...
[ "0.6110026", "0.5988009", "0.5985353", "0.5741001", "0.5596539", "0.5589506", "0.55479646", "0.5542845", "0.55302805", "0.5492529", "0.5491629", "0.54801345", "0.5469861", "0.54658246", "0.54637504", "0.54476047", "0.5442807", "0.543293", "0.5415737", "0.5393574", "0.53840727...
0.59492534
3
plot a Cepheid at its reddened position on the HR diag. (assume that deredden_cepheids() have been used)
def plot_dereddening(): extinction_coefficients = {'2365-2764-1': np.array([0.2622, 0.844]), '4109-638-1': np.array([0.0524, 0.1576]), '2058-56-1': np.array([0.0751, 0.248]), '3642-2459-1': np.array([0.1907, 0.608]), '3999-1391-1': np.array([0.3911, 1.2480]), '2607-1448-1': np.array([0.0430, 0.1310])} cepheids = {'2365-2764-1': np.array([0.959, 2.09]), '4109-638-1': np.array([0.705, 2.385]), '2058-56-1': np.array([1.222, 1.333]), '3642-2459-1': np.array([1.088, 2.0518]), '3999-1391-1': np.array([1.360, 1.2567]), '2607-1448-1': np.array([1.484, 0.6963])} periods = {'2365-2764-1': 1.61, '4109-638-1': 15.31, '2058-56-1': 63.08, '3642-2459-1': 1.86, '3999-1391-1': 24.98, '2607-1448-1': 8.54} max_periods = max(periods.values()) new_positions_bv_mv = [] # in M_V vs B-V space colors = [] theoretical_position = [] for obj in extinction_coefficients.keys(): # new_positions_bv_mv.append(cepheids[obj]-extinction_coefficients[obj]) new_positions_bv_mv.append(cepheids[obj]) colors.append(periods[obj]/max_periods) theoretical_position.append(-2.78*np.log10(periods[obj])-1.35) for pos in range(len(new_positions_bv_mv)): plt.scatter(new_positions_bv_mv[pos][0], new_positions_bv_mv[pos][1], marker='^', facecolor='w', s=40) plt.scatter(new_positions_bv_mv[pos][0], theoretical_position[pos], marker='o', facecolor='r', s=50) return new_positions_bv_mv, colors
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_1d_path(self):\n\n fig = plt.figure(figsize=(8,5))\n \n matches = (self.a_scale == self.c_scale)\n plt.plot(self.a_scale[matches], self.E_coh[matches])\n plt.xlabel('linear deformation coefficient: 0=fcc, 1=bcc')\n plt.ylabel('Cohesive energy (eV/atom)')\n ...
[ "0.563348", "0.5631599", "0.5533224", "0.5502739", "0.5487151", "0.5443683", "0.5419953", "0.5403358", "0.5385931", "0.53529364", "0.5345485", "0.53156674", "0.53142434", "0.53062516", "0.5289918", "0.52762717", "0.527185", "0.5271523", "0.524425", "0.52201706", "0.5217703", ...
0.6225962
0
Initializes the connection with IMDb.
def initialize_connection(): session = imdb.IMDb() return session
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _setup_connection(cls):\n try:\n cls.imdb_access = imdb.IMDb()\n except imdb.IMDbError, err:\n print \"Problem with connectivity to imdb.com due to %s \" \\\n % (err)", "def initialize():\n\t\tDBHelper.con = mdb.connect('localhost', 'root', 'sensepass', 'sens...
[ "0.75613075", "0.7126608", "0.70486325", "0.70344806", "0.6966653", "0.6887101", "0.6868013", "0.6741305", "0.6721468", "0.67194366", "0.6630532", "0.65871525", "0.6585673", "0.6537051", "0.6491186", "0.64337355", "0.6409378", "0.6344977", "0.6321777", "0.63136494", "0.628949...
0.75485164
1
Given an imdb session object, will search the site for the given search term.
def search_for_title(session, search_term): try: s_result = session.search_movie(search_term) shows = {} # made the keys of the namedtuple a digit for ease of selecting the correct one later for count, result in enumerate(s_result): show_id = count movie_id = result.movieID title = result['long imdb canonical title'] url = f'http://www.imdb.com/title/tt{movie_id}/parentalguide' shows[count] = Show(show_id, movie_id, title, url) return shows except imdb._exceptions.IMDbDataAccessError: display_error()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search(self, term):", "def run_search(term, imdb_page, debug = False):\n\n # confirm function call\n if debug:\n print(\"run_search()\")\n\n # scrub search term for imdb\n formatted_term = \"+\".join(term.split())\n\n # add page information to search term\n if imdb_page > 0:\n ...
[ "0.67246073", "0.6698477", "0.66643846", "0.64279336", "0.64254475", "0.6390886", "0.6354886", "0.6213453", "0.619048", "0.6099298", "0.60874957", "0.60230345", "0.60201484", "0.60025597", "0.5991887", "0.59684485", "0.5968053", "0.59504765", "0.5949628", "0.5926764", "0.5893...
0.5997695
14
Displays a generic error message when there is a connection error.
def display_error(): clear_screen() line = '#' * 20 print(f'{line}\n# CONNECTION ERROR #\n{line}') exit(1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_error(self, conn, msg):\n print(\"ERROR PLACEHOLDER\")\n\n return", "def __display_error(self, socket_error):\r\n\t\tif socket_error == QAbstractSocket.RemoteHostClosedError:\r\n\t\t\tself._window.open_dialog(\"Serveur déconnecté\", \"Le serveur s'est déconnecté !\")\r\n\t\t\t# Add signal ...
[ "0.7256641", "0.70974416", "0.7031372", "0.70112437", "0.69415045", "0.6857179", "0.6755222", "0.6755222", "0.67330766", "0.6692993", "0.66359854", "0.65511245", "0.6525908", "0.6504783", "0.6490381", "0.64878225", "0.64797825", "0.64601153", "0.64406806", "0.64355856", "0.64...
0.738177
0
Given a dictionary of show objects, displays them and gives you a choice of which one to get further details for.
def display_shows(shows): another = False # put this portion into an infinite loop to allow for reviewing other listed media while True: # display a different question on the second or more pass if another: again = input('\nWould you like to go back and review a different one? ([y]/n)') # if user replies with anything starting with a n, break out of the loop if again.lower().startswith('n'): clear_screen() break else: clear_screen() # list all of the shows that were found for n in range(len(shows)): print(f'[{n:2}] {shows[n].title}') # fix bug where a non-digit is given try: choice = int(input('\nWhich one would you like to review? ')) another = True # after first pass, set this flag except ValueError: clear_screen() break if choice in shows.keys(): clear_screen() print(f'Retrieving additional information for {shows[choice].title}') # the plot is not on the same page as the other information so requires its own scrape plot = get_plot(shows[choice].url) # if the plot was found, display it, otherwise skip past it if plot: print('\n[PLOT]\n') wrapped = textwrap.dedent(plot).strip() print(textwrap.fill(wrapped, initial_indent=' ', subsequent_indent=' ', width=110)) # scrape the actual content that we need scrape_movie(shows[choice].url) else: print(f'\n{choice} is not a valid choice!') break
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_show_information():\n\n #getting the guidebox_id variable from show_page.html\n guidebox_id = request.args.get(\"guidebox_id\")\n\n #get the show from the database\n show = Show.find_show_with_guidebox_id(guidebox_id)\n\n #check if show has a description, if it does then just pass the show o...
[ "0.6592299", "0.6279458", "0.62582874", "0.61725926", "0.61149275", "0.6025211", "0.60056853", "0.5981849", "0.59650505", "0.59365", "0.59159607", "0.58936185", "0.5889489", "0.5884984", "0.5873648", "0.5829819", "0.58108586", "0.57891476", "0.57777935", "0.5762831", "0.57577...
0.60066134
6
Displays the ratings that were scraped.
def display_ratings(ratings): # only attempt to display the ratings if any were found if ratings: print('\n[RATINGS]\n') for rating in ratings: print(f' {rating}', end=' ') # needed to get printing back to normal print()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_ratings(all_ratings):\n print(\"Here is the current list of all ratings:\")\n for restaurant, rating in sorted(all_ratings.items()):\n print(f'{restaurant} is rated at {rating}.')", "def display_player_ratings(player_ratings):\r\n print('\\nCLASSEMENT DES PARTICIPANTS:\\n Nom ELO ...
[ "0.6716487", "0.66836923", "0.6439657", "0.6439657", "0.64141905", "0.6388619", "0.6368018", "0.635137", "0.62618804", "0.6109449", "0.61091423", "0.609001", "0.6076961", "0.60705274", "0.6063568", "0.60551393", "0.60547274", "0.60209185", "0.60183233", "0.60183233", "0.60046...
0.74975514
0
Displays the given section in the proper format.
def display_section(title, category, category_comments): # only attempt to print these if either of them were found if category or category_comments: print(f'\n[{title.upper()}]') print(f' {category}\n') for comment in category_comments: # print(f' * {comment}') wrapped = textwrap.dedent(comment).strip() print(textwrap.fill(wrapped, initial_indent=' * ', subsequent_indent=' ', width=110))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_section(self, s):\n section = s.upper()\n\n self.print_newline()\n self.print_newline()\n self._write('%s\\n' % section)\n self._write('%s\\n' % ('-' * len(section)))\n self.print_newline()", "def print_section(section_name, width=120):\n section_name = ' ' ...
[ "0.7210139", "0.71652883", "0.7011607", "0.6947766", "0.6940115", "0.6729903", "0.6606709", "0.6531379", "0.6423387", "0.6411612", "0.64110327", "0.6390477", "0.6239066", "0.6006855", "0.59656584", "0.5911256", "0.5908014", "0.5903914", "0.58947486", "0.5894047", "0.58920234"...
0.6881852
5
Scraping handler Initiates scraping of the different sections required by the script.
def scrape_movie(url): soup = get_soup(url) if soup: # scrape all of the sections soup_sections = soup.find('section', {'class': 'article listo content-advisories-index'}) # scrape for the specific sections required soup_certificates = soup_sections.find('section', {'id': 'certificates'}) soup_nudity = soup_sections.find('section', {'id': 'advisory-nudity'}) soup_profanity = soup_sections.find('section', {'id': 'advisory-profanity'}) # further scrape the sections above ratings = parse_certificates(soup_certificates) nudity, nudity_comments = parse_section(soup_nudity) profanity, profanity_comments = parse_section(soup_profanity) # here is where we actually format and show the results display_ratings(ratings) display_section('nudity', nudity, nudity_comments) display_section('profanity', profanity, profanity_comments) else: display_error()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self):\r\n self.init_data = td.import_data(self.__module__)\r\n self.page1() # GET navigation (requests 101-153)\r\n\r\n grinder.sleep(20)\r\n self.page2() # GET case (requests 201-252)\r\n\r\n grinder.sleep(20)\r\n self.page3() # GET view (requ...
[ "0.6909366", "0.66830665", "0.6554945", "0.65500784", "0.64894116", "0.6398545", "0.63733447", "0.6339496", "0.6224981", "0.6167547", "0.6128595", "0.6099338", "0.6079297", "0.602946", "0.59992015", "0.59699357", "0.596249", "0.5953066", "0.586132", "0.5859717", "0.58555573",...
0.0
-1
Scrapes the plot from the provided URL.
def get_plot(url): soup = get_soup(url.rsplit('/', 1)[0]) if soup: # scrape the plot section plot_div = soup.find('div', {'id': 'titleStoryLine'}) # fixes bug were no plot is found try: plot_class = plot_div.find('span', {'itemprop': 'description'}) plot = plot_class.text.strip() return ' '.join(plot.split()) except AttributeError: return 'The plot was not available.' else: display_error()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def scrape_page(session, url):\n logging.info('Scraping %s', url)\n images = await get_url_images(session, url)\n await save_url_images(images)", "def scrape_url(url):\n html = requests.get(url).text\n return scrape_html(html)", "def fn_GetMoviePlot(self, details):\n\n # If the cust...
[ "0.59756243", "0.59229475", "0.5871458", "0.5760079", "0.56895536", "0.5675282", "0.56477475", "0.55973434", "0.5542551", "0.55007184", "0.54510456", "0.54468447", "0.54364306", "0.54364306", "0.54296917", "0.5414543", "0.53710335", "0.53710335", "0.5366538", "0.5339143", "0....
0.6619968
0
Cleans up the given comments.
def cleanup_comments(comments): clean_comments = [] if comments: for comment in comments: cleaned_up = sub(r'\n\n {8}\n {8}\n {12}\n {16}\n {16}\n {12}\nEdit', '', comment) clean_comments.append(cleaned_up) return clean_comments
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_comments(self):\n new_lines = list()\n for line in self.lines:\n if ((not line.startswith(\"//\")) & (not line.isspace()) &\n (not line.startswith(\"/*\") & (not line.startswith(\"*/\")))):\n line = Parser.strip_line(line)\n new_li...
[ "0.6856925", "0.64137363", "0.6254925", "0.6239691", "0.6239691", "0.62174577", "0.6139259", "0.5952024", "0.5854225", "0.5823274", "0.5761137", "0.5758094", "0.5758094", "0.5758094", "0.5758094", "0.5737992", "0.573623", "0.5734576", "0.5660582", "0.5650429", "0.56369406", ...
0.7856755
0
Parses the certificates specific to the United States.
def parse_certificates(soup): # removes the first item because it does not needed rating_tags = soup.find_all('a')[1:] rating_codes = [code.string for code in rating_tags] mpaa = [] if rating_codes: for rating in rating_codes: # sorry international folks, only interested in the US ratings if rating.startswith('United States'): mpaa.append(rating) return mpaa
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_country_states(self):\n pass", "def test_addr_country_good_values(self):\n for input_val, output_val in self.known_values:\n self.line._parse_addr_country(input_val)\n self.assertEqual(output_val, self.line.addr_country)", "def test_county_limit_by_state__valid_...
[ "0.52510595", "0.5242316", "0.50890213", "0.5040012", "0.49885833", "0.49216333", "0.49208397", "0.49044296", "0.48793742", "0.47967193", "0.4782242", "0.47812676", "0.4777004", "0.47749475", "0.47335306", "0.47322056", "0.47285786", "0.46640974", "0.46594405", "0.46486455", ...
0.54531664
0
Parses the given section.
def parse_section(soup): section_tag = soup.find_all('a', {'class': 'advisory-severity-vote__message'}) section_scale = [code.string for code in section_tag] section = section_scale[0] if section_scale else None section_comment_tags = soup.find_all('li', {'class': 'ipl-zebra-list__item'}) section_comment_list = [comment.text.strip() for comment in section_comment_tags] comments = cleanup_comments(section_comment_list) return section, comments
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_section(self, root, fmt):\n return self.parse_tag(root, fmt)", "def parse(self):\n for section in self.sections:\n section.parse()", "def do_section(parser, token, template='parts/section.html', end='endsection'):\n bits = token.split_contents()[1:]\n if len(bits) is 0:...
[ "0.7374695", "0.6986738", "0.68131596", "0.68070054", "0.6706419", "0.6671083", "0.65692985", "0.6440196", "0.64307415", "0.63216704", "0.62620395", "0.6214296", "0.6185266", "0.61728215", "0.6125363", "0.6123458", "0.61100674", "0.6085565", "0.6084057", "0.6030608", "0.60254...
0.71823096
1
Main entry point for the script
def main(): clear_screen() print("Establishing a connection with the IMDb service...") session = initialize_connection() another = True while another: clear_screen() search_term = input("What would you like me to look up for you? ") if search_term: clear_screen() print(f'Please wait while I search for "{search_term}"...') shows = search_for_title(session, search_term) clear_screen() print(f'Found {len(shows)} matches.') if shows: display_shows(shows) another_one = input("Would you like to search for a different title? ([y]/n)") if another_one.lower().startswith('n'): another = False else: break clear_screen() print('Bye!')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n return", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", ...
[ "0.8150395", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755", "0.81455755",...
0.0
-1
Return True if ``value`` is an health check.
def is_healthcheck(self, value): return is_healthcheck(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self, value) -> bool:\n return self._check_helper(value, raise_exceptions=False)", "def has_value(cls, value):\n return bool(isinstance(value, numbers.Number) or isinstance(value, time) or \\\n isinstance(value, datetime) or value)", "def is_true(value):\n \n return ...
[ "0.70862806", "0.6380764", "0.61718976", "0.598836", "0.5963879", "0.59439", "0.5902455", "0.5843611", "0.5777476", "0.57587725", "0.57587725", "0.57569546", "0.56969887", "0.56509334", "0.5631042", "0.55776083", "0.554896", "0.5548796", "0.55426407", "0.5515357", "0.55148315...
0.867911
0
Return copy of TestSuite where only health checks remain.
def filter_suite(self, suite): if isinstance(suite, unittest.TestSuite): suite_copy = self.suiteClass() for sub in suite: if isinstance(sub, unittest.TestSuite): suite_copy.addTest(self.filter_suite(sub)) else: if self.is_healthcheck(sub): suite_copy.addTest(sub) elif self.is_healthcheck(suite): suite_copy = suite.copy() return suite_copy
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dry_run(self):\n self.result.report = self._new_test_report()\n\n for pyunit_testcase in self.cfg.testcases:\n testsuite_report = TestGroupReport(\n name=pyunit_testcase.__name__,\n uid=pyunit_testcase.__name__,\n category=ReportCategories.T...
[ "0.63560736", "0.6105774", "0.59605616", "0.58906287", "0.588734", "0.58871996", "0.5851725", "0.58468413", "0.5832818", "0.5828046", "0.57777184", "0.57675064", "0.57567066", "0.5658222", "0.5646921", "0.56121224", "0.56025547", "0.56018823", "0.5576602", "0.5569374", "0.556...
0.7639181
0
Load healthchecks from TestCase.
def loadTestsFromTestCase(self, testCaseClass): suite = super(HealthCheckLoader, self).loadTestsFromTestCase( testCaseClass) return self.filter_suite(suite)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_health_get(self):\n pass", "def test_lint(self):\n l = self.l\n l.loadTestsFromTestCase\n l.loadTestsFromModule\n l.loadTestsFromName\n l.loadTestsFromNames", "def loadTestsFromModule(self, module, *args, **kwargs):\n suite = super(HealthCheckLoader, se...
[ "0.6312396", "0.62286896", "0.61631715", "0.6092404", "0.6075559", "0.60417944", "0.6005269", "0.6000439", "0.5768636", "0.57478154", "0.57459795", "0.57209116", "0.5693739", "0.5679516", "0.56593746", "0.56551856", "0.56339574", "0.55915415", "0.55771744", "0.5574354", "0.55...
0.68875015
0
Load healthchecks from module.
def loadTestsFromModule(self, module, *args, **kwargs): suite = super(HealthCheckLoader, self).loadTestsFromModule( module, *args, **kwargs) return self.filter_suite(suite)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def healthcheck(parameters): \n\n print(\"In healthcheck module\")", "def _load(self):\n p = os.path.join(paths.setup_dir, 'system_health.yaml')\n if os.path.isfile(p):\n with open(p, 'r') as rfile:\n config = yaml.load(rfile)\n if config:\n ...
[ "0.6399756", "0.6244733", "0.600857", "0.5915704", "0.57699925", "0.569914", "0.565888", "0.5624556", "0.5607272", "0.560578", "0.55228066", "0.5457219", "0.541206", "0.5375242", "0.53745407", "0.53611326", "0.5358373", "0.5354235", "0.53232366", "0.53232366", "0.53232366", ...
0.6768524
0