query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
calculate the yaw of the object
def computeYaw(Vx, Vy): #print(Vx, Vy) if Vx > 0: if Vy > 0: angle = (math.degrees(math.atan2(Vy,Vx)))#+ how far it is from the x axis) #print(angle) return angle elif Vy < 0: angle = (math.degrees(math.atan2(Vy,Vx)) )#- how far from x axis) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def yaw(self):\n return self._yaw", "def get_yaw(self):\r\n return self.state['yaw']", "def yawAngle(self):\n return self._yawAngle", "def yaw_pitch_roll(self):\n\n self._normalise()\n yaw = np.arctan2(2*(self.q[0]*self.q[3] - self.q[1]*self.q[2]),\n 1 - 2*(self....
[ "0.8203095", "0.78113264", "0.77804077", "0.75509167", "0.74476653", "0.73709863", "0.7311812", "0.7227242", "0.7172307", "0.71263266", "0.68762624", "0.68734187", "0.6838946", "0.68307424", "0.6699847", "0.66728705", "0.6631705", "0.65682185", "0.6424747", "0.6411919", "0.63...
0.71707344
9
Convert coordinates into pygame coordinates.
def convert_coords(x, y, conversion): if conversion == "cartesian" : # convert to cartesian plane coordinates x_new = x - (width/2) y_new = (height/2) + y elif conversion == "pygame": # only needed to place images in pygame x_new = x + (width/2) y_new = (height...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_pygame(coords):\r\n return (coords[0], HEIGHT - coords[1])", "def to_pygame_coords(self, coords):\n coords = Vector(coords)\n if Window.FollowPlayer:\n # offset coords by screen center\n coords = coords + (self.size * .5)\n # offset coords by centered_obj\...
[ "0.78059673", "0.7273889", "0.7208624", "0.6877637", "0.6870061", "0.6828133", "0.6746528", "0.66239125", "0.66116726", "0.6578236", "0.6463106", "0.6436829", "0.64202493", "0.63641745", "0.6275642", "0.62741685", "0.6270626", "0.6260293", "0.6182381", "0.6165396", "0.6151951...
0.6974331
3
Set all parameters of the model to 0 Parameters. layers_dims list, the number of layers of the model and the number of nodes corresponding to each layer Returns parameters a dictionary containing all W and b W1 weight matrix with dimension (layers_dims[1], layers_dims[0]) b1 bias vector, dimension (layers_dims[1], 1) W...
def initialize_parameters_zeros(layers_dims): parameters = {} # the number of layers L = len(layers_dims) for l in range(1, L): parameters["W" + str(l)] = np.zeros((layers_dims[l], layers_dims[l - 1])) parameters["b" + str(l)] = np.zeros((layers_dims[l], 1)) return parameters
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_parameters_random(layers_dims):\n # set random seed\n np.random.seed(3)\n parameters = {}\n L = len(layers_dims)\n\n for l in range(1, L):\n parameters['W' + str(l)] = np.random.randn(layers_dims[l], layers_dims[l - 1]) * 10\n parameters['b' + str(l)] = np.zeros((layers_...
[ "0.66994137", "0.6524211", "0.6484232", "0.6440478", "0.64257056", "0.63918364", "0.6384597", "0.63792133", "0.6360458", "0.63285124", "0.6324615", "0.6255973", "0.61910826", "0.61910826", "0.61910826", "0.61248976", "0.609352", "0.6068253", "0.6025813", "0.6024569", "0.59612...
0.80968946
0
the parameter's dim is same as above
def initialize_parameters_random(layers_dims): # set random seed np.random.seed(3) parameters = {} L = len(layers_dims) for l in range(1, L): parameters['W' + str(l)] = np.random.randn(layers_dims[l], layers_dims[l - 1]) * 10 parameters['b' + str(l)] = np.zeros((layers_dims[l], 1)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dim(self) -> int:", "def dimension(self):", "def dim(self):\n raise NotImplementedError", "def dim(self):\n raise NotImplementedError()", "def __call__(self, *args):\n return args[self.i_dim]", "def dim(self) -> int:\n pass", "def dim(self):\n return (self.n, )", ...
[ "0.781317", "0.7463058", "0.7403146", "0.7294205", "0.72452676", "0.71214265", "0.692741", "0.6892263", "0.68439007", "0.6780016", "0.6690328", "0.665558", "0.6597072", "0.6597072", "0.65559304", "0.6551745", "0.653437", "0.65108186", "0.6459135", "0.6456878", "0.64568514", ...
0.0
-1
Compute conventional batch mean and variance.
def _compute_batch_moments(x): return torch.mean(x, dim=(0, 2, 3), keepdim=True), torch.var(x, dim=(0, 2, 3), keepdim=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batch_stat(x):\n\tmean = torch.mean(x, dim=[0, 2, 3], keepdim=True)\n\tvar = torch.mean((x-mean)**2, dim=[0, 2, 3], keepdim=True)\n\treturn mean, var", "def _compute_mean_std(self, sum_, ssum, size):\n assert size > 1, 'BatchNorm computes unbiased standard-deviation, which requires size > 1.'\n ...
[ "0.7335093", "0.7076149", "0.7028218", "0.6966497", "0.6955343", "0.67826116", "0.6779366", "0.66976017", "0.66172445", "0.65709674", "0.6552331", "0.65507686", "0.6510585", "0.65076244", "0.6413702", "0.6331475", "0.6327264", "0.6293395", "0.62796533", "0.62605953", "0.62585...
0.7130227
1
Compute instance mean and variance.
def _compute_instance_moments(x): return torch.mean(x, dim=(2, 3), keepdim=True), torch.var(x, dim=(2, 3), keepdim=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_calculate_nhpp_mean_variance_inst_mean(self):\n\n _mean_var = calculate_nhpp_mean_variance(46, 3000.0, 0.332, 0.616, 2)\n self.assertAlmostEqual(_mean_var, 489.07164965)", "def get_mean_and_variance(self):\n self._set_statistics()\n return self.statistics_object.get_mean(), s...
[ "0.7042789", "0.7030097", "0.684569", "0.6785732", "0.6705467", "0.65460956", "0.6473726", "0.6455855", "0.64296347", "0.6423424", "0.64022136", "0.63945234", "0.6373781", "0.6314979", "0.6271918", "0.6263915", "0.62379485", "0.6202545", "0.61835915", "0.6181711", "0.6178875"...
0.7274688
0
Compute layer mean and variance.
def _compute_layer_moments(x): return torch.mean(x, dim=(1, 2, 3), keepdim=True), torch.var(x, dim=(1, 2, 3), keepdim=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_mean(self):\n return [layer._get_mean() for layer in self.layers]", "def variance(self, mean=None):\n raise NotImplementedError", "def mean(self):\n return self.vmean", "def _compute_mean_variance(self, mean_dict: Dict) -> None:\n self.eval_dict = defaultdict()\n f...
[ "0.68845415", "0.68721896", "0.68708557", "0.6631005", "0.6604006", "0.6520616", "0.6506461", "0.6493008", "0.6486367", "0.64617854", "0.643203", "0.639767", "0.6389797", "0.6380059", "0.6377723", "0.6370964", "0.63681614", "0.636281", "0.6351963", "0.6349545", "0.6343845", ...
0.69694275
0
Combine batch moments with augment moments using blend factor alpha.
def _compute_pooled_moments(x, alpha, batch_mean, batch_var, augment_moment_fn): augment_mean, augment_var = augment_moment_fn(x) pooled_mean = alpha * batch_mean + (1.0 - alpha) * augment_mean batch_mean_diff = batch_mean - pooled_mean augment_mean_diff = augment_mean - pooled_mean ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alpha_blend(input_image, segmentation_mask, alpha=0.5):\n blended = np.zeros(input_image.size, dtype=np.float32)\n blended = input_image * alpha + segmentation_mask * (1 - alpha)\n return blended", "def blending_example2():\n pic_earth = read_image(relpath(\"./externals/pic_earth.jpg\"), 2)\n ...
[ "0.59165734", "0.57801425", "0.57290673", "0.56443745", "0.5604431", "0.5587423", "0.55799013", "0.55666465", "0.55648756", "0.55581915", "0.55063105", "0.5502954", "0.5480455", "0.5472708", "0.5440756", "0.5434398", "0.5434398", "0.5413661", "0.5396812", "0.53911597", "0.538...
0.6051326
0
The parameters here get registered after initialization because the pretrained resnet model does not have these parameters and would fail to load if these were declared at initialization.
def register_extra_weights(self): device = self.weight.device # Initialize and register the learned parameters 'a' (SCALE) and 'b' (OFFSET) # for calculating alpha as a function of context size. a = torch.Tensor([0.0]).to(device) b = torch.Tensor([0.0]).to(device) self.r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _set_training_params(self, params):\n self.lyapunov_hybrid_system.lyapunov_relu.load_state_dict(\n params[\"lyap_relu_params\"])\n if not self.R_options.fixed_R:\n self.R_options._variables = params[\"R_params\"].clone()\n if isinstance(self.lyapunov_hybrid_system.sys...
[ "0.68823785", "0.6851002", "0.6845517", "0.6694499", "0.6601292", "0.6566945", "0.6486249", "0.64748377", "0.6469585", "0.64005995", "0.63946164", "0.6357663", "0.6351537", "0.63105786", "0.6289853", "0.62844247", "0.62796485", "0.62754023", "0.62484515", "0.6247907", "0.6222...
0.0
-1
Provides the function to compute augment moemnts.
def _get_augment_moment_fn(self): pass # always override this function
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_augment_moment_fn(self):\n return self._compute_instance_moments", "def augment(self, image):\n pass", "def apply_augmentations(self, x, augmentations):\r\n # print(\"\\n#####################\\nSQDataset.apply_augmentations: x shape == \", x.shape)\r\n # print(\"SQDataset.a...
[ "0.64456785", "0.63316554", "0.62134147", "0.61737436", "0.6164592", "0.6051583", "0.60132986", "0.6005452", "0.5988301", "0.59473735", "0.5941723", "0.5938459", "0.5922076", "0.5920503", "0.58844405", "0.5810467", "0.57589525", "0.5726853", "0.56997806", "0.56924295", "0.569...
0.635719
1
Override the base class to get the function to compute instance moments.
def _get_augment_moment_fn(self): return self._compute_instance_moments
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moments(self):", "def _compute_instance_moments(x):\n return torch.mean(x, dim=(2, 3), keepdim=True), torch.var(x, dim=(2, 3), keepdim=True)", "def _get_augment_moment_fn(self):\n pass # always override this function", "def getMomentum(self):\n return self.p", "def _moments_match_nume...
[ "0.7662759", "0.68491524", "0.68225145", "0.57082653", "0.56545275", "0.56478214", "0.5608952", "0.55368495", "0.5529006", "0.5525961", "0.5501195", "0.54991955", "0.54955935", "0.5492941", "0.5492941", "0.54882663", "0.53813344", "0.53759295", "0.53658104", "0.532169", "0.53...
0.7838273
0
RadiationModel() returns a DataFrame of which the size depends on the input. The time resolution for the output is a quarter ("15T") by default but can be changed with the "TimeResolution" parameter.
def __init__(self, t0, t1, hours=("00:00", "23:45"), forecast_zones="DK", norm=False, TimeResolution="15T"): self.t0 = t0 self.t1 = t1 self.muni_input = forecast_zones self.norm = norm self.Time = TimeResolution self.fc_zones = self._muni_interpr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compute_TTR(self) -> pd.DataFrame:\n\n # user options\n res = self.options.resolution\n dim = self.options.dimension\n\n # sample the corpus\n x_choices = (np.arange(res) + 1) / res\n TTR = [self.sample(x=x).as_datarow(dim) for x in x_choices]\n\n # save to sel...
[ "0.566602", "0.55865186", "0.55567604", "0.55247164", "0.5453741", "0.54424953", "0.5365442", "0.5311694", "0.5263339", "0.52498996", "0.5234416", "0.52332824", "0.52237743", "0.52104026", "0.5177271", "0.515588", "0.5075149", "0.50734264", "0.5069924", "0.5063935", "0.506119...
0.0
-1
Handles muni input as either list (or array like) or some predefined strings.
def _muni_interpreter(self, muni_input): if isinstance(muni_input, (list, tuple, np.ndarray)): return(muni_input) elif muni_input == "all": if not hasattr(self, 'muni_info'): self._load_muni_info() return(list(self.muni_info.index[3:])) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input2strlist_nomapfile(invar):\n \n str_list = None\n if type(invar) is str:\n if invar.startswith('[') and invar.endswith(']'):\n str_list = [f.strip(' \\'\\\"') for f in invar.strip('[]').split(',')]\n else:\n str_list = [invar.strip(' \\'\\\"')]\n elif type(in...
[ "0.61064446", "0.6048012", "0.60012585", "0.5989305", "0.5966896", "0.5906677", "0.59033054", "0.58828855", "0.5752301", "0.57429147", "0.5707196", "0.5682213", "0.5681342", "0.5658818", "0.5644289", "0.5642251", "0.5619448", "0.5618888", "0.55098224", "0.548022", "0.54716176...
0.6802392
0
Make sure we can store a string and retrieve it.
def test_put_and_get(): test_key = 'qmk_compiler_test_unique_key_name' # Make sure our test key doesn't exist try: qmk_storage.get(test_key) raise RuntimeError('%s exists on S3 when it should not!' % test_key) except Exception as e: if e.__class__.__name__ != 'NoSuchKey': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_string(self, string: str) -> None:", "def test_get_value_str(self):\n val = self.setting_str.get_value()\n self.assertIsInstance(val, str)\n self.assertEqual(val, 'test')", "def test_get_value_str(self):\n val = self.setting_str.get_value()\n self.assertIsInstance(v...
[ "0.7784715", "0.6122228", "0.6122228", "0.61021465", "0.59463865", "0.59263575", "0.5916713", "0.58905464", "0.5887827", "0.58563024", "0.58510256", "0.58482605", "0.58470726", "0.58311313", "0.5813009", "0.5805731", "0.5805206", "0.5759576", "0.57541996", "0.5738663", "0.571...
0.0
-1
Create and then delete an object from s3, make sure we can't fetch it afterward.
def test_delete(): test_key = 'qmk_compiler_test_unique_key_name' # Make sure our test key doesn't exist try: qmk_storage.get(test_key) raise RuntimeError('%s exists on S3 when it should not!' % test_key) except Exception as e: if e.__class__.__name__ != 'NoSuchKey': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _removeAWSS3Object(self, path: str):\n log.warning(f'Deleting AWS S3 object {path}')\n bucket, key = storage_utils.SplitStoragePath(path)\n s3_client = boto3.client('s3')\n try:\n s3_client.delete_object(Bucket=bucket, Key=key)\n except Exception as error: # pylint: disable=broad-except\n ...
[ "0.7155508", "0.69353044", "0.66972363", "0.6665433", "0.6630202", "0.66159564", "0.65772355", "0.6512925", "0.64956784", "0.6417047", "0.63897026", "0.6348161", "0.627056", "0.6259172", "0.6250383", "0.61582154", "0.6149929", "0.6120848", "0.6094047", "0.60888565", "0.603231...
0.56207746
69
Make sure we can list objects on S3.
def test_list_objects(): x = 0 for obj in qmk_storage.list_objects(): assert 'Key' in obj assert type(obj.get('LastModified')) == datetime.datetime if x > 5: break x += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_public_s3_objects(self):\n _response = urllib.urlopen(self.options.s3_bucket_url)\n _html = _response.read()\n\n if LOCAL_DEBUG:\n print _html\n\n try:\n assert \"AccessDenied\" not in _html\n assert \"NoSuchBucket\" not in _html\n except:\n print(\"ERROR: AccessDenied o...
[ "0.7614375", "0.7051694", "0.67730415", "0.6648005", "0.6610973", "0.66037107", "0.6603098", "0.65443665", "0.6526971", "0.634856", "0.6333928", "0.6296448", "0.62847036", "0.62788695", "0.62781334", "0.6244884", "0.6211903", "0.62019926", "0.6147974", "0.61345005", "0.613410...
0.0
-1
Make sure we can stream filelike objects to S3.
def test_save_fd(): test_key = 'qmk_compiler_test_unique_key_name' # Make sure our test key doesn't exist try: qmk_storage.get(test_key) raise RuntimeError('%s exists on S3 when it should not!' % test_key) except Exception as e: if e.__class__.__name__ != 'NoSuchKey': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _s3_stash(self):\n s3_url = 's3://{}/{}'.format(BUCKET, self.atom_file)\n bucketpath = BUCKET.strip(\"/\")\n bucketbase = BUCKET.split(\"/\")[0]\n parts = urlparse.urlsplit(s3_url)\n mimetype = 'application/xml' \n \n conn = boto.connect_s3()\n\n try:\n ...
[ "0.6714194", "0.6538487", "0.64656186", "0.6400292", "0.62917095", "0.62451416", "0.6186291", "0.6185394", "0.6147944", "0.61407965", "0.6138119", "0.61183417", "0.61051106", "0.610099", "0.60936815", "0.6061965", "0.60556763", "0.60543287", "0.6051277", "0.6039379", "0.60314...
0.0
-1
Make sure we can store a file and retrieve it.
def test_save_file(): test_key = 'qmk_compiler_test_unique_key_name' # Make sure our test key doesn't exist try: qmk_storage.get(test_key) raise RuntimeError('%s exists on S3 when it should not!' % test_key) except Exception as e: if e.__class__.__name__ != 'NoSuchKey': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store(self, filename):", "def ensure_file(self):\n if not self.has_file():\n raise AttributeError(\"No file set\")", "def test_get_file(self):\n django_file = None\n \n with open(TEST_AVATAR_PATH, 'rb') as avatar:\n self.user.avatar_tmp = File(avatar)\n ...
[ "0.6567378", "0.6410996", "0.6294041", "0.62256885", "0.6012488", "0.60082453", "0.5987928", "0.59667057", "0.59397805", "0.5928058", "0.5901034", "0.58676183", "0.58391476", "0.58256185", "0.58020294", "0.5774438", "0.5768754", "0.57649964", "0.57503694", "0.57429343", "0.57...
0.0
-1
Make sure we can get a file with a filelike interface
def test_get_fd(): test_key = 'qmk_compiler_test_unique_key_name' # Make sure our test key doesn't exist try: qmk_storage.get(test_key) raise RuntimeError('%s exists on S3 when it should not!' % test_key) except Exception as e: if e.__class__.__name__ != 'NoSuchKey': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_file_object(self):\n pass", "def _file_format_adapter(self):\n raise NotImplementedError", "def _get_file_object(inputfile=None):\n if type(inputfile) == str:\n return open(inputfile, 'r')\n return inputfile", "def _get_filelike(string, encoding):\n import _io as io...
[ "0.7177712", "0.68210065", "0.6792964", "0.64844126", "0.64717895", "0.63765824", "0.63413405", "0.6337909", "0.6312321", "0.6231084", "0.62086606", "0.6177126", "0.6120128", "0.61107844", "0.6102432", "0.609374", "0.60691303", "0.6064178", "0.6041926", "0.6038978", "0.603695...
0.0
-1
This takes the number to guess and the guess and compares them
def compare(number_to_guess, guess): if guess > number_to_guess: print('Too high. \n Guess again') elif guess < number_to_guess: print('Too low. \n Guess again') else: print(f'You got it! The answer was {number_to_guess}')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_guess(number, guess):\r\n if number == guess:\r\n return False, \"you won.\"\r\n elif number < guess:\r\n return True, \"too high.\"\r\n else:\r\n return True, \"too low.\"", "def checkGuess(guess, secretNum): \n if guess < secretNum:\n return \"Your guess is ...
[ "0.7632458", "0.7420763", "0.7156625", "0.7070007", "0.7053276", "0.6971584", "0.6961167", "0.69260126", "0.6814522", "0.67901284", "0.6761293", "0.67394257", "0.6682385", "0.6645885", "0.6593592", "0.6592362", "0.6556644", "0.65454453", "0.65333205", "0.65158445", "0.6447257...
0.76252204
1
Update the neb energies and forces
def get_neb_energies_forces(self): energies = [] forces = [] for i in self.path.inner_images: e, f = self.model.predict_energy_and_forces(i) energies.append(e) forces.append(f) self.model_forces = forces self.energies[1:-1] = energies s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_forces(self):\r\n # update all the functions\r\n self.compute_gravity()\r\n self.compute_tides()\r\n self.compute_centrifugal()\r\n self.compute_coriolis()\r\n\r\n # add together the forces into the summation function\r\n self.forcing.assign(self.ftides+s...
[ "0.7071552", "0.7028039", "0.6974602", "0.60360223", "0.60316986", "0.6016974", "0.5976503", "0.59699845", "0.5962121", "0.5897876", "0.5874239", "0.58718544", "0.584177", "0.58307546", "0.5797778", "0.5794067", "0.578954", "0.5766696", "0.57582974", "0.575816", "0.5734929", ...
0.71072215
0
Update CI NEB energies and forces for images of indices
def get_ci_energies_forces(self, indices: List[int]): self.get_neb_energies_forces() for i in indices: if i < 1 or i > len(self.path) - 2: raise ValueError('Index %d is at boundary' % i) self.forces[i] = self.model_forces[i] - 2 * np.sum(self.model_forces[i] * sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_neb_energies_forces(self):\n energies = []\n forces = []\n for i in self.path.inner_images:\n e, f = self.model.predict_energy_and_forces(i)\n energies.append(e)\n forces.append(f)\n self.model_forces = forces\n self.energies[1:-1] = energ...
[ "0.59176993", "0.5626548", "0.5580271", "0.5580271", "0.55643463", "0.5498005", "0.540635", "0.5385511", "0.53412944", "0.53172666", "0.5275748", "0.5260982", "0.52208763", "0.52207667", "0.52154756", "0.5145676", "0.5142759", "0.51413727", "0.5129286", "0.5127432", "0.512379...
0.63668287
0
Opinion Lexicon (or Sentiment Lexicon) Bing Liu (~6.800 entries)
def read_bing_liu(): fp = ta_config.BING_LIU_positive fn = ta_config.BING_LIU_negative lexicon = defaultdict() with open(fp, "r") as raw_file: reader = csv.reader(raw_file) for i in range(35): next(reader) for row in reader: lexicon[row[0].replace("-", "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def performLexiconBasedSentimentAnalysis(data):\n opinions = data[0]\n taggedTweets = data[3]\n sentiments_mapping = lexiconBasedSentimentPrediction(\n taggedTweets) # identify the sentiment orientation of each tweet\n for key in sentiments_mapping:\n opinions[key].setSO(sentiments_mappi...
[ "0.66169864", "0.63280505", "0.62549835", "0.60124046", "0.5934756", "0.59308743", "0.589986", "0.5878562", "0.5845378", "0.57806647", "0.5737055", "0.57287276", "0.57061267", "0.5689893", "0.568618", "0.56512994", "0.5585707", "0.55769116", "0.55455333", "0.5544087", "0.5541...
0.5265308
64
MPQA (MultiPerspective Question Answering) Subjectivity Lexicon (8.222 entries)
def read_mpqa(): fname = ta_config.MPQA with open(fname, "r") as f: lines = f.read().splitlines() entries = [tuple(line.split("\t")) for line in lines] lexicon = defaultdict(dict) for entry in entries: priorpolarity = entry[5].split('=')[1] pos_map = {'no...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def possession_ques(analysis):\n\n #processing as statement\n phrase = statement(analysis)\n\n #We have to know if it is plural or singular\n if other_functions.plural_noun(analysis.sn) == 1:\n return ['whose'] + phrase[:len(phrase) - 1] + ['these'] + ['?']\n else:\n return ['whose'] +...
[ "0.5961933", "0.5959305", "0.58352005", "0.58204293", "0.575788", "0.57116324", "0.5685468", "0.56761533", "0.5612229", "0.5584282", "0.5581954", "0.5495818", "0.5487884", "0.5465028", "0.5460172", "0.5444511", "0.5440515", "0.5398719", "0.53861916", "0.53840286", "0.5369511"...
0.74378127
0
AFINN is a list of English words rated for valence with an integer between minus five (negative) and plus five (positive). The words have been manually labeled by Finn Arup Nielsen in 20092011. The file is tabseparated 2477 words and phrases.
def read_affin(): filename = ta_config.AFFIN with open(filename, "r") as f: reader = csv.reader(f, delimiter="\t") lexicon = defaultdict(dict) for row in reader: word = row[0] score = row[1] lexicon[word] = { "positive": 1 if score > 0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_afinn():\n \n afinn = dict()\n print(\"Reading Afinn words........\")\n with open('AFINN-111.txt', 'r') as val:\n for line in val:\n l = line.strip().split()\n if len(l) == 2:\n afinn[l[0]] = int(l[1])\n\n print(' %d AFINN words are read.' % (len(...
[ "0.6993629", "0.611835", "0.5791885", "0.5501247", "0.5458271", "0.5242966", "0.518413", "0.5075442", "0.506856", "0.49806586", "0.49069563", "0.48904803", "0.48904535", "0.48791325", "0.48773", "0.48743063", "0.48621935", "0.4858531", "0.48235747", "0.48226544", "0.48213983"...
0.561662
3
Parse the xml file
def parseXML(xmlFile, strL): f = open(xmlFile) xml = f.read() f.close() tree = etree.parse(BytesIO(xml.encode('utf-8'))) #context = etree.iterparse(BytesIO(xml.encode('utf-8'))) data = tree.getroot() blockID = '0' for action in data: if action.get('id') == '1': blockID = action.get('id') strL...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __parse(self):\n\t\tparser=xml.sax.make_parser()\n\t\tparser.setContentHandler(OSMXMLFileParser(self))\n\t\tparser.parse(self.filename)\n\t\n\t\t# convert them back to lists\n\t\tself.nodes = self.nodes.values()\n\t\tself.ways = self.ways.values()\n\t\tself.relations = self.relations.values()", "def parsexml...
[ "0.75176644", "0.74928975", "0.7201614", "0.7178409", "0.7175466", "0.7081453", "0.69014853", "0.6880011", "0.6851029", "0.68418354", "0.67601335", "0.6757079", "0.6751641", "0.6712353", "0.6670032", "0.6667893", "0.66315633", "0.6615761", "0.6610617", "0.66074437", "0.656138...
0.5956294
58
Qlearning is based on DISCRETE actions. Therefore, if we want to correct for Zernike aberrations which are continuous, we have to discretize the action space
def __init__(self, N_zern, initial_state, DM_stroke=0.05): aberration_correction = [DM_stroke, -DM_stroke] self.ACTION = N_zern * aberration_correction ### Initialize Zernike polynomials x = np.linspace(-1, 1, self.N_pix, endpoint=True) xx, yy = np.meshgrid(x, x) rho, t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def learn(self, state, action, reward, next_state):\r\n\r\n \"\"\"Please Fill Your Code Here.\r\n \"\"\"\r\n self.Q[state][action] = self.Q[state][action] + self.alpha * (reward + self.gamma * max(self.Q[next_state]) - self.Q[state][action])\r\n\r\n return 0", "def choose_action( self...
[ "0.66756207", "0.65098524", "0.65061414", "0.6481986", "0.63933593", "0.6383092", "0.6234665", "0.6221809", "0.6213232", "0.61575735", "0.61553764", "0.61485934", "0.6123872", "0.61120117", "0.60807794", "0.5981917", "0.59812754", "0.5977964", "0.5975286", "0.5967645", "0.595...
0.0
-1
Compute the PEAK of the PSF without aberrations so that we can normalize everything by it
def peak_PSF(self): return self.compute_PSF(np.zeros(self.N_zern))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def peak_PSF(self):\n im, strehl = self.compute_PSF(np.zeros(self.N_act))\n return strehl", "def pulp_smash():", "def cal_pn(grams_set, grams, candidate, reference):\n count = 0\n for gram in grams_set:\n # print(gram)\n count += count_clip(gram, grams, reference)\n # calcu...
[ "0.60213965", "0.5855361", "0.5634777", "0.5621128", "0.5568037", "0.55468833", "0.5537976", "0.55128574", "0.54912055", "0.5485965", "0.538236", "0.5360213", "0.53334594", "0.53278303", "0.5325024", "0.53225136", "0.5314099", "0.5313874", "0.52809626", "0.5279202", "0.527653...
0.5827183
2
Creates an epsilongreedy policy based on a given Qfunction and epsilon. Returns a function that takes the state as an input and returns the probabilities for each action in the form of a numpy array of length of the action space(set of possible actions).
def createEpsilonGreedyPolicy(Q, epsilon, num_actions): def policyFunction(state): Action_probabilities = np.ones(num_actions, dtype=float) * epsilon / num_actions best_action = np.argmax(Q[state]) Action_probabilities[best_action] += (1.0 - epsilon) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createEpsilonGreedyPolicy(Q, epsilon, num_actions):\n def policyFunction(state):\n\n Action_probabilities = np.ones(num_actions,\n dtype = float) * epsilon / num_actions\n\n best_action = np.argmax(Q[state])\n Action_probabilities[best_action] += (1.0 - epsilon)\n ...
[ "0.85712636", "0.79445827", "0.7728248", "0.7678616", "0.76707244", "0.75580287", "0.7514789", "0.744547", "0.73657966", "0.73407954", "0.7282954", "0.7080421", "0.7035401", "0.70255274", "0.69141966", "0.6895311", "0.6749669", "0.6707011", "0.6700968", "0.6691628", "0.667362...
0.8536859
1
Gets inventory for user with ``user_id``.
def get_ingredients_in_progress(cls, user_id: str) -> list: ingredients = IngredientController.get_ingredients(user_id=user_id) data = [] for ingredient in ingredients: curr_stock_data = cls.get_in_stock_data(ingredient=ingredient) in_progress_data = cls.get_query().filt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_inventory_with_http_info(self, user_id, id, **kwargs):\n\n all_params = ['user_id', 'id']\n all_params.append('async')\n all_params.append('_return_http_data_only')\n all_params.append('_preload_content')\n all_params.append('_request_timeout')\n\n params = lo...
[ "0.7569133", "0.7155626", "0.6762009", "0.66601497", "0.66140306", "0.65519214", "0.6390761", "0.6237989", "0.62156236", "0.60586905", "0.6012444", "0.5902178", "0.5890392", "0.58257943", "0.5816766", "0.58158743", "0.5763474", "0.5743524", "0.571121", "0.56950724", "0.568245...
0.5242527
95
Gets all ingredients in progress for user with ``user_id``.
def get_in_stock_data(cls, ingredient: dict) -> tuple: curr_stock = float(ingredient["currentStock"]) curr_stock_decimal = float(ingredient["currentStockEquivalent"]) / float(ingredient["capacityEquivalent"]) curr_stock_percentage = float(100) * curr_stock_decimal return curr_stock, cur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ingredients_in_progress(cls, user_id: str) -> list:\n ingredients = IngredientController.get_ingredients(user_id=user_id)\n data = []\n\n for ingredient in ingredients:\n curr_stock_data = cls.get_in_stock_data(ingredient=ingredient)\n in_progress_data = cls.get_q...
[ "0.82737595", "0.77235246", "0.6530208", "0.62933844", "0.62313634", "0.5976115", "0.5850843", "0.5776963", "0.570023", "0.5661846", "0.5653032", "0.56467754", "0.55553746", "0.5512869", "0.5502797", "0.54599315", "0.5439984", "0.5435582", "0.5389472", "0.53699523", "0.535007...
0.0
-1
Deletes ingredient in progress for user with ``user_id``.
def delete_ingredients_in_progress(cls, user_id: str, ingredient_id: str): session: Session = cls.get_session() ingredient_in_progress = cls.get_query().filter( and_( IngredientsInProgressModel.ingredient_id == ingredient_id, IngredientsInProgressModel.user_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(self, user_id):\n pass", "def delete(self, user: 'UserCondensed'):\n self._delete(entity=user)", "async def red_delete_data_for_user(self, *, requester, user_id):\n return", "async def red_delete_data_for_user(self, *, requester, user_id):\n return", "def delete_item(...
[ "0.678601", "0.66784865", "0.66746336", "0.66746336", "0.6618471", "0.65111923", "0.6441183", "0.6438016", "0.64127743", "0.6369499", "0.6331467", "0.6273206", "0.62685937", "0.62605387", "0.62178457", "0.61816704", "0.61548245", "0.6083064", "0.6066107", "0.60525554", "0.602...
0.858545
0
set an author by default
def get_form(self, request, *args, **kwargs): form = super().get_form(request, *args, **kwargs) form.base_fields['author'].initial = request.user return form
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_author (self, author):\n self.author = author", "def setAuthor(self,value):\n self.PDFreactorConfiguration.in1[\"author\"] = value", "def set_author(self, author):\n self.author = author\n self.opf.author = author", "def author(self, value):\n self._set_attr('author...
[ "0.8252654", "0.82439995", "0.8213634", "0.81213117", "0.80845183", "0.8008694", "0.7875689", "0.781252", "0.781252", "0.77202326", "0.75019264", "0.7146604", "0.70541865", "0.6889957", "0.6874267", "0.6835159", "0.6833864", "0.67333144", "0.6685209", "0.66688204", "0.6666579...
0.64095044
39
Example parsing code for a CSV source.
def parse_cases(raw_data_file: str, source_id: str, source_url: str): with open(raw_data_file, "r") as f: reader = csv.DictReader(f) for row in reader: case = { "caseReference": { "sourceId": source_id, "sourceUrl": source_url, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_csv(self):\n try:\n reader = csv.reader(open(self.options.datafile, 'r'))\n except IOError:\n errormsg(_('Cannot read \"{}\"'.format(self.options.datafile)))\n raise Exception(_('Cannot read \"{}\"'.format(self.options.datafile)))\n if self.options.v...
[ "0.6806217", "0.6775352", "0.67593104", "0.65402895", "0.65128577", "0.65104544", "0.64284414", "0.6417455", "0.6400888", "0.63765883", "0.63530666", "0.63315237", "0.62040013", "0.6188222", "0.6160359", "0.61375195", "0.6134819", "0.6079229", "0.605635", "0.605257", "0.60455...
0.59040284
34
Get a specific users details
def get(self, user_id): user = UserModel.find_by_id(user_id) # print(user) # print(user.json()) if user is None: return {"error": "User not found"} return {"user": user.json()}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_users_info(): \n \n data = user_obj.get_users_info()\n return data", "def get_user_profile(self):\n return self.request('get', 'id/users')", "def get_user_details():\n rv = query_db('select * from user')\n return rv[0] if rv else None", "def show(user_id):\n return users.get_...
[ "0.7819347", "0.749697", "0.74156606", "0.72951585", "0.7266293", "0.72311664", "0.7205414", "0.7146677", "0.7114651", "0.70705914", "0.7045462", "0.70427537", "0.70305145", "0.70301265", "0.7024021", "0.7016661", "0.701514", "0.69674814", "0.69592905", "0.69330657", "0.69309...
0.0
-1
Get the top users
def get(self): users = UserModel.get_top_earners() users_json = [user.json() for user in users] return {"users": users_json}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTopUsers(self):\n\n\t\tquery = \"\"\"select M.user_id, count( distinct M.venue_id) as cnt\n\t\t\t\t\tfrom\n\t\t\t\t\t(\n\t\t\t\t\tselect J.user_id, J.venue_id, J.latitude, J.longitude, J.Homelat, J.Homelong,\n\t\t\t\t\tCASE\n\t\t\t\t\t\tWHEN J.latitude = J.Homelat and J.longitude = J.Homelong THEN 1\n\t\t\t...
[ "0.8160978", "0.78488797", "0.7793435", "0.7471113", "0.73085314", "0.7147013", "0.7104958", "0.6948201", "0.67802286", "0.6777022", "0.6769666", "0.67549616", "0.6740057", "0.67323506", "0.67101157", "0.6645782", "0.6604185", "0.6591461", "0.6571291", "0.6565868", "0.6499772...
0.6374396
24
Get the list of all jobs owned by user
def get(self, user_id): user = UserModel.find_by_id(user_id) jobs = [job.json() for job in user.posted_jobs] return {"jobs": jobs}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self):\n qs = Job.objects.filter(user=self.request.user)\n return qs", "def list_jobs(user_data, cache):\n user = cache.ensure_user(user_data)\n\n jobs = []\n for job in cache.get_jobs(user):\n try:\n if job.project_id:\n job.project = cach...
[ "0.74576366", "0.7313575", "0.71735066", "0.70125955", "0.70085806", "0.69305784", "0.6763451", "0.66647565", "0.66647565", "0.6635297", "0.663202", "0.662919", "0.6612873", "0.65772283", "0.65222675", "0.6484244", "0.6477744", "0.6405315", "0.63975054", "0.6392879", "0.63916...
0.6504865
15
Get a list of jobs the user has volunteered for
def get(self, user_id): user = UserModel.find_by_id(user_id) print("Getting volunteered jobs") jobs = [job.json() for job in user.volunteered_jobs] return {"jobs": jobs}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_job_list(self):\n return self.job_list", "def get_job_list(self):\n return self.job_list", "def get(self):\n # TODO: auth\n return list(self.app.db.jobs.find())", "def get_job_query(self):\n context = aq_inner(self.context)\n catalog = getToolByName(context, 'portal_...
[ "0.6712661", "0.6712661", "0.66783905", "0.6636779", "0.6613315", "0.65323234", "0.6438695", "0.64050114", "0.63789976", "0.6336263", "0.63244027", "0.6301153", "0.6282709", "0.62449884", "0.61884457", "0.61836964", "0.6181903", "0.61756855", "0.61736864", "0.6167379", "0.614...
0.7515113
0
Allocate a 2dimensional array, with the specified initial value. May do weird things with objects, I'm not sure. >>> alloc2d(2,5) [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]] >>> alloc2d(2,2,"x") [['x', 'x'], ['x', 'x']]
def alloc2d(x,y,iv=0): return [[iv for j in range(int(x))] for i in range(int(y))]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_two_d_array(dimens, val):\n w, x = dimens\n return [[val for j in range(x)] for i in range(w)]", "def create2d(row_count, col_count, value=None):\n a = [None] * row_count\n for row in range(row_count):\n a[row] = [value] * col_count\n return a", "def init_one_d_array(len, val):\n...
[ "0.65265894", "0.645137", "0.6148947", "0.60284287", "0.5584389", "0.5562695", "0.5459762", "0.544923", "0.54422444", "0.54183143", "0.5393952", "0.53860515", "0.5328383", "0.5234134", "0.5222009", "0.51992697", "0.51929575", "0.51736486", "0.5124553", "0.5068666", "0.5011701...
0.6807487
0
Swap around the keys and values of a dictionary (i.e. flip on the diagonal)
def swapdict(d): x = {} for k, v in d.iteritems(): x[v] = k return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dictflip(dictionary):\n\n return {v: k for k, v in dictionary.items()}", "def InvertDict(dict_in):\n return dict(zip(dict_in.values(), dict_in.keys()))", "def reverse(dictionary):\n return {b: a for a, b in dictionary.items()}", "def invert(d):\n if d:\n return [dict(zip(d, i)) for i i...
[ "0.74185795", "0.6716613", "0.6570254", "0.6523662", "0.63917285", "0.6351405", "0.6295982", "0.62575823", "0.6197628", "0.6113169", "0.60507005", "0.5998684", "0.5996646", "0.59498805", "0.59498805", "0.5944426", "0.5940815", "0.59240943", "0.59042305", "0.5894332", "0.58929...
0.6341142
6
Swap the values and indices of a list. Values default to None if something is doubled up and not specified. Values should be numbers, because they will become indices! >>> el = [0,4,1,3,2] basic list >>> swaplist(el) [0, 2, 4, 3, 1] >>> swaplist(swaplist(el)) == el invertable True >>> swaplist([0, 1, 2]) already match ...
def swaplist(l, base=0): r = [None] * len(l) for i, v in enumerate(l): r[v - base] = i + base return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap(in_list: List, index1: int, index2: int) -> List:\n\n in_list[index1], in_list[index2] = in_list[index2], in_list[index1] \n\n return in_list", "def swap(lst: list, index_1: int, index_2: int) -> None:\n lst[index_1], lst[index_2] = lst[index_2], lst[index_1]", "def _swap(mylist, a, b):\n ...
[ "0.7364025", "0.72524476", "0.72344494", "0.72169846", "0.71410453", "0.71264017", "0.7103082", "0.683433", "0.68322676", "0.67205346", "0.65408766", "0.6530119", "0.6401396", "0.63965213", "0.62192625", "0.6189153", "0.61377716", "0.59910136", "0.5957726", "0.59556746", "0.5...
0.62726593
14
Subtract the list b from a, return a copy >>> sublist([1, 2, 3, 4, 5], [2, 3]) [1, 4, 5]
def sublist(a, b): r = a[:] for i in b: r.remove(i) return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listSubtract(alist,blist):\n result = []\n for item in alist:\n if item not in blist:\n result.append(item)\n return result", "def list_subtract(a, b):\n a_only = list(a)\n for x in b:\n if x in a_only:\n a_only.remove(x)\n return a_only", "def sub_list...
[ "0.7625603", "0.75862557", "0.70652115", "0.7039867", "0.69050086", "0.6803992", "0.66484016", "0.66435206", "0.6537795", "0.6537795", "0.6537795", "0.64460796", "0.6338398", "0.62913436", "0.6228029", "0.61968637", "0.61660093", "0.6100752", "0.6035787", "0.60106146", "0.600...
0.7964486
0
Recursively mkdir() when necessary to ensure a path exists Kinda like mkdir p
def rmkdir(path): t = [] sep = os.path.sep if sep != "/": parts = path.replace(os.path.sep, "/").split("/") else: parts = path.split(sep) if path[0] == "/": t = ["/" + parts[0]] parts = parts[1:] for p in parts: t.append(p) # I chose ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mkdir(path):\n\tif not Path(path).exists():\n\t\tPath(path).mkdir(parents=True, exist_ok=True)", "def _mkdir_p(path):\n if not osp.exists(path):\n os.makedirs(path)", "def mkdir(path):", "def mkdir_p(path):\n try:\n os.makedirs(path) # , exist_ok=True\n except OSError:\n pas...
[ "0.82731116", "0.8173715", "0.80575997", "0.8045974", "0.8042844", "0.8042844", "0.80413026", "0.80393386", "0.80019957", "0.7990324", "0.7987171", "0.7981489", "0.7981489", "0.7964019", "0.7953215", "0.7949716", "0.79429233", "0.7914269", "0.78956777", "0.78757656", "0.78671...
0.0
-1
Adds a RgbdSensor to to the scene_graph at (fixed) pose X_PC relative to the parent_frame. If depth_camera is None, then a default camera info will be used. If renderer is None, then we will assume the name 'my_renderer', and create a VTK renderer if a renderer of that name doesn't exist. If parent_frame is None, then ...
def AddRgbdSensor( builder, scene_graph, X_PC, depth_camera=None, renderer=None, parent_frame_id=None, ): if sys.platform == "linux" and os.getenv("DISPLAY") is None: from pyvirtualdisplay import Display virtual_display = Display(visible=0, size=(1400, 900)) virtual_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AddRgbdSensors(\n builder,\n plant,\n scene_graph,\n also_add_point_clouds=True,\n model_instance_prefix=\"camera\",\n depth_camera=None,\n renderer=None,\n):\n if sys.platform == \"linux\" and os.getenv(\"DISPLAY\") is None:\n from pyvirtualdisplay import Display\n\n virt...
[ "0.6333064", "0.5002681", "0.4995963", "0.4986556", "0.4950906", "0.4458174", "0.44040585", "0.43817294", "0.43758163", "0.43542552", "0.43490773", "0.43313876", "0.43151295", "0.4292971", "0.42469728", "0.4221219", "0.4216358", "0.42138645", "0.4201191", "0.4180696", "0.4163...
0.8106876
0
Adds a RgbdSensor to the first body in the plant for every model instance with a name starting with model_instance_prefix. If depth_camera is None, then a default camera info will be used. If renderer is None, then we will assume the name 'my_renderer', and create a VTK renderer if a renderer of that name doesn't exist...
def AddRgbdSensors( builder, plant, scene_graph, also_add_point_clouds=True, model_instance_prefix="camera", depth_camera=None, renderer=None, ): if sys.platform == "linux" and os.getenv("DISPLAY") is None: from pyvirtualdisplay import Display virtual_display = Display(v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AddRgbdSensor(\n builder,\n scene_graph,\n X_PC,\n depth_camera=None,\n renderer=None,\n parent_frame_id=None,\n):\n if sys.platform == \"linux\" and os.getenv(\"DISPLAY\") is None:\n from pyvirtualdisplay import Display\n\n virtual_display = Display(visible=0, size=(1400, 90...
[ "0.60445213", "0.47997555", "0.47449347", "0.46184856", "0.45942456", "0.43920726", "0.43797317", "0.4326893", "0.42549992", "0.42535293", "0.4234432", "0.42307407", "0.42210782", "0.42094594", "0.41918367", "0.4191364", "0.41856608", "0.41717416", "0.41657764", "0.41477117", ...
0.7247001
0
Adds illustration geometry representing the coordinate frame, with the xaxis drawn in red, the yaxis in green and the zaxis in blue. The axes point in +x, +y and +z directions, respectively.
def AddTriad( source_id, frame_id, scene_graph, length=0.25, radius=0.01, opacity=1.0, X_FT=RigidTransform(), name="frame", ): # x-axis X_TG = RigidTransform( RotationMatrix.MakeYRotation(np.pi / 2), [length / 2.0, 0, 0] ) geom = GeometryInstance( X_FT.mul...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_geometry(self):\n import matplotlib.pyplot as plt\n fig_geom = plt.figure()\n ax_geom = fig_geom.add_subplot(111)\n rectangle = []\n for i in range(len(self.coordinates)):\n rectangle.append(plt.Rectangle((self.coordinates[i][0],\n ...
[ "0.60328215", "0.5996463", "0.5956841", "0.58766353", "0.584359", "0.5682301", "0.5665153", "0.5662804", "0.5646933", "0.5517312", "0.54503894", "0.54486495", "0.54443985", "0.54315335", "0.540777", "0.54059607", "0.53843856", "0.53843856", "0.53731394", "0.53583723", "0.5347...
0.0
-1
Do not return anything, modify nums1 inplace instead.
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: # nums1 = [1,2,3,0,0,0], m = 3 # nums2 = [2,5,6], n = 3 i = 0 for num2 in nums2: n -= 1 while i <= m - 1: if nums1[i] < num2: i += 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge1(self, nums1, m, nums2, n): \n nums1[:m].extend(nums2[:n]) # 此方法改变了nums1的指向,无效\n # extend没改变指向,但是切片改了 \n nums1[:m] + nums2[:n] # 此方法改变了nums1的指向,无效\n # +号改变了指向\n\n nums1.sort()", "def merge(self, nums1, m, nums2, n):\n nums1.extend([0]*...
[ "0.7024941", "0.7011506", "0.700616", "0.6987223", "0.6916323", "0.68455774", "0.68288964", "0.68022573", "0.6770004", "0.67557144", "0.67438185", "0.67422545", "0.6737672", "0.6709356", "0.6707213", "0.6683853", "0.6668475", "0.6639533", "0.6638752", "0.6636657", "0.6634697"...
0.66302735
22
Given a participant_id, return a participant_id. If we can claim the given participant_id, we will. Otherwise we'll find a random one that isn't taken yet. Whichever we return is guaranteed to be claimed in the database.
def claim_id(participant_id): seatbelt = 0 while 1: try: db.execute( "INSERT INTO participants (id) VALUES (%s)" , (participant_id,) ) except IntegrityError: # Collision, try again with a random value. participant_id = hex(int...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getParticipant(self, discordId):\n if discordId in participants:\n return participants[discordId]\n else:\n return None", "def participant_id(self):\n return self.data[\"id\"]", "def get_authorized_user(p):\n if Participant.objects.filter(psid=p).count() == 0:\...
[ "0.586102", "0.57109445", "0.55985445", "0.5515024", "0.53133464", "0.52435404", "0.51992923", "0.5119271", "0.51169336", "0.50899434", "0.5082975", "0.50726396", "0.50724584", "0.5045251", "0.49716988", "0.49658343", "0.496167", "0.4956202", "0.49425507", "0.49274588", "0.49...
0.7340709
0
Given two str, return a participant_id.
def resolve(login): FETCH = """\ SELECT participant_id FROM social_network_users WHERE network='github' AND user_info -> 'login' = %s """ # XXX Uniqueness constraint on login? rec = db.fetchone(FETCH, (login,)) if rec is Non...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_id(self):\n\t\tx , y = self.id.split(':')\n\t\treturn int(x), int(y)", "def create_id(uid, begintime, endtime):\n allowed_chars = string.ascii_lowercase[:22] + string.digits\n temp = re.sub('[^{}]'.format(allowed_chars), '', uid.lower())\n return re.sub('[^{}]'.format(allowed_chars), '', uid.lo...
[ "0.5985564", "0.5962005", "0.5810053", "0.5755434", "0.54641163", "0.5442869", "0.53757674", "0.5325997", "0.5302757", "0.52820987", "0.5280876", "0.526967", "0.52021563", "0.5186585", "0.51583683", "0.51234263", "0.5106121", "0.5097307", "0.50853866", "0.506013", "0.50570905...
0.49279866
35
Given str, unicode, unicode, and dict, return unicode and boolean. Network is the name of a social network that we support (ASCII blah). User_id is an immutable unique identifier for the given user on the given social network. Username is the user's login/user_id on the given social network. We will try to claim that f...
def upsert(network, user_id, username, user_info, claim=False): typecheck( network, str , user_id, (int, unicode) , user_info, dict ) user_id = unicode(user_id) # Record the user info in our database. # ===================================== INSERT = """\ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def username(provider, username):\n\n if provider == 'alditalk':\n if username.isdigit(): # only mobile number\n return True\n else:\n return False\n elif provider == 'netzclub': # mobile number and email\n if ((username.isdigit()) or (...
[ "0.51669383", "0.5083092", "0.49614066", "0.49047366", "0.48961347", "0.4839635", "0.47655556", "0.4718195", "0.47101656", "0.46781144", "0.46727902", "0.46368912", "0.46256196", "0.46220523", "0.46210793", "0.4603513", "0.45982912", "0.45585674", "0.45509598", "0.45504412", ...
0.60893
0
Load initial simulation data
def loadSimData(datafile): global dt, ti, Lx, Ly, nsamp, N, M, L, B, totalStep, Fmc, Kbend, kT, \ dtSamp, T, box_area, nt, body_length, Pe, persistence, flexure datafile = open(datafile,"r") for line in datafile: A = line.split() if A[0] == "dt": # Time interval...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_test_data(self):\n self._save_test_data()", "def load_data(self) -> None:", "def load_data(self):\n if self.debug:\n print(\"Loading data\")", "def initialise_sim(self):\n pass", "def initialize_simulation(self) -> Simulation:\n pass", "def load_data(self)...
[ "0.68683255", "0.67498815", "0.67211765", "0.6705084", "0.66544074", "0.6615124", "0.65464187", "0.6518159", "0.6498119", "0.64464325", "0.6364063", "0.6356504", "0.63125604", "0.63113856", "0.6292319", "0.6265532", "0.6231823", "0.6209781", "0.61972326", "0.61970484", "0.619...
0.6294475
14
Assign colors to beads indices based on the cluster they belong
def colorToBeads(clidx, filament_list, color, part_list_x, part_list_y, part_list_phi): cl_beads_x = [] cl_beads_y = [] cl_beads_p = [] for i in filament_list: for j in range(N): ind = int(i*N+j) clidx[ind] = color cl_beads_x.append(part_list_x[ind]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_cluster(self, cluster):\n for patch in cluster:\n patch.config(fill=\"red\")", "def node_colors(self, nodes):\n zmin, zmax = nodes[:, 2].min(), nodes[:, 2].max()\n start_color = np.array(self.background) + 5\n end_color = np.array(self.nodeColor)\n z = (node...
[ "0.6752229", "0.6413582", "0.6365808", "0.62394375", "0.62341064", "0.6156939", "0.60395414", "0.5976058", "0.5893515", "0.5878506", "0.5829808", "0.5804872", "0.57884765", "0.57642937", "0.5725985", "0.57257324", "0.5701969", "0.5693013", "0.5686574", "0.5674862", "0.5640789...
0.59784216
7
Find the indices of the largest 5 clusters in the system
def findIndex(cluster_size, cluster_idx, tracked_clusters, index_tracked_clusters): print 'Update is conducting' # Calculate the largest 5 clusters size_arr = np.asarray(cluster_size) maxs = -bot.partsort(-size_arr, 5)[:5] # 5 largest clusters maxs = sorted(maxs, reverse=True) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clusters(self):\n return np.argmax(self.alpha[:, :, 0], axis=0)", "def get_cluster_indices(self,dataset, cluster_number):\n\t\tself.__init__(dataset, self.k)\n\t\tself.e_step() #got responsibilities\n\t\tmax_cluster = np.argmax(self.w, axis = 1)\n\t\tindices = []\n\t\tfor i in range(dataset.shape[0]):...
[ "0.6519562", "0.65038353", "0.64770246", "0.64451647", "0.64059144", "0.63642323", "0.6343986", "0.6262098", "0.61906475", "0.6190452", "0.6188377", "0.61648357", "0.61436564", "0.61352074", "0.61263", "0.61253023", "0.609048", "0.6041876", "0.6037949", "0.6018775", "0.601396...
0.66095847
0
Find the indices of the largest cluster in the system
def findSpecificIndex(cluster_size, cluster_idx, tracked_clusters, index_tracked_clusters, indi): # Calculate the largest cluster maxi = max(cluster_size) # Index the largest cluster for i, cs in enumerate(cluster_size): if cs == maxi: index_tracked_clusters[indi] = i ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_largest_cluster(self) -> tuple:\n flat_cluster = self.cluster.reshape(-1)\n true_clusters = np.extract(flat_cluster > 0, flat_cluster)\n counts = np.bincount(true_clusters)\n largest = np.argmax(counts)\n size = counts[largest]\n return largest, size", "def maxCl...
[ "0.7134205", "0.6980508", "0.6905988", "0.69008315", "0.67803144", "0.6777812", "0.67298543", "0.6696416", "0.6619129", "0.65645915", "0.65588987", "0.6476951", "0.6383289", "0.63413584", "0.6317239", "0.631608", "0.62252176", "0.62064445", "0.62033117", "0.6182841", "0.61767...
0.6476292
12
Find the array index of cluster indices to access elements of the cluster information
def findArrayIndex(cluster_idx, tracked_clusters, index_tracked_clusters): found = np.zeros(5, dtype=int) # Index the clusters again since the unique cluster ids may be changed for i, indi in enumerate(cluster_idx): if indi == tracked_clusters[0]: index_tracked_clusters[0] = i ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cluster_indices(self,dataset, cluster_number):\n\t\tself.__init__(dataset, self.k)\n\t\tself.e_step() #got responsibilities\n\t\tmax_cluster = np.argmax(self.w, axis = 1)\n\t\tindices = []\n\t\tfor i in range(dataset.shape[0]):\n\t\t\tif max_cluster[i] == cluster_number:\n\t\t\t\tindices.append(i)\n\t\tret...
[ "0.716429", "0.71586674", "0.6817519", "0.6754379", "0.66942763", "0.66888386", "0.6679992", "0.6642885", "0.6531381", "0.6458431", "0.6403385", "0.6389278", "0.6359146", "0.6343633", "0.62577176", "0.624503", "0.62423474", "0.6216787", "0.61988443", "0.61608666", "0.6144706"...
0.7065493
2
Greedy algorithm which finds a probable mutation subgraph for given nodes. This algorithm chooses splits within the tree based on which mutation occurs most frequently, weighted by the prior probabilities of each mutation state for each character. Strings with NA ('') as a state in the split character are segregated wi...
def greedy_build(nodes, priors=None, cutoff=200, considered=set(), uniq='', targets=[]): # Tracks frequency of states for each character in nodes character_mutation_mapping = defaultdict(int) # G models the network that is returned recursively G = nx.DiGraph() root = root_finder(nodes) # Base case check for r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def greedy_learn(self,node,db,labels,ids):\n if node.depth >= self.maxdepth or len(ids) <= self.minexamples:\n #terminate recursion\n node.pick_best_label(db,labels,ids)\n err = misclassification_error([labels[id] for id in ids])\n if err > 0:\n pri...
[ "0.590502", "0.5824857", "0.58222175", "0.5818163", "0.5810747", "0.5779823", "0.57535565", "0.572609", "0.5676844", "0.5671201", "0.5649606", "0.56414163", "0.5636852", "0.5616348", "0.56067246", "0.5597054", "0.55416656", "0.5537339", "0.55193657", "0.55169916", "0.5503138"...
0.7791946
0
If class' attribute is accessed and it does not exist, this method will be called.
def __getattr__(self, name): def func(*args, **kwargs): # Python gives arguments as a tuple, convert them to list. f = getattr(self.obj, name) if not callable(f): return f # Print the function call as it would be written in code. a = '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_class_attribute(self):\n return self.class_attr", "def class_attr(self, attr, ignore_protected):\n protected = False if not ignore_protected else self.protected_attr(attr)\n return re.match('^(?!__).*', attr) and not callable(getattr(self, attr)) and not protected", "def identify_c...
[ "0.64051455", "0.6383376", "0.6280858", "0.6135352", "0.61144465", "0.6098986", "0.60924375", "0.60924375", "0.6068345", "0.6041043", "0.6018358", "0.6006583", "0.5995561", "0.595049", "0.5933787", "0.591861", "0.59055686", "0.59027994", "0.5867237", "0.5861424", "0.5860365",...
0.0
-1
return all columns as a dictionary, data presented in sql format
def _getValues(self): res = {} for colname, column in self._iterNameColumn(): res[colname] = column.toSql(self._values[colname]) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _as_dict(self):\r\n values = self._dynamic_columns or {}\r\n for name, col in self._columns.items():\r\n values[name] = col.to_database(getattr(self, name, None))\r\n return values", "def as_dict(self):\r\n values = {}\r\n for name, col in self._columns.items():\...
[ "0.7897001", "0.7752987", "0.7322894", "0.7274344", "0.72569364", "0.72569364", "0.72569364", "0.72569364", "0.7232694", "0.7187313", "0.718492", "0.7174157", "0.7159821", "0.7130308", "0.7062997", "0.7037842", "0.7029279", "0.7029279", "0.699056", "0.699056", "0.699056", "...
0.75123715
2
return all columns as a dictionary, data presented as strings
def _getStrValues(self): res = {} for colname in self._iterName(): res[colname] = str(self._values[colname]) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _as_dict(self):\r\n values = self._dynamic_columns or {}\r\n for name, col in self._columns.items():\r\n values[name] = col.to_database(getattr(self, name, None))\r\n return values", "def as_dict(self) -> Dict[str, Any]:\n return {\n column_title: cell.value\...
[ "0.7178168", "0.70843846", "0.70544076", "0.7044062", "0.70232564", "0.68531674", "0.6817989", "0.6817989", "0.6817989", "0.6817989", "0.6817989", "0.6794319", "0.678346", "0.678346", "0.678346", "0.678346", "0.67630386", "0.6753806", "0.67057407", "0.6687591", "0.66824704", ...
0.70319206
4
Compares the weather forecast of two cities passed in
def get_weather_forecast_comparison(user_city, explored_city, days=7): user_city_forecast = weather_client.getForecastWeather(q=user_city, days=days)['forecast']['forecastday'] explored_city_forecast = weather_client.getForecastWeather(q=explored_city, days=days)['forecast']['forecastday'] weather_forecast_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_weather_forecast_comparison(user_city=\"lagos\", explored_city=\"london\", days=7):\n user_city_forecast = weather_client.getForecastWeather(q=user_city, days=days)['forecast']['forecastday']\n explored_city_forecast = weather_client.getForecastWeather(q=explored_city, days=days)['forecast']['forecas...
[ "0.71536994", "0.6245935", "0.6226744", "0.60275173", "0.5958302", "0.57983166", "0.5735847", "0.56872874", "0.5631134", "0.5619025", "0.5510218", "0.5439192", "0.5397346", "0.53896284", "0.5317874", "0.52734953", "0.5242966", "0.5232327", "0.521958", "0.5216427", "0.5195094"...
0.7030591
1
This returns a dictionary of relevant weather info
def get_weather_info(forecast): day_forecast = {} try: day_forecast['condition_text'] = forecast['day']['condition']['text'] # this icon is a url to an image that describes the weather condition day_forecast['condition_icon_url'] = forecast['day']['condition']['icon'] day_forecas...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_weather(self):\n with urllib.request.urlopen(self.url) as response:\n json_data = response.read().decode('utf-8')\n\n data = json.loads(json_data)\n\n weather = {}\n weather['current'] = {\n 'temp': round(data['current']['temp_f']),\n 'humidity':...
[ "0.75960606", "0.7591139", "0.759041", "0.75648737", "0.74014914", "0.7290076", "0.72553915", "0.7060927", "0.6992882", "0.69674724", "0.69420385", "0.69393855", "0.6929554", "0.6903778", "0.68632424", "0.680844", "0.6804196", "0.67913526", "0.670719", "0.66605264", "0.665604...
0.6845341
15
Convert pixels of the image to world coordinates
def get_world_coords(self): # get pixel cordinates (H, W, _) = self.shape i, j = numpy.indices((H, W), dtype=numpy.float32) # Rescale to UV coordinates. u is to the right, v is up. u = rescale(0, W - 1, -1, 1, j) v = rescale(0, H - 1, 1, -1, i) # Because I alway...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pointToWorld( nImageX, nImageY, rDepth, rMaxX = 320, rMaxY = 240, rFieldOfViewX = 60, rFieldOfViewY = 40 ):\n # convert to [-0.5,0.5]\n rCenteredX = ( nImageX / rMaxX ) - 0.5;\n rCenteredY = ( nImageY / rMaxY ) - 0.5;", "def Pixel2World(geoMatrix, x, y):\r\n ulX = geoMatrix[0]\r\n ulY = geoMat...
[ "0.75094324", "0.7325349", "0.7322535", "0.7198944", "0.7048137", "0.7047548", "0.69544333", "0.66800016", "0.6670515", "0.665026", "0.6632581", "0.6566683", "0.65048647", "0.63582677", "0.63332766", "0.6328008", "0.6324152", "0.6288652", "0.62716603", "0.6234238", "0.6233980...
0.6962051
6
Convert world space coordinates to pixel coordinates
def to_indices(self, world_coords): (x, y, z) = world_coords (cx, cy, cz) = self.center px = x - cx py = y - cy pz = z - cz # project u and v # TODO: Can this be done with some built-in Numpy operation? (ux, uy, uz) = self.u_dir (vx, vy, vz) = se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def world2Pixel(geoMatrix, x, y):\r\n ulX = geoMatrix[0]\r\n ulY = geoMatrix[3]\r\n xDist = geoMatrix[1]\r\n yDist = geoMatrix[5]\r\n rtnX = geoMatrix[2]\r\n rtnY = geoMatrix[4]\r\n # pixel = int((x - ulX) / xDist)\r\n # line = int((ulY - y) / xDist)\r\n # Floor for x and ceiling for y s...
[ "0.7813827", "0.7644184", "0.7641467", "0.75160825", "0.73816305", "0.72449976", "0.71286684", "0.71147805", "0.7101196", "0.7005821", "0.69036907", "0.68787587", "0.6874656", "0.68495816", "0.6820127", "0.68121105", "0.6807642", "0.6774522", "0.6698339", "0.66840273", "0.666...
0.63809294
38
Returns True if the given term tuple (fieldname, text) is in this reader.
def __contains__(self, term): fieldname, text = term query = dict(fieldname=fieldname, text=text) return bool(self.index.collection.find(query).count())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contains(self, term):\n\t\tif term in self.textFile:\n\t\t\treturn True\n\t\t\n\t\treturn False", "def _is_term_exist(self, term):\n return term in self.postingDict", "def __contains__(self, doc_label):\n return doc_label in self.docs", "def __contains__(self, item):\n return item in...
[ "0.7650702", "0.68390197", "0.6475184", "0.6443119", "0.6418949", "0.63440895", "0.63410914", "0.6325038", "0.6281455", "0.6252877", "0.6130331", "0.6100055", "0.60711753", "0.5990042", "0.5925225", "0.59213024", "0.59145826", "0.5882695", "0.58655465", "0.58621746", "0.58379...
0.7103255
1
Yields (fieldname, text, docfreq, indexfreq) tuples for each term in the reader, in lexical order.
def __iter__(self): fields = 'fieldname', 'text', 'docfreq', 'indexfreq' cur = self.index.collection.find(fields=fields).sort('fieldname') return (tuple(rec[field] for field in fields) for rec in cur)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_from(self, fieldname, text):\n\t\tfields = 'fieldname', 'text', 'docfreq', 'indexfreq'\n\t\tcur = self.index.collection.find(fields=fields).sort('fieldname')\n\t\treturn (tuple(rec[field] for field in fields) for rec in cur\n\t\t\tif rec['fieldname'] >= fieldname)", "def docTermCountMapper( (docname, te...
[ "0.6394344", "0.63895833", "0.63554066", "0.6069107", "0.59565014", "0.595314", "0.58934623", "0.5815445", "0.5812689", "0.5799563", "0.5794913", "0.57896703", "0.57124174", "0.56017923", "0.5583592", "0.55833954", "0.5558156", "0.5510152", "0.54602987", "0.5457762", "0.54360...
0.61912984
3
Yields (field_num, text, doc_freq, index_freq) tuples for all terms in the reader, starting at the given term.
def iter_from(self, fieldname, text): fields = 'fieldname', 'text', 'docfreq', 'indexfreq' cur = self.index.collection.find(fields=fields).sort('fieldname') return (tuple(rec[field] for field in fields) for rec in cur if rec['fieldname'] >= fieldname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docTermCountMapper( (docname, term), (payload, n)):\n yield docname, (term, payload, n)", "def corpusTermCountMapper( (term, docname), (payload, n, N) ):\n yield term, (docname, payload, n, N, 1)", "def terms(self) -> Tuple[Term, ...]:\n ...", "def corpusTermCountReducer(term, values):\n ...
[ "0.68192494", "0.6475116", "0.61195904", "0.5971918", "0.59598106", "0.5913069", "0.58945346", "0.5879545", "0.5876062", "0.5830351", "0.5784476", "0.57442003", "0.5735431", "0.56609225", "0.56596565", "0.5655239", "0.5642833", "0.56098855", "0.5602108", "0.56014043", "0.5596...
0.63166904
2
Returns the stored fields for the given document number.
def stored_fields(self, docnum): return self.index.collection.get(docnum).keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stored_fields(self, docnum):\r\n return self.doc_reader[docnum]", "def getFieldNumbers():\n return _getCampaignDict()[\"field_numbers\"]", "def field_by_number(self, number):\r\n return self._by_number[number]", "def field_by_number(cls, number):\n return cls.__by_number[number]",...
[ "0.83763015", "0.68768024", "0.6653822", "0.621729", "0.6031412", "0.5998559", "0.5727719", "0.5719909", "0.5710211", "0.56648844", "0.5622993", "0.5617283", "0.5602116", "0.558327", "0.5546262", "0.5530749", "0.5526932", "0.5522419", "0.5505145", "0.5499001", "0.5497499", ...
0.83722156
1
Returns the total number of documents, DELETED OR UNDELETED, in this reader.
def doc_count_all(self): return self.index.collection.count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_total_number_of_documents(self):\n return self.total_number_of_documents", "def doc_count(self):\n\t\treturn self.index.collection.count()", "def count_deleted(self):\n count = 0\n for _, e in self.contents.items():\n count = count + e.count_deleted()\n return cou...
[ "0.7694914", "0.7510874", "0.7456718", "0.74369824", "0.7400394", "0.7376454", "0.7318653", "0.70306486", "0.6979551", "0.69476104", "0.6910956", "0.68551785", "0.6845533", "0.67889684", "0.67852783", "0.67809534", "0.675962", "0.6714335", "0.6646297", "0.66243535", "0.661896...
0.7317203
7
Returns the total number of UNDELETED documents in this reader.
def doc_count(self): return self.index.collection.count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_deleted(self):\n count = 0\n for _, e in self.contents.items():\n count = count + e.count_deleted()\n return count", "def count_deleted(self): # EntryList.count_deleted\n count=0\n for name, e in self.contents.iteritems():\n count = co...
[ "0.774052", "0.7685259", "0.7200083", "0.71623373", "0.6974863", "0.69508916", "0.68825483", "0.6874336", "0.67723584", "0.65331846", "0.6532005", "0.64764756", "0.64342594", "0.6419995", "0.64097446", "0.639157", "0.63764316", "0.6351271", "0.63395876", "0.62947416", "0.6248...
0.65769726
9
Returns the number of terms in the given field in the given document. This is used by some scoring algorithms.
def doc_field_length(self, docnum, fieldname, default=0): doc = self.index.collection.get(docnum, fields=[fieldname]) field = doc['field'] return len(field)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def doc_frequency(self, fieldname, text):\n\t\tquery = {fieldname: text}\n\t\treturn self.index.collection.find(query).count()", "def count_term_in_document(self, term, document):\n doc = self.get_document(document)\n for docterm, value in doc.get_terms():\n if docterm == term:\n ...
[ "0.72676206", "0.7165055", "0.70114183", "0.66553545", "0.64877266", "0.6448544", "0.64057785", "0.6239052", "0.62141967", "0.6161071", "0.6133754", "0.61203957", "0.61141217", "0.6107903", "0.6076252", "0.60743505", "0.60632855", "0.6061969", "0.6047227", "0.60395795", "0.60...
0.613099
11
Returns how many documents the given term appears in.
def doc_frequency(self, fieldname, text): query = {fieldname: text} return self.index.collection.find(query).count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_term_in_document(self, term, document):\n doc = self.get_document(document)\n for docterm, value in doc.get_terms():\n if docterm == term:\n return value\n return 0", "def count_term_distinct_documents(self, term):\n term_entry = self.get_term(term)...
[ "0.8144007", "0.7901063", "0.7805863", "0.7593704", "0.7337906", "0.72929275", "0.70913726", "0.7029171", "0.700253", "0.69935983", "0.6934074", "0.6844122", "0.68305665", "0.6751197", "0.6741464", "0.67233396", "0.66798115", "0.6657282", "0.6632745", "0.6621583", "0.66213256...
0.65604246
24
Returns the total number of terms in the given field. This is used by some scoring algorithms.
def field_length(self, fieldname): # todo: is this right? query = {fieldname: {'$exists': 1}} return self.index.collection.find(query).count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_term(self, term):\n term_entry = self.get_term(term)\n if term_entry:\n return term_entry.count\n else:\n return 0", "def all_for_field(self, field):\n sum_ = 0\n for cat, cat_name in self.CATEGORIES:\n val = getattr(self, '%s_%s' % (c...
[ "0.6676837", "0.65731615", "0.64483917", "0.6415971", "0.6294213", "0.61543", "0.6123947", "0.6059807", "0.60554504", "0.60289246", "0.59715825", "0.59456694", "0.59362334", "0.5894546", "0.5893738", "0.5855221", "0.58436567", "0.5833092", "0.5828044", "0.5794682", "0.5728545...
0.5903449
13
This function takes a ply that does not contain colored faces and convert it to a colored file format. Note that if you want to work with the colors
def colorize(filename): # Read data from existing ply plydata = PlyData.read(filename) # Return false if the file already contains colored faces properties = str(plydata['face'].properties) if "red" and "green" and "blue" and "counter" in properties: return True faces = plydata['face'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_pointcloud(rgb_file, mask_file,depth_file,ply_file):\n rgb = Image.open(rgb_file)\n # depth = Image.open(depth_file)\n depth = Image.open(depth_file).convert('I')\n mask = Image.open(mask_file).convert('I')\n\n # if rgb.size != depth.size:\n # raise Exception(\"Color and depth im...
[ "0.58714455", "0.57085764", "0.56858146", "0.54114306", "0.5275804", "0.5268924", "0.5008679", "0.49845684", "0.4942795", "0.49143073", "0.4902455", "0.4884634", "0.48557335", "0.48439094", "0.48289695", "0.48243293", "0.48167127", "0.47649246", "0.47608292", "0.4744698", "0....
0.72984517
0
Calculate distance between two vectors.
def distance(self, vector1, vector2, type_): if type_ == "braycurtis": return distance.braycurtis(vector1, vector2) elif type_ == "canberra": return distance.canberra(vector1, vector2) elif type_ == "chebyshev": return distance.chebyshev(vector1, vector2) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _vector_dist(self, vec1, vec2):\r\n return sqrt(sum([(float(v1) - float(v2)) ** 2 for v1, v2 in\r\n zip(vec1, vec2)]))", "def dist(v1: vect2d, v2: vect2d) -> float:\n d = ((v2.x - v1.x)**2 + (v2.y - v1.y)**2) ** 0.5\n return d", "def distance(v1, v2):\r\n return magnit...
[ "0.84512544", "0.7946819", "0.7885775", "0.77465785", "0.77394795", "0.76349956", "0.7605549", "0.7579331", "0.754522", "0.7451612", "0.7417736", "0.7382795", "0.7381552", "0.73787606", "0.7359042", "0.7357606", "0.73309225", "0.73192996", "0.72966", "0.7295556", "0.72912675"...
0.0
-1
Use trained model to classify a document.
def classify(self, document, k, distance_type="sqeuclidean"): if k == 0: raise ValueError("Must enter positive value for k parameter.") # If only one neighbor, do more optimal calculation if k == 1: return self.__classify_nearest_neighbor(document...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model(self):\n filePath = self.config['data_path']['train_data']\n data = self.loadCSV(filePath)\n cleandata = self.preprocess(data)\n X, y = self.dataSplit(cleandata)\n X = self.CountVect(X, self.config['transform_path']['transform_model_path'])\n X_train, X_test, y_t...
[ "0.6856484", "0.6855123", "0.65202457", "0.64663416", "0.6446124", "0.62844443", "0.62707925", "0.6240914", "0.619588", "0.61694115", "0.61624026", "0.6160073", "0.6160073", "0.6157931", "0.61330557", "0.6119248", "0.60993385", "0.60628384", "0.60483456", "0.6022452", "0.6005...
0.0
-1
Special case of knearest neighbors where k= = 1.
def __classify_nearest_neighbor(self, document, distance_type): min_distance = sys.float_info.max min_class = "" for index in self.vectors.shape[0]: vector = self.vectors[index:].data.tolist() distance = self.distance(document, vector, distance_type) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_nearest_neighbors_idx(X, x, k):\n ## homework:start\n result = \n ## homework:end\n return result", "def k_nearest_neighbors(x_test, df_training, k):\n\n return np.argpartition(distance_to_each_training_point(x_test,\n df_training)...
[ "0.746246", "0.7261196", "0.7228868", "0.72147983", "0.7099051", "0.709009", "0.6993821", "0.6966697", "0.69588214", "0.6923221", "0.69164014", "0.690752", "0.68625754", "0.6857904", "0.68447673", "0.68146485", "0.6767023", "0.6753044", "0.669507", "0.668546", "0.66382563", ...
0.0
-1
This method is used to convert a given pd.Series object into a list
def series_to_list(series: pd.Series) -> List: list_cols = [] for item in series: list_cols.append(item) return list_cols
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_list(self):\n return SeriesDefault.register(pandas.Series.to_list)(self)", "def _to_list(series: Union[TimeSeries, Sequence[TimeSeries]]) -> Sequence[TimeSeries]:\n\n return [series] if not isinstance(series, Sequence) else series", "def to_real_series(self, data: pd.Series) -> pd.Series:\n ...
[ "0.8163235", "0.8084659", "0.67696327", "0.6688192", "0.6478346", "0.6332372", "0.63315487", "0.63113815", "0.6291304", "0.6289916", "0.6243208", "0.6221836", "0.62096226", "0.6204572", "0.6184458", "0.6167135", "0.6163509", "0.61454004", "0.61151385", "0.6111333", "0.608589"...
0.80512226
2
This method is used to gather the X (features) and y (targets) from a given dataframe based on a given target name
def get_X_y(df: pd.DataFrame, name_target: str) -> Tuple[List, List]: X_list = [] y_list = [] for index, record in df.iterrows(): fl = series_to_list(record.drop(name_target)) X_list.append(fl) y_list.append(int(record[name_target])) return X_list, y_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_feat_and_target(df, target):\n x = df.drop(target, axis = 1)\n y = df[target]\n return x, y", "def get_targets(self, df):\n return df.iloc[:, self.target_col]", "def __get_x_y_from_data(\n logger, df, predictors, target):\n if df is not None:\n df_X = df[predictors]\n ...
[ "0.7217679", "0.6761475", "0.6600984", "0.6574773", "0.636862", "0.63467455", "0.6319424", "0.62599015", "0.617897", "0.6085072", "0.60718614", "0.6002464", "0.59024835", "0.5899294", "0.5896933", "0.58856267", "0.5781165", "0.5759055", "0.5751264", "0.5698898", "0.5694174", ...
0.6518206
4
This method is used to perform Label Encoding on a given list
def label_encode(data: List) -> [np.ndarray, List[LabelEncoder]]: labels_encoded = [] data_encoded = np.array(data) for i in range(data_encoded.shape[1]): le = preprocessing.LabelEncoder() le.fit(data_encoded[:, i]) labels_encoded.append(le) data_encoded[:, i] = le.transform(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_labels(labels_list: np.ndarray, label_encoder) -> np.ndarray:\n labels = label_encoder.fit_transform(labels_list)\n if label_encoder.classes_.size == 2:\n return labels\n else:\n return to_categorical(labels)", "def one_hot_encoding((uri, label), all_labels):\n labels = [0]*N...
[ "0.7562382", "0.6891295", "0.6828393", "0.67302644", "0.67219895", "0.65855664", "0.655393", "0.6548483", "0.65094924", "0.64900345", "0.64831984", "0.6471565", "0.6455571", "0.64494634", "0.6426103", "0.6385746", "0.62811464", "0.62680995", "0.622862", "0.6193661", "0.617948...
0.75347763
1
Check whether sequence str contains ALL of the items in set.
def containsAll(str, set): return 0 not in [c in str for c in set]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def containsAny(str, set):\n return 1 in [c in str for c in set]", "def containsAny(str, set):\n return 1 in [c in str for c in set]", "def containsAny(str, set):\n return 1 in [c in str for c in set]", "def all_unique_set(string):\n return len(string) == len(set(string))", "def all_in_set(the_...
[ "0.75599706", "0.75599706", "0.75599706", "0.73432213", "0.7040939", "0.69977653", "0.67504674", "0.65502936", "0.6536207", "0.64373004", "0.63491184", "0.6310514", "0.6302475", "0.6282493", "0.6272134", "0.62464535", "0.62243676", "0.6215836", "0.62083054", "0.6190645", "0.6...
0.8373326
1
Loads a snippet from a dictionary. If an existing snippet with this date is found, that one is updated, committed to the database, and returned. Otherwise a new instance is populated, committed to the database, and returned.
def load_from_json(user_id, json): year = json["year"] week = json["week"] text = json.get("text", "") tags = json.get("tags", []) return Snippet.update(user_id, year, week, text, tags)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n if not os.path.isfile(self.DBFILE):\n self.snippets = {}\n return\n\n with open(self.DBFILE) as fobj:\n content = fobj.read()\n if not content.strip():\n content = \"{}\"\n\n self.snippets = {\n ...
[ "0.5525752", "0.5340668", "0.52998114", "0.5021224", "0.49906397", "0.48999608", "0.47908178", "0.47714812", "0.47337997", "0.4732373", "0.47303945", "0.47028187", "0.4698919", "0.46946174", "0.4689702", "0.46578616", "0.46578616", "0.46391878", "0.4634687", "0.4631234", "0.4...
0.57506377
0
Serializes this snippet to a dictionary.
def to_json(self): json = { "url": url_for( "api.get_week", year=self.year, week=self.week, ), "year": self.year, "week": self.week, "text": self.text or "", "tags": [tag.text for tag in self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(self):\n return {\n 'title': self.title,\n 'description': self.description,\n 'id': self.id,\n }", "def serialize(self):\n return {\n 'id': self.id,\n 'title': self.title,\n 'description': self.description,\n ...
[ "0.6837822", "0.66297317", "0.6602671", "0.6591415", "0.65640765", "0.6554913", "0.65533537", "0.65455", "0.64985853", "0.64985853", "0.64985853", "0.6452853", "0.6409583", "0.640126", "0.6401137", "0.6398112", "0.6344605", "0.6341496", "0.6340976", "0.6338145", "0.633426", ...
0.0
-1
Returns the specified snippet (or None if it does not exist).
def get_by_week(user_id: str, year: int, week: int) -> Optional[Snippet]: snippet = Snippet.query.filter_by( user_id=user_id, year=year, week=week ) return snippet.first()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_snippet(self, title=None):\n for snippet in self.snippets:\n if snippet[\"title\"] == title:\n return snippet\n return None", "def get_snippet(res_type, snippet_name):\n\treturn get_settings_resource(res_type, snippet_name, 'snippets');", "def get(name):\n # c...
[ "0.7803083", "0.7509804", "0.68043727", "0.6783305", "0.64907616", "0.5895668", "0.5698813", "0.5681696", "0.5681696", "0.5670628", "0.5629642", "0.55866885", "0.5575976", "0.5484937", "0.5417822", "0.53710085", "0.5361792", "0.5350893", "0.5321844", "0.5257878", "0.5215702",...
0.55412996
13
Returns a query for all the specified snippets.
def get_all(user_id, tag_text=None) -> Query: query = Snippet.query.filter_by(user_id=user_id) if tag_text: tag = Tag.query.filter_by(text=tag_text).first() tag_id = tag and tag.id query = query.join(tagged_snippets).filter_by(tag_id=tag_id) return query.order...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSnippets(self, folderpath):\n print(\"Getting snippets for {}\".format(folderpath))\n # s2q = self.helper.loadJson(os.path.join(folderpath, 'final',\n # 'subject2svoqueries.json'))\n queries = self.helper.loadCsv(\n folderpath+\"...
[ "0.6417341", "0.5955669", "0.5799018", "0.5799018", "0.57882434", "0.56366897", "0.56245464", "0.56226546", "0.55856466", "0.55196714", "0.5429914", "0.54079545", "0.53793526", "0.53777164", "0.5342365", "0.534001", "0.53096443", "0.5303962", "0.5249011", "0.5232009", "0.5195...
0.58999836
2
Reads ident and direction from packet, and returns the associated struct description from structs global. Normalises return to be a ((str, str), ...)
def get_struct(self, packet): o = structs[packet.ident] if isinstance(o, dict): o = o[packet.direction] if len(o) and not isinstance(o[0], tuple): o = (o), return o
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def struct_handler(rdr: TextIO) -> str:\n # What is the indent level?\n line = rdr.readline()\n spaces = 0\n for c in line:\n if c != ' ':\n break\n spaces += 1\n if spaces < 4: # this would be a false positive exit early\n return line\n # define an exit condition\...
[ "0.60142964", "0.5952989", "0.5886524", "0.55371803", "0.5497203", "0.5459148", "0.5436307", "0.53541756", "0.529343", "0.5292839", "0.5251687", "0.5219966", "0.5216221", "0.5205466", "0.51578975", "0.50616544", "0.5050829", "0.50503224", "0.5029179", "0.50224257", "0.5017213...
0.71432406
0
Reads buff (consuming bytes) and returns the unpacked value according to the given type.
def unpack(self, data_type): if data_type in data_types: format = data_types[data_type] return self.unpack_real(format[0], format[1]) if data_type == "string8": length = self.unpack('short') if length < 0: raise Exception("Negative length for string") if len(self.buff) < length: raise Inco...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unpack_real(self, data_type, length):\n\t\tif len(self.buff) < length:\n\t\t\traise IncompleteData()\n\t\to = struct.unpack_from('!'+data_type, self.buff)[0]\n\t\tself.buff = self.buff[length:]\n\t\treturn o", "def recv_type(self, type_):\n msg = self.recv()\n assert msg and msg['type'] == type...
[ "0.6121442", "0.6102325", "0.6010905", "0.59326094", "0.59165037", "0.57921314", "0.57729095", "0.5755466", "0.5736085", "0.5672907", "0.5606049", "0.5564489", "0.5529752", "0.5459146", "0.54543996", "0.5428361", "0.5421578", "0.5403828", "0.53911126", "0.5365144", "0.5348785...
0.6249607
0
A helper function for unpack(), it handles any data type that is understood by the struct module.
def unpack_real(self, data_type, length): if len(self.buff) < length: raise IncompleteData() o = struct.unpack_from('!'+data_type, self.buff)[0] self.buff = self.buff[length:] return o
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_type(fobj, data_type):\n if data_type == \"Boolean\": ## False if 0x00 else True\n return bool(fobj.read(1))\n elif data_type == \"Byte\": ## 1 byte int\n return fobj.read(1)[0]\n elif data_type == \"DateTime\": ## 8 bytes signed int\n return struct.unpack(\"<q\", fobj.read(...
[ "0.7574141", "0.7300555", "0.7035982", "0.6990688", "0.6908454", "0.6716404", "0.6593183", "0.65563977", "0.64701086", "0.64119905", "0.63946146", "0.6381894", "0.63355225", "0.6306007", "0.6268735", "0.6262881", "0.6244263", "0.62122506", "0.6211503", "0.6190626", "0.616264"...
0.69019985
5
Reads the bytestring in self.buff, and returns the first packet contained within it. Sets self.buff to remaining bytestring. If packet is incomplete, returns None. But may raise if it thinks a real malformed packet has been recieved.
def read_packet(self): #self.debug("READ BUFFER SIZE: %d" % len(self.buff)) backup = self.buff[:] packet = Packet() try: packet.direction = self.node packet.ident = self.unpack('ubyte') #Defined structs from huge dict for datatype, name in self.get_struct(packet): # this populates packet.da...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recv_packet(self):\r\n self.recv_bytes()\r\n\r\n packet_length_index = 0\r\n \r\n amount_data = len(self.recvBuffer) # available amount of data to read\r\n \r\n if amount_data <= packet_length_index: # just 0's in the buffer\r\n return None\r\n\r\n ...
[ "0.7178027", "0.67700803", "0.6706211", "0.66330725", "0.645455", "0.6333611", "0.62824416", "0.6110825", "0.6101818", "0.60921735", "0.60903865", "0.60903865", "0.6066746", "0.60435694", "0.60384893", "0.6006668", "0.5956292", "0.5912572", "0.5874441", "0.5867553", "0.585880...
0.6022976
15
Takes a packet, and returns the encoded bytestring representing it.
def encode_packet(self, packet): try: output = self.pack('ubyte', packet.ident) append = '' #0x17 if packet.ident == 0x17: if packet.data['unknown'] > 0: for i in ('x2','y2','z2'): append += self.pack('short', packet.data[i]) #0x33 if packet.ident in (0x33, 0x34): packet.data['da...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_packet(self, packet, b64=False):\n if packet.binary and not b64:\n bytes = six.int2byte(packet.type)\n else:\n bytes = six.binary_type(packet.type)\n if packet.binary and b64:\n bytes = 'b' + bytes\n\n if packet.binary and b64:\n ...
[ "0.7865717", "0.6886599", "0.67298377", "0.6656107", "0.63058937", "0.62062097", "0.61510146", "0.6113067", "0.6092784", "0.60803", "0.60527766", "0.6038609", "0.6027137", "0.6022875", "0.59639084", "0.5963516", "0.5936586", "0.59108037", "0.58827156", "0.5860486", "0.5859598...
0.7339893
1
A wrapper about the normal objects, that lets you unpack encoded packets easily. Returns (packet, remaining_buff), where remaining_buff is the given buffer without the bytes eaten by the packet. If no more packets can be read from buff, returns (None, buff).
def stateless_unpack(buff, to_server): decoder = PacketDecoder(to_server) decoder.buff = buff packet = decoder.read_packet() return packet, decoder.buff
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_packet(self):\n\n\t\t#self.debug(\"READ BUFFER SIZE: %d\" % len(self.buff))\n\t\tbackup = self.buff[:]\n\t\tpacket = Packet()\n\t\ttry:\n\t\t\tpacket.direction = self.node\n\t\t\tpacket.ident = self.unpack('ubyte')\n\t\t\t\n\t\t\t#Defined structs from huge dict\n\t\t\tfor datatype, name in self.get_struct...
[ "0.6680396", "0.6446139", "0.635691", "0.61377084", "0.60597813", "0.59214246", "0.59068066", "0.5846877", "0.5788773", "0.57825875", "0.5771481", "0.5694871", "0.5669175", "0.5655013", "0.5589426", "0.55781716", "0.5572244", "0.5557182", "0.55246246", "0.55121374", "0.551061...
0.72920316
0
A wrapper about the normal objects, that lets you pack decoded packets easily. Returns the bytestring that represents the packet.
def stateless_pack(packet, to_server): decoder = PacketDecoder(to_server) return decoder.encode_packet(packet)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def packetize(self):\n byte_str = b''\n\n # Bit string to accumulate bit values until we are ready to convert it into bytes\n bit_str = \"\"\n\n for field in self.fields:\n #if the current field is a special type, the bit_str value to the byte string and clear the accumulated...
[ "0.6658192", "0.6616389", "0.661359", "0.6557513", "0.6539478", "0.65270644", "0.63207364", "0.62352747", "0.62149036", "0.6198456", "0.6153788", "0.613428", "0.6095934", "0.605854", "0.60508865", "0.6032792", "0.60198796", "0.5980188", "0.5960326", "0.5957138", "0.59558177",...
0.64134574
6
Lift a sampling function to one that draws multiple iid samples.
def iid_sample(sample_fn, sample_shape): sample_shape = distribution_util.expand_to_vector( ps.cast(sample_shape, np.int32), tensor_name='sample_shape') n = ps.cast(ps.reduce_prod(sample_shape), dtype=np.int32) static_n = tf.get_static_value(tf.convert_to_tensor(n)) def unflatten(x): sample_dims = 0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iid_sample_fn(*args, **kwargs):\n\n with tf.name_scope('iid_sample_fn'):\n\n seed = kwargs.pop('seed', None)\n if samplers.is_stateful_seed(seed):\n kwargs = dict(kwargs, seed=SeedStream(seed, salt='iid_sample')())\n def pfor_loop_body(_):\n with tf.name_scope('iid_sample_fn...
[ "0.6780334", "0.6380335", "0.5978483", "0.59762675", "0.5962528", "0.5962528", "0.59488493", "0.58723915", "0.5839884", "0.5820229", "0.5768919", "0.5750288", "0.5728591", "0.57276875", "0.5725391", "0.57026887", "0.5686771", "0.5677376", "0.56756586", "0.5674957", "0.5672077...
0.6582716
1
Draws iid samples from `fn`.
def iid_sample_fn(*args, **kwargs): with tf.name_scope('iid_sample_fn'): seed = kwargs.pop('seed', None) if samplers.is_stateful_seed(seed): kwargs = dict(kwargs, seed=SeedStream(seed, salt='iid_sample')()) def pfor_loop_body(_): with tf.name_scope('iid_sample_fn_stateful_bod...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iid_sample(sample_fn, sample_shape):\n sample_shape = distribution_util.expand_to_vector(\n ps.cast(sample_shape, np.int32), tensor_name='sample_shape')\n n = ps.cast(ps.reduce_prod(sample_shape), dtype=np.int32)\n static_n = tf.get_static_value(tf.convert_to_tensor(n))\n\n def unflatten(x):\n samp...
[ "0.64719844", "0.5108194", "0.5058195", "0.5022143", "0.5005775", "0.49909416", "0.49430317", "0.4896238", "0.48929828", "0.4841593", "0.48388526", "0.48310915", "0.48164558", "0.481505", "0.48034382", "0.47747755", "0.4774165", "0.47662959", "0.47544459", "0.474792", "0.4742...
0.6562505
0
Wraps `fn` to take only those args with non`None` core ndims.
def _lock_in_non_vectorized_args(fn, arg_structure, flat_core_ndims, flat_args): # Extract the indices and values of args where core_ndims is not `None`. (vectorized_arg_indices, vectorized_arg_core_ndims, vectorized_args) = [], [], [] if any(nd is not None for nd in flat_core_ndims): vectorized_arg_in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_keepdims(func):\n @functools.wraps(func)\n def wrapped(a, axis, **kwargs):\n res = func(a, axis=axis, **kwargs)\n if axis is None:\n axis = 0 # res is now a scalar, so we can insert this anywhere\n return np.expand_dims(res, axis=axis)\n return wrapped", "def ar...
[ "0.60580367", "0.5733432", "0.5674461", "0.5585218", "0.55187184", "0.537419", "0.5331399", "0.5270151", "0.5239943", "0.52073294", "0.50932014", "0.5054553", "0.50446254", "0.50378776", "0.5035789", "0.50340813", "0.4959851", "0.49438873", "0.4940812", "0.49344712", "0.49254...
0.50251055
16
Lift a function to one that vectorizes across arbitraryrank inputs.
def make_rank_polymorphic(fn, core_ndims, name=None): def vectorized_fn(*args): """Vectorized version of `fn` that accepts arguments of any rank.""" with tf.name_scope(name or 'make_rank_polymorphic'): # If we got a single value for core_ndims, tile it across all args. core_ndims_structure = ( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def autovectorized(f):\r\n def wrapper(input):\r\n if N.isscalar(input)==False:\r\n return N.vectorize(f)(input)\r\n return f(input)\r\n return wrapper", "def autovectorized(f):\r\n def wrapper(input):\r\n if N.isscalar(input)==False:\r\n return N.vecto...
[ "0.71565306", "0.71565306", "0.6703871", "0.62867755", "0.6109641", "0.60993487", "0.60616183", "0.5936452", "0.59198844", "0.5880423", "0.57778794", "0.57708", "0.5769331", "0.57459575", "0.57459575", "0.5743964", "0.5737575", "0.5717322", "0.57160723", "0.5654426", "0.56408...
0.6002288
7
Vectorized version of `fn` that accepts arguments of any rank.
def vectorized_fn(*args): with tf.name_scope(name or 'make_rank_polymorphic'): # If we got a single value for core_ndims, tile it across all args. core_ndims_structure = ( core_ndims if tf.nest.is_nested(core_ndims) else tf.nest.map_structure(lambda _: core_ndims, args)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def autovectorized(f):\r\n def wrapper(input):\r\n if N.isscalar(input)==False:\r\n return N.vectorize(f)(input)\r\n return f(input)\r\n return wrapper", "def autovectorized(f):\r\n def wrapper(input):\r\n if N.isscalar(input)==False:\r\n return N.vecto...
[ "0.6786364", "0.6786364", "0.6500684", "0.5944921", "0.5887587", "0.5769011", "0.5756932", "0.55749714", "0.5569364", "0.5535822", "0.55204463", "0.5485098", "0.5388941", "0.5376015", "0.53529257", "0.53529257", "0.53479564", "0.53440005", "0.5334205", "0.529618", "0.5241454"...
0.65664375
2
Adds master file location for each page to the metadata_local.xml saf output file.
def add_page_admin_data(self, top, record): # type: (Element, Element) -> None cdm_struc = Fields.cdm_structural_elements dspace_local = Fields.dspace_local_field structure_el = record.find(cdm_struc['compound_object_container']) pages_el = structure_el.iterfind('.//' + cdm_stru...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build_local_metadata_file(files, home=''):\n filepaths = [os.path.join(home, f) for f in files]\n shas = [_get_sha_metadata(f) for f in filepaths]\n metadata = dict(zip(files, shas))\n\n with open(LOCAL_METADATA_FILE, 'w') as f:\n f.write(json.dumps(metadata))", "def master_archive(f, e):...
[ "0.5722937", "0.5389413", "0.5272536", "0.5261582", "0.52335477", "0.5231832", "0.5230986", "0.5189005", "0.5180332", "0.5165523", "0.5151534", "0.5123532", "0.51147246", "0.50322574", "0.50167596", "0.4984998", "0.49717563", "0.49513733", "0.49408144", "0.4935451", "0.493191...
0.4666643
61
Returns full text extracted from cdm compound object pages.
def extract_text(self, record): # type: (Element) -> str cdm_struc = Fields.cdm_structural_elements structure_el = record.find(cdm_struc['compound_object_container']) pages_el = structure_el.iterfind('.//' + cdm_struc['compound_object_page']) fulltext = '' for page in pag...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_text(self):\n\t\t\n\t\t #eliminating more headers\n\t\traw_text = re.sub(r\".*OPERATIONS O[PF].*\",r\"\",self.doc)\n\t\traw_text = re.sub(r\"Page \\d+\",r\"\",raw_text)\n\t\traw_text = re.sub(r\".*B[lL]OCK.*\",r\"\",raw_text)\n\t\traw_text = re.sub(r\".*WEST GULF.*\",r\"\",raw_text)\n\t\traw_text = re.sub(...
[ "0.6273365", "0.62023115", "0.6014343", "0.59526193", "0.5892059", "0.5881646", "0.5855388", "0.58526736", "0.58320683", "0.58169097", "0.5788491", "0.5753858", "0.57474256", "0.5684555", "0.56561995", "0.5646933", "0.5620174", "0.5598048", "0.55893654", "0.5587107", "0.55830...
0.7681376
0
Get the list of chromosome names from a fasta file
def _chrom_names(fasta_file): from pysam import FastaFile with FastaFile(fasta_file) as fa: chroms = list(fa.references) return chroms
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readFasta(self, fastaFile):\t\n\t\tname, seq = None, []\n\t\tfor line in fastaFile:\n\t\t\tline = line.rstrip()\n\t\t\tif (line.startswith(\">\")):\n\t\t\t\tif name: yield (name, ''.join(seq))\n\t\t\t\tname, seq = line, []\n\t\t\telse:\n\t\t\t\tseq.append(line)\n\t\tif name: yield (name, ''.join(seq))", "def...
[ "0.6546648", "0.64621747", "0.63865525", "0.63529944", "0.63245755", "0.63238037", "0.6276679", "0.6252582", "0.62015104", "0.6200787", "0.6186508", "0.6152302", "0.6124569", "0.60324305", "0.60317713", "0.60203993", "0.60121757", "0.6001881", "0.60012823", "0.59866214", "0.5...
0.79199076
0
Get the chromosome sizes for a fasta file
def _chrom_sizes(fasta_file): from pysam import FastaFile fa = FastaFile(fasta_file) chrom_lens = OrderedDict([(name, l) for name, l in zip(fa.references, fa.lengths)]) if len(chrom_lens) == 0: raise ValueError(f"no chromosomes found in fasta file: {fasta_file}. " "Make ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expected_readlen(bedfile, bedHeader, annoList):\n\n #chromosomes from project bed\n with open(bedfile, 'r') as f:\n if bedHeader=='yes':\n chroms = [key for key in dict(Counter([line.split('\\t')[0] for il, line in enumerate(f) if il>0])).keys()]\n else:\n chroms = [ke...
[ "0.6612106", "0.65703803", "0.6373489", "0.6340387", "0.629946", "0.62345374", "0.6110134", "0.60759944", "0.6062779", "0.6048343", "0.60378957", "0.60344946", "0.6015284", "0.59918827", "0.59908766", "0.59731734", "0.5965608", "0.5897269", "0.58564174", "0.58517754", "0.5796...
0.7949907
0