query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Constructor. Takes either 2 ints ( or longs ) or a fraction. Passing the constructor a fraction simply makes a copy of the original.
def __init__( self, *arg ): if ( len( arg ) == 2 ): # if one of the arguments is a fraction: if ( type( self ) in ( type( arg[ 0 ] ), type( arg[ 1 ] ) ) ): # future division is broken, so simple division doesn't work here. if ( type( self ) == type( arg[ 0 ] ) == type( arg[ 1 ] ) ): self.num...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,top,bottom):\n \n if (type(top) is not int or type(bottom) is not int):\n raise TypeError('Numerator and denominator must be integers.')\n elif bottom == 0:\n raise ZeroDivisionError('The denominator cannot be zero.')\n elif bottom < 0: #store ...
[ "0.7400744", "0.7310966", "0.7159644", "0.69801784", "0.697844", "0.6774786", "0.6733332", "0.6578595", "0.65011233", "0.64986014", "0.64979523", "0.64520395", "0.6437857", "0.6373404", "0.6037887", "0.60288614", "0.6013549", "0.5960694", "0.5945378", "0.59018946", "0.5872792...
0.76828134
0
Returns true if the value passed in is equal to this fraction
def __eq__( self, value ): if ( type( self ) == type( value ) ): selfval, valueval = self.numerator / self.denominator, value.numerator / value.denominator if ( types.ComplexType in ( type( selfval ), type( valueval ) ) ): if not ( types.ComplexType == type( selfval ) == type( valueval ) ): return...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, frac):\n\n if isinstance(frac,Fraction):\n if self.numerator ==0 and self.denominator==0:\n if frac.numerator ==0 and frac.denominator==0:\n return True\n return 0 == frac.numerator/frac.denominator\n return self.numerat...
[ "0.7765323", "0.73697495", "0.7367525", "0.6607162", "0.6582022", "0.65724844", "0.6492013", "0.6416986", "0.63977706", "0.63715607", "0.6242642", "0.62248075", "0.6121435", "0.60975385", "0.6053899", "0.6016333", "0.60125846", "0.59804916", "0.5958486", "0.5916052", "0.58880...
0.6639716
3
Returns true if the values are not equal
def __ne__( self, value ): return not ( self == value )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def are_not_equal(value1, value2):\n return not ObjectComparator.are_equal(value1, value2)", "def __ne__(self, values):\n self = self.__eq__(values)\n return self.__invert__()", "def test_not_equal_on_not_equal_value(self):\n a = objects.OpaqueObject(self.bytes_a, enums.OpaqueDataTy...
[ "0.80345213", "0.7712322", "0.74838823", "0.74260503", "0.736753", "0.7336081", "0.7213194", "0.7213194", "0.72095615", "0.7204377", "0.7178061", "0.7174621", "0.7144386", "0.70782506", "0.707036", "0.70698273", "0.70548314", "0.7051565", "0.70500237", "0.70306087", "0.702160...
0.69295126
32
Returns true if the fraction is not equal to zero
def __nonzero__( self ): return bool( self.numerator )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_zero(self):\n return float(self.coeff.nominator) / self.coeff.denominator == 0.0", "def _is_zero(a):\n return (isinstance(a, int) and a == 0) or (is_rational_value(a) and a.numerator_as_long() == 0)", "def test_notequal(self):\n self.assertTrue(Fraction(144,2)!=Fraction(8,4))", "def t...
[ "0.7385792", "0.71018094", "0.7080985", "0.68883467", "0.68000823", "0.67511946", "0.67322105", "0.67237115", "0.6656879", "0.66293436", "0.6595094", "0.6594518", "0.6533588", "0.6525537", "0.6494031", "0.6488874", "0.6477827", "0.6455527", "0.6438921", "0.64348835", "0.64287...
0.6953782
3
Function splits path to file to directory, filename and extension.
def filename_split(path): directory = os.path.dirname(path) filename, extension = os.path.splitext(os.path.basename(path)) return directory, filename, extension
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitpath_root_file_ext(path):\r\n head, tail = os.path.split(path)\r\n filename, ext = os.path.splitext(tail)\r\n return head, filename, ext", "def split_path(path:str):\n if path is None or len(path) == 0:\n return '', '', ''\n path = sanitize_path(path)\n folder, filename = os.pat...
[ "0.7786279", "0.7487892", "0.7141793", "0.70819336", "0.6869256", "0.6802811", "0.67744833", "0.67744833", "0.6767643", "0.6618268", "0.66069454", "0.6591664", "0.654305", "0.6503773", "0.64845127", "0.64714813", "0.6411037", "0.63925314", "0.63868105", "0.6355024", "0.632642...
0.7997475
0
Get a string containing the path to the user's temp directory.
def getTempPath(): os.path.join(os.path.expanduser("~"),"AppData\Local\Temp")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_temp_path():\n return os.getcwd() + \"/temp/\"", "def temp_directory(self):\n\n return self.get_raw(\"temp_directory\")", "def sys_get_temp_dir(space):\n return space.newstr('/tmp')", "def get_temp_dir():\n return tempfile.mkdtemp()", "def get_temp_dir():\n return settings.FI...
[ "0.8666661", "0.81888396", "0.81644255", "0.804604", "0.8029801", "0.7999388", "0.7978534", "0.79457664", "0.7897148", "0.7832997", "0.78188306", "0.78028816", "0.771677", "0.7700281", "0.7685738", "0.7655481", "0.76315004", "0.7628951", "0.76267743", "0.758522", "0.75801384"...
0.86171883
1
The learning rate decay for xception (as presented in their paper) is a decay of rate 0.94 every second epoch, which is much less than what is presented by UCLA
def xceptionLrUpdate(epoch, lr): if (1 + epoch) % 2 == 0: return lr * 0.94 else: return lr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def learning_rate(epoch):\n return alpha / (1 + decay_rate * epoch)", "def learning_rate(epoch):\n return alpha / (1 + decay_rate * epoch)", "def step_decay(epoch):\n initial_lrate = 0.1\n drop = 0.5\n epochs_drop = 10.0\n lrate = initial_lrate * math.pow(drop, math.floor((1 + epoch) ...
[ "0.7891862", "0.7891862", "0.78638226", "0.77865595", "0.7392954", "0.7392374", "0.73783296", "0.73212713", "0.73052734", "0.7103807", "0.7060857", "0.70530945", "0.70418316", "0.6985323", "0.6910814", "0.68909365", "0.68463135", "0.68222547", "0.68222547", "0.68086696", "0.6...
0.6887779
16
Performs a min max operation into a dataframe column specified using a string All NaN values are ignored.
def minMax(df, column): df_result = df.copy() not_nulls = df[column].isnull() == False v = np.matrix(df_result.loc[not_nulls, column]) #.as_matrix() scaler = skpreprocess.MinMaxScaler() df_result.loc[not_nulls, column] = scaler.fit_transform(v.T) return df_result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def column_max_min(data, column, sep_type=\"\", skip_rows=0):\n\n if sep_type==\"\":\n info=pd.read_csv(data, skiprows=skip_rows, header=None, delim_whitespace=True) \n else:\n info=pd.read_csv(data, skiprows=skip_rows, header=None, sep=sep_type)\n\n print(\"Min: %f\" %(info[column].min()))\...
[ "0.57827795", "0.5629731", "0.5515408", "0.5361681", "0.53558785", "0.52945614", "0.5264549", "0.5260896", "0.5246771", "0.5212616", "0.51181895", "0.5112062", "0.50223345", "0.50223345", "0.4979459", "0.49631584", "0.49300772", "0.49194902", "0.4901448", "0.48601252", "0.485...
0.62369275
0
pass vect as list or array returns the magnitude
def magnitude_vect(vect): mag = (vect[0] ** 2 + vect[1] ** 2 + vect[2] ** 2) ** .5 return mag
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def magnitude(v):\n if len(v.arr) != 4 or v[3] != 0.0:\n raise ValueError(\"Only use this function with vectors.\")\n return np.sqrt(np.sum(np.square(v.arr)))", "def magnitude(v: Vector) -> float:\n return math.sqrt(sum_of_squares(v)) #math.sqrt() is a square root function", "def magnitude(v):\...
[ "0.8057131", "0.7726903", "0.7703504", "0.76115716", "0.75562453", "0.7540449", "0.75095165", "0.7498011", "0.7489628", "0.72921", "0.7159412", "0.70309687", "0.7005887", "0.6990905", "0.6894926", "0.6787001", "0.6748078", "0.6645406", "0.6608981", "0.65921754", "0.6549621", ...
0.8271519
0
normalizes a given vector RETURNS A UNIT VECTOR
def norm_vect(vect): mag = (vect[0] ** 2 + vect[1] ** 2 + vect[2] ** 2) ** .5 return np.divide(vect, mag)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n normalized = [i * normalizer for i in v]\n return normalized", "def unit_vector(vector):\n #print 'unit_vector'\n #print vector\n #print type(vector)\n #npvector = np.array(vector)\n return vector / np.linalg.norm(vector)", "def un...
[ "0.8226037", "0.81699914", "0.8166605", "0.8166605", "0.8166605", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8137791", "0.8088808", "0.8080485", "0.8069073", "0.80654675", "0.8058697", ...
0.7224149
72
Returns Point a Point b
def vect_creator(point_a, point_b): vect = np.subtract(point_a, point_b) return vect
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point_add(self, a, b):\n\n if a.at_inf and b.at_inf: return point.inf()\n if a.at_inf: return b.dup()\n if b.at_inf: return a.dup()\n if a == b: return self.point_double(a)\n if a.x == b.x and a.y == -b.y: return point.inf()\n\n x1, y1, x2, y2 = modp(self.p, a.x, a.y, ...
[ "0.741782", "0.6969519", "0.6827688", "0.6773029", "0.67634207", "0.67617345", "0.6736863", "0.66990584", "0.6694711", "0.665635", "0.6636528", "0.66241735", "0.65940046", "0.6585437", "0.6523569", "0.65230745", "0.65128535", "0.65102386", "0.6506792", "0.65039843", "0.650398...
0.60581416
63
Finds the normal unit vector of a plane
def plane_equation(point_a, point_b, point_c): v1 = np.subtract(point_a, point_c) v2 = np.subtract(point_a, point_b) normal = np.cross(v1, v2) # print 'b4 norm', normal unit_normal = norm_vect(normal) # print 'unityyy', unit_normal return unit_normal
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_normal_vector_of_plane(p1, p2, p3):\n v12 = np.array(p1) - np.array(p2)\n v13 = np.array(p1) - np.array(p3)\n nvec = np.cross(v12, v13)\n ## print 'norm: '+str(np.linalg.norm(nvec))\n return nvec / np.linalg.norm(nvec)", "def normal(self) -> Vec:\n # The three points are in clock...
[ "0.77399087", "0.7669633", "0.74817395", "0.7437714", "0.7231757", "0.7206108", "0.72044635", "0.70723814", "0.7072374", "0.7072374", "0.7072374", "0.701597", "0.701597", "0.701597", "0.701597", "0.701597", "0.701597", "0.701597", "0.701597", "0.701597", "0.701597", "0.7015...
0.74306595
4
plots a plane given a normal vector and a point on the plane
def plot_plane(unit_normal, x_array, y_array, fore): # print'unit normal = ', unit_normal z = (((unit_normal[0] * (fore[0] - x_array)) + (unit_normal[1] * (fore[1] - y_array))) / unit_normal[2]) + fore[2] # print 'plane numbers\n', z return z
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_plot_plane_2d(axis=(1.0, 1.0), origin=(0.0,0.0), size=(2.0,2.0)):\n ft = ImageFont.truetype (FONT_RESOURCES_DIR+\"/courier.ttf\", 12)\n gl_font = GlFont('', ft)\n gl_font.color = [0.0, 0, 0, 1.0]\n gl_plot = PlotPlane2d(gl_font)\n gl_plot.i_axis = axis\n gl_plot.i_origin = origin\n ...
[ "0.65726674", "0.65083426", "0.6467405", "0.64498204", "0.6433219", "0.64003235", "0.6356803", "0.62633014", "0.6235757", "0.62135434", "0.61715204", "0.61489546", "0.61202085", "0.6106968", "0.6051524", "0.6032826", "0.5948895", "0.5939567", "0.5936206", "0.5910457", "0.5892...
0.7952929
0
Plots the static suspension front or rear
def suspension_plot(ax, full_car_dict, planes_choice, instant_center_choice, *keys): # -------------------------Stack 3d Points To Form Links----------------------------------- left = keys[0] right = keys[1] # Left left_lower_control_arm = np.stack((full_car_dict[left]['Lower Fore'], full_car_dict[l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show():\n setup()\n plt.show()", "def show():\n\tplt.show()", "def show():\n plt.show()", "def show():\n plt.show()", "def show():\n plt.show()", "def show(self):\n plt.show()", "def show(im,fig= None): #X\n im = im.copy()\n if len(im.shape)==1 or im.shape[1]==1:\n ...
[ "0.65639836", "0.6529013", "0.647966", "0.647966", "0.647966", "0.6238393", "0.6231375", "0.61223924", "0.6003835", "0.5999601", "0.5972391", "0.596409", "0.5900321", "0.58785236", "0.5846444", "0.5837019", "0.58282423", "0.5811291", "0.5787819", "0.5786803", "0.57805675", ...
0.5269006
92
Get empirical CDF from a weighted 1D sample
def get_ecdf( sample: np.ndarray, weights: Optional[np.ndarray] = None ) -> Tuple[np.ndarray, np.ndarray]: assert len(sample.shape) == 1, "Only 1D CDF is implemented" if weights is None: weights = np.ones_like(sample, dtype=sample.dtype) assert sample.shape == weights.shape ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cdf(weights):\r\n\treturn np.cumsum(weights) / sum(weights)", "def compute_cdf(ordered_weights):\n return numpy.cumsum(ordered_weights) - 0.5 * ordered_weights", "def cdf(self,x):\n return self.categoricalDist.cdf(x)", "def cdf(sample, location=0, scale=1):\n location = T.cast(location, theano.c...
[ "0.77753884", "0.6673068", "0.66728866", "0.65556353", "0.62679976", "0.62481284", "0.624177", "0.61951363", "0.61283237", "0.61253685", "0.61094093", "0.6099108", "0.6076243", "0.6064817", "0.60573864", "0.6017543", "0.60054207", "0.60054207", "0.59874034", "0.5937544", "0.5...
0.70031375
1
Returns the List of Questions for Auth User
def get(self,request,format=None): answers = SingleWordQuizAnswer.objects.filter(user=request.user.info) serializer = SingleWordQuizAnswerSerializer(answers,many=True) return Response(data=serializer.data,status=status.HTTP_200_OK)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self):\n loggedin_user = get_jwt_identity()\n user = get_user_by_username(user_name=loggedin_user[\"username\"], password=loggedin_user[\"password\"])\n qstn_owner = user[\"username\"]\n user_questions = get_all_user_questions(user_name=qstn_owner)\n if user_questions:\n ...
[ "0.7338821", "0.7181348", "0.7040394", "0.659352", "0.6573922", "0.6528633", "0.64609003", "0.6439575", "0.64166725", "0.6371958", "0.6325498", "0.63013244", "0.6283444", "0.6180859", "0.61421907", "0.6120981", "0.61099", "0.610688", "0.60971975", "0.60923624", "0.60856146", ...
0.62867707
12
Returns the List of Questions for Auth User
def get(self,request,format=None): answers = MultipleQuizAnswer.objects.filter(user=request.user.info) serializer = MultipleQuizAnswerSerializer(answers,many=True) return Response(data=serializer.data,status=status.HTTP_200_OK)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self):\n loggedin_user = get_jwt_identity()\n user = get_user_by_username(user_name=loggedin_user[\"username\"], password=loggedin_user[\"password\"])\n qstn_owner = user[\"username\"]\n user_questions = get_all_user_questions(user_name=qstn_owner)\n if user_questions:\n ...
[ "0.7338821", "0.7181348", "0.7040394", "0.659352", "0.6573922", "0.6528633", "0.64609003", "0.6439575", "0.64166725", "0.6371958", "0.6325498", "0.63013244", "0.62867707", "0.6283444", "0.6180859", "0.61421907", "0.61099", "0.610688", "0.60971975", "0.60923624", "0.60856146",...
0.6120981
16
If the input is a simple python list of observations, we transform it to numpy array type. If it is already a numpy array type, there will be no change.
def predict(self, data): length = len(data) """ We check if the size of the data is equal to the number of input neurons """ assert length == self.structure[0], 'ERROR: the length of the input list is not equal to the number of input neurons' data = np.reshape(data, (le...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_numpy(x):\n if isinstance(x, list):\n return [to_numpy(e) for e in x]\n elif isinstance(x, np.ndarray):\n return x\n elif isinstance(x, (pd.DataFrame, pd.Series)):\n return x.values\n elif get_backend() == 'pytorch':\n return x.detach().numpy()\n else:\n ret...
[ "0.7377716", "0.7114607", "0.7015742", "0.6992929", "0.6960427", "0.68950933", "0.68851334", "0.6788789", "0.6762338", "0.6708188", "0.66845524", "0.6670787", "0.66212666", "0.6594083", "0.6548536", "0.6544979", "0.6544658", "0.65354556", "0.65354556", "0.64788485", "0.641017...
0.0
-1
The below code initializes the weights based on the number of newurons in each respective layer
def weights_initializer(self): self.weights = [np.random.normal(0, 1 / np.sqrt(x), (x, y)) for x, y in list(zip(self.structure[1:], self.structure[:-1]))]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, layerNeurons, numberOfLayers, initialWeights = None, lowerBound = None, upperBound = None):\r\n \r\n # Ensure that there is at-least one input and one output layer in the network\r\n assert len(layerNeurons) > 1, \"At least one input layer and one output layer is...
[ "0.7812822", "0.76935613", "0.76303506", "0.76197976", "0.7554685", "0.7550582", "0.7542766", "0.7541005", "0.75255847", "0.7490823", "0.7479021", "0.74696004", "0.7457206", "0.74382657", "0.74027264", "0.7387109", "0.73726714", "0.73484653", "0.725473", "0.7245847", "0.72456...
0.6750553
96
The below code mutates the weights and biases in the brain. We go over all the transition in the brain, we remember the shape of the weight matrix for each transition, then we reshape the weights into a 1 dimensional array. We go over this 1 dimensional array and if a uniformly distributed random variable takes a value...
def mutate1(self, probability): for i in range(self.number_of_transitions): shape = np.shape(self.weights[i]) size = self.weights[i].size weights = self.weights[i].flatten() for j in range(len(weights)): if np.random.uniform(0, 1) < probability: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randomize(self):\n self.weights = np.random.rand(*self.weights.shape) - 0.5", "def mutate(weights,gen):\n mutated_weights = []\n for weight in weights:\n new_weight = np.random.normal(loc=weight, scale=0.5/(gen+1))\n if new_weight >= -1 and new_weight <= 1:\n mutated_wei...
[ "0.7121324", "0.68690926", "0.6864408", "0.6629897", "0.6607024", "0.65598345", "0.6545833", "0.65330493", "0.64942557", "0.6421874", "0.6418693", "0.64108884", "0.64108884", "0.6396933", "0.634268", "0.6342147", "0.62955153", "0.6280411", "0.62770486", "0.62644315", "0.62385...
0.69907403
1
Returns a list of available colors
def get_available_colors(self): # Get reportlab available colors colors = getAllNamedColors() # Remove bad colors colors.pop('white', None) colors.pop('black', None) # Returns only the colors values (without their names) colors = list(colors.values()) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getColors():\n return ['#8c99fc', '#cacefd', '#fff1d7', '#feda98', '#fda85a', '#fc6647']", "def getColors():\n colors = ['#d53e4f',\n '#fc8d59',\n '#fee08b',\n '#ffffbf',\n '#e6f598',\n '#99d594',\n '#3288bd',\n ]...
[ "0.8220294", "0.7917729", "0.77049005", "0.77049005", "0.76413804", "0.7490964", "0.743418", "0.7425", "0.73045015", "0.7164366", "0.71389514", "0.7106622", "0.70913506", "0.7045858", "0.6958721", "0.6900322", "0.6880106", "0.68654346", "0.6823051", "0.68126637", "0.6788121",...
0.8152713
1
Reverses a string by attaching the last character to a new string.
def reverse_string(n): k = "" for i in n: k = i + k return k
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse(s):\n\n rev = ''\n for ch in s:\n rev = ch + rev\n\n return rev", "def reverse(string):\n return string[::-1]", "def reverse(s):\n result = ''\n for i in xrange(len(s)-1, -1, -1):\n result += s[i]\n return result", "def reverse_string(s):\n s.reverse()", "d...
[ "0.79708683", "0.78860074", "0.78804606", "0.7869329", "0.78607017", "0.7815649", "0.7814877", "0.7804441", "0.778919", "0.777333", "0.7766762", "0.77285904", "0.77164996", "0.76951104", "0.76817226", "0.76758283", "0.7548874", "0.7433749", "0.74228126", "0.73908454", "0.7370...
0.65831196
64
Reversing a string by using `reversed` and `join`
def reversed_of_string(n): return ''.join(reversed(n))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_string(s):\n return \"\".join(reversed(list(s)))", "def reverse(s):\n result = ''\n for i in xrange(len(s)-1, -1, -1):\n result += s[i]\n return result", "def reverse_string(s):\n s.reverse()", "def reverse(s):\n\n rev = ''\n for ch in s:\n rev = ch + rev\n\n ...
[ "0.8551116", "0.80505514", "0.7946059", "0.7917613", "0.7874249", "0.78176576", "0.77860975", "0.77740824", "0.7744881", "0.75851667", "0.75804037", "0.75772727", "0.75748557", "0.756134", "0.75373423", "0.75206065", "0.7502419", "0.7497282", "0.74577296", "0.74225014", "0.74...
0.80295014
2
Reversing a string with the Python slice's function
def reverse_slice(n): return n[::-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_string_2(s):\n s[:] = s[::-1]", "def reverse(string):\n return string[::-1]", "def reverseString(string):\n return string[::-1]", "def reverse(s):\n return s[::-1]", "def reverse_string( str ):\n return str[::-1]", "def reverse_string(s):\n s.reverse()", "def reverseString(s...
[ "0.77767235", "0.77611154", "0.7663185", "0.7650213", "0.76155096", "0.75429255", "0.75274104", "0.7517033", "0.73999107", "0.7317258", "0.73080647", "0.7180572", "0.71556777", "0.7144047", "0.7044793", "0.7023994", "0.69817924", "0.69493043", "0.69227177", "0.68837625", "0.6...
0.7133455
14
Create the default template for test devices. Returns the created template ID.
def create_template(jwt: str) -> str: LOGGER.debug("Creating template...") args = { "url": "{0}/template".format(CONFIG['dojot']['url']), "headers": { "Content-Type": "application/json", "Authorization": "Bearer {0}".format(jwt), }, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_device_template(self):\n pass", "def create_device(jwt: str, template_id: str, label: str) -> str:\n LOGGER.debug(\"Creating template...\")\n\n args = {\n \"url\": \"{0}/device\".format(CONFIG['dojot']['url']),\n \"headers\": {\n \"Content...
[ "0.7089084", "0.6910906", "0.67117316", "0.6702307", "0.6666792", "0.66139627", "0.6485868", "0.64736146", "0.6419218", "0.6342329", "0.6174287", "0.6086853", "0.60828334", "0.60057974", "0.5966493", "0.59054005", "0.58356255", "0.5807076", "0.57979596", "0.57846993", "0.5737...
0.64858985
6
Generates a random sequence of DNA or RNA of a given length
def random_seq(length, nucleic_acid='DNA'): if nucleic_acid == 'DNA': alphabet = ('A','C','T','G') elif nucleic_acid == 'RNA': alphabet = ('A','C','U','G') so_far = '' for i in range(length): so_far += random.sample(alphabet, 1)[0] return so_far
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_random_sequence(length):\n sequence = ''\n for i in range(length):\n random_letter = format(random.randrange(9), 'x')\n sequence = '{}{}'.format(sequence, random_letter)\n return sequence", "def getRandomSequence(seqLength):\n nucleotides = (\"A\", \"C\", \"G\", \"T\")\n seq ...
[ "0.77703136", "0.75811446", "0.7319348", "0.7064686", "0.70456266", "0.6977995", "0.6954371", "0.6954297", "0.69364744", "0.6929101", "0.6927687", "0.6919305", "0.68775755", "0.68070567", "0.6805089", "0.6781951", "0.67719024", "0.67655754", "0.67591405", "0.67432123", "0.673...
0.8230043
0
return all products for this retailer for this API
def get_products(self): page = 1 out = [] while True: resp = self.get_session().Product.find(limit=10,page=page) if not len(resp): return yield resp page += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_products(self):\n\t\tpass", "def products(self):\n response = requests.get(self._url(self._PRODUCTS_PATH), headers=self._headers)\n return response.json()", "def get_all_products():\n data = order_obj.get_all_products()\n return data", "def list_products(self):\n return...
[ "0.8045648", "0.79895526", "0.76991254", "0.767355", "0.7583054", "0.75064933", "0.7392728", "0.7369783", "0.7350614", "0.7285786", "0.7271403", "0.7263289", "0.723435", "0.715939", "0.7134755", "0.71215415", "0.71132666", "0.7081856", "0.703363", "0.6999894", "0.6983051", ...
0.7351253
8
Calculate the color histogram of image (colors and their counts)
def histogram_image(image, method='rgb'): histogram = get_color_histogram(image) if method == 'hex': return {'#{:02X}{:02X}{:02X}'.format(*color): count for color, count in histogram.items()} else: return {'[{}, {}, {}]'.format(r, g, b): count for (r, g, b), c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_histogram(self, img_data):\n\n histogram = [0] * self.color_depth\n\n for w in range(img_data.shape[0]):\n for h in range(img_data.shape[1]):\n pixel = img_data[w][h]\n histogram[pixel] += 1\n\n return histogram", "def distict_color_count(img...
[ "0.7836429", "0.76806796", "0.76806796", "0.764672", "0.76331973", "0.760842", "0.7543625", "0.73545796", "0.7288626", "0.7254019", "0.7117666", "0.71135885", "0.70927024", "0.70810384", "0.70613134", "0.70077723", "0.6959427", "0.68844986", "0.687471", "0.68145305", "0.67927...
0.71548826
10
Return a palette of at most n_colors unique colors extracted after sampling histogram by sample_fraction.
def histogram_palette(histogram, n_colors=8, method='auto', sample_fraction=5, background_value=25, background_saturation=20): fraction = sample_fraction and sample_fraction / 100.0 sampled_histogram = sample_histogram(histogram, sample_fraction=fra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uniquecolors(n):\n hues = [360.0 / n * i for i in range(n)]\n hs = [math.floor(hue / 60) % 6 for hue in hues]\n fs = [hue / 60 - math.floor(hue / 60) for hue in hues]\n return [('rgb({}%, {}%, {}%)'.format(*tuple(a * 100 for a in rgbcolor(h, f)))) for h, f in zip(hs, fs)]", "def unique_colors_rgb...
[ "0.7159166", "0.69201875", "0.6617888", "0.6587972", "0.65695655", "0.6491672", "0.64589477", "0.6443654", "0.6192278", "0.6164119", "0.61593413", "0.61417735", "0.605269", "0.6008756", "0.594077", "0.5937621", "0.5832729", "0.5827697", "0.5823258", "0.5810641", "0.5801144", ...
0.7058821
1
Get the maximum width of the given column index.
def get_max_width(table, index): return max([len(str(row[index])) for row in table])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_width_col(table, col_idx):\n return max(len(row[col_idx]) for row in table)", "def get_column_width(self, index):\n return self.colwid[index]", "def max_col(self):\n return self.screen.getmaxyx()[1]", "def excel_max_col(self, sheet_name):\n return self.wb[sheet_name].max_c...
[ "0.82507503", "0.8111238", "0.6919115", "0.66512185", "0.66396725", "0.64200413", "0.6387219", "0.6361288", "0.63277537", "0.629417", "0.62761223", "0.61648864", "0.61180365", "0.60681355", "0.6040671", "0.5988129", "0.59870154", "0.5986662", "0.59815633", "0.5978618", "0.597...
0.79526037
2
Propagates the data through the network.
def forward_propagate(self, input_data, sample=False): if input_data.shape[1] != self.input_dim: raise Exception("Input dimensionality has to match dbn.input_dim!") self.states[0] = input_data for l in range(len(self._layers)): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_propagate(self):\n # Get network components\n data = array([[0], [1]])\n cdata = LabeledCData(data, labels=array([0, 1]))\n encoder = BinaryEncoding(cdata)\n unitary = ProductAnsatz(1)\n measure = Measurement(1, [0])\n qnn = Network([encoder, unitary, measu...
[ "0.68641394", "0.66963166", "0.6441051", "0.6359643", "0.63324183", "0.63101137", "0.63101137", "0.6257037", "0.6253874", "0.6247254", "0.6211242", "0.6176311", "0.6163471", "0.6163471", "0.6163471", "0.6140208", "0.6100872", "0.6097221", "0.6067948", "0.6050653", "0.6029381"...
0.0
-1
Converts instance of google.cloud.bigquery.table.Row to a JSON encoded string
def to_json_line(bq_row): row = dict() for key in bq_row: row[key] = bq_row[key] # default=str converts non JSON serializable objects to str eg datetime.datetime row_json = json.dumps(row, default=str) return row_json.encode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format(self, row):\n return json.dumps(row.print_fields)", "def row_to_json(row: sqlite3.Row) -> str:\n d = {}\n for key in row.keys():\n d[key] = row[key]\n\n return json.dumps(d)", "def __data_row_to_json(self, row):\n raw_data = {}\n raw_data[\"body\"] = row.body\n ...
[ "0.7785266", "0.76456165", "0.7388369", "0.683482", "0.6769471", "0.6328033", "0.62902254", "0.6218498", "0.6213668", "0.6138196", "0.6138088", "0.611975", "0.6118808", "0.60859877", "0.60803175", "0.6054449", "0.6024035", "0.6014852", "0.59622514", "0.5941998", "0.5900335", ...
0.7934797
0
Dumps an object to json in very compact form
def json_compact(obj) -> str: return json.dumps(obj, separators=(",", ":"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumps(obj):\n return json.dumps(obj, indent=4, sort_keys=True, cls=CustomEncoder)", "def json_dumps(self, obj: object) -> str:\n return json.dumps(obj, sort_keys=self.beautify, indent=4)", "def toJSON(object):\n\treturn json.dumps(object, ensure_ascii=False)", "def print_json(obj):\n print(j...
[ "0.7737683", "0.7522783", "0.74519473", "0.74086034", "0.7398938", "0.73686117", "0.73514694", "0.73185146", "0.729583", "0.72939223", "0.7252722", "0.7251775", "0.7247516", "0.7235917", "0.7160099", "0.7132713", "0.7124954", "0.71018946", "0.7086901", "0.7086901", "0.7086901...
0.71397513
15
A utility method that filters results based on ''Question'' models that are only ''Active''.
def active(self, **kwargs): group = False if kwargs.get('group'): group = kwargs['group'] if kwargs.get('slug'): slug = kwargs['slug'] return self.filter(status__exact=enums.STATUS_ACTIVE, slug__exact=slug) elif group: return self.exclude(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queryset(self):\n if current_user.is_authenticated:\n return Question.query.filter(User.rooms.any(User.id == current_user.id))\n if session.get(\"rooms\") is not None:\n return Question.query.filter(Room.id.in_(session.get(\"rooms\")))\n return Question.query.filter(s...
[ "0.65031886", "0.6330509", "0.61179566", "0.61179566", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.60576475", "0.6010787", ...
0.52683085
87
List available security configuration policy
def appsec_policy(config, waf_config_name, policy_name, name_contains): logger.info('Start Akamai CLI onboard') _, wrap_api = init_config(config) util = utility.utility() config_id, version, df = util.validate_waf_config_name(wrap_api, waf_config_name) if not waf_config_name: logger.warning(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_hyperflex_sys_config_policy_list(self):\n pass", "def list_policies(self):\n client = self.connect(VAULT_TOKEN)\n return client.list_policies()", "def test_get_hyperflex_ucsm_config_policy_list(self):\n pass", "def test_get_hyperflex_vcenter_config_policy_list(self):\...
[ "0.6887365", "0.6640611", "0.6593883", "0.6497711", "0.64777267", "0.64664215", "0.6361258", "0.63531184", "0.6352575", "0.6296842", "0.623093", "0.6181602", "0.6150301", "0.6129843", "0.6118077", "0.6118077", "0.6080167", "0.60639554", "0.60140646", "0.60126626", "0.5895451"...
0.0
-1
uuid of the network provider
def __init__(self): self.id = None """"true if individual services can be enabled/disabled""" self.canenableindividualservice = None """"the destination physical network""" self.destinationphysicalnetworkid = None """"the provider name""" self.name = None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provider_id(self):\n raise NotImplementedError", "def private_network_uuid(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"private_network_uuid\")", "def private_network_uuid(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"private_network_uuid\")", "def pri...
[ "0.69252914", "0.69152564", "0.68285495", "0.68285495", "0.6777245", "0.67448914", "0.6728686", "0.6728686", "0.67107946", "0.67107946", "0.67107946", "0.66786104", "0.66786104", "0.66786104", "0.6610773", "0.6610773", "0.66035175", "0.6602503", "0.65948594", "0.65948516", "0...
0.0
-1
Loads embeddings from a memory map directory to allow lazy loading (and reduce the memory usage).
def load_memory_map_dir(directory: str) -> Embeddings: meta_file = os.path.join(directory, "meta.json") mem_map_file = os.path.join(directory, "memory_map") with open(meta_file, "r") as f: meta = json.load(f) shape = tuple(meta['shape']) vocab = meta['vocab'] mem_map = np.memmap(mem_map_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_embeddings(path, vocab, source_domain, target_domain, emb_name):\n\n pkl = './work/embeddings/%s_%s_%s.pkl' % (source_domain, target_domain, emb_name)\n if os.path.exists(pkl):\n print(\"Load embeddings from existing pkl file %s...\" % pkl)\n # word embeddings weights have been loaded\...
[ "0.6826984", "0.67814565", "0.67749166", "0.6711091", "0.65536225", "0.65461594", "0.63857025", "0.6374055", "0.6310007", "0.6302064", "0.6223559", "0.61545897", "0.6153864", "0.61419713", "0.61397874", "0.6125278", "0.61017495", "0.6095603", "0.60675037", "0.6064279", "0.604...
0.783985
0
Return DataFrame with artist, album, and track data.
def get_artist_audio_features(q, interactive = False, genre_delimiter = '-!!-', to_file = '', client = None): query = client.search(q = q, type = "artist") items = query['artists']['items'] if not items: raise Exception("No artists found") if interactive: print("Select the artist to us...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_tracks_info_df(df):\n\n gen_df = df.copy()\n gen_df = gen_df[['artist_name', 'title', 'release', 'track_id', 'song_id']]\n\n for column_name in gen_df.columns:\n gen_df[column_name] = gen_df[column_name].map(lambda x: ast.literal_eval(x).decode('utf-8'))\n\n gen_df.rename(columns={'rel...
[ "0.73855996", "0.7296023", "0.70509386", "0.6883711", "0.6645396", "0.66240525", "0.6534886", "0.6492285", "0.64602077", "0.6419907", "0.6368293", "0.62970656", "0.6187233", "0.6171175", "0.6066169", "0.6057835", "0.6018025", "0.6007643", "0.5981228", "0.59622", "0.5916955", ...
0.0
-1
Mutates track with artist and album info at top level.
def _hoist_track_info(track): track['album_name'] = track['album']['name'] artist = track['artists'][0] track['artist_name'] = artist['name'] return track
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_nowplaying_metadata(self, track, album, artist):\n\n\t\tparts = [artist[:30], album[:30], track[:30]]\n\t\tself._send_message(\"MUSIC_CONTROL\", self._pack_message_data(16, parts))", "def set_nowplaying_metadata(self, track, album, artist):\n\n\t\tparts = [artist[:30], album[:30], track[:30]]\n\t\tself._...
[ "0.7148686", "0.7148686", "0.6659982", "0.6493693", "0.63027", "0.6112815", "0.6101719", "0.6063078", "0.6058862", "0.6042309", "0.60266507", "0.601729", "0.59120744", "0.58931917", "0.58761543", "0.58679426", "0.58659995", "0.5863555", "0.58527327", "0.5852409", "0.5826257",...
0.7093144
2
Insert an item in the requested position in line.
def insert(self, index, item, **data): self._items.insert(index, item) if data: self._data[item] = data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(self, line, where=0):\n self.buffer.insert(where, line)", "def insert(self, index: int, item: Any) -> None:\n self.contents.insert(index, item)\n return", "def insert(self, element):\n self.line.append(element)", "def insert(self, item: T, index: int) -> None:\n ...
[ "0.78842634", "0.7312104", "0.7302066", "0.7137516", "0.71027565", "0.7088087", "0.7046474", "0.6960423", "0.6903925", "0.689829", "0.68323565", "0.6830593", "0.67799056", "0.67581624", "0.6662531", "0.66269743", "0.66250753", "0.66109544", "0.6598826", "0.6594711", "0.658753...
0.7031924
7
Uniform sample on unit sphere.unit Uses Muller method.
def on_sphere(): vec = np.random.standard_normal(3) return vec / np.linalg.norm(vec)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_from_unit_ball(rng, dim):\n vec = rng.randn(dim)\n return vec / np.sqrt(np.sum(vec**2))", "def random_vector_in_unit_ball():\n x = np.random.normal(loc=0.0, scale=1.0, size=(numSamples, self.dim))\n z = np.random.exponential(scale=1.0, size=(numSamples,))\n d = (np.s...
[ "0.729564", "0.67688584", "0.66636777", "0.6361928", "0.6339075", "0.6338932", "0.629839", "0.62432885", "0.6116671", "0.6092011", "0.6090756", "0.6081154", "0.6070129", "0.6000689", "0.59811306", "0.5970813", "0.5948987", "0.59311444", "0.5922267", "0.5922061", "0.5921167", ...
0.6510901
3
Get the minimum and maximum point from the array of points
def get_boundary_corners_2D(points): padding=0.05 if points.shape[0] == 3: assert (len(points.shape)==2) minPt_3d_x = np.amin(points[0,:]) maxPt_3d_x = np.amax(points[0,:]) minPt_3d_y = np.amin(points[1,:]) maxPt_3d_y = np.amax(points[1,:]) boudary = [minPt_3d_x-padding, maxPt_3d_x+padding, minP...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _random2min_max(points):\n x_max = max([x for x, y in points])\n x_min = min([x for x, y in points])\n y_max = max([y for x, y in points])\n y_min = min([y for x, y in points])\n return np.array([x_min, y_min, x_max, y_max])", "def maxmin(x):\n point_list = x[0]\n lons = [f for [f,s] in ...
[ "0.78453314", "0.7571098", "0.7102674", "0.70515424", "0.7024737", "0.6961069", "0.69545823", "0.69506407", "0.67135644", "0.6705046", "0.668358", "0.667309", "0.6659474", "0.662355", "0.6564933", "0.65531707", "0.65502274", "0.652726", "0.6514044", "0.6509946", "0.64925545",...
0.0
-1
Creates a URL (containing only the querystring [including "?"]) derived from the current URL's querystring, by updating it with the provided keyword arguments.
def add_querystring(context, **kwargs): updated = context['request'].GET.copy() # have to iterate over and not use .update as it's a QueryDict not a dict for k, v in kwargs.items(): updated[k] = v return '?{}'.format(updated.urlencode()) if updated else ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url_with_querystring(url, **kwargs):\n return url + '?' + urlencode(kwargs)", "def append_query_params(original_url, **kwargs):\n scheme, netloc, path, query_string, fragment = urlsplit(original_url)\n query_params = parse_qs(query_string)\n if kwargs is not None:\n for key, value in kwarg...
[ "0.71257776", "0.7096542", "0.7096542", "0.6911867", "0.6741147", "0.6690303", "0.66799045", "0.6545899", "0.6545899", "0.6519924", "0.64958197", "0.64822185", "0.64051634", "0.63512623", "0.6323477", "0.62888473", "0.6253023", "0.6248688", "0.6226326", "0.6224532", "0.622095...
0.66046584
7
Parse the input XML file and store the result in a pandas DataFrame with the given columns. The first element of df_cols is supposed to be the identifier variable, which is an attribute of each node element in the XML data; other features will be parsed from the text content of each subelement.
def parse_XML(xml_file, df_cols): xtree = et.parse(xml_file) xroot = xtree.getroot() rows = [] for node in xroot: res = [] #res.append(node.attrib.get(df_cols[0])) for el in df_cols: if node is not None and node.find(el) is not None: res.ap...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_xml(filename, columns, path_to_listings):\n \n tree = etree.parse(filename)\n root = tree.getroot()\n rows = get_rows(root.xpath(path_to_listings), columns)\n\n return pd.DataFrame(rows,columns=[col['name'] for col in columns])", "def load_xml(self,filename):\n self.initvars()\n...
[ "0.68699", "0.590695", "0.58222234", "0.5710685", "0.5634154", "0.54677343", "0.53373206", "0.5306806", "0.518718", "0.5177976", "0.51280653", "0.5077313", "0.50754356", "0.50503814", "0.503817", "0.49750164", "0.49642408", "0.4943877", "0.4939388", "0.49062857", "0.4901088",...
0.8436309
0
Returns the list of all State objects
def list_all_states(): if request.method == 'POST': new_state_name = None try: res_dict = request.get_json() new_state_name = res_dict.get('name') except: abort(400, description='Not a JSON') if new_state_name is None: abort(400, descr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_states(self):\n return self._states", "def get_list_of_states(self):\n return self.states", "def all_states(self):\n return self._states", "def state_list(self) -> Sequence[TState]:\n pass", "def all_states():\n dict = storage.all(State)\n list = []\n for st...
[ "0.8359784", "0.83062667", "0.8192103", "0.81201696", "0.81062526", "0.80257535", "0.79129446", "0.7835829", "0.7702118", "0.7631662", "0.7560284", "0.7558888", "0.75285685", "0.74739134", "0.7463121", "0.7444379", "0.73769706", "0.73444057", "0.7324362", "0.7291024", "0.7286...
0.6737661
46
Returns all chars till a nonescaped } is found. Other non escaped { are taken into account and skipped over. Will also consume the closing }, but not return it
def _parse_till_closing_brace(stream): rv = "" in_braces = 1 while True: if EscapeCharToken.starts_here(stream, '{}'): rv += stream.next() + stream.next() else: c = stream.next() if c == '{': in_braces += 1 elif c == '}': in_braces -= 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_till_unescaped_char(stream, chars):\n rv = \"\"\n while True:\n escaped = False\n for c in chars:\n if EscapeCharToken.starts_here(stream, c):\n rv += stream.next() + stream.next()\n escaped = True\n if not escaped:\n c = str...
[ "0.6250915", "0.58294165", "0.5747967", "0.5711438", "0.568947", "0.5593052", "0.539932", "0.5382931", "0.53242207", "0.529679", "0.50949246", "0.50841594", "0.50191087", "0.50059247", "0.49963653", "0.49935997", "0.49297944", "0.49192727", "0.48985416", "0.48917583", "0.4851...
0.7019249
0
Tests that update_author_posts_comments calls update_field_values_by_query with the right parameters
def test_update_author_posts_comments(mocker, mock_es_profile_serializer, user): patched_task = mocker.patch("search.indexing_api.update_field_values_by_query") call_data = { key: val for key, val in es_profile_serializer_data.items() if key in {"author_name", "author_avatar_small", "aut...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_post_removal_for_comments(mocker, reddit_submission_obj):\n patched_task = mocker.patch(\n \"search.search_index_helpers.update_field_values_by_query\"\n )\n field_name, field_value = (\"field1\", \"value1\")\n update_field_for_all_post_comments(\n reddit_submission_obj, f...
[ "0.6929632", "0.596866", "0.59334606", "0.58721405", "0.57905614", "0.5770552", "0.57620466", "0.57104015", "0.56983256", "0.56068945", "0.5597352", "0.559168", "0.558022", "0.5507707", "0.5504611", "0.5497125", "0.5429094", "0.5416346", "0.5404739", "0.53867286", "0.5376264"...
0.8000518
0
Chop up a list of level n (length 4^n) to 4^(n1) sublists with 4 items
def chop_up_to_4s(list, n): sublists = [] num_sublists = 4**(n-1) for i in range(num_sublists): sublists.append(list[4*i: 4*i + 4]) return sublists
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permute4(values: List) -> List:\n o = []\n ld4 = len(values) // 4\n for i in range(ld4):\n o.extend(\n [values[i], values[i + ld4], values[i + ld4 * 2], values[i + ld4 * 3]])\n return o", "def permute(l):\n\n if len(l) <= 1:\n return [l]\n\n elif len(l) == 2:\n return [l, l[...
[ "0.64946455", "0.6405767", "0.6278779", "0.62585443", "0.62538177", "0.62534714", "0.62078404", "0.6191465", "0.6153848", "0.61282927", "0.6108554", "0.6070361", "0.60585284", "0.60438275", "0.60240227", "0.5937477", "0.59264785", "0.5883009", "0.5879559", "0.58387184", "0.58...
0.8530873
0
This method computes the distance lof latitudes and longitudes of two GPS coordinates in decimeters to return the contagius probability of the colocation represented by (lat1,lon1) and (lat2,lon2).
def probaContagius(lat1,lon1,lat2,lon2,M): GAMMA = 0.02 dlon = abs(lon2 - lon1) * 10000 dlat = abs(lat2 - lat1) * 10000 distance_Y = int(round(dlon, 0)) distance_X = int(round(dlat, 0)) proba = 0 if ( (distance_X>=0 and distance_X<300) and (distance_Y>=0 and distance_Y<300) ): proba ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dist_vincenty(lat1, lon1, lat2, lon2, iterations=20):\r\n if lat1 < -90 or lat1 > 90 or lat2 < -90 or lat2 > 90 or lon1 < -180 or lon1 > 180 or lon2 < -180 or lon2 > 180:\r\n raise ValueError(\r\n \"Latitude values shoulds range from (-90,90) and longitude from (-180,180) but one of the in...
[ "0.7279316", "0.72729856", "0.71103024", "0.70295435", "0.7023867", "0.70048046", "0.69444233", "0.6919719", "0.68975955", "0.6814633", "0.6801774", "0.6796018", "0.672447", "0.66860074", "0.6676038", "0.6667263", "0.66492856", "0.664693", "0.6637518", "0.6633473", "0.6618001...
0.66832596
14
Make random string from lowercase letter, uppercase letter and digits
def make_random_string( self, length: int = 8 ) -> str: return ''.join(choice(self.lowercase + self.uppercase + self.digits) for _ in range(length))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_random_alphanumeric_string():\n return get_random_string(char_choice=string.ascii_letters + string.digits)", "def random_string(length=1, uppercase=False, lowercase=False):\n characters = digits\n code = str()\n\n if uppercase:\n characters += ascii_uppercase\n if lowercase:\n ...
[ "0.8008689", "0.78119236", "0.7775539", "0.7541196", "0.75225407", "0.751025", "0.7495513", "0.74817675", "0.7481358", "0.7468065", "0.74486744", "0.74438804", "0.74309736", "0.74208", "0.74181294", "0.74159825", "0.74141854", "0.73925066", "0.7377188", "0.7364145", "0.732566...
0.7066012
41
Test that endpoint returns 200 to retrieve an existent campaign by id
def test_get_campaign_by_id_passes(self): response = self.client.get(f"{self.endpoint_url}{self.test_campaign.id}/") response_body = response.get_json() self.assertEqual(response.status_code, 200) self.assertEqual(response_body, {"id": CAMPAIGN_ID, "name": CAMPAIGN_NAME})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_non_existent_campaign_by_id_fails(self):\n response = self.client.get(f\"{self.endpoint_url}99/\")\n response_body = response.get_json()\n error_details = response_body[\"error\"]\n self.assertEqual(response.status_code, 404)\n self.assertEqual(error_details[\"messag...
[ "0.79387337", "0.7656781", "0.72351617", "0.7138563", "0.7050303", "0.6957356", "0.67599565", "0.67582405", "0.6669701", "0.66489273", "0.660551", "0.6589384", "0.6535411", "0.6513889", "0.6491505", "0.64241004", "0.64087886", "0.6393694", "0.6365254", "0.6364168", "0.6361835...
0.86482996
0
Test that endpoint returns 404 to retrieve a nonexistent campaign by id
def test_get_non_existent_campaign_by_id_fails(self): response = self.client.get(f"{self.endpoint_url}99/") response_body = response.get_json() error_details = response_body["error"] self.assertEqual(response.status_code, 404) self.assertEqual(error_details["message"], CAMPAIGN_N...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_campaign_by_id_passes(self):\n response = self.client.get(f\"{self.endpoint_url}{self.test_campaign.id}/\")\n response_body = response.get_json()\n self.assertEqual(response.status_code, 200)\n self.assertEqual(response_body, {\"id\": CAMPAIGN_ID, \"name\": CAMPAIGN_NAME})"...
[ "0.79862225", "0.7770832", "0.7569785", "0.747294", "0.72638595", "0.7096757", "0.6904741", "0.6897897", "0.686764", "0.68627083", "0.680434", "0.6735292", "0.6730329", "0.6714595", "0.66978174", "0.6692594", "0.66698354", "0.6660586", "0.6655855", "0.6649207", "0.6642563", ...
0.8927358
0
Test that enpoint returns 200 to update an existent campaign by admin
def test_update_existent_campaign_by_admin_passes(self): response = self.client.patch( f"{self.endpoint_url}{self.test_campaign.id}/", json={ "logo": None, "name": NEW_CAMPAIGN_NAME, "organisations": [], "url": None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_non_existent_campaign_by_id_fails(self):\n response = self.client.patch(\n f\"{self.endpoint_url}99/\",\n json={\n \"logo\": None,\n \"name\": NEW_CAMPAIGN_NAME,\n \"organisations\": [],\n \"url\": None,\n ...
[ "0.72859365", "0.7226406", "0.70596355", "0.7052297", "0.70482343", "0.67557484", "0.6701698", "0.66396433", "0.6485177", "0.6417338", "0.639237", "0.63541967", "0.6337371", "0.6260363", "0.6254718", "0.6252448", "0.6232217", "0.62255967", "0.62044984", "0.6199698", "0.619681...
0.8017433
0
Test that endpoint returns 403 to update an existent campaign by a non_admin
def test_update_existent_campaign_by_non_admin_fails(self): response = self.client.patch( f"{self.endpoint_url}{self.test_campaign.id}/", json={ "logo": None, "name": NEW_CAMPAIGN_NAME, "organisations": [self.test_org.id], "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_existent_campaign_by_admin_passes(self):\n response = self.client.patch(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n json={\n \"logo\": None,\n \"name\": NEW_CAMPAIGN_NAME,\n \"organisations\": [],\n ...
[ "0.7764879", "0.7742583", "0.7312997", "0.7218098", "0.7084599", "0.6841752", "0.6822194", "0.68097866", "0.6683955", "0.6683955", "0.6668582", "0.6656737", "0.66486746", "0.66368127", "0.6614663", "0.65768945", "0.6576404", "0.6533789", "0.6532356", "0.6532356", "0.6532356",...
0.83779484
0
Test that endpoint returns 401 to update a campaign by an unauthenticated user
def test_update_existent_campaign_by_unauthenticated_user_fails(self): response = self.client.patch( f"{self.endpoint_url}{self.test_campaign.id}/", json={ "logo": None, "name": NEW_CAMPAIGN_NAME, "organisations": [self.test_org.id], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_campaign_by_unauthenticated_user_fails(self):\n response = self.client.delete(f\"{self.endpoint_url}{self.test_campaign.id}/\")\n self.assertEqual(response.status_code, 401)", "def test_update_existent_campaign_by_non_admin_fails(self):\n response = self.client.patch(\n ...
[ "0.746231", "0.7405055", "0.7184852", "0.6946452", "0.6898385", "0.6845872", "0.6830202", "0.68240243", "0.6819922", "0.6808537", "0.67683476", "0.6756591", "0.67228556", "0.6700539", "0.66882074", "0.6621921", "0.6609377", "0.6596191", "0.6582913", "0.6556822", "0.65567786",...
0.840172
0
Test that endpoint returns 400 to update a campaign using invalid keys/data
def test_update_campaign_using_invalid_request_keys_fails(self): response = self.client.patch( f"{self.endpoint_url}{self.test_campaign.id}/", json={ "logo": None, "campaign_name": NEW_CAMPAIGN_NAME, "organisations": [self.test_org.id], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_non_existent_campaign_by_id_fails(self):\n response = self.client.patch(\n f\"{self.endpoint_url}99/\",\n json={\n \"logo\": None,\n \"name\": NEW_CAMPAIGN_NAME,\n \"organisations\": [],\n \"url\": None,\n ...
[ "0.77003133", "0.75376886", "0.74078184", "0.73666924", "0.71961004", "0.71726424", "0.6950805", "0.68813014", "0.68767375", "0.6868816", "0.6849397", "0.6793891", "0.6772106", "0.67709476", "0.66953164", "0.66649246", "0.66298944", "0.65878797", "0.6576047", "0.65646636", "0...
0.88247275
0
Test that endpoint returns 404 to update a nonexistent campaign
def test_update_non_existent_campaign_by_id_fails(self): response = self.client.patch( f"{self.endpoint_url}99/", json={ "logo": None, "name": NEW_CAMPAIGN_NAME, "organisations": [], "url": None, }, h...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_existent_campaign_by_unauthenticated_user_fails(self):\n response = self.client.patch(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n json={\n \"logo\": None,\n \"name\": NEW_CAMPAIGN_NAME,\n \"organisations\": [self.t...
[ "0.7992819", "0.7917667", "0.7849319", "0.76256526", "0.76154625", "0.73876125", "0.6998243", "0.68609", "0.6833241", "0.663463", "0.6592568", "0.65001893", "0.64547414", "0.6418407", "0.6412864", "0.63933057", "0.63859636", "0.63509965", "0.6334499", "0.63320655", "0.6329521...
0.8409422
0
Test that endpoint returns 403 for deletion of campaign by nonadmin
def test_delete_campaign_by_non_admin_fails(self): response = self.client.delete( f"{self.endpoint_url}{self.test_campaign.id}/", headers={"Authorization": self.non_admin_token}, ) response_body = response.get_json() self.assertEqual(response.status_code, 403) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_campaign_by_admin_passes(self):\n response = self.client.delete(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n headers={\"Authorization\": self.admin_token},\n )\n response_body = response.get_json()\n self.assertEqual(response.status_code, ...
[ "0.7930471", "0.76928866", "0.74763006", "0.72566366", "0.7207169", "0.71943295", "0.7139239", "0.70871496", "0.70595527", "0.7003732", "0.69855046", "0.6887569", "0.6883396", "0.6883396", "0.6883396", "0.6883396", "0.68717414", "0.6813316", "0.68105435", "0.67953223", "0.678...
0.8392894
0
Test that endpoint returns 401 for deletion of campaign by unauthenticated user
def test_delete_campaign_by_unauthenticated_user_fails(self): response = self.client.delete(f"{self.endpoint_url}{self.test_campaign.id}/") self.assertEqual(response.status_code, 401)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_campaign_by_admin_passes(self):\n response = self.client.delete(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n headers={\"Authorization\": self.admin_token},\n )\n response_body = response.get_json()\n self.assertEqual(response.status_code, ...
[ "0.7739274", "0.7735631", "0.7543431", "0.74322635", "0.7419826", "0.7219091", "0.7214939", "0.71800596", "0.71661407", "0.7054762", "0.7002759", "0.69437146", "0.694235", "0.69412", "0.6939283", "0.6921958", "0.69148886", "0.69083035", "0.6884176", "0.68815", "0.6821617", ...
0.88400143
0
Test that endpoint returns 404 for deletion of nonexistent campaign
def test_delete_non_existent_campaign_fails(self): response = self.client.delete( f"{self.endpoint_url}99/", headers={"Authorization": self.admin_token} ) response_body = response.get_json() error_details = response_body["error"] self.assertEqual(response.status_code,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_campaign_by_unauthenticated_user_fails(self):\n response = self.client.delete(f\"{self.endpoint_url}{self.test_campaign.id}/\")\n self.assertEqual(response.status_code, 401)", "def test_delete_campaign_by_admin_passes(self):\n response = self.client.delete(\n f\"{s...
[ "0.7529435", "0.74790096", "0.7442258", "0.7440079", "0.7282299", "0.7222002", "0.7155004", "0.7105838", "0.6930263", "0.6849414", "0.6846241", "0.6808129", "0.67872965", "0.6747343", "0.67254066", "0.66918474", "0.66761464", "0.667322", "0.6649135", "0.6624386", "0.65996903"...
0.8682521
0
Test that endpoint returns empty list if there are no campaigns
def test_get_non_existent_campaigns_returns_empty_list(self): response = self.client.get(self.endpoint_url) response_body = response.get_json() self.assertEqual(response.status_code, 200) self.assertEqual(response_body, {"campaigns": []})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_existent_campaigns_returns_campaigns_list(self):\n test_campaign = return_canned_campaign()\n test_campaign.create()\n response = self.client.get(self.endpoint_url)\n response_body = response.get_json()\n self.assertEqual(response.status_code, 200)\n self.asse...
[ "0.8238536", "0.7091674", "0.6653467", "0.65996057", "0.65763676", "0.65077597", "0.64960444", "0.6449043", "0.6415917", "0.641432", "0.6378035", "0.6372244", "0.63444835", "0.63199174", "0.6302004", "0.6270445", "0.625399", "0.6196928", "0.6127678", "0.607269", "0.6066673", ...
0.90419984
0
Test that endpoint returns 201 for successful creation of a new campaign
def test_create_new_campaign_by_admin_passes(self): response = self.client.post( self.endpoint_url, json={ "logo": None, "name": NEW_CAMPAIGN_NAME, "organisations": [self.test_org.id], "url": None, }, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_success(self, acme_id, response_headers, args, request_params):\n\n # Setup the mocked response\n responses.add(responses.POST, self.api_url, headers=response_headers,\n match=[responses.json_params_matcher(request_params)],\n status=201)\n\n ...
[ "0.7326313", "0.72506005", "0.7233565", "0.7196815", "0.71685386", "0.7080897", "0.7010996", "0.6873335", "0.6826285", "0.6755084", "0.67318976", "0.67244476", "0.6719058", "0.66885614", "0.66883576", "0.66788745", "0.66405934", "0.66113925", "0.6565267", "0.65392894", "0.653...
0.78945535
0
Test that endpoint returns 403 creation of a campaign by nonadmin
def test_create_new_campaign_by_non_admin_fails(self): non_admin = create_canned_user() non_admin_token = generate_encoded_token(non_admin.id) response = self.client.post( self.endpoint_url, json={ "logo": None, "name": CAMPAIGN_NAME, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_campaign_by_non_admin_fails(self):\n response = self.client.delete(\n f\"{self.endpoint_url}{self.test_campaign.id}/\",\n headers={\"Authorization\": self.non_admin_token},\n )\n response_body = response.get_json()\n self.assertEqual(response.status...
[ "0.75994253", "0.7424692", "0.73501694", "0.72087175", "0.71643704", "0.71199083", "0.7083378", "0.70680904", "0.70680904", "0.70680904", "0.70680904", "0.69741863", "0.6972026", "0.68376905", "0.68229663", "0.68065006", "0.6803991", "0.6795885", "0.6723573", "0.670129", "0.6...
0.81331587
0
Test that endpoint returns 401 creation of a campaign by unauthenticated user
def test_create_new_campaign_by_unauthenticated_user_fails(self): response = self.client.post( self.endpoint_url, json={ "logo": None, "name": CAMPAIGN_NAME, "organisations": [self.test_org.id], "url": None, }, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_campaign_by_unauthenticated_user_fails(self):\n response = self.client.delete(f\"{self.endpoint_url}{self.test_campaign.id}/\")\n self.assertEqual(response.status_code, 401)", "def test_update_existent_campaign_by_unauthenticated_user_fails(self):\n response = self.client.pat...
[ "0.7795392", "0.7552156", "0.7342111", "0.7315034", "0.7007749", "0.69437265", "0.6921539", "0.6915407", "0.68840295", "0.6855513", "0.6821829", "0.6809722", "0.679098", "0.6782062", "0.6782062", "0.6761736", "0.67564917", "0.675216", "0.6746047", "0.6745087", "0.6741512", ...
0.83854777
0
Test that endpoint returns 409 for creation of already existing campaign
def test_create_already_existing_campaign_fails(self): test_campaign = return_canned_campaign() self.test_org.campaign = [test_campaign] test_campaign.save() response = self.client.post( self.endpoint_url, json={ "logo": test_campaign.logo, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_non_existent_campaign_by_id_fails(self):\n response = self.client.patch(\n f\"{self.endpoint_url}99/\",\n json={\n \"logo\": None,\n \"name\": NEW_CAMPAIGN_NAME,\n \"organisations\": [],\n \"url\": None,\n ...
[ "0.74548936", "0.74228567", "0.73339623", "0.72460294", "0.7126231", "0.7021713", "0.70214033", "0.70125043", "0.6996458", "0.6900586", "0.6851231", "0.68318146", "0.6802583", "0.6746609", "0.6693663", "0.6636079", "0.6630937", "0.65868443", "0.64876413", "0.64863646", "0.647...
0.84497815
0
Convert a value in Hertz to Mels
def hz2mel(hz): return 2595 * np.log10(1+hz/700.)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mel_to_hertz(self, mel):\n # return 700.0 * (10**(mel / 2595.0)) - 700.0\n return 250.0 * (9**(mel / 3340.0)) - 250.0", "def hertz_to_mel(self, freq):\n return 3340.0 * log(1 + (freq / 250.0), 9)", "def hertz_to_mel(freq: float, mel_scale: str = \"htk\") -> float:\n\n if mel_scale n...
[ "0.6562281", "0.64037156", "0.6180278", "0.61466455", "0.61109316", "0.602301", "0.6009003", "0.600111", "0.59200937", "0.58808076", "0.58377075", "0.5740704", "0.5724527", "0.5709943", "0.5707225", "0.5699766", "0.56717217", "0.5622939", "0.5597856", "0.55874133", "0.5579861...
0.53013974
38
Convert a value in Mels to Hertz
def mel2hz(mel): return 700*(10**(mel/2595.0)-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mel_to_hertz(self, mel):\n # return 700.0 * (10**(mel / 2595.0)) - 700.0\n return 250.0 * (9**(mel / 3340.0)) - 250.0", "def torch_mel_to_hertz(frequencies_mel):\r\n # return _MEL_BREAK_FREQUENCY_HERTZ * (\r\n # tf.math.exp(frequencies_mel / _MEL_HIGH_FREQUENCY_Q) - 1.)\r\n ret...
[ "0.70506203", "0.623059", "0.6167129", "0.6112413", "0.60073316", "0.5894534", "0.5847603", "0.5803304", "0.57038623", "0.57026047", "0.5696639", "0.5662661", "0.56594324", "0.56498003", "0.5649764", "0.56444424", "0.56267905", "0.56040764", "0.55701286", "0.5518103", "0.5517...
0.0
-1
Delete all files in the run dir not explicitly kept.
def removeNonKeepFiles(self): if not self.deleteNonKeepFiles: self.logger.info('Deletion of non keep files (to save space) has not been requested.') return self.logger.info('Deletion of non-keep files is requested. Scanning...') toDelete = [] for root, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clearRunDirectory(self):\n for root, dirs, files in os.walk(self.run_dir, topdown=False):\n for name in files:\n if name.lower().endswith(('.cps', '.txt', '.sbml', '.csv')):\n os.remove(os.path.join(root, name))\n for name in dirs:\n ...
[ "0.7942389", "0.79151165", "0.7616193", "0.75483", "0.75255996", "0.750995", "0.7460959", "0.74301267", "0.7388324", "0.7334961", "0.7322656", "0.73173505", "0.73088837", "0.7297228", "0.7272341", "0.7267702", "0.7256353", "0.72134346", "0.72077125", "0.7182519", "0.7180802",...
0.7235095
17
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes.
def AddHeader(r): r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" r.headers["Pragma"] = "no-cache" r.headers["Expires"] = "0" r.headers['Cache-Control'] = 'public, max-age=0' return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response", "def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m...
[ "0.82238126", "0.82229567", "0.82229567", "0.82229567", "0.82229567", "0.81962067", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736", "0.8163736...
0.6962547
71
Sets the occurred_at of this ActivityLogEntry.
def occurred_at(self, occurred_at): self._occurred_at = occurred_at
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def observed_at(self, observed_at):\n\n self._observed_at = observed_at", "def created_at(self, created_at):\n\n self._created_at = created_at", "def created_at(self, created_at):\n\n self._created_at = created_at", "def created_at(self, created_at):\n\n self._created_at = created...
[ "0.61523443", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56549", "0.56249046", "0.55959594", "0.55285245", "0.5371318", "0.5343059", "...
0.79084903
0
Sets the category of this ActivityLogEntry.
def category(self, category): allowed_values = ["Trace", "Verbose", "Info", "Wait", "Highlight", "Gap", "Alert", "Warning", "Error", "Fatal", "Planned", "Updated", "Finished", "Abandoned"] # noqa: E501 if category not in allowed_values: raise ValueError( "Invalid value for `...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_category(self, category):\n\n\t\tif category is not None and not isinstance(category, str):\n\t\t\traise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: category EXPECTED TYPE: str', None, None)\n\t\t\n\t\tself.__category = category\n\t\tself.__key_modified['category'] = 1", "def category(self, category: s...
[ "0.7642309", "0.74504656", "0.7319519", "0.7319519", "0.7319519", "0.7319519", "0.7319519", "0.7092356", "0.7004229", "0.6967852", "0.6655953", "0.66009134", "0.653097", "0.64533794", "0.6287445", "0.61377895", "0.6132529", "0.6077546", "0.58836603", "0.58362156", "0.5736947"...
0.73802495
2
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, ActivityLogEntry): return False return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively.
def render(self, name, value, attrs=None, renderer=None): html = "" html += "%s" % value html += '<input type="hidden" name="%s" value="%s">' % (escape(name), escape(value)) return mark_safe(html)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(self, value):\r\n return value", "def render(self, value, context=None):\n if self.raw_html is not None:\n return format_html(self.raw_html)\n else:\n return ''", "def value_as_html(self):\n property_name = \"_%s_as_html\" % self.attribute.type\n ...
[ "0.7228298", "0.71553177", "0.6852488", "0.6496512", "0.6461218", "0.64505625", "0.63727593", "0.63704574", "0.63286406", "0.63286406", "0.62907326", "0.61872095", "0.61872095", "0.61736727", "0.6173238", "0.6139459", "0.6117022", "0.6071683", "0.60670286", "0.6064211", "0.60...
0.57990104
43
Sets the password of this PortainerLDAPSettings.
def password(self, password): self._password = password
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_password(self, password):\n self.PASS = password", "def set_password(self, password):\n self.password = password", "def set_password(self, password):\n self.PASSWORD = password", "def password(self, password):\n self._password = password\n return self", "def set_p...
[ "0.76276875", "0.7538999", "0.74898046", "0.74545574", "0.7389635", "0.72963125", "0.7235245", "0.71513766", "0.71265405", "0.7102492", "0.7046511", "0.70372564", "0.69899124", "0.69473714", "0.6921138", "0.69051456", "0.68861514", "0.68677115", "0.68578404", "0.6846932", "0....
0.7310181
5
Sets the start_tls of this PortainerLDAPSettings.
def start_tls(self, start_tls): self._start_tls = start_tls
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def starttls(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"starttls\")", "def starttls(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"starttls\")", "def starttls(self) -> pulumi.Output[bool]:\n return pulumi.get(self, \"starttls\")", "def setTlsOp...
[ "0.6176375", "0.6176375", "0.59787226", "0.518653", "0.515646", "0.51369727", "0.50366986", "0.50366986", "0.50092655", "0.49887902", "0.49547777", "0.49264896", "0.48441023", "0.4817266", "0.47957292", "0.47957292", "0.47957292", "0.47957292", "0.47813776", "0.47434035", "0....
0.7728805
0
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, PortainerLDAPSettings): return False return self.to_dict() == other.to_dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): if not isinstance(other, PortainerLDAPSettings): return True return self.to_dict() != other.to_dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748", "0.8042487", "0.8042487", "0.8042487", "0.8042487", "0.8042487", "0.8042487", "0.8042487", ...
0.0
-1
Dot product of two vectors,represented as dicts
def dot(a,b): acc = 0 for k in b.keys(): acc += a[k] * b[k] return acc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dot_product(v1,v2):\n #sets default dot product\n dot_product = 0\n \n for key in v2:\n if key in v1:\n # updates the dot product if key is present in both vectors\n dot_product += v1[key]*v2[key]\n #returns final dot product\n return dot_product", "def dot_...
[ "0.78392833", "0.77257454", "0.7606124", "0.73988634", "0.73623437", "0.7303379", "0.7259748", "0.7239587", "0.7227672", "0.7208351", "0.71773446", "0.7061669", "0.7045881", "0.7045277", "0.7031112", "0.7024047", "0.7008208", "0.7004543", "0.7001658", "0.6974973", "0.6974525"...
0.8039093
0
``Dimensions.variable`` cannot be selected for decompression.
def test_select_variable_fails(self): msg = r"^cannot decompress Dimensions.variable" with pytest.raises(ValueError, match=msg): self.get_setup().decompress(["dimensions.variable"])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Decompress(self, var_name):\n self.Write('%s_uncompressed = new uint8_t[%s_uncompressed_size];', var_name,\n var_name)\n self.Write('uLongf %s_temp_size = %s_uncompressed_size;', var_name,\n var_name)\n self.Write('CHECK_EQ(Z_OK, uncompress(%s_uncompressed, &%s_temp_size,',...
[ "0.5387579", "0.5129787", "0.5120904", "0.5110061", "0.49942133", "0.49444634", "0.49018326", "0.4883947", "0.4863551", "0.48445618", "0.48249692", "0.48245734", "0.4820919", "0.4818199", "0.4816123", "0.48014274", "0.47956103", "0.47896308", "0.47889823", "0.47844273", "0.47...
0.78747714
0
return a list of words with all punctuation removed, and all in lowercase.
def text_to_words(the_text): my_substitutions = the_text.maketrans( # If you find any of these "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&()*+,-./:;<=>?@[]^_`{|}~'\\", # Replace them by these "abcdefghijklmnopqrstuvwxyz ") # Translate the text ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_text(text):\n words = word_tokenize(text)\n return [word.lower() for word in words if word not in string.punctuation]", "def _remove_punctuation(words):\n new_words = []\n for word in words:\n new_word = re.sub(r'[^\\w\\s]', '', word)\n if new_word != '':\n ...
[ "0.7956763", "0.7878966", "0.7845311", "0.7824117", "0.7813351", "0.7812678", "0.7812678", "0.7812678", "0.7812678", "0.7812678", "0.7812678", "0.7806695", "0.77951044", "0.76570535", "0.7651017", "0.75280476", "0.7470464", "0.7460644", "0.74281484", "0.7389016", "0.7380924",...
0.0
-1
Returns the number of lives left.
def getLives(self): return self._lives
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timesLeft(self)->int:\n return self.maxTimes - self.timesUsed", "def lives(self) -> int:\n return self.__state.lives()", "def count_left_players(definition):\n return int(parse_player_definition(definition)[1]['left_players'])", "def get_lives(self) -> int:\n return self.rstate.live...
[ "0.7550713", "0.7228932", "0.7132914", "0.6974487", "0.69070894", "0.6857751", "0.6823933", "0.6805185", "0.67947066", "0.6678426", "0.6641202", "0.6629609", "0.65389735", "0.6528649", "0.6438563", "0.6409963", "0.6337465", "0.63232225", "0.6305847", "0.6264315", "0.61429435"...
0.56606895
57
Sets self._lives to the parameter life.
def setLives(self,life): self._lives = life
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_lives(self, lives):\n self._lives = lives", "def setLives(self, lives):\n assert type(lives) == int\n self._lives = lives", "def set_lives(self, new_number_of_lives):\n self.__lives = new_number_of_lives", "def change_lives(self, dl):\n\t\tself._lives += dl\n\t\tif dl < 0:...
[ "0.8675207", "0.8279536", "0.7872753", "0.7309931", "0.7190719", "0.7116154", "0.70372903", "0.7018059", "0.6519084", "0.6359622", "0.63150537", "0.62604713", "0.62435114", "0.62223077", "0.61454904", "0.61081994", "0.6083255", "0.60794127", "0.6070953", "0.59042156", "0.5847...
0.8398945
1
Returns the length of the self._aliens list.
def getLengthAlien(self): return len(self._aliens)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aln_length(self) -> int:\n return sum([l for l, _ in self])", "def aln_length(self) -> int:\n return len(self)", "def __len__(self) -> int:\n return self._num_ann", "def lena(self) -> int:\n return self._core.lena()", "def __len__(self) -> int:\n return len(self._wave...
[ "0.785114", "0.74447954", "0.7257787", "0.7226374", "0.70385027", "0.70371115", "0.7030841", "0.7030841", "0.7030841", "0.6956366", "0.69427055", "0.69311523", "0.6920326", "0.6916269", "0.68915546", "0.68915546", "0.6872252", "0.6864506", "0.6846906", "0.68193954", "0.678879...
0.8695191
0
Returns the minimum y cooridinate of the lowest existing alien in the wave.
def _minY(self): pos = GAME_HEIGHT for n in range(self.getLengthAlien()): for x in range(len(self._aliens[0])): if self._aliens[n][x] != None and self._aliens[n][x].y<pos: pos = self._aliens[n][x].y return pos
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y_min(self):\n return self.get_min_value(self.Y_INDEX)", "def minY(self):\n return min(self.gety())", "def min_y_arg(self):\n return min((self(0).y,0), (self(1).y,1))[1]", "def getMinY(self):\n return self.miny", "def argminY( self ):\n min = 1e30\n for i in range(...
[ "0.75315404", "0.73841596", "0.735099", "0.7162696", "0.70928776", "0.70717394", "0.7024408", "0.69919765", "0.6971468", "0.6856954", "0.67723644", "0.6760077", "0.65353966", "0.65353966", "0.65353966", "0.65353966", "0.65353966", "0.65353966", "0.65353966", "0.65353966", "0....
0.72284085
3
Animates the alien wave to move to the right and move down one step when it reaches the right side of the game screen. Then it changes self._direction = True.
def _animateRightAlien(self): incr = self.speedChange() max = self._maxAlien() min = self._minAlien() right = self.getRPos() if right <= GAME_WIDTH-ALIEN_H_SEP: if self._direction == False: for a in self._aliens: for b in a: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MoveRightStep(self):\n if self.facing == 0:\n self.facing = 1\n self.x += self.stepLeft\n elif self.facing == 1:\n self.facing = 2\n self.y += self.stepUp\n elif self.facing == 2:\n self.facing = 3\n self.x -= self.stepRight...
[ "0.7560472", "0.7326481", "0.7315909", "0.7250124", "0.7104741", "0.70689166", "0.70290685", "0.70134866", "0.6943645", "0.69079274", "0.6895286", "0.68196106", "0.6816997", "0.68162125", "0.6791669", "0.6720988", "0.6689889", "0.6689276", "0.6686773", "0.66721594", "0.662358...
0.7681299
0
Animates the alien wave to move to the left and move down one step when it reaches the left side of the game screen. Then it changes self._direction = False.
def _animateLeftAlien(self): incr = self.speedChange() max = self._maxAlien() min = self._minAlien() left = self.getLPos() if left > ALIEN_H_SEP: if self._direction == True: for a in self._aliens: for b in a: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MoveLeftStep(self):\n if self.facing == 0:\n self.facing = 3\n self.x -= self.stepLeft\n elif self.facing == 1:\n self.facing = 0\n self.y -= self.stepUp\n elif self.facing == 2:\n self.facing = 1\n self.x += self.stepRight\...
[ "0.7402728", "0.7298043", "0.7156221", "0.703347", "0.69554234", "0.6895542", "0.686062", "0.68593943", "0.68572307", "0.6852351", "0.67829233", "0.6763053", "0.6728716", "0.67177904", "0.66386014", "0.66238403", "0.6606976", "0.6602875", "0.6588452", "0.65765685", "0.6535339...
0.7554214
0
Returns the y position of the first alien that exists. Its x position is less than the game height and is in the column pos.
def _findBottom(self,col): min = GAME_HEIGHT mpos = 0 for x in range(self.getLengthAlien()): if self._aliens[x][col] != None and self._aliens[x][col].y < min: min = self._aliens[x][col].y mpos = x return mpos
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _minY(self):\n pos = GAME_HEIGHT\n for n in range(self.getLengthAlien()):\n for x in range(len(self._aliens[0])):\n if self._aliens[n][x] != None and self._aliens[n][x].y<pos:\n pos = self._aliens[n][x].y\n return pos", "def get_y_pos(self, bo...
[ "0.7190884", "0.70716554", "0.6574719", "0.6548093", "0.6435174", "0.63859314", "0.63349897", "0.6331141", "0.631633", "0.6237659", "0.6230744", "0.62209994", "0.62032974", "0.617926", "0.61622995", "0.6155755", "0.61380297", "0.6124345", "0.6105917", "0.61004597", "0.6095004...
0.6598068
2
Method to check if a ship bolt collided with an alien in the wave. If a collision occurs, the alien that was hit is set to None and the bolt is removed, and self._key is also set to False.
def _shipCollide(self): for s in range(self.getLengthAlien()): for t in range(len(self._aliens[0])): for b in self._bolts: if self._aliens[s][t] != None and + \ self._aliens[s][t].collides(b): self._aliens[s][t] = No...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _alienCollide(self):\n for b in self._bolts:\n if self._ship != None and self._ship.collides(b):\n self._ship = None\n self._bolts = []\n self._key = False\n self._lives -= 1", "def _shipCollision(self):\r\n for bolt in self...
[ "0.67231286", "0.66083646", "0.6458905", "0.6362415", "0.63619363", "0.6240022", "0.6163472", "0.61227936", "0.606599", "0.6048042", "0.59405136", "0.5913031", "0.5912366", "0.58920544", "0.5870766", "0.5780905", "0.57688284", "0.5750317", "0.5748801", "0.5742827", "0.5726313...
0.6640098
1
Returns the maximum y cooridinate of an existing alien in the alien wave.
def _maxAlien(self): maxA = 0 for r in self._aliens: for y in r: if(y != None): maxA = max(maxA,y.x) return maxA
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_y_arg(self):\n return max((self(0).y,0), (self(1).y,1))[1]", "def getMaxY(self):\n return self.maxy", "def y_max(self):\n return self.get_max_value(self.Y_INDEX)", "def get_max_y(self) -> float:\n return self.pendulum2.get_max_y()", "def MaxY(*args, **kwargs):\n r...
[ "0.72812593", "0.7259981", "0.7189287", "0.70617086", "0.7013833", "0.70004076", "0.69206834", "0.68916106", "0.6794025", "0.6580953", "0.64303094", "0.6400917", "0.6346628", "0.625422", "0.6194663", "0.6139304", "0.6103091", "0.609848", "0.60971737", "0.6094934", "0.6080568"...
0.705783
4
Changes the speed of aliens after each alien is killed.
def speedChange(self): original = ALIENS_IN_ROW *ALIEN_ROWS i = 0 # accumulator for x in range(ALIEN_ROWS): for y in range(ALIENS_IN_ROW): if self._aliens[x][y] != None: i+=1 return i / original
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increase_aliens_speed(self):\r\n self.alien_speed_factor += 0.01\r\n self.alien_bullet_speed_factor += 0.02", "def _update_aliens(self):\n\n #update position of aliens\n self.aliens.update()\n\n #increase counter\n self.counter += 1\n\n #delete offscreen alien...
[ "0.7195051", "0.7015628", "0.6462147", "0.6351858", "0.63009137", "0.6244651", "0.61454713", "0.61414474", "0.61111826", "0.60876393", "0.60780466", "0.6040096", "0.60251874", "0.59252274", "0.58111304", "0.58111304", "0.58056825", "0.5778729", "0.5761722", "0.57436025", "0.5...
0.5538225
44
Performs search from middle item in ordered list and eliminates half that does not contain number
def binary_search_iterative(a_list, item): first = 0 last = len(a_list) - 1 found = False while first <= last and not found: midpoint = (first + last) // 2 if a_list[midpoint] == item: found = True else: if item < a_list[midpoint]: last = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def missing_binary_search(item_list):\n first = 0\n last = len(item_list)-1\n while first < last:\n mid = (first + last)//2\n if mid not in item_list:\n return mid\n if mid - first != item_list[mid] - item_list[first]:\n last = mid\n elif last - mid != ite...
[ "0.69280416", "0.6263242", "0.61207527", "0.5955321", "0.59102803", "0.5903856", "0.58369046", "0.58252555", "0.57854253", "0.56831723", "0.56421363", "0.5619837", "0.55652744", "0.5539781", "0.5536686", "0.55321395", "0.55314285", "0.5529659", "0.5527952", "0.5523458", "0.55...
0.5375548
37
Performs search from middle item in ordered list and eliminates half that does not contain number with recursion
def binary_search_recursive(a_list, item): if len(a_list) == 0: return False else: midpoint = len(a_list) // 2 if a_list[midpoint] == item: return True else: if item < a_list[midpoint]: return binary_search_recursive(a_list[:midpoint], item...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def missing_binary_search(item_list):\n first = 0\n last = len(item_list)-1\n while first < last:\n mid = (first + last)//2\n if mid not in item_list:\n return mid\n if mid - first != item_list[mid] - item_list[first]:\n last = mid\n elif last - mid != ite...
[ "0.71205354", "0.65956014", "0.6588399", "0.6350014", "0.63448304", "0.6200435", "0.6132744", "0.61215585", "0.6110542", "0.6072131", "0.6013122", "0.59974086", "0.59722495", "0.595542", "0.59552103", "0.5948189", "0.5947438", "0.5848077", "0.5842047", "0.58403385", "0.583201...
0.605889
10
Get the position of an impurity defect. Look at all sites with impurity atoms, and take the average of the positions of the sites.
def get_impurity_position( self, defect_structure: Structure, base_structure: Structure ): # get the pbc average position of all sites not in the base structure base_species = {site.species_string for site in base_structure} impurity_sites = [ *filter(lambda x: x.species_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_average_position():\n pass", "def average_impurity(self):\n children = tf.squeeze(tf.slice(self.variables.tree, [0, 0], [-1, 1]),\n squeeze_dims=[1])\n is_leaf = tf.equal(LEAF_NODE, children)\n leaves = tf.to_int32(tf.squeeze(tf.where(is_leaf), squeeze_dims=[1]))\n ...
[ "0.6139922", "0.5611627", "0.5610802", "0.55794036", "0.5571224", "0.54152685", "0.54104424", "0.5362027", "0.5348595", "0.5339481", "0.5281956", "0.5259325", "0.52564806", "0.52499396", "0.5235139", "0.52139497", "0.51942074", "0.51795053", "0.5161109", "0.5156384", "0.51284...
0.7521096
0
Get the boundary index for the highdistortion indices. Assuming arr is sorted in reverse order,
def _get_broundary(arr, n_max=16, n_skip=3): sub_arr = np.array(arr[n_skip:n_max]) diffs = sub_arr[1:] - sub_arr[:-1] return np.argmin(diffs) + n_skip + 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kernel(bin_arr):\n mf = minusframe(bin_arr)\n mf.sort('i', inplace=True, ascending=False) # prefer smaller extents\n max_wi = mf['w'].idxmax()\n max_i = mf.loc[max_wi, 'i']\n return mf[mf['i'] >= max_i].index", "def get_peak_ind(discrete_array):\n\n indexes = [j for j in range(discrete_arra...
[ "0.62960047", "0.6200405", "0.6131086", "0.6040252", "0.60015666", "0.59515846", "0.5946061", "0.5945839", "0.5936712", "0.5923544", "0.58673507", "0.58484507", "0.5746903", "0.5744324", "0.5730083", "0.5694448", "0.5652181", "0.5652181", "0.5651673", "0.5648979", "0.5629835"...
0.5348776
59
Get the weighted average position of a set of positions in frac coordinates. The algorithm starts at position with the highest weight, and gradually moves the average point by finding the closest image of each additional position to the average point. This can be used to find the center of mass of a group of sites in a
def get_weighted_average_position(lattice, frac_positions, weights=None) -> NDArray: if weights is None: weights = [1.0] * len(frac_positions) if len(frac_positions) != len(weights): raise ValueError("The number of positions and weights must be the same.") # TODO: can be replaced with the z...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_average_position():\n pass", "def estimate(particles, weights):\n\n pos = particles[:, 0:2]\n mean = np.average(pos, weights=weights, axis=0)\n var = np.average((pos - mean)**2, weights=weights, axis=0)\n return mean, var", "def estimate(particles, weights):\n\n pos = particles[:, 0...
[ "0.651824", "0.62862164", "0.62862164", "0.5999447", "0.5996934", "0.5946555", "0.5938577", "0.5928272", "0.5864895", "0.5862376", "0.58327436", "0.57718074", "0.57549894", "0.57491726", "0.5734213", "0.5707035", "0.55769026", "0.55388546", "0.55330986", "0.55287236", "0.5520...
0.7692397
0
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(self, cm, classes, normalize=False, title=None, cmap=plt.cm.Blues): if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] print("Normalized confusion matrix...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.8194862", "0.80949175", "0.8029915", "0.8019153", "0.79941195", "0.7991258", "0.7980955", "0.7976606", "0.79610753", "0.79590565", "0.79378676", "0.7934962", "0.7934504", "0.79313844", "0.7926313", "0.7924577", "0.79241234", "0.7923211", "0.7923023", "0.7921931", "0.791787...
0.0
-1
Calculates the curvature of polynomial functions in pixels.
def measure_curvature_pixels(ploty, leftx, lefty, rightx, righty): # Start by generating our fake example data # Make sure to feed in your real data instead in your project! #ploty, left_fit, right_fit = generate_data() # Define y-value where we want radius of curvature # We'll choose the maxi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_curvature(P):\n y = P[:,1].copy()\n x = P[:,0].copy()\n dx = np.gradient(x)\n yd = np.gradient(y, dx)\n ydd = np.gradient(yd, dx)\n return np.sum(ydd**2)", "def calc_curvature(self, windows: List[Window]):\n x, y = zip(*[window.pos_xy() for window in windows])\n x = ...
[ "0.7504194", "0.74695694", "0.74036103", "0.7271254", "0.7154004", "0.70006746", "0.68935233", "0.6879775", "0.6856747", "0.676435", "0.67511743", "0.6709103", "0.6701515", "0.6512093", "0.6470589", "0.6412676", "0.63845927", "0.63292474", "0.6272403", "0.6266002", "0.619774"...
0.7033541
5
Returns the guard bars for Jenkins to identify. For example the OverviewBucket returns "OVERVIEW".
def get_guard(self): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bars(self):\n return self.percent_2_bars(self.percent)", "def get_bar(self):\n return self.__bar", "def get_bar(self):\n # return self.__bar # NOTE: will not work, cuz it's trying _SubExample__bar\n return self._Example__bar", "def bar(self) -> str:\n return self._...
[ "0.6264973", "0.5912136", "0.5623356", "0.56129205", "0.55951154", "0.5282579", "0.5199309", "0.51929563", "0.5032141", "0.5022909", "0.5017751", "0.5001129", "0.49915498", "0.4985041", "0.49646553", "0.49621773", "0.49517912", "0.49517912", "0.49477017", "0.49466738", "0.494...
0.0
-1
Scatter plot with contour over dense regions
def scatter_contour(x, y, levels=10, bins=40, threshold=50, log_counts=False, histogram2d_args={}, plot_args={}, contour_args={}, ax=None): if ax is None: ax = plt.gca() # H, xbins, ybins = np.histogram2d(x, y, **histogram2d_args) # extent...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plotit(X,Y=None,clf=None, markers = ('s','o'), hold = False, transform = None):\n eps=1e-6\n minx, maxx = np.min(X[:,0]), np.max(X[:,0])\n miny, maxy = np.min(X[:,1]), np.max(X[:,1])\n \n if clf is not None:\n npts = 150\n x = np.linspace(minx,maxx,npts)\n y = np.linspace(mi...
[ "0.6413699", "0.6402964", "0.6291107", "0.6247415", "0.6247415", "0.6247415", "0.62390184", "0.6211225", "0.62045515", "0.62045515", "0.62045515", "0.62045515", "0.6131246", "0.6105118", "0.6084301", "0.608259", "0.5993672", "0.5981581", "0.5968162", "0.59619623", "0.59405816...
0.5703868
33