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
Method to be override by users. In this method, the user should register the model, optimizer, criterion, and data loaders to the operator class via the `register()` method.
def setup(self, operator_config): raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register(self, *, model, optimizer, criterion, **kwargs):\n raise NotImplementedError()", "def __init__(self):\n super(OperatorCodegen, self).__init__()", "def with_cpu(ops, model):\n ...", "def __init__(self, optimizer):\n super(ShardedOptimizer, self).__init__(optimizer, name=\"Shar...
[ "0.6899107", "0.66595286", "0.6124426", "0.6026871", "0.59907895", "0.5983626", "0.58599967", "0.58491737", "0.58475566", "0.58451897", "0.5803376", "0.57841396", "0.57816666", "0.5777081", "0.57398814", "0.5711376", "0.56904393", "0.5654849", "0.5644213", "0.5643954", "0.561...
0.61587465
2
Converts a given matplotlib figure to an image / uri that can be displayed as html.
def plot2uri(figure): image = io.BytesIO() figure.savefig(image, format="png") image.seek((0)) string = base64.b64encode(image.read()) uri = urllib.parse.quote(string) return uri
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_pylab(figure, fmt=\"jpg\"):\n if not callable(getattr(figure, \"savefig\", None)):\n return None\n output = StringIO()\n figure.savefig(output, format=fmt)\n contents = output.getvalue()\n output.close()\n return contents, \"image/%s\" % fmt", "def test_html_report_save_figure...
[ "0.7435153", "0.6891032", "0.6856928", "0.6856928", "0.67785925", "0.6753025", "0.67023116", "0.6651859", "0.6541583", "0.6539001", "0.65350056", "0.65350056", "0.6513177", "0.6492599", "0.6408445", "0.639338", "0.6339896", "0.63398343", "0.6336781", "0.6336781", "0.6336781",...
0.7336543
1
Get string data from yaml file.
def _load_yaml(source_dir, file_name): return yaml.dump(utils.load_yaml_dict(os.path.join(source_dir, file_name)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_yaml(file):\n with open(file, 'r') as file:\n data = yaml.safe_load(file)\n return data", "def _read(self, text):\n return yaml.safe_load(text)", "def get_yaml_data(path):\n yaml_path = \"%s%s.yml\" % (CONTENT_FILE_DIR, path[:-5])\n if os.path.isfile(yaml_path):\n f = ...
[ "0.68649375", "0.68588954", "0.6726348", "0.671994", "0.66377175", "0.65322", "0.6509068", "0.64714706", "0.6443366", "0.64120436", "0.63799274", "0.63719374", "0.6351046", "0.6342371", "0.6338306", "0.6317867", "0.63118523", "0.6305448", "0.62378806", "0.62234616", "0.617979...
0.5927551
48
Return the string representation of this Multiaddr.
def __str__(self): return bytes_to_string(self._bytes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n \n return self._addr[0] + \":\" + str(self._addr[1])", "def __str__(self):\n return format_address(**self._get_elements())", "def to_string(self):\n return \"Address: {city} {state} {country}\".format(\n city=self.city,\n state=self.state,\...
[ "0.7921497", "0.750054", "0.73202235", "0.72178984", "0.7084201", "0.7028867", "0.7009324", "0.6919844", "0.68940187", "0.687264", "0.6810318", "0.6747569", "0.6711324", "0.6710023", "0.6710023", "0.6710023", "0.6710023", "0.6710023", "0.6710023", "0.6710023", "0.6710023", ...
0.0
-1
Run the backward process to update the gradient of each unit in the gate
def backward(self): self.units = self._units_history.pop() self._backward() # We must set the utop to previous state immediately, because the utop could be other gate's input unit # And other gate's backward could be called before this gate's backward self._utop_history.pop() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backward(self, gradient):\n #TODO\n pass", "def backward(self, gradient):\n #TODO\n pass", "def backward(self, i):\n \n #Compute gradient for w1, w2, w3\n w1_grad = np.zeros((2, 3))\n w2_grad = np.zeros((3, 3))\n w3_grad = np.zeros((3, 1))\n ...
[ "0.7649687", "0.7649687", "0.7647074", "0.76331234", "0.760687", "0.760687", "0.7531579", "0.7417706", "0.74047595", "0.7398327", "0.7237265", "0.72323453", "0.7227327", "0.7189413", "0.7138388", "0.71084356", "0.71068233", "0.70795107", "0.70451134", "0.7043444", "0.7015585"...
0.0
-1
Here, we define the derivative at x=0 to 0
def _backward(self): if self.units[0].value > 0: self.units[0].gradient += 1 * self.utop.gradient else: self.units[0].gradient += 0 * self.utop.gradient
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def derivative(self,x,dx=None):\n if dx is None:\n x = np.array(x,copy=False)\n if len(x.shape)>0:\n dx = np.convolve(x,[1,-1],mode='valid')\n dx = np.insert(dx,0,np.mean(dx))/2\n else:\n dx = 1\n return (self(x+dx)-self(x)...
[ "0.7789218", "0.7742882", "0.76327366", "0.7551887", "0.7546453", "0.7480661", "0.7480661", "0.7430074", "0.72675794", "0.72120214", "0.7164857", "0.71531934", "0.7138351", "0.71006554", "0.7061819", "0.70548165", "0.70067865", "0.6958436", "0.6950731", "0.6939282", "0.689047...
0.0
-1
Return the output of the network in a list Must set the `_outputs` property if the network has multiple output
def outputs(self): return self._outputs if self._outputs else [self.utop]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _list_outputs(self):\n \n outputs = self._outputs().get()\n return outputs", "def get_outputs(self):\n return self.outputs", "def outputs(self):\r\n return self._outputs", "def get_outputs(self):\n return self.attributes[\"outputs\"]", "def get(self, *args):\n ...
[ "0.7627549", "0.73325163", "0.72073185", "0.71948427", "0.71188223", "0.70936215", "0.7075045", "0.7041719", "0.7041719", "0.6989479", "0.687403", "0.686725", "0.67957425", "0.6725267", "0.66783535", "0.66630435", "0.66423535", "0.66271496", "0.6593826", "0.6530676", "0.64836...
0.69615173
10
Gets an unsorted sequence of values.
def values(self): return self.d.keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def values(self, values=None):\n return [self[key] for key in self._sequence]", "def toSequence(self):\n return list(self.iteritems())", "def get_values(self, no_values=400):\r\n return [self.get_value() for i in range(no_values)]", "def values(self):\n return [i.value for i in se...
[ "0.6785029", "0.6705594", "0.6674962", "0.6532796", "0.6198259", "0.61587596", "0.6153168", "0.608443", "0.6071032", "0.60555875", "0.60538757", "0.60134226", "0.59874403", "0.5961428", "0.59596306", "0.5936548", "0.59224194", "0.5911974", "0.59030515", "0.589837", "0.5898338...
0.0
-1
Start playing the first video in the queue unless something is already playing." Returns True if it started playing the first video of the queue, returns False otherwise (nothing happened).
def play(self, room): if self.waiting and not self.playing(): self.playing_task = asyncio.ensure_future(self._play(room)) #asyncio.ensure_future(self._play(room)) return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play(self): \n if(self.isLoaded() == False):\n return\n self.isPlaying = True\n #if the video is end, we restart\n if(self.ret == False):\n self.video.set(1, 0)", "async def play(\n self,\n ctx: commands.Context,\n ) -> Optional[bool]:\n\n if not ctx.voice_clien...
[ "0.7003244", "0.65322226", "0.6486291", "0.6359785", "0.6242944", "0.6233513", "0.620361", "0.6106298", "0.6062429", "0.6017791", "0.60084164", "0.5962782", "0.5950048", "0.594383", "0.59415036", "0.5931849", "0.5903034", "0.5899874", "0.58955616", "0.585434", "0.583411", "...
0.60726154
8
Find indices of unique rows in tensor. Prioritizes the first instance.
def _unique_ind(x: to.Tensor) -> to.Tensor: # Get unique rows and inverse indices unique_rows, inverse_ind = to.unique(x, sorted=False, return_inverse=True, dim=0) # get unique inverse indices uii = inverse_ind.unique() # find where unique index in inverse index (uii x ii matrix) where_unique ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_rows(mat, return_inverse=False):\n\n b = np.ascontiguousarray(mat).view(np.dtype((np.void, mat.dtype.itemsize * mat.shape[1])))\n if not return_inverse:\n _, idx = np.unique(b, return_index=True)\n else:\n _, idx = np.unique(b, return_inverse=True)\n \n return idx", "def f...
[ "0.659938", "0.62869847", "0.61881524", "0.59433514", "0.59144515", "0.5900803", "0.582126", "0.5789741", "0.57394606", "0.57062465", "0.5693678", "0.5658446", "0.56312484", "0.55789924", "0.5572636", "0.5561542", "0.551482", "0.54761684", "0.5434007", "0.53807", "0.5336013",...
0.7581342
0
Return the height above WGS84 earth ellipsoid of geocentric location X,Y,Z
def ellipsoidHeight(X,Y,Z): a = 6378137. f = 1./298.2572236 e2 = 2*f-f*f epsilon = e2/(1.-e2) b = a*(1.-f) p = sqrt(X*X+Y*Y) q = atan((Z*a)/(p*b)) phi = atan( (Z+epsilon*b*sin(q)**3)/(p-e2*a*cos(q)**3) ) nu = a / sqrt( 1-e2*sin(phi)**2) h = p/cos(phi) - nu return h
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point2wgs84_9603(self, datum):\n \"\"\"\n h is the height above the ellipsoid. This is the height value that is \n delivered by GPS satellite observations but is not the gravity-related height \n value which is normally used for national mapping and levelling operations. The\n ...
[ "0.69148016", "0.6912799", "0.687575", "0.6372516", "0.6349687", "0.6261464", "0.6226034", "0.6156621", "0.61558044", "0.611448", "0.6056222", "0.5949006", "0.5922837", "0.5906384", "0.58847564", "0.58700114", "0.5860478", "0.58596724", "0.58507705", "0.58422536", "0.57640404...
0.804347
0
Generate the string of formatted affine registration options
def format_affine_params(self): return self.format_param_pairs(self.get_affine_reg_params())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self) -> str:\n\n sources_joined = \" \".join(self.sources)\n sources = f\"[SOURCES]\\n{sources_joined}\"\n\n sp_joined = \"\\n\".join(map(str, self.source_parameters))\n source_parameters = f\"[SOURCE-PARAMETERS]\\n{sp_joined}\"\n\n hints_joined = \"\\n\".join(map(st...
[ "0.6128604", "0.61047244", "0.60431737", "0.5989979", "0.59814495", "0.5880894", "0.5756988", "0.5736655", "0.5693833", "0.569322", "0.56924766", "0.56700814", "0.5659404", "0.5658237", "0.56457156", "0.5635233", "0.56328726", "0.5626076", "0.562337", "0.5604731", "0.55941916...
0.6448838
0
Generate the string of formatted segmentation options
def format_segmentation_params(self): return self.format_param_pairs(self.get_segmentation_params())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n segments = []\n if self.comment:\n segments.append('\"%s\"' % self.comment)\n if self.sg:\n if self.dbow_words:\n segments.append('dbow+w') # also training words\n else:\n segments.append('dbow') # PV-DBOW (s...
[ "0.7144592", "0.6766662", "0.6476094", "0.63708335", "0.63574475", "0.6300372", "0.6232984", "0.6209325", "0.62061036", "0.6168211", "0.6165109", "0.61485225", "0.61244804", "0.61218077", "0.6069434", "0.6051844", "0.6050242", "0.6030782", "0.60190237", "0.5999584", "0.598837...
0.58780855
29
This function computes the unobserved component of the MTE in MTE = mte_x + mte_u, where mte_u depends on the unobserved esistance to treatment u_D.
def mte_unobserved_semipar( X, Y, b0, b1_b0, prop_score, bandwidth, gridsize, startgrid, endgrid ): # 0) Construct Xp := X * P(z) Xp = _construct_Xp(X, prop_score) # Turn the X, Xp, and Y DataFrames as well as the # propensity score Series into np.ndarrays X_arr = np.array(X) Xp_arr = np.ar...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ttd_u_func(self):\n T_i1 = T_mix_ph(self.inl[0].to_flow(), T0=self.inl[0].T.val_SI)\n T_o2 = T_mix_ph(self.outl[1].to_flow(), T0=self.outl[1].T.val_SI)\n return self.ttd_u.val - T_i1 + T_o2", "def ttd_u_func(self):\n i1 = self.inl[0].to_flow()\n o2 = self.outl[1].to_flow()\...
[ "0.6497477", "0.6319751", "0.6162096", "0.5897398", "0.5892473", "0.5869995", "0.5789975", "0.5761974", "0.5745801", "0.5719212", "0.5709441", "0.56804293", "0.5671031", "0.56615144", "0.5655082", "0.56525564", "0.56382453", "0.56382453", "0.56224895", "0.5522628", "0.5481878...
0.56209916
19
Get the state of the master watcher.
def master_state(lock_file=None): if lock_file is None: lock_file = config.LOCK_FILE # We'll never acquire the lock, so the lifetime doesn't matter. lock = Lock(lock_file) try: hostname, pid, tempfile = lock.details except NotLockedError: return WatcherState.none, lock if...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_master(self):\n\n def watcher(watched_event):\n if watched_event.type and watched_event.path:\n msg = \"child changed, try to get master again.type %s, state %s, path %s.\" % (\n watched_event.type, watched_event.state, watched_event.path)\n ...
[ "0.6882314", "0.6466916", "0.6427733", "0.6425098", "0.6421211", "0.63100934", "0.6249418", "0.6234995", "0.6234995", "0.62273437", "0.6168876", "0.6153005", "0.6153005", "0.6153005", "0.6153005", "0.6153005", "0.61340183", "0.61321723", "0.61280906", "0.61274517", "0.6127402...
0.6779075
1
Return the Intersection over Union (IoU) for a given label.
def def_iou( y_true, y_pred, label): # extract the label values using the argmax operator then # calculate equality of the predictions and truths to the label y_true = backend.cast(y_true, tf.uint8) # compute cross entropy y_pred = backend.reshape(y_pred, shape=(-1, y_pred.shape[-1])) # y_pred =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_IoU(seg_mask, true_mask):\n eps = 1e-6 # Prevent divide by zeroes\n\n # Convert seg_mask to binary mask with only 1 or 0 values.\n binary_seg = torch.where(seg_mask > 0, torch.ones_like(seg_mask), torch.zeros_like(seg_mask))\n\n # Inclusion-exclusion principle\n intersection = binary_s...
[ "0.64850307", "0.592822", "0.58965766", "0.58761334", "0.581359", "0.580522", "0.5781693", "0.5754722", "0.57465595", "0.57369214", "0.57355297", "0.5661091", "0.5638574", "0.56309074", "0.56269425", "0.5609908", "0.5517878", "0.55079716", "0.54638666", "0.54615796", "0.54570...
0.49582854
98
Return the Intersection over Union (IoU) score.
def def_mean_iou(y_true, y_pred): # get number of labels to calculate IoU for num_labels = backend.int_shape(y_pred)[-1] # initialize a variable to store total IoU in mean_iou = backend.variable(0) class_iou_dict = {} # iterate over labels to calculate IoU for for label in range(0, num_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_iou(prediction_box, gt_box):\n if is_overlapping(prediction_box, gt_box):\n overlap_box = get_overlap_box(prediction_box, gt_box)\n\n intersection = calculate_box_area(overlap_box)\n pred_box_area = calculate_box_area(prediction_box)\n gt_box_area = calculate_box_area(g...
[ "0.71824914", "0.69739294", "0.6969529", "0.68095833", "0.6769171", "0.67648524", "0.6684313", "0.66604173", "0.65717834", "0.65717834", "0.6508256", "0.6492452", "0.6471471", "0.64113253", "0.6371623", "0.63599265", "0.63498473", "0.6339803", "0.6338301", "0.6299029", "0.622...
0.55667764
76
Compute the lambda message Y > X.
def __get_lambda_msg(self, Y, X): lamsg = {} for x in self.domain[X]: val = log2(BayesianNetwork.EPS) for y in self.domain[Y]: val2 = log2(BayesianNetwork.EPS) for parent_values in self.pds[Y][y]: # e.g., parent_values == "0,1,0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_lambda_mle(X: np.ndarray) -> float:\n\n Poisson._check_input_data(X=X)\n Poisson._check_support(X=X)\n\n lambda_ = X.mean()\n return lambda_", "def __call__(self, **kwargs):\n x = kwargs[\"x_new\"]\n return (sum(x)<self.maxT)", "def value(a, y, weights, lam...
[ "0.6357689", "0.6189473", "0.59497327", "0.5902779", "0.58779544", "0.57850206", "0.5638556", "0.5623084", "0.5610431", "0.5601228", "0.5572179", "0.5557001", "0.5472947", "0.54700434", "0.5455052", "0.54454106", "0.54390925", "0.5434521", "0.5416797", "0.5401739", "0.5385898...
0.5541969
12
Test loading a KSR requesting signatures that has expired already, but allowing it
def test_load_ksr_with_signatures_in_the_past2(self): fn = os.path.join(self.data_dir, "ksr-root-2018-q1-0-d_to_e.xml") policy = RequestPolicy( signature_horizon_days=-1, rsa_approved_exponents=[3, 65537] ) load_ksr(fn, policy, raise_original=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_load_ksr_with_signatures_in_the_past3(self):\n fn = os.path.join(self.data_dir, \"ksr-root-2018-q1-0-d_to_e.xml\")\n # first load the KSR, allowing the old signatures\n policy = RequestPolicy(\n signature_horizon_days=-1, rsa_approved_exponents=[3, 65537]\n )\n ...
[ "0.72572184", "0.72132236", "0.62630516", "0.6112471", "0.60333705", "0.60078055", "0.5984549", "0.597484", "0.59665215", "0.5892956", "0.5874885", "0.5839486", "0.5823783", "0.5798151", "0.57964", "0.5746418", "0.57458866", "0.5738346", "0.57283705", "0.57066506", "0.5704061...
0.6975686
2
If we're saving an Organization for the first time, give it a slug based on name.
def save(self, **kwargs): if not self.id and not self.slug: self.set_unique_slug() super().save(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, *args, **kwargs):\n if not self.slug:\n self.slug = slugify(self.name)", "def save(self, *args, **kwargs):\n if not self.slug:\n # Ensure uniqueness:\n slug = slugify(self.name)\n if not Initiative.objects.filter(slug=slug).exists():\n ...
[ "0.7270296", "0.7229955", "0.71761143", "0.71761143", "0.71414065", "0.6944971", "0.6933153", "0.679367", "0.6790736", "0.6770966", "0.6760141", "0.6730352", "0.6725238", "0.6693434", "0.66663086", "0.65704775", "0.6558187", "0.65566206", "0.650255", "0.64662975", "0.6436476"...
0.6572698
15
Return the 'name' of the resource_class.
def provider_name(self): return self.resource_class.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CFN_RESOURCE_TYPE_NAME(cls) -> str:\n return jsii.sget(cls, \"CFN_RESOURCE_TYPE_NAME\")", "def CFN_RESOURCE_TYPE_NAME(cls) -> str:\n return jsii.sget(cls, \"CFN_RESOURCE_TYPE_NAME\")", "def CFN_RESOURCE_TYPE_NAME(cls) -> str:\n return jsii.sget(cls, \"CFN_RESOURCE_TYPE_NAME\")", "def...
[ "0.7922816", "0.7922816", "0.7922816", "0.7922816", "0.7922816", "0.7922816", "0.7922816", "0.7917809", "0.77795994", "0.77793133", "0.7742374", "0.7742374", "0.7742374", "0.7742374", "0.7742374", "0.77317977", "0.77296525", "0.77008456", "0.77008456", "0.76887167", "0.767923...
0.76164705
25
Return the 'name' of the resource_class.
def provider_name(self): return self.resource_class.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CFN_RESOURCE_TYPE_NAME(cls) -> str:\n return jsii.sget(cls, \"CFN_RESOURCE_TYPE_NAME\")", "def CFN_RESOURCE_TYPE_NAME(cls) -> str:\n return jsii.sget(cls, \"CFN_RESOURCE_TYPE_NAME\")", "def CFN_RESOURCE_TYPE_NAME(cls) -> str:\n return jsii.sget(cls, \"CFN_RESOURCE_TYPE_NAME\")", "def...
[ "0.7922112", "0.7922112", "0.7922112", "0.7922112", "0.7922112", "0.7922112", "0.7922112", "0.791809", "0.777922", "0.7778229", "0.7741287", "0.7741287", "0.7741287", "0.7741287", "0.7741287", "0.77316636", "0.77289516", "0.76998496", "0.76998496", "0.768812", "0.76786005", ...
0.7616001
24
Return start (if possible) else S.Infinity. adapted from Set._infimum_key
def _start_key(expr): try: start = expr.start except (NotImplementedError, AttributeError, ValueError): start = S.Infinity return start
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_min(self):\n if self.root is None: # BC1\n return float('+inf')\n\n current = self.root\n while current.left is not None: # Traverse like a linked-list\n current = current.left\n\n return current.key", "def _infimum_key(expr):\n try:\n ...
[ "0.67480123", "0.65913004", "0.63788307", "0.63427985", "0.6277715", "0.6276748", "0.62709355", "0.6267121", "0.6262728", "0.61920077", "0.6185956", "0.61260504", "0.61131066", "0.6086716", "0.6065141", "0.60578275", "0.60369956", "0.60164326", "0.60164326", "0.6008707", "0.5...
0.7157655
0
Cumulative of all the bound variables
def variables(self): return tuple(flatten([a.variables for a in self.args]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getCummulativeValues(self):\n self.cumulativePhaseHeightInRing1 = np.cumsum(self.phaseHeightInRing1)\n self.cumulativePhaseHeightInRing2 = np.cumsum(self.phaseHeightInRing2)\n self.cumulativeLeftCriticalPointsRing1 = np.cumsum(self.leftCriticalPointsRing1)\n self.cumulativeRightCrit...
[ "0.63340014", "0.6260842", "0.6197877", "0.61112285", "0.6009518", "0.5950442", "0.5842735", "0.58412653", "0.583534", "0.58278793", "0.58197075", "0.57999605", "0.5788151", "0.5784808", "0.5751236", "0.57431906", "0.5737228", "0.57187325", "0.57128996", "0.56540686", "0.5652...
0.0
-1
adds up the coefficients of all the sequences at point pt
def _eval_coeff(self, pt): return sum(a.coeff(pt) for a in self.args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polyFeat(X, p):\r\n # You need to return the following variables correctly.\r\n X_poly = np.zeros((X.shape[0], p))\r\n\r\n # ====================== YOUR CODE HERE ======================\r\n\r\n for i in range(p):\r\n X_poly[:, i] = X[:, 0] ** (i + 1)\r\n\r\n # ============================...
[ "0.56348103", "0.5618802", "0.56123304", "0.55653864", "0.55123633", "0.54804504", "0.5472838", "0.5448897", "0.54257023", "0.5410524", "0.5410524", "0.53889495", "0.5365064", "0.5357065", "0.53551", "0.535123", "0.53395605", "0.5321332", "0.53155625", "0.5305625", "0.5304194...
0.6057553
0
Generate the random coordinates of given number "n_rectangles" of rectangles on the 28x28 image.
def get_random_rectangles(self): while len(self.rectangles) < self.n_rectangles: upper_left = [np.random.randint(0, 28) for i in range(2)] # upper-left corner coordinate lower_right = [np.random.randint(0, 28) for i in range(2)] # lower-right corner coordinate # Have upper...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _rectangles(m, n):\n return m * (m+1) * n * (n+1) // 4", "def rect(rng, lines, columns):\n\n w = rng.randint(1, max(1, lines // 2))\n h = rng.randint(1, max(1, columns // 2))\n\n i = rng.randint(0, lines - h)\n j = rng.randint(0, columns - w)\n \n return i, j, w, h", "def landmarks...
[ "0.7079673", "0.6746927", "0.65639985", "0.6549473", "0.6535832", "0.6504055", "0.64248335", "0.6359662", "0.63448954", "0.6308192", "0.6237708", "0.60406804", "0.6004424", "0.59759605", "0.5936015", "0.5925772", "0.58898", "0.5833518", "0.58138436", "0.5808997", "0.577005", ...
0.73385006
0
Convert index to label name
def fromIndex(index): return Data.labels[index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def label_from_index(self, index):\n raise NotImplementedError", "def label_from_index(self, index):\n assert self.labels is not None, \"Labels not processed\"\n return self.labels[index]", "def get_label(self, index, key=\"Name\"):\n return eval(self.names[key][index])", "def lab...
[ "0.83522266", "0.7762987", "0.7558062", "0.7498074", "0.71639824", "0.70324", "0.6907393", "0.6899446", "0.68933344", "0.68690693", "0.6843206", "0.6824809", "0.6808006", "0.68033534", "0.67067057", "0.6681843", "0.6673693", "0.66443664", "0.66440415", "0.6639841", "0.6639841...
0.67928237
14
Calculate the distance between the two endpoints of two vectors. A vector is defined as a list, tuple, or numpy 1D array. >>> euclidean_distance((0, 0), (2, 2)) 2.8284271247461903 >>> euclidean_distance(np.array([0, 0, 0]), np.array([2, 2, 2])) 3.4641016151377544 >>> euclidean_distance(np.array([1, 2, 3, 4]), np.array(...
def euclidean_distance(vector_1: Vector, vector_2: Vector) -> VectorOut: return np.sqrt(np.sum((np.asarray(vector_1) - np.asarray(vector_2)) ** 2))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(vector1, vector2):\n e_dist = [(v1 - v2) ** 2 for v1, v2 in zip(vector1, vector2)]\n e_dist = math.sqrt(sum(e_dist))\n return e_dist", "def euclidean_distance(x: np.ndarray, y: np.ndarray) -> float:\n distance_vector: np.ndarray = x - y\n distance = compute_norm(distance_vec...
[ "0.78316605", "0.7783354", "0.7779151", "0.7772161", "0.76587975", "0.75956106", "0.7533977", "0.7512383", "0.74900794", "0.74482596", "0.74364394", "0.7432446", "0.7401572", "0.73887694", "0.73651385", "0.73605186", "0.73554146", "0.73460555", "0.72749656", "0.72641957", "0....
0.7786148
1
Calculate the distance between the two endpoints of two vectors without numpy. A vector is defined as a list, tuple, or numpy 1D array. >>> euclidean_distance_no_np((0, 0), (2, 2)) 2.8284271247461903 >>> euclidean_distance_no_np([1, 2, 3, 4], [5, 6, 7, 8]) 8.0
def euclidean_distance_no_np(vector_1: Vector, vector_2: Vector) -> VectorOut: return sum((v1 - v2) ** 2 for v1, v2 in zip(vector_1, vector_2)) ** (1 / 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(x: np.ndarray, y: np.ndarray) -> float:\n distance_vector: np.ndarray = x - y\n distance = compute_norm(distance_vector)\n return distance", "def euclidean_distance(x: np.ndarray, y: np.ndarray) -> float:\n\n distance = np.linalg.norm(x - y)\n\n return distance", "def eucl...
[ "0.72806704", "0.7138312", "0.709125", "0.7053504", "0.7001449", "0.6965503", "0.6915398", "0.68263143", "0.6824499", "0.6800085", "0.6782156", "0.6782139", "0.6780746", "0.67683345", "0.67521465", "0.6617625", "0.6610903", "0.658301", "0.65605736", "0.65150213", "0.65011734"...
0.8091274
0
Creates an instance of this model from a dictionary
def from_dictionary(cls, dictionary): if dictionary is None: return None # Extract variables from the dictionary fqdn = dictionary.get('fqdn') guid = dictionary.get('guid') id = dictionary.get('id') name = dictionary.get('name') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction...
[ "0.83181584", "0.8168118", "0.8168118", "0.8118749", "0.8089047", "0.79787344", "0.7949278", "0.79231393", "0.7898951", "0.78923255", "0.788838", "0.7882321", "0.7882212", "0.7876749", "0.78585315", "0.7836853", "0.7801407", "0.7801407", "0.7801407", "0.7801407", "0.7801407",...
0.7742912
64
Test to see if an error is raised if secret_key is missing
def test_init(self): with self.assertRaises(ValueError): TraxionPay(api_key=self.api_key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_key(key):\r\n try:\r\n secret.Secret(key)\r\n except secret.Secret.InvalidSecret as e:\r\n raise KeyIsInvalid(e.message)", "def test_secret():\r\n try:\r\n straxen.get_secret('somethingnonexistent')\r\n except ValueError:\r\n # Good we got some message we cann...
[ "0.73247534", "0.70913684", "0.6839799", "0.6811461", "0.6801148", "0.6706267", "0.6692907", "0.668212", "0.6641133", "0.6584238", "0.6545772", "0.65040916", "0.65031034", "0.6400448", "0.6396976", "0.63911223", "0.6383503", "0.63654065", "0.63233465", "0.6305709", "0.6296243...
0.0
-1
Return a custom 404 error.
def page_not_found(e): return 'Sorry, Nothing at this URL.', 404
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_found():\n return HttpError(404)", "def error_404(error):\n return '404 Error'", "def error_404(error):\n return 'Bummer, there is nothing at this URL.'", "def error_not_found(error):\n return 'No page here, dood. 404!', 404", "def not_found(self, error):\n return jsonify({'error': 'NO...
[ "0.81159586", "0.80410045", "0.7738874", "0.77369535", "0.77182025", "0.7689595", "0.7670471", "0.76112473", "0.7602477", "0.7570698", "0.75528365", "0.7545827", "0.751882", "0.74745256", "0.7458403", "0.7455682", "0.74548143", "0.74505144", "0.7442062", "0.7428278", "0.74065...
0.7254463
41
Test that bad search returns no results
def test_search_by_bad_ingredients(self): recipe_id = self.request_mgr.search_by_ingredients(['asdfadsfa']) self.assertEqual(recipe_id, None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_existent_term_search(self):\n\n expected_results = []\n results = self.searcher.search(\"asdasdasdas\")\n\n self.assertListEqual(results, expected_results)", "def test_search_not_found(self):\n s = Searcher( self.logger )\n ( search_key, search_value ) = ( 'ISBN', ...
[ "0.80588096", "0.75740945", "0.7532176", "0.7414892", "0.7412188", "0.738438", "0.7342488", "0.72875774", "0.724622", "0.7204059", "0.7195484", "0.7045242", "0.7037355", "0.6990668", "0.6990402", "0.6970769", "0.6968213", "0.6963713", "0.69579816", "0.69220495", "0.68718404",...
0.6836373
22
Test that bad search returns no results
def test_search_by_no_ingredients(self): recipe_id = self.request_mgr.search_by_ingredients([]) self.assertEqual(recipe_id, None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_existent_term_search(self):\n\n expected_results = []\n results = self.searcher.search(\"asdasdasdas\")\n\n self.assertListEqual(results, expected_results)", "def test_search_not_found(self):\n s = Searcher( self.logger )\n ( search_key, search_value ) = ( 'ISBN', ...
[ "0.80588096", "0.75740945", "0.7532176", "0.7414892", "0.7412188", "0.738438", "0.7342488", "0.72875774", "0.724622", "0.7204059", "0.7195484", "0.7045242", "0.7037355", "0.6990668", "0.6990402", "0.6970769", "0.6968213", "0.6963713", "0.69579816", "0.69220495", "0.68718404",...
0.6370275
71
Gets the histogram features for an image on all 3 channels. (from CarND 05 / lesson 12. Histograms of Color)
def get_hist_features(image, nbins=32, bins_range=(0., 1.)): # Compute the histogram of the RGB channels separately r = np.histogram(image[:,:,0], bins=nbins, range=bins_range) g = np.histogram(image[:,:,1], bins=nbins, range=bins_range) b = np.histogram(image[:,:,2], bins=nbins, range=bins_range) #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def color_hist(img, nbins=32): # Note : bins_range=(0, 256) from lecture will not work\n # Compute the histogram of the colour channesl separately\n channel1_hist = np.histogram(img[:, :, 0], bins=nbins)\n channel2_hist = np.histogram(img[:, :, 1], bins=nbins)\n channel3_hist = np.histogram(img[:, :, ...
[ "0.8403473", "0.8198114", "0.7964726", "0.7843926", "0.7335022", "0.7295205", "0.72474384", "0.7009572", "0.6942532", "0.68649095", "0.6837832", "0.68072224", "0.6754781", "0.6740287", "0.6670645", "0.6635937", "0.66221267", "0.65892076", "0.6584663", "0.65577173", "0.6546266...
0.7559548
4
Gets a payload config.
def GetPayloadsDict(self, payloads_name): return json.loads(file_utils.ReadFile(self.GetResourcePath(payloads_name)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config(self):\n return self.config", "def get_config():\n return CONFIG", "def get_config():\n return _config", "def _get_config(self):\n return self._get_from_settings(settings.INTEGRATIONS_PAGER_DUTY_WEBHOOKS, 'service_key')", "def get(self) -> dict:\n return Config.get...
[ "0.68645227", "0.6793532", "0.67261505", "0.6726099", "0.6691151", "0.6680222", "0.6680222", "0.66630965", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", "0.6649623", ...
0.0
-1
Gets a resource's full path.
def GetResourcePath(self, resource_name, check=True): path = os.path.join(self.resources_dir, resource_name) if check: file_utils.CheckPath(path, 'resource') return path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_path(self, resource):\n return str(self.path.joinpath(resource))", "def resource_path(self, resource):\n return str(self.path.joinpath(resource))", "def _get_resource_path(filename, path=Path.TEST):\n return os.path.normpath(os.path.join(path.value, filename))", "def get_res...
[ "0.83867383", "0.83867383", "0.7562001", "0.7543106", "0.74803495", "0.74548024", "0.7449718", "0.74453807", "0.7383769", "0.7315119", "0.7258901", "0.7258901", "0.7245459", "0.723656", "0.72175646", "0.717997", "0.71694165", "0.7155479", "0.71176285", "0.7114805", "0.7088526...
0.68517977
60
Configure selenium browser Run headless firefox and configure download path
def browserConfiguration(path): profile = FirefoxProfile() profile.set_preference("browser.download.panel.shown", False) profile.set_preference("browser.download.manager.showWhenStarting", False) profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream") profile.set_preference("br...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_firefox(self):\n fp = webdriver.firefox.firefox_profile.FirefoxProfile(\"/Users/robertvesco/Library/Application Support/Firefox/Profiles/j2rjfnw0.default\")\n # fp.set_preference(\"browser.download.folderList\",2)\n # fp.set_preference(\"browser.download.manager.showWhenStarting\",Fa...
[ "0.754272", "0.73627007", "0.71745586", "0.7151331", "0.6967134", "0.6873512", "0.68524253", "0.6681138", "0.66488194", "0.6646325", "0.6552416", "0.65446144", "0.64742726", "0.64666617", "0.6399129", "0.6337346", "0.63368917", "0.6327931", "0.6327931", "0.63262486", "0.63175...
0.8094743
0
Return tokens randomly masked using standard BERT probabilities.
def randomize_tokens(tokens, mask, tokenizer): targets = torch.ones_like(tokens) * -1 # get random data p = torch.rand_like(tokens.float()) * mask.float() random_tokens = torch.randint_like(tokens, len(tokenizer.vocab)) # set targets for masked tokens thresh = 0.85 targets[p >= thresh] = t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_mask_tokens(inputs, alphabet, mlm_probability=0.15):\n labels = inputs.clone()\n device = inputs.device\n # We sample a few tokens in each sequence for MLM training\n # (with probability `self.mlm_probability`)\n probability_matrix = torch.full(labels.shape, mlm_probability,\n ...
[ "0.7307822", "0.6828806", "0.67503387", "0.67240417", "0.6688074", "0.65036905", "0.6409755", "0.6392549", "0.6333399", "0.62787116", "0.62429005", "0.6168626", "0.61480874", "0.6102631", "0.5840826", "0.580556", "0.57512087", "0.57287586", "0.5720218", "0.5684592", "0.564094...
0.69530916
1
Return a list of viewpoints that are in the graphs and feature reader.
def get_viewpoints( data, graphs, feature_reader, ): scan_list = set(item["scan"] for item in data) viewpoints = {} for scan in scan_list: graph_viewpoints = set(graphs[scan].nodes()) feats_viewpoints = feature_reader.viewpoints[scan] viewpoints[scan] = feats_viewpoints.intersect...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_view_endpoints(self):\n return []", "def getViews(self):\n return list(self.__views)", "def getReachableViews(self):\n return [self]", "def vertices(self):\n return self.pointlist", "def getReachableViews(self):\n raise NotImplementedError()", "def getViews(self...
[ "0.64240915", "0.6283286", "0.623044", "0.61901563", "0.60740286", "0.6072229", "0.6065391", "0.59739506", "0.5956511", "0.59131676", "0.586649", "0.58353883", "0.58227557", "0.57824063", "0.5780283", "0.57470226", "0.57328576", "0.57139295", "0.5713371", "0.5706782", "0.5701...
0.72511464
0
Check, to be used at the end of each player turn, to see if the round is complete. True if the most recent player discarded their final card and now has 0 cards. False otherwise (allowing for the game to continue even if the player has 0 cards).
def is_round_over(whose_turn,players): if ((len(players[whose_turn].hand.cards) == 0) and (players[whose_turn].has_discarded == True)): round_over = True else: round_over = False return round_over
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_finished(game: List[int]) -> bool :\n return sum(game) == 0", "def won_game(self):\n for player in self.players:\n if len(player.cards) == 0:\n\n return True\n return False", "def is_complete(self):\n return self.winner is not None", "def finished(self...
[ "0.7359608", "0.7323492", "0.7174609", "0.70911855", "0.7054729", "0.69461435", "0.694031", "0.69349885", "0.6905075", "0.6898985", "0.68823355", "0.6854528", "0.6818869", "0.67921484", "0.6787332", "0.67746794", "0.6772798", "0.6743222", "0.6709704", "0.66952306", "0.6683208...
0.6963725
5
convert pixel values from [0, 255] > [0.0, 1.0]
def _scale_to_zero_one(img): if img.dtype == np.uint8: img = img.astype(np.float32) return np.multiply(img, 1.0 / 255.0) else: print("image values already seem to be float") return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(image):\n return (image / 255) * 2 - 1", "def normalize_01(x):\n return x / 255.0", "def reverse_black_and_white(img):\n img = 255 - img\n\n return img", "def convert_image_to_floats(image):\n\n if np.max(image) <= 1.0:\n return image\n else:\n return image / 25...
[ "0.7011388", "0.68976545", "0.6879721", "0.68654597", "0.6749471", "0.67372614", "0.6720305", "0.6707296", "0.669469", "0.66808003", "0.66643196", "0.6656332", "0.66397583", "0.6638525", "0.66318065", "0.6626406", "0.66206676", "0.6602296", "0.65947574", "0.6594072", "0.65894...
0.62999856
48
String name of the input tag.
def key(self) -> str: return self._key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"tag_name\")", "def input_name(self):\n return self.__input_name", "def name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"name\")", "def name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"name...
[ "0.81052077", "0.7767699", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964", "0.72058964",...
0.0
-1
Assures each array of crosscorrelation values is of the same length (9), padding smaller arrays with zero for plotting purposes.
def pad_corr_series(corr_list): if len(corr_list) == 9: return np.array(corr_list) elif len(corr_list) < 9: if len(corr_list) % 2 == 1: return np.pad(np.array(corr_list), pad_width=((9-len(corr_list)) // 2), mode='constant', constant_values=0.0) else: right_pad_width = int(np.f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_remove_autos():\n test_array = np.ones((3, 3, 11, 21))\n out_array = utils.remove_auto_correlations(test_array, axes=(0, 1))\n assert (6, 11, 21) == out_array.shape", "def test_remove_middle_axis():\n test_array = np.ones((13, 17, 19, 3, 3, 11, 21))\n out_array = utils.remove_auto_correla...
[ "0.6384935", "0.6044329", "0.59156483", "0.5629401", "0.5623146", "0.5595254", "0.5430751", "0.5413027", "0.5376466", "0.5371484", "0.5366848", "0.5294089", "0.52847147", "0.5273357", "0.5262963", "0.5236557", "0.52342147", "0.5228484", "0.5216261", "0.5215159", "0.5213868", ...
0.59414965
2
Yield successive nsized chunks from l.
def chunks(l, n): for i in range(0, len(l), n): yield l[i:i + n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]", "def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]", "def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]", "def get_chunks(self, ...
[ "0.8038813", "0.79248375", "0.7923423", "0.7885103", "0.78773195", "0.7815877", "0.77655786", "0.77556044", "0.77441615", "0.7731815", "0.77288336", "0.772473", "0.77028215", "0.76889825", "0.76889825", "0.7664208", "0.76570904", "0.7655856", "0.7655856", "0.76458347", "0.764...
0.7448925
64
Return a (argparse) parser for command arguments. The parsing can then be done using parser.parse_args(args)
def _argParser(): parser = argparse.ArgumentParser( prog='modelc', description='Compile the given sources.') if FULL_INTERFACE: for (parameter,label) in OPTIONS: parser.add_argument( '--'+parameter, dest=parameter, const=1, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command_line_parse(iargs=None):\n\n parser = create_parser()\n inps = parser.parse_args(args=iargs)\n\n return inps", "def get_parser(self):\n parser = ArgumentParser()\n parser.add_argument(\n \"-c\", default='', dest='cmd',\n help=(\"just like python -c or sh -c...
[ "0.7755324", "0.77028143", "0.7633569", "0.7585324", "0.75728416", "0.7531271", "0.7514368", "0.7500204", "0.74969023", "0.7487999", "0.7458546", "0.7423178", "0.7417605", "0.74173164", "0.74097687", "0.74097687", "0.74041635", "0.7395661", "0.73810023", "0.7360539", "0.73600...
0.0
-1
The name of the application that this session represents.
def app_name(self): return self._app_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def app_name(self) -> str:\n return self._app_name", "def application_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"application_name\")", "def application_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"application_name\")", "def app_name(self) -> pulumi.Out...
[ "0.8640284", "0.84897065", "0.84897065", "0.84262556", "0.84206855", "0.8383061", "0.8375058", "0.81801504", "0.8149001", "0.8149001", "0.8149001", "0.8149001", "0.8086944", "0.80170363", "0.7986112", "0.79020053", "0.79002017", "0.7694021", "0.76935315", "0.76209426", "0.758...
0.8681932
0
Calculate perspective transform for a road image from the test set
def birds_eye_view(ref_image): # define source and destination points for transform w, h = ref_image.shape[1], ref_image.shape[0] src = np.float32([(575,464), (707,464), (258,682), (1049,682)]) dst = np.float32([(450,0), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perspective_transform():\n src = np.float32([(220,720), (1110, 720), (570, 470), (722, 470)]) # Manually get these numbers from plot\n dst = np.float32([[320, 720], [920, 720], [320, 1], [920, 1]])\n M = cv2.getPerspectiveTransform(src, dst)\n Minv = cv2.getPerspectiveTransform(dst, src)\n\n re...
[ "0.7430655", "0.72448575", "0.71060574", "0.6953691", "0.6935786", "0.6886514", "0.68040824", "0.68033737", "0.67266864", "0.66600704", "0.6567068", "0.6540925", "0.6534466", "0.652947", "0.6489918", "0.6431671", "0.6418216", "0.634205", "0.63239664", "0.62283945", "0.6179625...
0.0
-1
Calculate perspective transform for a road image from the test set
def birds_eye_view_garching(ref_image): # define source and destination points for transform w, h = ref_image.shape[1], ref_image.shape[0] src = np.float32([(643,338), (708,338), (398,500), (957,500)]) dst = np.float32([(450,0), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perspective_transform():\n src = np.float32([(220,720), (1110, 720), (570, 470), (722, 470)]) # Manually get these numbers from plot\n dst = np.float32([[320, 720], [920, 720], [320, 1], [920, 1]])\n M = cv2.getPerspectiveTransform(src, dst)\n Minv = cv2.getPerspectiveTransform(dst, src)\n\n re...
[ "0.7431482", "0.72451717", "0.71061474", "0.69531715", "0.693581", "0.68875456", "0.6804755", "0.6804296", "0.67256", "0.6660475", "0.6567685", "0.6540974", "0.6535216", "0.6530707", "0.6490656", "0.6431617", "0.6418693", "0.6342727", "0.632436", "0.6229876", "0.6180597", "...
0.0
-1
Performs the backward pass with respect to ``loss``, as well as a gradient step or gradient accumlation. If a ``scaler`` is passed it is used to perform the gradient step (automatic mixed precision support). If a ``clip_grad`` is passed gradient will be clipped by this value considered as maximum l2 norm. ``accumulate`...
def optimizer_step( optimizer: Optimizer, loss: torch.Tensor, scaler: Optional[torch.cuda.amp.GradScaler] = None, clip_grad: Optional[float] = None, accumulate: bool = False, **params, ) -> torch.Tensor: set_params(optimizer, **params) if scaler is not None: # autocast is not re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grad_step(\n *,\n optimizer: Optimizer,\n optimizer_wds: List[float] = 0,\n grad_clip_fn: Callable = None\n ):\n for group, wd in zip(optimizer.param_groups, optimizer_wds):\n if wd > 0:\n for param in group[\"params\"]:\n param...
[ "0.63238347", "0.61002105", "0.5914328", "0.58098453", "0.58083516", "0.5770216", "0.57649887", "0.5705947", "0.57011634", "0.5699213", "0.5696014", "0.5669987", "0.5653403", "0.56514305", "0.56440586", "0.5643658", "0.56070143", "0.55805975", "0.5563239", "0.55586463", "0.55...
0.74366945
0
Returns a single random char from given letters.
def get_random_char(letters: str) -> str: return letters[random.randint(0, len(letters) - 1)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_letter(letters):\n return random.choice(letters)", "def random_char(alph):\n char = alph[rand_generator.randrange(len(alph))]\n return char", "def get_random_char():\n return chr(randint(97, 122))", "def random_char():\n return chr(random.randrange(32, 126, 1))", "def get_random_a...
[ "0.8686186", "0.8659065", "0.83927304", "0.81753415", "0.8125783", "0.7997917", "0.79541194", "0.78839564", "0.77984357", "0.76346934", "0.7435365", "0.7368929", "0.7283319", "0.7193602", "0.7127847", "0.70942557", "0.709159", "0.707191", "0.70667416", "0.69708765", "0.696336...
0.90977997
0
Generates a matrix of batch indices for the 'merged' beam tensor; each index denotes the batch from which the sequence occupying the same relative position as the index within the 'merged' tensor belongs.
def compute_batch_indices(batch_size, beam_size): batch_range = tf.range(batch_size * beam_size) // beam_size batch_index_matrix = tf.reshape(batch_range, [batch_size, beam_size]) return batch_index_matrix
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_batch_indices(batch_size: int, beam_size: int) ->torch.LongTensor:\n batch_pos = torch.arange(batch_size)\n batch_pos = batch_pos.view(-1, 1).expand(batch_size, beam_size)\n return batch_pos", "def construct_indices(after_pooling):\n our_indices = np.zeros_like(after_pooling, dtype=np.int...
[ "0.62728876", "0.6033282", "0.5998787", "0.59736156", "0.5924092", "0.5799555", "0.5715651", "0.5712429", "0.57117695", "0.56984967", "0.56859976", "0.5668897", "0.5622296", "0.5622296", "0.5622296", "0.56121147", "0.5595616", "0.5577882", "0.5537838", "0.55324566", "0.549458...
0.6476074
0
Returns 'True' if all of the sequences in the extended hypotheses exceeded the maximum specified length or if none of the extended hypotheses are more likely than the lowest scoring finished hypothesis.
def _continue_decoding(curr_time_step, alive_sequences, alive_log_probs, finished_sequences, finished_scores, finished_eos_flags, alive_memories): # C...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seq_exceeds_homopolymers(curr_seq, max_len=6):\r\n for base in 'ATGC':\r\n curr = base * (max_len + 1)\r\n if curr in curr_seq:\r\n return True\r\n return False", "def _check_max_length(self, p: list) -> bool:\n\n return (\n len(p[0].split(\" \")) < self.max_l...
[ "0.6858876", "0.65908694", "0.6355858", "0.6258919", "0.6185774", "0.6131835", "0.6103622", "0.60948825", "0.6022707", "0.60095936", "0.6002055", "0.5989526", "0.59833395", "0.5957619", "0.5935298", "0.59185594", "0.590893", "0.5870848", "0.5859513", "0.58123004", "0.58074975...
0.0
-1
Returns the function f(x) = ax^2 + bx + c
def build_quadratic_function(a, b, c): return lambda x: a*x**2 + b*x + c
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def func(f,c):\n return(f**2+c)", "def f(self, x: np.array) -> np.array:\n return self.a * x**2 + self.b * x + self.c", "def f(x):\n return ((x[0] - 1) ** 2) + ((x[1] + 3) ** 2)", "def fn(x):\n\n # coefficients\n A = 728.0\n B = 0.317\n C = 0.486\n D = -8.99 * 1.6\n\n # functio...
[ "0.8041608", "0.7799213", "0.76336646", "0.75670856", "0.75141126", "0.73687065", "0.73557436", "0.7307502", "0.73051745", "0.72963065", "0.7294468", "0.72818834", "0.72474295", "0.72461724", "0.7238463", "0.72056884", "0.7200313", "0.7171346", "0.7095455", "0.7095455", "0.70...
0.64444196
63
Returns the distance value of the closest intersection by the length of the wire's paths. The return value is the addition of the two wires' total distances.
def shortest_combined_wire_path(grid): current_minimum = sys.maxsize for crossing in grid.crossings: crossing_wires = grid.get(crossing[0], crossing[1]) crossing_total = 0 for wire in crossing_wires: crossing_total += wire['distance'] if crossing_total < cu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance(self) -> float:\n return self._dist_two_wire() # at this time we only support 2-wire meausre", "def closest_intersect_steps(self, other: Wire) -> Tuple[Intersection, int]:\n intersections = self.intersect(other)\n\n # For each intersection, iterate along each wire's path until ...
[ "0.7238766", "0.711846", "0.704656", "0.67733943", "0.6770595", "0.67062926", "0.65934193", "0.6590767", "0.6553382", "0.6520906", "0.6509929", "0.64998615", "0.64803636", "0.64801675", "0.6457368", "0.64489776", "0.64264023", "0.64161205", "0.6379374", "0.63793653", "0.63742...
0.61225826
51
Changes the predicted reward of won games to be 1 and lost games to be 0
def fix_rewards(predicts, win_status): for i, status in enumerate(win_status): if status != -1: predicts[i, :] = 0 predicts[i, int(status)] = 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reward(self, player, winning_state):\n if winning_state == \"Tie\":\n return 1\n elif winning_state == \"Resume\":\n return -1\n else:\n if player == \"agent\":\n return 10\n else:\n return -10", "def _update_rewar...
[ "0.68476295", "0.6542239", "0.65236217", "0.6486676", "0.6426589", "0.6368385", "0.634094", "0.6311143", "0.6270636", "0.62167025", "0.6215321", "0.6163636", "0.6138454", "0.61348826", "0.6134419", "0.6121837", "0.6121837", "0.6121837", "0.6121837", "0.6121837", "0.6121837", ...
0.65448886
1
Produces a QuerySet of most recent activities from actors the user follows
def stream_for_user(self, user): follows = self.filter(user=user) qs = (Action.objects.stream_for_actor(follow.actor) for follow in follows if follow.actor is not None) return reduce(or_, qs, Action.objects.none()).order_by('-timestamp')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sorted_activity(self):\n # TODO shouldn't need a normal sort when we can interleave\n # already-sorted items. or maybe that's overthinking.\n self.activity.sort(key=operator.attrgetter('timestamp'), reverse=True)\n return self.activity[:self.max_count]", "def get_performed_activi...
[ "0.63963413", "0.6322838", "0.62061393", "0.6138859", "0.59537244", "0.5939302", "0.5909962", "0.5887659", "0.5818511", "0.57783294", "0.57263815", "0.56896466", "0.56770086", "0.56539786", "0.5652413", "0.56189924", "0.56170076", "0.5616952", "0.5580442", "0.5577736", "0.556...
0.5853533
8
Produces a QuerySet of most recent activities for any actor
def stream_for_actor(self, actor): return self.filter( actor_content_type = ContentType.objects.get_for_model(actor), actor_object_id = actor.pk, ).order_by('-timestamp')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sorted_activity(self):\n # TODO shouldn't need a normal sort when we can interleave\n # already-sorted items. or maybe that's overthinking.\n self.activity.sort(key=operator.attrgetter('timestamp'), reverse=True)\n return self.activity[:self.max_count]", "def get_sorted_activitie...
[ "0.65721685", "0.62001574", "0.60457397", "0.6000678", "0.59083235", "0.58976996", "0.5872676", "0.5824743", "0.5795241", "0.57831436", "0.57393754", "0.5735533", "0.5717249", "0.57127273", "0.5695259", "0.5644351", "0.5633267", "0.56322205", "0.55978334", "0.55705935", "0.55...
0.62930703
1
Produces a QuerySet of most recent activities where the object is the object or target of the action
def stream_for_object(self, obj): return self.filter( Q(target_object_id = obj.id) | Q(action_object_object_id = obj.id) ).order_by('-timestamp')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_activities(cls):\n objs = cls.objects\n return objs", "def get_queryset(self):\n filter = {self.kwargs.get('field'): self.kwargs.get('constraint')}\n return self.get_model_obj().history.filter(**filter).order_by(\"history_id\")", "def get_last_activity(self):\n return...
[ "0.61625355", "0.6055947", "0.5974058", "0.59149086", "0.5862408", "0.582701", "0.58126163", "0.5746588", "0.5746245", "0.5683365", "0.56646484", "0.56636053", "0.5652458", "0.56212395", "0.5609553", "0.5566945", "0.5534907", "0.5531991", "0.5524681", "0.5524652", "0.5518219"...
0.56773204
10
Produces a QuerySet of most recent activities where the model is the object of the action
def stream_for_object_as_object(self, obj): return self.filter( action_object_object_id = obj.id ).order_by('-timestamp')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_activities(cls):\n objs = cls.objects\n return objs", "def sorted_activity(self):\n # TODO shouldn't need a normal sort when we can interleave\n # already-sorted items. or maybe that's overthinking.\n self.activity.sort(key=operator.attrgetter('timestamp'), reverse=Tru...
[ "0.6481345", "0.6295055", "0.6293265", "0.62208223", "0.6150074", "0.6106105", "0.6097796", "0.60893595", "0.6026985", "0.60219735", "0.59566647", "0.5905824", "0.5876594", "0.58631396", "0.58378476", "0.5804249", "0.57789636", "0.5778754", "0.5777672", "0.57625467", "0.57528...
0.0
-1
Produces a QuerySet of most recent activities where the object is the target of the action
def stream_for_object_as_target(self, obj): return self.filter( target_object_id = obj.id ).order_by('-timestamp')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_activities(cls):\n objs = cls.objects\n return objs", "def get_last_activity(self):\n return Activity.objects.filter(campaign=self.campaign, status=\"P\", contact=self.contact).latest(\"id\")", "def sorted_activity(self):\n # TODO shouldn't need a normal sort when we can int...
[ "0.62092394", "0.61107135", "0.602723", "0.5968355", "0.5959979", "0.59542656", "0.59538186", "0.5928069", "0.5840372", "0.5768274", "0.5764441", "0.5739393", "0.5713641", "0.5707903", "0.56628734", "0.565609", "0.5649256", "0.5612551", "0.56097174", "0.5599695", "0.55916727"...
0.0
-1
Returns the xdr object for this MuxedAccount object.
def to_xdr_object(self) -> stellar_xdr.MuxedAccount: if self.account_muxed_id is None: return StrKey.decode_muxed_account(self.account_id) assert self.account_muxed is not None return StrKey.decode_muxed_account(self.account_muxed)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_bytes(self) -> bytes:\n\n # for extendability\n version = ACCOUNT_DATA_STRUCTURE_VERSION\n\n flags = 0\n if self._locked:\n flags |= AccountFlag.LOCKED\n if self._c_rep:\n flags |= AccountFlag.C_REP\n\n return Account._struct.pack(version, self...
[ "0.5801153", "0.5620654", "0.5612093", "0.56108373", "0.56108373", "0.55892074", "0.55820763", "0.5455546", "0.5402483", "0.5387725", "0.53633374", "0.53633374", "0.52975523", "0.5284272", "0.5231779", "0.5222513", "0.5222513", "0.5188391", "0.5180638", "0.51757133", "0.51385...
0.78686965
0
Test moving mafs when maf column headers need to be remapped
def test_move_maf_rename(self): testdf = pd.DataFrame({"CHROMOSOME": [1]}) with patch.object(pd, "read_csv", return_value=testdf), patch.object( process_mutation, "determine_dtype", return_value=self.column_types ) as patch_determine, patch.object( process_mutation, "_con...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_filter_maf_file_cols(self):\n maf_lines = [\n ['# comment 1'], # keep the comments\n ['# comment 2'],\n ['Hugo_Symbol', 'foo_value'], # foo_value column should be removed in output\n ['SUFU', '1'],\n ['GOT1', '2']\n ]\n # run the ...
[ "0.609957", "0.56698906", "0.5660261", "0.55530846", "0.5531649", "0.5451922", "0.54350805", "0.5320638", "0.5318485", "0.530315", "0.52557296", "0.52458453", "0.5187623", "0.51815504", "0.5177608", "0.5167684", "0.51658934", "0.51644605", "0.51602894", "0.5142569", "0.512873...
0.7168869
0
Test creating dataframe when filepath passed in doesn't exist
def test_append_or_createdf_create_none_exist_path(): test_df = pd.DataFrame({"test": ["testme"]}) with patch.object(test_df, "to_csv") as patch_tocsv: process_mutation.append_or_createdf(test_df, "DNE") patch_tocsv.assert_called_once_with("DNE", sep="\t", index=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_from_file_inputdf_persists(self):\n with TemporaryDirectory() as tmp:\n fp, df_test = save_simple_dataframe(tmp, 'test.xlsx')\n df_read = BaseDataClass.from_file(fp, copy_input=True).input_df\n self.assertEqual(\n pd.testing.assert_frame_equal(df_test...
[ "0.665201", "0.6611255", "0.66100097", "0.6453065", "0.64219284", "0.63955396", "0.63221", "0.6316112", "0.63016915", "0.6277204", "0.6270761", "0.62687504", "0.6261756", "0.62181956", "0.62144756", "0.61855775", "0.61750066", "0.6172306", "0.61539656", "0.6114359", "0.611359...
0.62996244
9
Return the retention rate of each line.
def _retention_rate(self): res = {} for ret_line in self.browse(self.ids): if ret_line.invoice_id: pass else: res[ret_line.id] = 0.0 return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retention(self):\r\n return resources.Retention(self)", "def linefreq(transition) :\n return s.lineFreq(transition)", "def get_rate(timestamps):\n return (timestamps[1, 1] - timestamps[0, 1]) / (timestamps[1, 0])", "def avg_added(self):\n avg = {}\n for path, lines in self.line...
[ "0.5742648", "0.55894", "0.5566232", "0.5376354", "0.5372051", "0.536804", "0.534734", "0.52323747", "0.517202", "0.5169327", "0.5142862", "0.5090267", "0.50892943", "0.5088047", "0.50662833", "0.5050963", "0.5032424", "0.5009057", "0.49902532", "0.49800852", "0.49702197", ...
0.60757655
0
Sets the team_id of this TeamDto.
def team_id(self, team_id): self._team_id = team_id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_team(self, team):\n self.team_id = team.instance_id\n self.team_id_friendlyname = team.friendlyname\n self.team_name = team.name", "def team_identifier(self, team_identifier):\n if team_identifier is None:\n raise ValueError(\"Invalid value for `team_identifier`, mu...
[ "0.74974704", "0.7079266", "0.6972843", "0.6972843", "0.6972843", "0.6972843", "0.6717", "0.6418327", "0.6385621", "0.63508433", "0.6164747", "0.604366", "0.5974416", "0.59244937", "0.5737026", "0.56279945", "0.5544794", "0.5472106", "0.54448736", "0.54274905", "0.5409813", ...
0.8556988
1
Sets the team_name of this TeamDto.
def team_name(self, team_name): self._team_name = team_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_set_name(self, team_type: TeamType, team_name):\r\n\t\tself._teams[team_type].team_name = team_name\r\n\t\t_logger.info(\"Set the name of team {0} to \\\"{1}\\\".\" \\\r\n\t\t\t.format(team_type, team_name))", "def team_name(self, team_name):\n self.team_id = self.get_team_id(team_name)\n ...
[ "0.79264736", "0.7404456", "0.72240055", "0.69328934", "0.6778148", "0.6674635", "0.6674635", "0.6674635", "0.6674635", "0.65510285", "0.65510285", "0.65510285", "0.65510285", "0.6177862", "0.60933846", "0.5950691", "0.591123", "0.5898303", "0.5897521", "0.58969575", "0.58895...
0.84548676
0
Sets the custom_data of this TeamDto.
def custom_data(self, custom_data): self._custom_data = custom_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_custom_data(self, user_custom_data):\n\n self._user_custom_data = user_custom_data", "def __init__(self, team_id=None, team_name=None, custom_data=None): # noqa: E501 # noqa: E501\n self._team_id = None\n self._team_name = None\n self._custom_data = None\n self.discr...
[ "0.65394515", "0.6186537", "0.5999225", "0.5942151", "0.56416523", "0.56263095", "0.55940014", "0.5579955", "0.5571738", "0.5545465", "0.54118705", "0.53905165", "0.53905165", "0.53905165", "0.53905165", "0.53905165", "0.53256357", "0.5322997", "0.5322997", "0.52837986", "0.5...
0.7371998
0
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, TeamDto): 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.808826", "0.808826", "0.8054592", "0.79827315", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "0.79666996", "...
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
At least `x` of `a` and `b` `Tensors` are equal.
def _at_least_x_are_equal(a, b, x): match = tf.equal(a, b) match = tf.cast(match, tf.int32) return tf.greater_equal(tf.reduce_sum(match), x)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_equal(self, a, b):\n return a.X[0] == b.X[0]", "def assert_predictions_equal(first, second, x):\n preds1 = first.predict(x, batch_size=batch_size)\n preds2 = second.predict(x, batch_size=batch_size)\n np.testing.assert_array_equal(preds1, preds2)", "def tensors_equal(self, x, y):\n ...
[ "0.72024846", "0.70103174", "0.6976275", "0.6856269", "0.671568", "0.6702403", "0.6564142", "0.65186685", "0.6482881", "0.6456954", "0.6375332", "0.6348565", "0.63285816", "0.6302871", "0.62920105", "0.62733054", "0.6267568", "0.6266609", "0.62592125", "0.6257338", "0.6224264...
0.8409212
0
Adjust the weights test data to only span the core dimension that the function is being applied over.
def adjust_weights(dim, weight_bool, weights): if weight_bool: drop_dims = [i for i in weights.dims if i not in dim] drop_dims = {k: 0 for k in drop_dims} return weights.isel(drop_dims) else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_weights(self):\n\t\tpass", "def my_assign_weights(context, data):\n pass", "def test_feature_computation(self):\n k = [2, 3, 4, 5, 6]\n mn = self.create_chain_model(k)\n d = 4\n\n for i in range(len(k)):\n mn.set_unary_weights(i, np.random.randn(k[i], d))", ...
[ "0.61763644", "0.60896087", "0.5779569", "0.57381105", "0.5706837", "0.5647279", "0.5628892", "0.560451", "0.5588875", "0.5587478", "0.55750656", "0.5567103", "0.5558002", "0.5551067", "0.5503261", "0.5486037", "0.54854965", "0.5481398", "0.5463204", "0.5449826", "0.54374456"...
0.0
-1
Test whether distancebased metric for xarray functions (from deterministic.py) give save numerical results as for numpy functions (from np_deterministic.py).
def test_distance_metrics_ufunc_same_np( a, b, dim, weight_bool, weights_cos_lat, metrics, skipna, has_nan ): if has_nan: a[0] = np.nan # unpack metrics metric, _metric = metrics # Generates subsetted weights to pass in as arg to main function and for # the numpy testing. weights = a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_calculate_distance():\n\n r1 = np.array([0, 0, 0])\n r2 = np.array([0, 1, 0])\n\n expected_distance = 1\n\n calculated_distance = molecool.calculate_distance(r1, r2)\n\n assert expected_distance == calculated_distance", "def test_results():\n x = 0.5\n np.testing.assert_almost_equal...
[ "0.63863873", "0.60913295", "0.60851735", "0.6007944", "0.57925814", "0.57648015", "0.5733269", "0.5717609", "0.5706992", "0.56968087", "0.5666464", "0.5652567", "0.56467026", "0.56221604", "0.56218314", "0.5619822", "0.5615134", "0.56077534", "0.5602821", "0.55916107", "0.55...
0.5952812
4
Test keep_attrs for all metrics.
def test_keep_attrs(a, b, metrics, keep_attrs): metric, _metric = metrics # ths tests only copying attrs from a res = metric(a, b, "time", keep_attrs=keep_attrs) if keep_attrs: assert res.attrs == a.attrs else: assert res.attrs == {} da = xr.DataArray([0, 1, 2], dims=["time"]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_unused_attributes(self):\n all_attrs_read = collections.defaultdict(set)\n\n def _add_attrs(typ, attr_names_read):\n if typ is None:\n return\n all_attrs_read[typ] |= attr_names_read\n for base_cls in typ.__bases__:\n all_attrs_...
[ "0.5730946", "0.5615559", "0.5467264", "0.5444867", "0.54087806", "0.5399894", "0.53933066", "0.5360069", "0.52982926", "0.5297992", "0.52957344", "0.52746356", "0.5249494", "0.52462137", "0.522295", "0.5222857", "0.5184012", "0.5181019", "0.5151637", "0.5132526", "0.51320255...
0.7175717
0
Test that `dim=None` reduces all dimensions as xr.mean(dim=None) and fails for effective metrics.
def test_dim_None(a, b, metrics): metric, _metric = metrics if metric in [effective_sample_size, spearman_r_eff_p_value, pearson_r_eff_p_value]: with pytest.raises(ValueError) as excinfo: metric(a, b, dim=None) assert ( "Effective sample size should only be applied to a s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_mean(tensor, valid=None, dim=None):\n dim = () if dim is None else dim\n if valid is None:\n return tensor.mean(dim=dim)\n valid = valid.type(tensor.dtype) # Convert as needed.\n return (tensor * valid).sum(dim=dim) / valid.sum(dim=dim)", "def mean(\n self,\n dim: Dims...
[ "0.6633983", "0.6385673", "0.6259493", "0.623737", "0.6149921", "0.61486477", "0.61486477", "0.6138712", "0.6122924", "0.60890543", "0.6051227", "0.60331255", "0.60093784", "0.60093784", "0.5938308", "0.5891731", "0.5883901", "0.5874584", "0.5872978", "0.57691866", "0.5739355...
0.6717721
0
Test that `dim=[]` reduces no dimensions as xr.mean(dim=[]) and fails for correlation metrics.
def test_dim_empty_list(a, b, metrics): if metrics in correlation_metrics: metric, _metric = metrics with pytest.raises(ValueError) as excinfo: metric(a, b, dim=[]) assert "requires `dim` not being empty, found dim" in str(excinfo.value) elif metrics in distance_metrics: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mean_custom_dtype(self):\r\n # We try multiple axis combinations even though axis should not matter.\r\n axes = [None, 0, 1, [], [0], [1], [0, 1]]\r\n idx = 0\r\n for input_dtype in imap(str, theano.scalar.all_types):\r\n x = tensor.matrix(dtype=input_dtype)\r\n ...
[ "0.6270111", "0.6269739", "0.62406635", "0.6124326", "0.6032025", "0.6027202", "0.58814675", "0.5800481", "0.57783276", "0.5777277", "0.57452774", "0.57428604", "0.57402575", "0.57333547", "0.57140803", "0.5709752", "0.5708542", "0.567462", "0.56524056", "0.5613613", "0.56105...
0.66090703
0
Test whether correlation metric broadcasts dimensions other than dim.
def test_correlation_broadcasts(a, b, metrics): # unpack metrics metric, _metric = metrics metric(a, b.isel(lat=0), dim="time") metric(a, b.isel(lat=[0]), dim="time") b_changed_coords = b.isel(lat=[0]).assign_coords(lat=[123]) if ( "eff" not in metric.__name__ ): # effective metrics...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_dimensions(self, workspace_to_check):\n for i in range(self._raw_ws.getNumDims()):\n if self._raw_ws.getDimension(i).getNBins() != workspace_to_check._raw_ws.getDimension(i).getNBins():\n return False\n return True", "def test_convolve_input_dim_check(self, case, fn, x_shape, y...
[ "0.6644599", "0.6548751", "0.650936", "0.6198247", "0.61502266", "0.61379963", "0.6109381", "0.6092938", "0.5986885", "0.59820646", "0.59623456", "0.5936421", "0.5921231", "0.5909196", "0.58585566", "0.58428633", "0.5839256", "0.58179075", "0.5770494", "0.57557553", "0.572723...
0.5404486
50
Save the policy parameter vector to the given PATH.
def save(self, PATH): self._saver.save(self._sess, PATH)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, save_path):\n # params\n model_params = {\n \"batch_size\": self.batch_size,\n \"lr\": self.lr,\n \"epsilon\": self.epsilon,\n \"gamma\": self.gamma,\n \"epsilon_min\": self.epsilon_min,\n \"epsilon_decay\": self.epsilon...
[ "0.6873011", "0.6500038", "0.63687795", "0.6351313", "0.61863935", "0.6158092", "0.6057987", "0.59755", "0.5950737", "0.5924115", "0.5909149", "0.5909149", "0.5909149", "0.58992416", "0.58832693", "0.5870723", "0.5866092", "0.58633786", "0.5844345", "0.5837947", "0.5837585", ...
0.594686
9
Restore saved policy parameter vector from the given PATH.
def restore(self, PATH): self._saver.restore(self._sess, PATH)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _restore(self, a_path):\n super(RDPAnalyzer, self)._restore(a_path)\n self._model._restore()", "def restore(self, checkpoint_path: str):\r\n raise NotImplementedError", "def restore(self):\n if os.path.isfile( \\\n os.path.join(self.network_path,'net_parameters.nnprm....
[ "0.5887802", "0.5747581", "0.57451123", "0.56570965", "0.5623591", "0.56126684", "0.560569", "0.5453918", "0.54310435", "0.54148644", "0.53955996", "0.52864", "0.52862364", "0.5250133", "0.5235163", "0.5193843", "0.51691514", "0.5143465", "0.51329213", "0.5122482", "0.5110104...
0.65302485
0
Return true if the given filename appears to be binary. File is considered to be binary if it contains a NULL byte. This approach returns True for .fits files, but incorrectly reports UTF16 as binary.
def is_binary(filename): with open(filename, 'rb') as f: for block in f: if '\0' in block: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_binary(filename):\n fin = open(filename, 'rb')\n try:\n CHUNKSIZE = 1024\n while 1:\n chunk = fin.read(CHUNKSIZE)\n if '\\0' in chunk: # found null byte\n return True\n if len(chunk) < CHUNKSIZE:\n break # done\n # A-wooo!...
[ "0.8203498", "0.81073", "0.7734137", "0.7441015", "0.74408156", "0.6913967", "0.6826614", "0.674586", "0.66406864", "0.6625764", "0.654231", "0.6530945", "0.64554536", "0.64130974", "0.63910574", "0.633013", "0.6255447", "0.61884904", "0.6177324", "0.6151319", "0.61394435", ...
0.8308521
0
Private function for rank a arrays. Compute the median ignoring Nan.
def _nanmedian(arr1d, preop=None): # This only works on 1d arrays x = arr1d.copy() c = np.isnan(x) s = np.where(c)[0] if s.size == x.size: warnings.warn("All-NaN slice encountered", RuntimeWarning) return np.nan elif s.size != 0: # select non-nans at end of array eno...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nanmedian(arr, **kwargs):\r\n return ma.median( ma.masked_where(arr!=arr, arr), **kwargs )", "def _nanmedian(arr1d): # This only works on 1d arrays\n cond = 1-np.isnan(arr1d)\n x = np.sort(np.compress(cond,arr1d,axis=-1))\n if x.size == 0:\n return np.nan\n return np.median(x)", "def...
[ "0.75331664", "0.7349562", "0.7301079", "0.7256789", "0.71578264", "0.7150396", "0.7145492", "0.7036653", "0.686201", "0.68059045", "0.67676514", "0.67510784", "0.67387575", "0.6724518", "0.6705233", "0.6671147", "0.6657448", "0.6657448", "0.6657448", "0.6650114", "0.66241616...
0.7184332
4
Called by copyweights. See also splitListIntoHomogenousLists. Converts [1,2,3,5,6,7] into [[1,2,3],[5,6,7]], etc. Todd Hunter
def splitListIntoContiguousLists(mylist): mylists = [] if (len(mylist) < 1): return(mylists) newlist = [mylist[0]] for i in range(1,len(mylist)): if (mylist[i-1] != mylist[i]-1): mylists.append(newlist) newlist = [mylist[i]] else: newlist.appen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertToTwoDList(l, n):\n\treturn [l[i:i+n] for i in range(0, len(l), n)]", "def transformation_flatten(twoDlistinput):\r\n oneDlistoutput = []\r\n for i in range(len(twoDlistinput)):\r\n for j in range(len(twoDlistinput[i])):\r\n oneDlistoutput.append(twoDlistinput[i][j])\r\n ret...
[ "0.6097925", "0.59802985", "0.5952782", "0.5941847", "0.593753", "0.58956546", "0.58763796", "0.58710295", "0.5813005", "0.5805338", "0.57693607", "0.5721972", "0.5721104", "0.57113093", "0.57089496", "0.56733805", "0.562423", "0.56228364", "0.5610414", "0.55956465", "0.55807...
0.0
-1
Converts a frequency string into floating point in GHz, based on the units. If the units are not present, then the value is assumed to be GHz if less than 1000. Todd Hunter
def parseFrequencyArgumentToGHz(bandwidth): value = parseFrequencyArgument(bandwidth) if (value > 1000): value *= 1e-9 return(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xhz_to_hz(freq): \r\n freq, unit = val_to_type_unit(freq)\r\n multipliers = {'khz':1000, 'mhz':1000000, 'ghz':1000000000, 'thz':1000000000000}\r\n if unit != None:\r\n unit = unit.lower()\r\n if unit in multipliers.keys():\r\n freq *= multipliers[unit]\r\n elif unit in [None, 'h...
[ "0.6659534", "0.6636956", "0.63847065", "0.63059694", "0.60199875", "0.5982724", "0.5945536", "0.58222383", "0.5807804", "0.5731729", "0.5718253", "0.5690635", "0.5690202", "0.56700647", "0.56440336", "0.56414586", "0.5639018", "0.5603662", "0.558904", "0.5586161", "0.5581221...
0.69968146
0
Returns the number of channels in the largest group of channels in a CASA selection string.
def channelsInLargestGroup(selection): if (selection == ''): return 0 ranges = selection.split(';') largest = 0 for r in ranges: c0 = int(r.split('~')[0]) c1 = int(r.split('~')[1]) channels = c1-c0+1 if (channels > largest): largest = channels retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def largest_cc_size(ugraph):\n\tconnected = cc_visited(ugraph)\n\tmaxnum = 0\n\tfor content in connected:\n\t\tmaxnum = max(maxnum,len(content))\n\treturn maxnum", "def get_largest_cc(binary):\n cc, n_cc = measure.label(binary)\n max_n = -1\n max_area = 0\n for n in range(1, n_cc + 1):\n area ...
[ "0.6207327", "0.616134", "0.6159609", "0.6077755", "0.5945781", "0.5863727", "0.58155674", "0.5756704", "0.5669654", "0.5620904", "0.55061585", "0.5483647", "0.54618204", "0.545464", "0.5450856", "0.54202133", "0.54145676", "0.5361238", "0.53577685", "0.5351", "0.53403866", ...
0.8465952
0
Random problem command handler.
def get_random_problem(args: argparse.Namespace): problem = get_problem(random.randint(1, 757)) render_problem(problem, getattr(args, 'format', None))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def work3():\n logging.info(\"work3 doing a job\")\n if random.randint(1, 5) == 1:\n logging.error(\"Error in work3: bad input\")", "def problem_statement():\n pass", "async def _defacto(self, ctx: commands.Context):\n responses = ['DI FACTO', 'di facto']\n await ctx.send(random.cho...
[ "0.6212216", "0.6044852", "0.5877543", "0.5802901", "0.57140374", "0.5677553", "0.5634472", "0.5609472", "0.55304205", "0.5522548", "0.5516423", "0.5513836", "0.55096143", "0.5502239", "0.5493456", "0.5489194", "0.5480684", "0.54725814", "0.54601794", "0.54553986", "0.544144"...
0.67767084
0
Location is the full sequence by default.
def initialized_on_problem(self, problem, role="constraint"): def location_or_default(location): default = Location(0, len(problem.sequence), 1) return default if location is None else location location = location_or_default(self.location) reference = location_or_defaul...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location(self):\r\n\r\n raise SemanticError(\"Location not implemented\");", "def location(self, location):\n self._location = location", "def location(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"location\")", "def location(self) -> pulumi.Input[str]:\n return pulu...
[ "0.6413898", "0.60141426", "0.59690434", "0.59690434", "0.59690434", "0.59522307", "0.59030867", "0.58940643", "0.58358186", "0.58358186", "0.58358186", "0.58358186", "0.58358186", "0.58358186", "0.58358186", "0.58317435", "0.5809984", "0.5805795", "0.5805795", "0.5805795", "...
0.0
-1
two layer cnn model
def two_layers_cnn( input_layer ): # Convolutional Layer #1 # Computes 8 features using a 4x4 filter with ReLU activation. # Padding is added to preserve width and height. # Input Tensor Shape: [batch_size, NXCHANNELS, NVCHANNELS, 1] # Output Tensor Shape: [batch_size, NXCHANNELS, NVCHANNELS, 8] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cnn_2_model(input_pl, activation=tf.nn.relu, dropout=1):\n kernel1 = [1, 5, num_channels, num_kernel_1]\n kernel2 = [2, 7, num_kernel_1, num_kernel_2]\n conv1 = conv(input_pl, kernel1, activation, 'conv_1', dropout)\n # pool = tf.nn.avg_pool(conv1, ksize=[1, 1, 3, 1], strides=[1, 1, 1, 1], padding=...
[ "0.7222937", "0.7082397", "0.7017631", "0.69939375", "0.6956731", "0.69491816", "0.68690795", "0.6834718", "0.6793657", "0.671937", "0.6705467", "0.6693801", "0.6682268", "0.66788125", "0.663292", "0.6622287", "0.66078556", "0.65986174", "0.6594598", "0.65936935", "0.6593313"...
0.6246135
82
Get whether the speaker is enabled
def speaker_enabled(): return (_read_device_state() & _get_addr_for_bit(_speaker_bit)) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")", "def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")", "def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")", "def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")", "def...
[ "0.67752063", "0.67752063", "0.67752063", "0.67752063", "0.67752063", "0.67752063", "0.6770599", "0.67257386", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6702462", "0.6695559", "0.669294", "0.66723514", "0.666439...
0.88702184
0
Get the timestamp from the given tweet.
def extract_timestamp(tweet): if 'timestamp_ms' in tweet: timestamp_ms = int(tweet["timestamp_ms"]) timestamp_ms = timestamp_ms - timestamp_ms % 1000 return timestamp_ms / 1000. elif 'created_at' in tweet: return parse(tweet['created_at']).timestamp() raise KeyError("Neithe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tweet_time(tweet):\n return tweet['time']", "def get_tweet_timestamp(tid):\n offset = 1288834974657\n tstamp = (tid >> 22) + offset\n return math.floor(tstamp/1000)", "def to_local_time(self, tweet_timestamp):\n timestamp = mktime_tz(parsedate_tz(tweet_timestamp))\n return datetim...
[ "0.751573", "0.72477835", "0.6645597", "0.66382194", "0.65814024", "0.64448696", "0.63507265", "0.6346815", "0.6196693", "0.61221623", "0.6109965", "0.60660464", "0.6039353", "0.6007834", "0.59855497", "0.5981461", "0.59692085", "0.5967157", "0.59454775", "0.59452915", "0.594...
0.8435428
0
Generator associating each raw/gt files
def generate_filename(self): file_pattern = os.path.join(self.path, "TCGA-*") for f in glob(file_pattern): organ = get_organ(f) for raw_f in glob(os.path.join(f, "*.tif")): gt_f = raw_f.replace(".tif", ".xml") yield raw_f, gt_f, organ
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_examples(self, files):\n idx = 0\n for filename in files:\n with open(filename) as file:\n for line in file:\n yield idx, {\"text\": line}\n idx += 1", "def FileIter(func_name):\n \n if func_name == 'convert_pmids_t...
[ "0.6735086", "0.65885204", "0.65628415", "0.6439447", "0.6385568", "0.62957543", "0.6234873", "0.6191832", "0.6184084", "0.6116352", "0.61006", "0.6072658", "0.60466146", "0.60407096", "0.6036145", "0.603186", "0.60293067", "0.60286117", "0.6025175", "0.60115194", "0.60005033...
0.6733576
1
Strip a string and reduce all blank space to a unique space. If you set keepNewLines as True, it will keep a unique '\n' at each blank space which contains a '\n' or a '\r'
def reduceBlank(text, keepNewLines=False): if text is None: return None text = text.strip() if not keepNewLines: return re.sub(r'\s+', ' ', text) else: text = re.sub(r'\r', '\n', text) text = re.sub(r'\s*\n+\s*', '\n', text) text = re.sub(r'[ \t\f\v]+', ' ', text)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _clean(self, string):\n return re.sub('\\s+', ' ', string).strip()", "def _clean(s):\n return re.sub(r'\\s+', ' ', s.strip())", "def remove_leading_whitespace_and_empty_lines(text: str) -> str:\n # We call lstrip() twice on the same line. This is inefficient but ok for small unit tests.\n #...
[ "0.71004176", "0.7037954", "0.69996136", "0.6953316", "0.691171", "0.691074", "0.6804225", "0.6773284", "0.67648774", "0.6748245", "0.6660545", "0.6580272", "0.6579722", "0.6576516", "0.65603596", "0.6546316", "0.6492183", "0.6485254", "0.6485254", "0.6471675", "0.6452244", ...
0.74334335
0
get the selected colour scheme
def get_palette(self) -> Palette: return Palette[self.colour_combo.get().upper()]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_colour(self):\n return self.colour", "def getColor(self):\n return self._l[2]", "def get_color_mode(self):\n mode=lib.is_SetColorMode(self.hcam,0x8000)\n return self._color_modes_inv.get(mode,mode)", "def _get_color(self):\n return self.__color", "def _get_color(self)...
[ "0.69872385", "0.6737478", "0.6713789", "0.666992", "0.666992", "0.666992", "0.666992", "0.6641921", "0.66243124", "0.6605013", "0.6599017", "0.64831936", "0.6482159", "0.64804363", "0.6478638", "0.6462587", "0.644782", "0.64259386", "0.6416665", "0.64066637", "0.63862365", ...
0.6554009
11
Returns actual player score Board board int score
def getScore(self,board): return board.getScore()[self.tile]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score(self,player, board):\r\n numPlayer = 0\r\n numOpp = 0\r\n for i in self.squares():\r\n if board[i] == player:\r\n numPlayer+= SQUARE_WEIGHTS[i]\r\n else:\r\n numOpp+=SQUARE_WEIGHTS[i]\r\n return numPlayer-numOpp", "def scor...
[ "0.7855503", "0.77247196", "0.76544553", "0.7567138", "0.747234", "0.747234", "0.747234", "0.7460387", "0.7460387", "0.7346631", "0.7326815", "0.73088795", "0.72950774", "0.7275153", "0.72476554", "0.72081816", "0.72079164", "0.7156719", "0.715394", "0.7132284", "0.7130691", ...
0.7957019
0
Check if the player can make a move Board board list(c+r8) list of posible moves in 1 dimension format
def checkMoves(self,board): possibleMoves = [] for c in xrange(0,8): for r in xrange(0,8): if board.isValidMove(self.tile,c,r): possibleMoves.append(c+r*8) return possibleMoves
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def legal_moves(self, player, board):\r\n #go through the whole board and check whether the piece is on the board or not\r\n #num/row size - num%col == num2/row size - num@%col\r\n #num/row size + num%col\r\n moves = list()\r\n opp = self.opponent(player)\r\n #print(board)...
[ "0.77980137", "0.7751658", "0.7490353", "0.747995", "0.74711967", "0.7464051", "0.7432093", "0.74045986", "0.74009705", "0.7373518", "0.73627156", "0.7311106", "0.72710496", "0.7222708", "0.7182432", "0.7134961", "0.71312374", "0.71179044", "0.70766354", "0.7066609", "0.70467...
0.79902846
0
Cross product of va by vb.
def cross_product(qa, qb): qa_0 = qa[:, :, 0] qa_1 = qa[:, :, 1] qa_2 = qa[:, :, 2] qb_0 = qb[:, :, 0] qb_1 = qb[:, :, 1] qb_2 = qb[:, :, 2] # See https://en.wikipedia.org/wiki/Cross_product q_mult_0 = qa_1 * qb_2 - qa_2 * qb_1 q_mult_1 = qa_2 * qb_0 - qa_0 * qb_2 q_mult_2 = qa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vec_cross(a,b):\r\n return [a[1] * b[2] - a[2] * b[1],\r\n a[2] * b[0] - a[0] * b[2],\r\n a[0] * b[1] - a[1] * b[0]]", "def cross(u,v):\n u1, u2, u3 = u\n v1, v2, v3 = v\n return np.array([u2*v3 - u3*v2,\n u3*v1 - u1*v3,\n ...
[ "0.7219093", "0.70910263", "0.7081996", "0.70207", "0.6984819", "0.6879287", "0.6851017", "0.68318456", "0.6807848", "0.68008584", "0.6799326", "0.67720944", "0.67500484", "0.6616882", "0.66131854", "0.65886015", "0.6556904", "0.65076023", "0.64794654", "0.6475932", "0.636959...
0.61648786
36
Rotate points by quaternions.
def quat_rotate(X, q): # repeat q along 2nd dim ones_x = X[[0], :, :][:, :, [0]] * 0 + 1 q = torch.unsqueeze(q, 1) * ones_x q_conj = torch.cat([q[:, :, [0]], -1 * q[:, :, 1:4]], dim=-1) X = torch.cat([X[:, :, [0]] * 0, X], dim=-1) X_rot = hamilton_product(q, hamilton_product(X, q_conj)) re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def qrotate(points, axis, theta):\n q = Quaternion.rotator(axis, theta)\n return q.rotate(points)", "def rotate_points(points,quaternions):\n \n res = np.zeros((quaternions.shape[0],points.shape[0],4)) \n res[:,:,1:] = points \n conjugates = conjugate(quaternions) \n \n f...
[ "0.79838574", "0.77192706", "0.7698028", "0.75039345", "0.7125828", "0.6768124", "0.66302985", "0.6611916", "0.652839", "0.64440787", "0.64172006", "0.64088035", "0.6362208", "0.6334814", "0.6297914", "0.6279539", "0.6245257", "0.611538", "0.6115277", "0.60798615", "0.6071520...
0.6787695
5
Calculate the histogram of an image on r, g, b
def histogram(img): BINS = 8 RANGE = np.tile(np.array([0, 255]), (3, 1)) # histogram of the first image r = np.ravel(img[:, :, 0]) g = np.ravel(img[:, :, 1]) b = np.ravel(img[:, :, 2]) hist, endpoints = np.histogramdd([r, g, b], bins = BINS, range = RANGE) # normalize the images re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_histogram(self, image):\n hist = [0] * 256\n [h, w] = image.shape\n print(h,w)\n i = 0\n while i < 256:\n for row in range(h):\n for col in range(w):\n if image[row, col] == i:\n hist[i] += 1\n ...
[ "0.73510206", "0.73195577", "0.72917515", "0.71590394", "0.7074251", "0.6975748", "0.69430894", "0.69259137", "0.69240725", "0.6875815", "0.6864523", "0.6803694", "0.67591286", "0.67297846", "0.67021245", "0.6690459", "0.6687008", "0.6677851", "0.66752255", "0.66494393", "0.6...
0.75960964
0
Reset the internal state to mean value.
def reset(self): self.state = copy.copy(self.mu)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_mean(self,new_mean):\n self.mean = new_mean\n return", "def reset_mean(self,new_mean):\n self.mean = new_mean\n return", "def reset_average(self):\n self._total_time = 0\n self._average_time = 0\n self._calls = 0", "def reset(self):\n self.ref...
[ "0.8142677", "0.8142677", "0.75402176", "0.7497922", "0.74893606", "0.74782056", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7336197", "0.7135869", "0.7073691", "0.70692", "0.7061524", ...
0.7340097
6
Add a new experience to memory.
def add(self, state, action, reward, next_state, done): e = self.experience(state, action, reward, next_state, done) self.memory.append(e)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_new_experience(self, state, action, reward, next_state, done):\n e = self.experience(state, action, reward, next_state, done, self.max_priority)\n self.memory.append(e)", "def add(self, state, action, reward, next_state, done):\n experience = Experience(state, action, reward, next_st...
[ "0.79570484", "0.79044235", "0.7879639", "0.75771767", "0.7570595", "0.74472857", "0.7361078", "0.7269946", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.7198787", "0.71452063", "0.710669",...
0.72183806
8
Return the current size of memory.
def __len__(self): return len(self.memory)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSize(self) -> int:\n return len(self.mem)", "def memsize(self):\n return self.xlist(\"get-memsize\")[1][0] * 1024", "def get_total_memory_size(self):\n return self.drt_manager.get_total_memory_size()", "def getSize(self):\n return self.bf.memory()", "def total_memory(self):\n...
[ "0.8533664", "0.8442759", "0.8356692", "0.8180822", "0.8138444", "0.80357385", "0.80304694", "0.80254656", "0.79680574", "0.79384464", "0.78658336", "0.7861912", "0.78567755", "0.78204757", "0.7810105", "0.770134", "0.76985765", "0.76985765", "0.7689115", "0.7681313", "0.7668...
0.7434966
61