query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Creates an operation to assign specific variables from a checkpoint. | def assign_from_checkpoint(model_path, var_list, ignore_missing_vars=False):
# Normalize var_list into a dictionary mapping names in the
# checkpoint to the list of variables to initialize from that
# checkpoint variable. Sliced (including partitioned) variables will
# end up under the same key.
grouped_vars ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_assignment_map_from_checkpoint(tvars, init_checkpoint, name_to_variable=None):\n assignment_map = {}\n initialized_variable_names = {}\n\n name_to_variable2 = collections.OrderedDict()\n for var in tvars:\n name = var.name\n m = re.match(\"^(.*):\\\\d+$\", name)\n if m is n... | [
"0.62168604",
"0.6137355",
"0.5944553",
"0.58872604",
"0.5835461",
"0.58348846",
"0.56185484",
"0.56177366",
"0.54648143",
"0.54312986",
"0.54274994",
"0.5423218",
"0.54030925",
"0.539969",
"0.5388923",
"0.53831977",
"0.53695744",
"0.5356509",
"0.53548026",
"0.5352984",
"0.53... | 0.6634538 | 0 |
Returns a function that assigns specific variables from a checkpoint. If ignore_missing_vars is True and no variables are found in the checkpoint it returns None. | def assign_from_checkpoint_fn(model_path, var_list, ignore_missing_vars=False,
reshape_variables=False):
if not var_list:
raise ValueError('var_list cannot be empty')
if ignore_missing_vars:
reader = pywrap_tensorflow.NewCheckpointReader(model_path)
if isinstance(var_list, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_from_checkpoint(model_path, var_list, ignore_missing_vars=False):\n # Normalize var_list into a dictionary mapping names in the\n # checkpoint to the list of variables to initialize from that\n # checkpoint variable. Sliced (including partitioned) variables will\n # end up under the same key.\n gro... | [
"0.6835312",
"0.6188763",
"0.61575705",
"0.61223775",
"0.60590607",
"0.60547477",
"0.60530305",
"0.5938661",
"0.59001887",
"0.5770553",
"0.57095337",
"0.5641516",
"0.56196856",
"0.5574251",
"0.55675596",
"0.544628",
"0.54410195",
"0.541373",
"0.537349",
"0.52755827",
"0.52731... | 0.7012747 | 0 |
Filter a list of variables using regular expressions. First includes variables according to the list of include_patterns. Afterwards, eliminates variables according to the list of exclude_patterns. For example, one can obtain a list of variables with the weights of all | def filter_variables(var_list, include_patterns=None, exclude_patterns=None,
reg_search=True):
if reg_search:
reg_exp_func = re.search
else:
reg_exp_func = re.match
# First include variables.
if include_patterns is None:
included_variables = list(var_list)
else:
included_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ignore_patterns(*patterns):\n def _ignore_patterns(path, names):\n ignored_names = []\n for pattern in patterns:\n ignored_names.extend(fnmatch.filter(names, pattern))\n return set(ignored_names)\n return _ignore_patterns",
"def lst_and_pattern (filer_lst, pattern):\r\n ... | [
"0.57964724",
"0.56442755",
"0.5636806",
"0.5577454",
"0.5503453",
"0.5431846",
"0.5402238",
"0.5400406",
"0.5364886",
"0.5311682",
"0.52818686",
"0.5244402",
"0.5224957",
"0.5188841",
"0.5184934",
"0.51625204",
"0.5143219",
"0.51350385",
"0.51347",
"0.5123511",
"0.5111287",
... | 0.8249065 | 0 |
Sets states of random generators according to the states in states | def set_states(self, states):
if states is None:
logging.getLogger('eval').warning(
'could not reproduce state, setting unreproducable random seed for all random states')
self.randomstate.seed(np.random.randint(0, 1000000))
if hasattr(self, 'random_mask_state'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_state(state):\n old_state = RandomState()\n state.set_global()\n yield\n old_state.set_global()",
"def random_state(numStates, numLetters):\n next_state = random.randrange(0, numStates)\n replace_letter = random.randrange(0, numLetters)\n movement = random.randrange(0, 2)\n return { \"... | [
"0.7308162",
"0.7162074",
"0.71002734",
"0.69366306",
"0.69144315",
"0.6910662",
"0.6889454",
"0.6862142",
"0.6765955",
"0.6736892",
"0.66670716",
"0.65672266",
"0.65635496",
"0.64309454",
"0.64149743",
"0.64095855",
"0.64001757",
"0.6359179",
"0.6358812",
"0.63491434",
"0.63... | 0.8103714 | 0 |
Subtracts gaussian filtered data from itself | def subtract_gauss(self, data):
return data - gaussian_filter(np.float32(data),
np.asarray(self.subtractGaussSigma) * 1.0 / np.asarray(
self.pixdim[:len(data.shape)])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def differenceOfGausssians(image,sigma0, sigma1,window_size, roi, out = None):\n return (vigra.filters.gaussianSmoothing(image,sigma0,window_size=window_size,roi = roi)-vigra.filters.gaussianSmoothing(image,sigma1,window_size=window_size,roi = roi))",
"def Gauss_filter(data, sigma=(0,2,2), mode='wrap'): \n ... | [
"0.7232165",
"0.6812391",
"0.6630381",
"0.6531644",
"0.64828616",
"0.6477279",
"0.61660564",
"0.6156645",
"0.6142812",
"0.6104122",
"0.60998803",
"0.6093763",
"0.60595775",
"0.60425436",
"0.6018657",
"0.5959132",
"0.59354967",
"0.5916816",
"0.591151",
"0.5873522",
"0.5873215"... | 0.7828164 | 0 |
Returns for sample in folder all feature and mask files | def _get_features_and_masks(self, folder, featurefiles=None, maskfiles=None):
if callable(folder):
return folder()
if featurefiles is None:
featurefiles = self.featurefiles
if maskfiles is None:
maskfiles = self.maskfiles
features = [self.load(os.path.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_samples_file(foldername, filter=None):\n samples = []\n for file in os.listdir(foldername):\n if filter and file.find(filter) == -1:\n continue\n for sample in sfile(foldername + '/' + file, None).get_samples():\n samples.append(sample)\n return samples",
"def... | [
"0.66166914",
"0.66130835",
"0.6608933",
"0.6530711",
"0.64481103",
"0.64200455",
"0.6325328",
"0.6314397",
"0.63045084",
"0.6299184",
"0.62664604",
"0.6253515",
"0.6250402",
"0.62471473",
"0.62376136",
"0.6235346",
"0.61357194",
"0.61341506",
"0.6125646",
"0.61032313",
"0.60... | 0.6891864 | 0 |
Returns for one sample in the batch the extracted features and mask(s). the required output has shape [wx,wy,wz,f],[wx,wy,wz,c] with wxyz being the subvolumesize and f,c the features and classes respectively. Use onehot in here if onehot is used, optionally, if at all no one hot vector encoded data is used, the flag ca... | def _extract_sample(self, features, masks, imin, imax, shapev, needslabels=False, one_hot=True):
# prepare containers
tempdata = np.zeros([len(features)] + self.w, dtype=np.float32)
featuredata = [f.squeeze() for f in features]
templabels = []
# accumulate mean and std for norm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_features(self, all_batches, patch_size, train=True):\n # manually derive basic intensities features\n # takes 20 sec / 1048 images batch on my laptop in 4 cores //\n p = patch_size\n r = 512 // p\n labels = np.empty(0)\n feats = np.empty(0)\n for counte... | [
"0.6499046",
"0.60755986",
"0.6026276",
"0.5969846",
"0.5926118",
"0.5907687",
"0.5883537",
"0.5882107",
"0.58685726",
"0.5866911",
"0.57820857",
"0.57748795",
"0.5774845",
"0.5772144",
"0.57626563",
"0.57436514",
"0.5726673",
"0.57221794",
"0.5715351",
"0.5692676",
"0.568699... | 0.65810096 | 0 |
Helper function to get deformation field. First we define a low resolution deformation field, where we sample randomly from $N(0,I deformSigma)$ at each point in the grid. We then use cubic interpolation to upsample the deformation field to our resolution. Returns Deformation field which will be applied to the regular ... | def _get_deform_field_dm(self):
self.deformationStrength = self.deformrandomstate.rand()
adr = [w // d + 4 for w, d in zip(self.w, self.deform)]
deformshape = [len(self.w)] + adr
tmp = np.zeros([4] * (len(self.w) - 1) + [len(self.w)] + self.w)
if np.isscalar(self.deformSigma):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createDeformationPenaltyObjectiveField(self, deformActiveMeshGroup, strainActiveMeshGroup,\n curvatureActiveMeshGroup):\n if deformActiveMeshGroup.getSize() == 0:\n return None\n applyStrainPenalty = strainActiveMeshGroup.getSize() > 0\n ... | [
"0.57037216",
"0.53045064",
"0.52392256",
"0.5229295",
"0.5181391",
"0.51384366",
"0.50601166",
"0.50341386",
"0.5010564",
"0.5002808",
"0.4946104",
"0.49426365",
"0.4942302",
"0.49319822",
"0.4881891",
"0.487214",
"0.484152",
"0.48367715",
"0.4801079",
"0.47986966",
"0.47952... | 0.7466439 | 0 |
Helper function to rotate an affine matrix | def _rotate(self, affine):
dims = affine.shape[0]
if not np.isscalar(self.rotation):
raise Exception('this class requires exactly one entry for rotation!')
theta = (self.deformrandomstate.rand() - 0.5) * 2 * self.rotation
if dims == 4:
# sample unit vector:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotMatToAffine(rotmat, origin=None):\n return compose([1, 1, 1], [0, 0, 0], rotmat, origin)",
"def rotMatToAffine(rotmat, origin=None):\n return compose([1, 1, 1], [0, 0, 0], rotmat, origin)",
"def rotate(mat,angle):\n return np.dot(Mueller.rotator(angle), np.dot(mat, Mueller.rotator(-angle)))... | [
"0.74109",
"0.74109",
"0.7340204",
"0.7239959",
"0.72251",
"0.7127506",
"0.71076864",
"0.6887209",
"0.6883431",
"0.6860695",
"0.6845767",
"0.6808031",
"0.678748",
"0.6691003",
"0.66220355",
"0.6619805",
"0.66074026",
"0.66008115",
"0.6597034",
"0.6579865",
"0.65723616",
"0.... | 0.7741185 | 0 |
Threaded version of DataSetCollection. Basically a thin wrapper which employs num_threads threads to preload random samples. This will however result in possibly nonreproducible sampling patterns, as the threads run concurrently. | def __init__(self, w, p, location, foldername, featurefiles, maskfiles, nclasses, kw={}, num_threads=4, batch_size=1):
super(ThreadedDataSetCollection, self).__init__(w, p, location, foldername, featurefiles, maskfiles, nclasses, kw={})
# data_kw, kw = compile_arguments(ThreadedDataSetCollection, kw, tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_sample(self, batch_size=1, dtype=None, tp=None, **kw):\n if dtype is not None or tp is not None:\n logging.getLogger('data').warning(\n 'cant handle any special terms in random sample in this step, will use next one. this will just return preloaded stuff. terms were: {},... | [
"0.66802025",
"0.6138111",
"0.5902051",
"0.5768021",
"0.5732783",
"0.5608655",
"0.5605206",
"0.55981016",
"0.55981016",
"0.55952644",
"0.55910057",
"0.5583792",
"0.5565052",
"0.5463837",
"0.546073",
"0.5447372",
"0.54222655",
"0.5351216",
"0.53342015",
"0.53146595",
"0.531126... | 0.7136719 | 0 |
Peels one (or `frac`) of an op's entropy. | def peel(self, frac=1):
entropy = frac * self.entropy / self.count
new_sample_args = _SampleArgs(self.count, self.entropy - entropy)
return entropy, new_sample_args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entropy_py(p):\n return 2 ** np.sum(-p*np.log2(p+1e-10))",
"def entropy(p):\n ent = tf.where(p > np.finfo(np.float32).eps, -p * tf.log(p), tf.zeros_like(p))\n ent = tf.reduce_sum(ent, axis=1)\n return ent",
"def entropy(p):\n assert (p >= 0).all()\n assert abs(np.sum(p)-1) < 1e-6\n ret... | [
"0.70132893",
"0.6991378",
"0.693475",
"0.68890244",
"0.67255324",
"0.6679676",
"0.66621834",
"0.6655518",
"0.66473377",
"0.662729",
"0.662729",
"0.66131973",
"0.6591619",
"0.6588812",
"0.65721923",
"0.6556902",
"0.6514464",
"0.6509582",
"0.65031326",
"0.6478141",
"0.64604336... | 0.7026099 | 0 |
Splits the entropy and op counts up. | def split(self, args):
non_integer_count = sum(not arg.is_Integer for arg in args)
assert non_integer_count <= self.count - 1
count_split = combinatorics.uniform_non_negative_integers_with_sum(
len(args), (self.count - 1) - non_integer_count)
for i, arg in enumerate(args):
if not arg.is_In... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entropy(group_counts):\n total = sum(group_counts)\n entro = 0\n for item_count in group_counts:\n entro += item_entropy(item_count, total)\n return entro",
"def split_counts(self) -> Dict[int, int]:\n if self._split_counts is None:\n self.RefreshStats()\n return self._split_cou... | [
"0.5761378",
"0.5672865",
"0.5488079",
"0.52845055",
"0.5280407",
"0.52783406",
"0.52770764",
"0.52719724",
"0.5269366",
"0.523502",
"0.52121806",
"0.5186149",
"0.5136074",
"0.50743896",
"0.5069492",
"0.5063618",
"0.5058398",
"0.50489265",
"0.50386006",
"0.50355333",
"0.50355... | 0.6354903 | 0 |
Returns sampled args for `ops.Add`. | def _add_op(value, sample_args, rationals_allowed):
entropy, sample_args = sample_args.peel()
if rationals_allowed and sample_args.count >= 3:
x = number.integer_or_rational(entropy, True)
else:
x = number.integer(entropy, True)
if random.choice([False, True]):
op_args = [x, value - x]
else:
o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_args(self):\n raise NotImplementedError",
"def add(*args, **kwargs): # real signature unknown\n pass",
"def test_variadic_addition_takes_arbitrary_arguments(self):\n self.assertEqual(\n variadic_addition(1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15), 90\n )",
"def smar... | [
"0.6216493",
"0.61264265",
"0.5964388",
"0.59383297",
"0.59285855",
"0.5879323",
"0.5831941",
"0.5820611",
"0.57964706",
"0.5786324",
"0.5755132",
"0.5755132",
"0.57527643",
"0.57221806",
"0.5721438",
"0.5695589",
"0.56697977",
"0.5649816",
"0.56385386",
"0.56325203",
"0.5614... | 0.6495394 | 0 |
Returns sampled args for `ops.Sub`. | def _sub_op(value, sample_args, rationals_allowed):
entropy, sample_args = sample_args.peel()
if rationals_allowed and sample_args.count >= 3:
x = number.integer_or_rational(entropy, True)
else:
x = number.integer(entropy, True)
if random.choice([False, True]):
op_args = [x, x - value]
else:
o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fsl_sub(*args, **kwargs):\n cmd = ['fsl_sub']\n cmd += wutils.applyArgStyle('--', singlechar_args=True, **kwargs)\n cmd += list(args)\n return cmd",
"def _process_args(sample1, sample2, period, Nsub):\n\n # check to make sure Nsub is reasonable\n Nsub = np.atleast_1d(Nsub)\n if len(Nsub... | [
"0.5980689",
"0.5954004",
"0.5722936",
"0.5660297",
"0.56141585",
"0.5555967",
"0.55227286",
"0.5479235",
"0.5429741",
"0.53813434",
"0.53811926",
"0.5375293",
"0.53663707",
"0.53398347",
"0.5328743",
"0.5305392",
"0.5305392",
"0.5305392",
"0.5288021",
"0.5285273",
"0.5257254... | 0.63849056 | 0 |
Returns sampled args for `ops.Mul`. | def _mul_op(value, sample_args, rationals_allowed):
if sample_args.count >= 3:
_, op_args, sample_args = _div_op(value, sample_args, rationals_allowed)
op_args = [op_args[0], sympy.Integer(1) / op_args[1]]
elif sample_args.count == 1:
entropy, sample_args = sample_args.peel()
assert _entropy_of_fact... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mul(*args):\n\treturn functools.reduce(numpy.dot, args)",
"def multiply(t):\n return mul(*t)",
"def multiplier(*args):\n if not args:\n return 0\n product = args[0]\n for a in args[1:]:\n print('a is: ',a)\n product *= a\n return product,args",
"def test_mul():\n l... | [
"0.65028644",
"0.63204134",
"0.6306697",
"0.62555164",
"0.6125967",
"0.6104781",
"0.59593093",
"0.5804312",
"0.58005226",
"0.5759414",
"0.57155824",
"0.5705221",
"0.569646",
"0.56955004",
"0.56347775",
"0.562892",
"0.5613025",
"0.5613025",
"0.56069446",
"0.5596474",
"0.558736... | 0.6510621 | 0 |
Returns sampled args for `ops.Div`. | def _div_op(value, sample_args, rationals_allowed):
assert rationals_allowed # should be True if this function gets invoked
entropy, sample_args = sample_args.peel()
numer = sympy.numer(value)
denom = sympy.denom(value)
if sample_args.count == 1:
mult = number.integer(entropy, signed=True, min_abs=1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(self, args):\n non_integer_count = sum(not arg.is_Integer for arg in args)\n assert non_integer_count <= self.count - 1\n count_split = combinatorics.uniform_non_negative_integers_with_sum(\n len(args), (self.count - 1) - non_integer_count)\n for i, arg in enumerate(args):\n if no... | [
"0.6529656",
"0.58581024",
"0.5752227",
"0.5677225",
"0.5623162",
"0.5591096",
"0.5504515",
"0.5476186",
"0.5455845",
"0.54382986",
"0.5422451",
"0.5277984",
"0.52687526",
"0.52652395",
"0.5249004",
"0.5245273",
"0.5217923",
"0.51698166",
"0.515731",
"0.5155507",
"0.5155202",... | 0.6686167 | 0 |
Returns length range to sample from for given entropy. | def length_range_for_entropy(entropy):
min_length = 3
max_length = min_length + int(entropy / 2)
return min_length, max_length | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_length(self, prob_end):\n try:\n x = random.random()\n return int(ceil(log(1 - x) / log(1 - self.prob_end)))\n except ZeroDivisionError:\n return float(\"inf\")\n except ValueError:\n return 1",
"def in_range(entropy, first, last):\n ... | [
"0.6674703",
"0.65702325",
"0.6277708",
"0.6152844",
"0.58854973",
"0.5875688",
"0.58664584",
"0.57293844",
"0.5678779",
"0.56634486",
"0.5618282",
"0.559013",
"0.5576008",
"0.55733544",
"0.5560943",
"0.55545115",
"0.55454737",
"0.55331683",
"0.5531522",
"0.5525172",
"0.54975... | 0.7723809 | 0 |
List all polls created by the authenticated user passed in the URL | def get_queryset(self):
user_requested = self.kwargs['user']
self.check_object_permissions(self.request, user_requested)
return Poll.objects.filter(created_by__username=user_requested) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polls_list(request):\n\n polls = Poll.objects.all()[:MAX_OBJECTS]\n data = {\n 'result': list(polls.values('question', 'created_by__username', 'pub_date'))\n }\n return JsonResponse(data)",
"def index(request, count=10, template_name=\"pollit/index.html\"):\n polls = Poll.objects.get_la... | [
"0.69232875",
"0.6559511",
"0.6250386",
"0.6135634",
"0.59702176",
"0.58997774",
"0.58936334",
"0.57557404",
"0.5718917",
"0.5704387",
"0.5675693",
"0.5666173",
"0.5629935",
"0.5623212",
"0.56217456",
"0.56151146",
"0.56149477",
"0.56029516",
"0.55847585",
"0.5569798",
"0.556... | 0.67192817 | 1 |
creates the database and displays the Add Person and Add Student buttons | def create_database_and_tables():
create_tables("gui_database.db")
tkinter.Button(m, text="Add Person", width=25, state=tkinter.NORMAL, command=add_person).grid(row=1, column=0)
tkinter.Button(m, text="Add Student", width=25, state=tkinter.NORMAL, command=add_student).grid(row=2, column=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addUsertoDatabase(self):\r\n self.c.execute(\"\"\"INSERT INTO student_information VALUES (?,?,?)\"\"\",(self.name,self.password,self.budget,))\r\n self.con.commit()\r\n print(\"Added to Database Student..\")",
"def add_student():\n first_name = tkinter.StringVar()\n last_name = tki... | [
"0.6824883",
"0.6640587",
"0.656537",
"0.6523174",
"0.6437727",
"0.64197564",
"0.6386109",
"0.63695455",
"0.62665915",
"0.6264689",
"0.62101686",
"0.61981875",
"0.61879396",
"0.6174592",
"0.6167906",
"0.61532515",
"0.61331177",
"0.6108429",
"0.6100703",
"0.6058265",
"0.604490... | 0.80205774 | 0 |
Adds labels and entries and a submit button to allow user input for the person table | def add_person():
first_name = tkinter.StringVar()
last_name = tkinter.StringVar()
L1 = tkinter.Label(m, text="First Name:").grid(row=1, column=2)
E1 = tkinter.Entry(m, textvariable=first_name).grid(row=1, column=3)
L2 = tkinter.Label(m, text="Last Name:").grid(row=2, column=2)
E2 = tkinter.Entr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\r\n # First Name\r\n Label(master=self.root, width=15, text=\"FirstName\",\r\n font=FONT).grid(row=0, column=0)\r\n Entry(master=self.root, textvariable=self.firstname_value,\r\n font=FONT).grid(row=0, column=1)\r\n\r\n # Last Name\r\n Lab... | [
"0.64071816",
"0.6135276",
"0.6070424",
"0.6054099",
"0.60281396",
"0.59361553",
"0.58976436",
"0.589121",
"0.58833677",
"0.5797347",
"0.57704985",
"0.5738657",
"0.5728256",
"0.5716521",
"0.5680689",
"0.5674947",
"0.5669476",
"0.5572688",
"0.5511656",
"0.55104005",
"0.5509949... | 0.6652105 | 0 |
Adds labels and entries and a submit button so that the user can add input in the student table | def add_student():
first_name = tkinter.StringVar()
last_name = tkinter.StringVar()
major = tkinter.StringVar()
start_date = tkinter.StringVar()
L1 = tkinter.Label(m, text="First Name:").grid(row=1, column=2)
E1 = tkinter.Entry(m, textvariable=first_name).grid(row=1, column=3)
L2 = tkinter.L... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_form():\n\n return render_template('add_new_student.html')",
"def added_student():\n\n first = request.form.get('first_name')\n last = request.form.get('last_name')\n github = request.form.get('github')\n\n hackbright.make_new_student(first, last, github)\n first, last, github = hac... | [
"0.70333654",
"0.6876895",
"0.68746686",
"0.6845135",
"0.68205607",
"0.6697629",
"0.66860986",
"0.6676845",
"0.66571903",
"0.6650463",
"0.662474",
"0.66140735",
"0.6535434",
"0.6360365",
"0.6243973",
"0.62207836",
"0.62163514",
"0.6191204",
"0.6112361",
"0.6092716",
"0.604631... | 0.7123746 | 0 |
Create a new person for table | def create_person(conn, person, first_name, last_name):
sql = ''' INSERT INTO person(firstname,lastname)
VALUES(?,?) '''
cur = conn.cursor() # cursor object
cur.execute(sql, person)
# print(str(cur.lastrowid))
# return cur.lastrowid # returns the row id of the cursor object, the pers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_person(self):",
"def add_person():\n # get values from user\n responses = accept_inputs([\"Name\"])\n # insert into db\n query_no_results(\"insert into person (name) values(?)\", [responses[\"Name\"]])\n print(\"New person created\")",
"def create_person(conn, person):\n sql = ''' INSERT INT... | [
"0.75722355",
"0.7091311",
"0.7030813",
"0.69849616",
"0.69827104",
"0.68513817",
"0.67928904",
"0.6791365",
"0.67700744",
"0.673956",
"0.67104316",
"0.663767",
"0.66096425",
"0.66022503",
"0.65933627",
"0.65524304",
"0.6526474",
"0.6523963",
"0.65099025",
"0.6498149",
"0.649... | 0.7253005 | 1 |
Query all rows of person table | def select_all_persons(conn):
cur = conn.cursor()
cur.execute("SELECT * FROM person")
rows = cur.fetchall()
return rows # return the rows | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_people(self):\n cursor = self.cur()\n cursor.execute('SELECT * FROM {tn} '.format(tn=\"person\"))\n all_people = cursor.fetchall()\n return all_people",
"def view_all_persons():\n message = ''\n global conn\n with conn:\n rows = select_all_persons(conn)\n ... | [
"0.7363749",
"0.6895184",
"0.687416",
"0.68115944",
"0.662752",
"0.65602213",
"0.64175993",
"0.6367989",
"0.6335529",
"0.6112283",
"0.6109994",
"0.6099865",
"0.6089587",
"0.604705",
"0.6026638",
"0.60263914",
"0.5989001",
"0.5972082",
"0.5965775",
"0.5960292",
"0.593724",
"... | 0.7783174 | 0 |
Displays a messagebox with all the rows of the table | def view_all_persons():
message = ''
global conn
with conn:
rows = select_all_persons(conn)
for row in rows:
message += str(row) + "\n"
messagebox.showinfo('Person Table', message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_all_students():\n message = ''\n global conn\n with conn:\n rows = select_all_students(conn)\n for row in rows:\n message += str(row) + \"\\n\"\n messagebox.showinfo('Student Table', message)",
"def __str__(self):\n if self.row_count > 0:\n text... | [
"0.7505962",
"0.6310384",
"0.6076864",
"0.6051865",
"0.60427654",
"0.6007633",
"0.59913427",
"0.5979509",
"0.59718764",
"0.59572536",
"0.59263",
"0.5876501",
"0.5850849",
"0.5850717",
"0.5835201",
"0.5832265",
"0.58259815",
"0.58259815",
"0.58230484",
"0.5809008",
"0.5731933"... | 0.68530905 | 1 |
Displays a messagebox with all the rows of the student table | def view_all_students():
message = ''
global conn
with conn:
rows = select_all_students(conn)
for row in rows:
message += str(row) + "\n"
messagebox.showinfo('Student Table', message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_all_persons():\n message = ''\n global conn\n with conn:\n rows = select_all_persons(conn)\n for row in rows:\n message += str(row) + \"\\n\"\n messagebox.showinfo('Person Table', message)",
"def _warn_no_students(self):\n message = \"<tr><h2>No student re... | [
"0.6710546",
"0.6578968",
"0.6251814",
"0.6181921",
"0.60837096",
"0.6018903",
"0.5993211",
"0.5866789",
"0.583961",
"0.58327323",
"0.577263",
"0.575517",
"0.5698783",
"0.5647193",
"0.56337273",
"0.56305057",
"0.5627709",
"0.5616866",
"0.56106",
"0.5580707",
"0.55800766",
"... | 0.8672504 | 0 |
Returns a subclass instance. It searchs in the subclasses of `parent_class` a class named `child_class_name` and return a instance od this class | def get_implementation(parent_class, child_class_name):
for child_class in parent_class.__subclasses__():
if child_class.__name__ == child_class_name:
return child_class()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_subclass(cls, name):\r\n if name == cls.__name__:\r\n return cls\r\n for sc in cls.__sub_classes__:\r\n r = sc.find_subclass(name)\r\n if r != None:\r\n return r",
"def cast(self):\n # If the method has already been called\n if ... | [
"0.65781033",
"0.64846843",
"0.6317492",
"0.603425",
"0.5866178",
"0.5827627",
"0.57500446",
"0.5721252",
"0.55896044",
"0.5579008",
"0.555809",
"0.55421966",
"0.5435526",
"0.5409199",
"0.5368892",
"0.53422046",
"0.53409344",
"0.52888674",
"0.5203807",
"0.51809543",
"0.515689... | 0.6997745 | 0 |
Checks if the parent class has a child with a given name. It searchs in the subclasses of `parent_class` a class named `child_class_name`. Return True if found and False if not found. | def is_subclass(parent_class, child_class_name):
for child_class in parent_class.__subclasses__():
if child_class.__name__ == child_class_name:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherits_from(child, parent_name):\n if inspect.isclass(child):\n if parent_name in [c.__name__ for c in inspect.getmro(child)[1:]]:\n return True\n return False",
"def _is_child(self, parent, child): # type: (str, str) -> bool\n return child != parent and child.startswith(par... | [
"0.7700175",
"0.70731133",
"0.69098306",
"0.6596217",
"0.6537888",
"0.64802736",
"0.64243335",
"0.63680506",
"0.6199604",
"0.61832905",
"0.61542344",
"0.61510503",
"0.61478734",
"0.60139066",
"0.59975356",
"0.59762204",
"0.59752065",
"0.5948166",
"0.58978444",
"0.5865212",
"0... | 0.7708733 | 0 |
Checks if the argument corresponds to a valid class. This function checks in the subclasses of `cla` if a class with name equal to `arg` exists. If `arg` is a name of a subclass it returns the arg. If `arg` is not found it shows a a error message. | def arg_validation(arg, cla):
if is_subclass(cla, arg):
return arg
else:
print(str(arg)+" is not a valid " + cla.__module__ + " name.")
sys.exit(2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def issubclass_(arg1, arg2):\n try:\n return issubclass(arg1, arg2)\n except TypeError:\n return False",
"def check_arguments(antns, lcls) -> None:\n for (arg, cls) in antns.items():\n if arg != 'return':\n if not isinstance(lcls[arg], cls):\n raise ValueEr... | [
"0.6454346",
"0.64175355",
"0.61525893",
"0.60177636",
"0.59561396",
"0.55886906",
"0.5530505",
"0.52847475",
"0.5262159",
"0.5234184",
"0.522848",
"0.522082",
"0.5180687",
"0.5173356",
"0.5148365",
"0.51405984",
"0.513356",
"0.5112392",
"0.511173",
"0.50969696",
"0.5075133",... | 0.8172663 | 0 |
set up start position and the goal postion. Path validation checking will be conducted. If it failed, an exception will be raised. | def set_start_pos_goal_pos(self, start_pos = None, goal_pos = None, min_dist=1, forbidden_zones = None):
# type: (Union[Pose, None], Union[Pose, None], int, list) -> float
def dist(x1, y1, x2, y2):
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
if start_pos is None or goal_pos is No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_to_start(self) -> None:\n start_config = self._path_points[0]\n self._mobile.set_2d_pose(start_config[:3])\n self._path_done = False",
"def _setup_move(self, position):\n self.log.debug(\"%s.setpoint = %s\", self.name, position)\n self.setpoint.put(position, wait=True)\... | [
"0.6470809",
"0.6145283",
"0.60857165",
"0.6057012",
"0.6018808",
"0.59821063",
"0.594341",
"0.5918662",
"0.5914467",
"0.5805872",
"0.57912034",
"0.5785619",
"0.5733482",
"0.5730754",
"0.56901944",
"0.5673473",
"0.5671163",
"0.5638374",
"0.56146973",
"0.5613257",
"0.5608064",... | 0.61862135 | 1 |
watch all trades made by the user | async def watch_my_trades(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
if symbol is None:
raise ArgumentsRequired(self.id + ' watchMyTrades() requires a symbol argument')
await self.load_markets()
token = await self.authent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watch(self):",
"async def watch_trades(self, symbol: str, since: Optional[int] = None, limit: Optional[int] = None, params={}):\n await self.load_markets()\n market = self.market(symbol)\n symbol = market['symbol']\n url = self.urls['api']['ws']\n messageHash = 'trades:' + ... | [
"0.65989274",
"0.64528435",
"0.61320347",
"0.5784951",
"0.5723866",
"0.5583962",
"0.55757254",
"0.5512249",
"0.54727966",
"0.53373635",
"0.5326498",
"0.5317278",
"0.52997416",
"0.5297604",
"0.52942914",
"0.5184158",
"0.50872606",
"0.50599825",
"0.5014978",
"0.5006698",
"0.500... | 0.6696437 | 0 |
Returns an instance of holdem | def new_hand(self):
return HoldemHand(self, self.living_bot_names()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Create(options: Options) -> HolLight:\n return HolLight(options)",
"def build_hpo_from_args(cls, args):\n return cls(args)",
"def build_hpo_from_args(cls, args):\n return cls(args)",
"def __call__(self):\n self.logger.debug(\"Calling the hortator's run.\")\n self.builder.ho... | [
"0.627575",
"0.58329314",
"0.58329314",
"0.5651895",
"0.55631053",
"0.55631053",
"0.55315727",
"0.55182695",
"0.5465998",
"0.5455502",
"0.5431616",
"0.53862494",
"0.53598964",
"0.53598964",
"0.5336995",
"0.5329138",
"0.53250754",
"0.5305638",
"0.53031796",
"0.5298407",
"0.527... | 0.6023465 | 1 |
Returns the ante for this type of poker (blinds) | def ante(self):
return self.blind_manager | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hand():\n return PokerHand()",
"def straight(handIn):",
"def getAc(self, state):\n\n # Pick Action\n flip = util.flipCoin(self.epsilon)\n\n if flip:\n\t\t\treturn random.choice(self.actions)\n\n return self.getPolicy(state)",
"def handDecision(handIn):",
"def balance(self... | [
"0.58611405",
"0.56369966",
"0.5614524",
"0.5371437",
"0.53028333",
"0.5290966",
"0.528925",
"0.5274155",
"0.5235064",
"0.522024",
"0.5196193",
"0.5178067",
"0.5177758",
"0.51718146",
"0.5150989",
"0.5147935",
"0.5129904",
"0.5092044",
"0.50580466",
"0.50205696",
"0.4998582",... | 0.57949626 | 1 |
Returns the first betting round & posts the blinds | def post_blinds(self, bots):
sb, sb_bot = self.blind_manager.next_sb()
bb, bb_bot = self.blind_manager.next_bb()
self.post_bet(bb_bot, bb) # TODO: check blinds too
self.post_bet(sb_bot, sb)
return BettingRound(bots,
bets={sb_bot: sb, bb_bot: bb},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def betting_round(self, method, params):\n self.bet_history += [[]]\n current_bets = [self.starting_player] * len(self.agents)\n \n max_bet = 0\n if method == self.deal_cards:\n max_bet = big_blind\n current_bets[self.starting_player] = small_blind\n ... | [
"0.64031976",
"0.63459027",
"0.6339349",
"0.6289014",
"0.5972598",
"0.59244263",
"0.5905973",
"0.58428574",
"0.5820309",
"0.5789842",
"0.5755028",
"0.57486844",
"0.5731801",
"0.56949615",
"0.5660893",
"0.5642125",
"0.5632964",
"0.5629314",
"0.56166506",
"0.5613868",
"0.560698... | 0.74083495 | 0 |
Posts a bet, returns False on failure | def post_bet(self, bot_name, amount):
canPost = self.parent.post_bet(bot_name, amount)
if canPost:
self.pot += amount
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bet(self, amount):\n if amount >self.budget:\n print 'you cannot bet because of little money'\n else:\n self.bet_amount = amount\n print 'you bet %s' % (amount)",
"def make_bet(self, bet):\n player = bet.created_by\n if not self.can_player_bet(play... | [
"0.66587836",
"0.63938236",
"0.62226427",
"0.612066",
"0.6087978",
"0.59893805",
"0.592081",
"0.5901322",
"0.5867166",
"0.58623075",
"0.58452487",
"0.5839252",
"0.5835709",
"0.58170795",
"0.57865393",
"0.5784058",
"0.5769637",
"0.57650435",
"0.5764567",
"0.5758723",
"0.575272... | 0.8153687 | 0 |
Initiates and runs betting round | def betting_round(self, br=None):
if not br:
br = BettingRound([], {}, pot=self.pot)
self.br = br
next_better = self.br.next_better()
while next_better is not None:
action = self.get_action(next_better)
if action.is_fold():
pass
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def betting_round(self, method, params):\n self.bet_history += [[]]\n current_bets = [self.starting_player] * len(self.agents)\n \n max_bet = 0\n if method == self.deal_cards:\n max_bet = big_blind\n current_bets[self.starting_player] = small_blind\n ... | [
"0.7190761",
"0.6691903",
"0.6648264",
"0.6599042",
"0.65813476",
"0.62831223",
"0.6254384",
"0.6233227",
"0.6184275",
"0.61698276",
"0.6165777",
"0.6158858",
"0.6108256",
"0.6106388",
"0.6080524",
"0.60109127",
"0.5990889",
"0.59829116",
"0.5955529",
"0.5910741",
"0.58902603... | 0.6761822 | 1 |
Deals out hands for players. Returns the list of hands | def deal_hands(self, num_bots):
hand_size = self.parent.hand_size()
hands = []
full_deck = cards.full_deck()
hand_cards = random.sample(full_deck, hand_size * num_bots)
self.deck = [c for c in full_deck if not c in hand_cards]
for i in range(0, num_bots):
han... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_hands(self):\n # hands = []\n if self.cards:\n all_cards = (self.cards+self.cards_on_table)\n\n self.pairs_threes_fours(self.hands_list, all_cards)\n self.find_flush(self.hands_list, all_cards)\n self.find_straight(self.hands_list, all_cards)\n\n hand_n... | [
"0.77157176",
"0.7376084",
"0.7310705",
"0.70669246",
"0.6998126",
"0.6788641",
"0.67345035",
"0.66299355",
"0.65859413",
"0.654248",
"0.6534959",
"0.649788",
"0.6426278",
"0.6397394",
"0.63757473",
"0.63277453",
"0.6233128",
"0.6232093",
"0.6202542",
"0.6178694",
"0.6160786"... | 0.7565972 | 1 |
Adds table cards and tells bots | def deal_table_cards(self):
if not self.table_cards:
# the flop
self.table_cards = random.sample(self.deck, 3)
elif len(self.table_cards) >= 3:
# river & turn
self.table_cards += random.sample(self.deck, 1)
# update the deck
self.deck = [c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_setup(self):\n self.deck = Shoe(6)\n self.initial_draw()\n self.pot = ask_for_bet(self.player.money)\n show_table(self.player, self.dealer, self.pot)\n self.surrender_and_insurance()",
"def setup_cards(self, server):\r\n\t\tversions_list = self.ice.getVersionsList()\r\... | [
"0.6039495",
"0.598432",
"0.59122515",
"0.5909286",
"0.5812814",
"0.57357216",
"0.57203305",
"0.5679844",
"0.565045",
"0.56462544",
"0.562184",
"0.5620804",
"0.55883497",
"0.5581568",
"0.5575068",
"0.55537236",
"0.55394304",
"0.55253357",
"0.55214214",
"0.55138457",
"0.550237... | 0.63231176 | 0 |
Biased sample of exoEarth candidates (this is for backwards compatibility and simply returns the attribute `STARS`) | def biased_sample(self):
return self.STARS | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self):\n raise NotImplementedError",
"def sample(self):\n raise NotImplementedError",
"def sample(self):\r\n raise NotImplementedError",
"def initial_sampling(y):\n samples = list(np.random.randint(0, len(y), 2))\n while len(np.unique(y[samples] > 0.5)) != 2:\n sample... | [
"0.6169686",
"0.6169686",
"0.61144924",
"0.59609085",
"0.5919147",
"0.5856848",
"0.5811232",
"0.58083063",
"0.5800289",
"0.5784671",
"0.5761217",
"0.5741988",
"0.57238656",
"0.5719347",
"0.57166845",
"0.5700802",
"0.5698308",
"0.5680637",
"0.56745595",
"0.56520945",
"0.563238... | 0.82090783 | 0 |
Number of targets in the biased sample of exoEarth candidates (this is for backwards compatibility and simply returns the attribute `len(STARS["dist"])`) | def NBIAS(self):
return len(self.STARS["dist"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_samples(self):\n return self._dist_samples",
"def __len__(self) -> int:\n return len(self.targets)",
"def _number_of_samples(self):\n return len(self._raw_data.samples)",
"def __len__(self):\n return len(self.dataset) * self.samples_per_pair",
"def __len__(self) -> int:\n ... | [
"0.6948504",
"0.6707745",
"0.6637588",
"0.6545723",
"0.65152943",
"0.64585",
"0.6456279",
"0.6437217",
"0.63766134",
"0.63334984",
"0.63327235",
"0.6316881",
"0.6302821",
"0.6291648",
"0.6274452",
"0.6272359",
"0.6272319",
"0.62585276",
"0.624298",
"0.6203801",
"0.62007356",
... | 0.7184152 | 0 |
Apply modifications to the default telescope parameters using the `telescope_mods` dictionary | def apply_telescope_mods(self):
for key, val in self.telescope_mods.items():
self.cn.telescope.__dict__[key] = val
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_custom_environment_params(self):\n allowed_parameter_keys = [\n k for k, v in signature(Environment).parameters.items() if v.kind == v.KEYWORD_ONLY\n ]\n\n for k in allowed_parameter_keys:\n if getattr(self, k) is None:\n setattr(self, k, self.DE... | [
"0.5424974",
"0.5380471",
"0.53370035",
"0.53113395",
"0.5262344",
"0.5109461",
"0.510126",
"0.5099439",
"0.5064386",
"0.5055455",
"0.5036368",
"0.5017925",
"0.5005514",
"0.4972145",
"0.49437353",
"0.49356097",
"0.4935042",
"0.49242944",
"0.4922237",
"0.48815882",
"0.48709315... | 0.763876 | 0 |
Calculate the exposure times and spectra in each bandpass for each star in biased sample, make a Lookup Table of Exposure times for each star in sample, and calculate the spectral completeness. | def generate_exptime_table(self, ):
# Perform calculation for all stars in biased sample
Ndraw = self.NBIAS
np.random.seed(seed=None)
# Allocate memory for exposure times
t_tots = np.zeros(Ndraw)
tpbpcs = []
pct_obs_iwas = []
lammax_obs_iwas = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n# pixel_to_wavelen_dir = r'C:\\Users\\nmishra\\Workspace\\TEMPO_Spectrometer\\\n# Spectral_Band_pass\\Pixel_to_wavelen_map'\n\n file_path = r'C:\\Users\\nmishra\\Workspace\\TEMPO_Spectrometer\\Spectral_Band_pass\\\n All_FWHM_only_Gaussian'\n radia... | [
"0.59251916",
"0.5889494",
"0.58668584",
"0.5852756",
"0.58206177",
"0.581019",
"0.5747778",
"0.5731288",
"0.5702638",
"0.565488",
"0.56268436",
"0.5614268",
"0.5537106",
"0.54683",
"0.5461099",
"0.5453713",
"0.5448088",
"0.54444",
"0.5418077",
"0.54004145",
"0.53974086",
"... | 0.69805944 | 0 |
Readin file of stars in the biased list from Aki and Chris | def read_luvoir_stars(path = os.path.join(HERE, '../inputs/luvoir-A_stars.txt')):
# Read in table of 50 biased draws
data = np.loadtxt(path, delimiter=',', skiprows=1, dtype = str)
# Parse
hip = np.array(data[:,0], dtype=int)
dist = np.array(data[:,1], dtype=float)
stype = np.array(data[:,2], ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_stars(self):\n if self.hip_stars: return\n all_stars = list(hipparcos.stars())\n self.hip_stars = [None]*(max(s[0] for s in all_stars)+1)\n for s in all_stars: self.hip_stars[s[0]] = s",
"def read_ratings(ratings_file, delimiter=\" \", lda_c_format=True):\n start = 0\n\n ... | [
"0.64967763",
"0.60215795",
"0.5772857",
"0.57571405",
"0.57187355",
"0.5572739",
"0.55429167",
"0.55410725",
"0.5469029",
"0.5468003",
"0.54531586",
"0.54250324",
"0.5419696",
"0.54102165",
"0.53734684",
"0.53723425",
"0.5354032",
"0.5329599",
"0.5307909",
"0.52989876",
"0.5... | 0.65601265 | 0 |
Readin file of stellar properties | def read_stellar_properties(path = os.path.join(HERE, '../inputs/stellar_properties.txt')):
# Read in table of stellar types
data = np.loadtxt(path, skiprows=19, dtype = str)
# Parse
stypes = data[:,0]
masses = np.array(data[:,1], dtype=float)
lums = np.array(data[:,2], dtype=float)
rads =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_properties(self, inputfile):\n raise NotImplementedError(\n \"Reading from this file format is not yet implemented\")",
"def read_properties(filename):\n\n with open(filename, 'r') as f:\n lines = f.readlines()\n\n properties = get_properties(lines)\n\n return properties",
"d... | [
"0.7123777",
"0.6732739",
"0.66238713",
"0.66238713",
"0.64176804",
"0.6378018",
"0.6257663",
"0.61885655",
"0.6146393",
"0.6132385",
"0.6130643",
"0.60788804",
"0.60464084",
"0.602756",
"0.60166645",
"0.600919",
"0.60070586",
"0.59919286",
"0.5987485",
"0.5971335",
"0.596456... | 0.74040854 | 0 |
Match stellar type ``s`` with the table of stellar types and return the index in table that matches | def match_stellar_type(s, verbose = True):
# Localize array of stellar types (look how formally I am describing nothing)
stypes = STARPROPS["stypes"]
# Case: exact match
for i, st in enumerate(stypes):
if s == st:
return i
if verbose: print("No exact match found")
# Case:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTypesAndIndices(self, findAllResults = None):\n\t\tresultsIndices = [i for i,j in findAllResults]\n\t\ttypesAndIndicesResults = list()\n\n\n\t\t#=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=#\n\t\t# (1) Iterate through the (INDEX, LOCATION) formatted tuple t... | [
"0.53276575",
"0.52919364",
"0.51122546",
"0.5055065",
"0.5049623",
"0.5042426",
"0.5041216",
"0.49823987",
"0.4979846",
"0.49671325",
"0.49203026",
"0.49178946",
"0.491686",
"0.48770025",
"0.4870287",
"0.4870287",
"0.47825223",
"0.47769064",
"0.4684574",
"0.46721205",
"0.467... | 0.7454265 | 0 |
Find the exposure time to a given S/N (``wantsnr``) by fitting a curve of S/N (``snrs``) vs. time (``times``) and solving for the time at ``wantsnr``. | def find_time_from_snr(times, snrs, wantsnr):
x = times
y = snrs**2
# Fit S/N**2 curve with a line
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
y_fit = slope * x + intercept
snr_fit = np.sqrt(y_fit)
# Solve for number of occultations to get desired SNR
t_snr = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_exposure_time(cn, bandlims, wantSNR = 10.0, wantetime = 5.0, ref_lam = 0.550,\n plot_snr_curves = False, plot_spectrum = False,\n title = \"\"):\n\n # Specify Kat's fiducial S/N\n iref = np.argmin(np.fabs(cn.lam - ref_lam))\n\n if bandlim... | [
"0.7494175",
"0.7466182",
"0.6430914",
"0.64122975",
"0.61550766",
"0.61267257",
"0.60428625",
"0.5979326",
"0.59225667",
"0.5918396",
"0.58736235",
"0.5803026",
"0.5795843",
"0.5795523",
"0.57811105",
"0.5769519",
"0.5746725",
"0.573689",
"0.56865156",
"0.5654816",
"0.558355... | 0.8647179 | 0 |
Determine the exposure time needed to get a desired S/N | def determine_exposure_time(cn, bandlims, wantSNR = 10.0, wantetime = 5.0, ref_lam = 0.550,
plot_snr_curves = False, plot_spectrum = False,
title = ""):
# Specify Kat's fiducial S/N
iref = np.argmin(np.fabs(cn.lam - ref_lam))
if bandlims is not None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exposuretime(self):\n _, = self.exposuretimes\n return _",
"def exposuretime(self) -> ErrorValue:\n return ErrorValue(self._data['ExpTime'], self._data.setdefault('ExpTimeError',0.0))",
"def determine_exposure_time(self, bandlims, wantSNR = 10.0, wantetime = 5.0, ref_lam = 0.550,\n ... | [
"0.6871581",
"0.6733417",
"0.6569598",
"0.64446235",
"0.6442494",
"0.63814855",
"0.6365483",
"0.6343048",
"0.63234967",
"0.6295506",
"0.62420726",
"0.6153275",
"0.6059925",
"0.5956373",
"0.58931917",
"0.58697295",
"0.578666",
"0.5785949",
"0.57800335",
"0.5765758",
"0.573768"... | 0.67711854 | 1 |
Calculate the wavelengths of the edges of bandpasses given a minimum and maximum wavelength for the channel and the bandwidth. | def calculate_bandpass_edges(lammin, lammax, bandwidth = 0.2):
edge = lammin
edges = []
edges.append(edge)
while edge < lammax:
edge += bandwidth*edge
edges.append(edge)
edges[-1] = lammax
edges = np.array(edges)
return edges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBandwidth(self):\n # Use mean of the magnitudes as threshold\n threshold = np.mean([x[1] for x in self.fDomain])\n \n # Find freqencies which have magnitude greater than threshold\n nonZero = [f for f,x in self.fDomain if x > threshold]\n\n bandwidth = max(nonZero) - min(nonZer... | [
"0.63597786",
"0.6234616",
"0.5965107",
"0.5775817",
"0.567612",
"0.56053424",
"0.5567193",
"0.5555411",
"0.55408025",
"0.5530542",
"0.55180204",
"0.55145234",
"0.55144113",
"0.550507",
"0.54970247",
"0.54587483",
"0.54476416",
"0.5440863",
"0.54020685",
"0.5399911",
"0.53965... | 0.7211859 | 0 |
Calculate the percentage of the spectrum observable, considering IWA and OWA | def calc_observable_spectrum(cn):
# Calculate percent of observable spectrum
pct_obs_iwa = float(sum(np.isfinite(cn.Cobs))) / float(len(cn.Cobs))
if pct_obs_iwa > 0.0:
lammax_obs_iwa = np.max(cn.lam[np.isfinite(cn.Cobs)])
else:
lammax_obs_iwa = np.nan
return pct_obs_iwa, lammax_ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_percent_wet():\n # Create an ADS1115 ADC (16-bit) instance.\n adc = Adafruit_ADS1x15.ADS1115()\n\n GAIN = 1\n DRY = 20280 # 100% Dry\n WET = 10140 # 100% Wet\n\n value = adc.read_adc(0, gain=GAIN)\n \n # print \"value: %d\" % value\n \n percent_dry = ((value - WET)*100)/(DRY-W... | [
"0.5626252",
"0.561582",
"0.5607241",
"0.55847454",
"0.5557009",
"0.55398446",
"0.5538227",
"0.54864305",
"0.54399765",
"0.5416714",
"0.54151183",
"0.5388908",
"0.53622645",
"0.5361504",
"0.5361131",
"0.5350198",
"0.53245234",
"0.5323617",
"0.531109",
"0.5304305",
"0.52901214... | 0.62991047 | 0 |
Calculate partial derivatives of exposure time wrt completeness for each bandpass | def calc_dtdc(tpbpcs, specs):
# Calc wavelength range of channels
deltas = []
for channel in CHANNELS:
l = default_luvoir(channel=channel)
deltas.append(l.lammax - l.lammin)
deltas = np.array(deltas)
Nbs = len(np.hstack(tpbpcs[0]))
Ndraw = len(tpbpcs)
dtpb = np.zeros((Ndra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fractional_degradation(bt):\n\n\n\n NomIch = 0.125 # Nominal charge current\n NomId = 0.25 # Nominal discharge current\n NomSoC = 0.5 # Nominal state of charge_mode\n NomDoD = 1.0 # Nominal depth of discharge\n B = 5 #Battery capacity\n qt = 5 * 0.5 # Amount of energy in the battery at t... | [
"0.5949696",
"0.58660024",
"0.586285",
"0.5764905",
"0.5730045",
"0.5618543",
"0.56079733",
"0.5597028",
"0.55723864",
"0.5553674",
"0.5533361",
"0.55212605",
"0.55199355",
"0.5518749",
"0.5514031",
"0.5483892",
"0.5474791",
"0.546746",
"0.5466294",
"0.5457997",
"0.5451753",
... | 0.5981035 | 0 |
Calculate partial derivatives of exposure time wrt completeness for each bandpass for a single star | def calc_dtdc_star(tpbpc0, spec):
# Calc wavelength range of channels
deltas = []
for channel in CHANNELS:
l = default_luvoir(channel=channel)
deltas.append(l.lammax - l.lammin)
deltas = np.array(deltas)
# Create array of times per bandpass
dtpb = np.hstack(tpbpc0)
Nbs = l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_derivative(x, y, finitediff_scheme = 'central'):\n if finitediff_scheme == 'central':\n return np.gradient(y, x[1]-x[0])\n \n elif finitediff_scheme == 'five point stencil':\n y = [0, 0] + list(y) + [0, 0]\n numerator = np.array([y[i-2] - 8*y[i-1] + 8*y[i+1] - y[i+2] for i i... | [
"0.63313264",
"0.5978934",
"0.5949833",
"0.58804667",
"0.5727019",
"0.5699118",
"0.5682633",
"0.56594366",
"0.56358135",
"0.56290436",
"0.5603968",
"0.56028265",
"0.56003475",
"0.5598034",
"0.5590458",
"0.55590606",
"0.5557983",
"0.55353916",
"0.55276895",
"0.5516486",
"0.548... | 0.6076038 | 1 |
Convenience function for getting bandpass indices to remove from exposure time estimates. Removes the `Nremove_uv` shortest UV bandpasses, and the `Nremove_nir` longest NIR bandpasses. | def get_iremove(drm, Nremove_uv = 0, Nremove_nir = 0):
iremove = []
ibp = np.arange(len(drm.bp_names))
iremove.append(ibp[drm.bp_chan == 0][:Nremove_uv])
if Nremove_nir > 0:
iremove.append(ibp[drm.bp_chan == 2][-Nremove_nir:])
iremove = np.hstack(iremove)
return iremove | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtain_filters_mask(model, threshold, cba_index, prune_index):\n\n num_pruned_bn = 0\n num_total_bn = 0\n num_remain_filters = []\n mask_remain_filters = []\n\n # The number of filters reserved must be a multiple of 8\n int_multiple = 8\n filter_switch = list(range(0, 1024, int_multiple))\... | [
"0.5299266",
"0.51571965",
"0.51164657",
"0.5102673",
"0.49791998",
"0.4863325",
"0.4843844",
"0.48289192",
"0.48070356",
"0.4788244",
"0.47462708",
"0.47393328",
"0.47309726",
"0.47026223",
"0.46649647",
"0.4661772",
"0.4650568",
"0.46372223",
"0.4625088",
"0.4616329",
"0.46... | 0.6156296 | 0 |
Returns the text representation of a specified font value. | def string_value ( self, font ):
return self.factory.str_font( font ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def font(value):\r\n retval = '{}, {}pt'.format(value.family(), value.pointSize())\r\n if value.bold():\r\n retval.append(', Bold')\r\n if value.italic():\r\n retval.append(', Italic')\r\n return retval",
"def get_text_font ( self, object ):\n return self.... | [
"0.7398471",
"0.72234523",
"0.7097466",
"0.68534625",
"0.68534625",
"0.68534625",
"0.68036646",
"0.6624019",
"0.6620017",
"0.6620017",
"0.6611013",
"0.6590705",
"0.6572161",
"0.6510399",
"0.64985096",
"0.64556724",
"0.64556724",
"0.64556724",
"0.6371767",
"0.63261575",
"0.628... | 0.8232986 | 1 |
Returns the text representation of a specified font value. | def string_value ( self, font ):
return self.factory.str_font( font ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def font(value):\r\n retval = '{}, {}pt'.format(value.family(), value.pointSize())\r\n if value.bold():\r\n retval.append(', Bold')\r\n if value.italic():\r\n retval.append(', Italic')\r\n return retval",
"def get_text_font ( self, object ):\n return self.... | [
"0.73973465",
"0.7225053",
"0.70989573",
"0.6854329",
"0.6854329",
"0.6854329",
"0.6805624",
"0.6625804",
"0.6620491",
"0.6620491",
"0.66118586",
"0.65923446",
"0.6572676",
"0.6510929",
"0.64974993",
"0.6456198",
"0.6456198",
"0.6456198",
"0.63728213",
"0.63254124",
"0.628266... | 0.8232984 | 0 |
Returns a list of all available font facenames. | def all_facenames ( ):
global facenames
if facenames is None:
facenames = FontEnumerator().facenames()
facenames.sort()
return facenames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAvailableFonts():\n return list(AVAILABLE_FONTS)",
"def EnumerateFacenames(*args, **kwargs):\n return _gdi_.FontEnumerator_EnumerateFacenames(*args, **kwargs)",
"def get_fonts(self):\n\n font_path = self.execute_shell([\"figlet\", \"-I2\"])\n\n # get the font files installed in f... | [
"0.7619632",
"0.75130725",
"0.7447827",
"0.728646",
"0.71849185",
"0.7153872",
"0.7141047",
"0.696342",
"0.68501276",
"0.67382056",
"0.66518176",
"0.6466054",
"0.62443954",
"0.62064373",
"0.6169622",
"0.6169622",
"0.5993528",
"0.59824425",
"0.594107",
"0.5912809",
"0.5901097"... | 0.8033729 | 0 |
Adds a facename to the list of facenames. | def OnFacename ( self, facename ):
self._facenames.append( facename )
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_name(self, msg, name):\n try:\n names = self.get_local(msg, \"names\")\n except KeyError:\n names = set()\n names.add(name)\n self.set_local(msg, \"names\", names)",
"def add_name(self, name: str) -> None:\n self._names.append(name)",
"def Add_P... | [
"0.62210596",
"0.62210333",
"0.6215424",
"0.6033222",
"0.5984161",
"0.5931371",
"0.5924651",
"0.58587897",
"0.5827593",
"0.5749837",
"0.5749821",
"0.57296735",
"0.5633959",
"0.5562073",
"0.55501986",
"0.5483315",
"0.5428961",
"0.541282",
"0.541282",
"0.541282",
"0.541282",
... | 0.7935888 | 0 |
Validates that the value is a valid font. | def validate ( self, object, name, value ):
if isinstance( value, wx.FontPtr ):
return wx.Font( value.GetPointSize(), value.GetFamily(),
value.GetStyle(), value.GetWeight(),
value.GetUnderlined(), value.GetFaceName() )
if isinst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def com_google_fonts_check_fontvalidator(font):\n\n # In some cases we want to override the severity level of\n # certain checks in FontValidator:\n downgrade_to_warn = [\n # There are reports that this fontval check has an out-of-date\n # understanding of valid bits in fsSelection.\n ... | [
"0.63009137",
"0.6169062",
"0.5997949",
"0.5961517",
"0.5961517",
"0.5899231",
"0.5867492",
"0.5738144",
"0.5730531",
"0.5730531",
"0.5730531",
"0.5730531",
"0.5719301",
"0.5707549",
"0.5670295",
"0.5636703",
"0.5623779",
"0.5587016",
"0.55710924",
"0.5545384",
"0.5523181",
... | 0.7866187 | 0 |
Initializes the view with a UI file and controller. | def __init__(self, ui_file, controller):
super(InputDeviceView, self).__init__()
self._controller = controller
self._controller.accepted_cb = self._accepted_cb
self._controller.finished_cb = self._finished_cb
self._controller.rejected_cb = self._rejected_cb
self._controll... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializeUI(self):\n self.setGeometry(100, 100, 450, 300)\n self.setWindowTitle('Model and View Example')\n\n self.setupModelView()\n\n self.show()",
"def __init__(self, controller):\n super().__init__(controller)\n\n # The hovered input when entering this View.\n ... | [
"0.7248268",
"0.7145642",
"0.7036695",
"0.70253474",
"0.70253474",
"0.7004317",
"0.6981535",
"0.69356894",
"0.6892194",
"0.6872939",
"0.6849647",
"0.6809081",
"0.67459863",
"0.67254186",
"0.6661732",
"0.6589518",
"0.658016",
"0.6536004",
"0.6531064",
"0.64835227",
"0.6429686"... | 0.72222 | 1 |
Create a button layout with a given list of buttons. | def create_layout(layout_list):
qt_button_layout = QGridLayout()
for row in range(len(layout_list)):
for column in range(len(layout_list[row])):
user_input_object = layout_list[row][column]
qt_button_layout.addWidget(user_input_object, row, column, 1, 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createButtons (self,buttons):\n \n assert(self.frame)\n self.buttonsFrame = f = Tk.Frame(self.top)\n f.pack(side=\"top\",padx=30)\n \n # Buttons is a list of dictionaries, with an empty dictionary at the end if there is only one entry.\n buttonList = []\n for... | [
"0.74043524",
"0.73431706",
"0.7313075",
"0.72893983",
"0.72875595",
"0.71218115",
"0.7068241",
"0.7052268",
"0.70102775",
"0.700969",
"0.69705063",
"0.6946102",
"0.6911984",
"0.691197",
"0.6894172",
"0.6798479",
"0.67800224",
"0.6755896",
"0.67166936",
"0.66708875",
"0.66404... | 0.77870786 | 0 |
View a dictionary as a tree. | def tree_view(dictionary, level=0, sep="| "):
return "".join(["{0}{1}\n{2}".format(sep * level, k,
tree_view(v, level + 1, sep=sep) if isinstance(v, dict)
else "") for k, v in dictionary.items()]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_tree(data):\r\n tree_dict = []\r\n ids = []\r\n for i in data:\r\n d = dict()\r\n if i[0] in ids:\r\n continue\r\n ids.append(i[0])\r\n d[\"id\"] = i[0]\r\n d[\"name\"] = i[1]\r\n d[\"parent_id\"] = i[2]\r\n tree_dict.append(d)\r\n re... | [
"0.6563242",
"0.65209043",
"0.6508701",
"0.64270383",
"0.637521",
"0.62833416",
"0.62653875",
"0.6258056",
"0.6221534",
"0.6127325",
"0.6058922",
"0.6045513",
"0.603142",
"0.5993908",
"0.58921003",
"0.5880034",
"0.58683693",
"0.58669186",
"0.58544075",
"0.58173305",
"0.578462... | 0.75033796 | 0 |
converts a "number" between two bases of arbitrary digits The input number is assumed to be a string of digits from the fromdigits string (which is in order of smallest to largest digit). The return value is a string of elements from todigits (ordered in the same way). The input and output bases are determined from the... | def baseconvert(number,fromdigits,todigits):
base_length = len(todigits)
if str(number)[0]=='-':
number = str(number)[1:]
neg=1
else:
neg=0
# make an integer out of the number
x=0
for digit in str(number):
x = x*len(fromdigits) + fromdigits.index(digi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_base(num, to_base):\n\n\tdigits = '0123456789ABCDEF'\n\tresult = ''\n\n\tif num < to_base:\n\t\treturn digits[num]\n\telse:\n\t\tresult += convert_base(num/to_base, to_base) + str(digits[num % to_base])\n\n\treturn result",
"def baseconvert(num, base):\n\n digits = \"0123456789abcdefghijklmnopqrst... | [
"0.7615766",
"0.75841296",
"0.7543608",
"0.7498576",
"0.73923254",
"0.73196465",
"0.7230216",
"0.7125774",
"0.70825726",
"0.70246345",
"0.6990899",
"0.69843537",
"0.69652426",
"0.69446844",
"0.6893685",
"0.6863349",
"0.68421364",
"0.68271345",
"0.67968136",
"0.676588",
"0.667... | 0.81449544 | 0 |
Given a python file object handle or string {handle_or_string} and an optional download filename {filename}, returns the file as an django HttpResponse with the file as an attachment (or inline) with the given mimetype (or text/plain) | def render_file(handle_or_string, filename=None, attachment=True, **kwargs):
mimetype = kwargs.get('mimetype', 'text/plain')
file_extension = mimetypes.guess_extension(mimetype)
try:
filename = filename or handle_or_string.name().split('/').pop()
except Exception:
filename = 'downl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_tmp_file(path, filename):\n try:\n _file = file(_path)\n wrapper = FileWrapper(_file)\n\n # use the same type for all files\n response = HttpResponse(wrapper, content_type='text/plain') \n response['Content-Disposition'] = \\\n 'attachment; filename=%s'... | [
"0.73793066",
"0.69927627",
"0.69741476",
"0.69505024",
"0.6823743",
"0.67004406",
"0.6698304",
"0.6663933",
"0.65978765",
"0.6586101",
"0.65085423",
"0.64557254",
"0.6353056",
"0.63301694",
"0.6327514",
"0.6306466",
"0.6271697",
"0.6250155",
"0.6235979",
"0.6226186",
"0.6203... | 0.8286043 | 0 |
Returns the response that should be used for any given exception. By default we handle the REST framework `APIException`, and also Django's builtin `Http404` and `PermissionDenied` exceptions. Any unhandled exceptions may return `None`, which will cause a 500 error to be raised. | def exception_handler(exc):
if isinstance(exc, exceptions.APIException):
headers = {}
if getattr(exc, 'auth_header', None):
headers['WWW-Authenticate'] = exc.auth_header
if getattr(exc, 'wait', None):
headers['X-Throttle-Wait-Seconds'] = '%d' % exc.wait
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_exception(self, e):\n if isinstance(e, exceptions.APIException):\n return e.get_response(self.request)\n else:\n exc = exceptions.OtherException(self.request)\n return exc.get_response(self.request)",
"def handle_rest_exceptions(exception):\n current_a... | [
"0.816386",
"0.7389566",
"0.73394346",
"0.7265155",
"0.722443",
"0.7183048",
"0.7134983",
"0.71019715",
"0.7067629",
"0.6941416",
"0.6903765",
"0.6816334",
"0.68008983",
"0.672555",
"0.6717365",
"0.6716618",
"0.6693696",
"0.6635723",
"0.66240084",
"0.6620419",
"0.6613883",
... | 0.7865565 | 1 |
Validates that role and/or visible is set. | def validate_schema(self, data, **kwargs):
if "role" not in data and "visible" not in data:
raise ValidationError(_("Missing fields 'role' and/or 'visible'.")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_role(self):\n\n\t\tif not self.required_roles or not self.available_roles:\n\t\t\treturn True\n\t\telif current_user.is_authenticated():\n\t\t\tcurrent_user_role = current_user.get_role()\n\t\t\tif current_user_role in self.available_roles:\n\t\t\t\tif current_user_role==self.admin_role or current_user_r... | [
"0.6381865",
"0.63730305",
"0.60829353",
"0.5916166",
"0.5800082",
"0.57887334",
"0.57834834",
"0.57579887",
"0.57150906",
"0.5697134",
"0.5692678",
"0.56645215",
"0.56466347",
"0.5625679",
"0.56247556",
"0.5615779",
"0.55929697",
"0.5543738",
"0.5543738",
"0.5540613",
"0.552... | 0.7275286 | 0 |
Downloads the SQuAD devv2 dataset and organises it into a more convenient pandas dataframe. | def import_squad_data():
squad_url = (
"https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v2.0.json"
)
squad_file = squad_url.split("/")[-1] # last part of URL
urllib.request.urlretrieve(squad_url, squad_file)
if not os.path.isfile(squad_file):
sys.exit("Dataset %s does not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_WDSC():\n url = \"http://www.astro.gsu.edu/wds/Webtextfiles/wdsnewframe.html\"\n df = pd.read_csv(url)\n return df",
"def get_data():\n \n \"\"\" Prepare variables\"\"\"\n urls = {\"cases\": \"https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_... | [
"0.64800286",
"0.6266322",
"0.6245987",
"0.61916196",
"0.6117389",
"0.6060555",
"0.6048737",
"0.60233825",
"0.59590787",
"0.59565973",
"0.5951806",
"0.59300363",
"0.5908885",
"0.5905963",
"0.58836305",
"0.586783",
"0.58453614",
"0.5840279",
"0.58102465",
"0.5787542",
"0.57478... | 0.6284212 | 1 |
Prints all the SQuAD entries for a given subject. | def print_squad_questions(subject=None):
squad_data = import_squad_data()
if subject:
if subject == "all":
squad_records = squad_data
else:
squad_records = squad_data.loc[squad_data["subject"] == subject]
if squad_records.empty:
print("Subjec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printSubjects(subjects):\n totalVal, totalWork = 0,0\n if len(subjects) == 0:\n return 'Empty SubjectList'\n res = 'Course\\tValue\\tWork\\n======\\t====\\t=====\\n'\n subNames = subjects.keys()\n subNames.sort()\n for s in subNames:\n # since subject names are mapped to a tuple... | [
"0.6460253",
"0.6202064",
"0.61894804",
"0.5799627",
"0.57277864",
"0.5642564",
"0.56296587",
"0.5510864",
"0.5427583",
"0.5416026",
"0.54028857",
"0.540213",
"0.5349518",
"0.5278738",
"0.527564",
"0.52662796",
"0.525741",
"0.5251228",
"0.5248044",
"0.52118486",
"0.5211167",
... | 0.77366245 | 0 |
sum series(n,v1=0,v2=1) return "n"th value of sum series having v1 and v2 as first and second values | def sum_series(n,v1=0,v2=1):
L1=v2
L2=v1
if n<0:
print("please enter positive int value")
elif n==0:
return v1
elif n==1:
return v2
else:
for i in range(n-1):
C=L1+L2
L2=L1
L1=C
return C | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_series(n, first_val = 0, second_val = 1):\n if n == 0:\n return first_val\n elif n == 1:\n return second_val\n else:\n return (sum_series(n-1,first_val,second_val) +\n sum_series(n-2, first_val, second_val))",
"def sum_series(n, first_value=0, second_value=1):... | [
"0.85407114",
"0.8399829",
"0.83239585",
"0.830645",
"0.8302319",
"0.8260728",
"0.8238859",
"0.8155529",
"0.7858599",
"0.7824844",
"0.7818001",
"0.75618297",
"0.75481045",
"0.7455415",
"0.73083234",
"0.72955143",
"0.7232084",
"0.71643716",
"0.71105635",
"0.7031175",
"0.694662... | 0.8511392 | 1 |
Inject an identity header for development purposes. | def process_request(self, request):
if hasattr(request, "META") and (hasattr(settings, "DEVELOPMENT_IDENTITY") and settings.DEVELOPMENT_IDENTITY):
request_id_header = None
if request.META.get(self.header):
request_id_header = json.loads(b64decode(request.META.get(self.hea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeIdentity(self) -> None:\n ...",
"def setIdentity(self) -> None:\n ...",
"def provider_identity(request):\r\n\r\n response = render_to_response('identity.xml',\r\n {'url': get_xrds_url('login', request)},\r\n mimetype='te... | [
"0.6080172",
"0.58050346",
"0.56467897",
"0.5593176",
"0.5590102",
"0.55792236",
"0.54829985",
"0.5461433",
"0.5455945",
"0.54513586",
"0.5390048",
"0.53465533",
"0.5326575",
"0.5318545",
"0.52557725",
"0.52359253",
"0.5210191",
"0.5182606",
"0.5162821",
"0.5150612",
"0.51262... | 0.59359044 | 1 |
Returns a copy of the locals for this instance | def get_locals_copy(self): # this function has none of its own testing because of its simplicity
return copy.deepcopy(self.__locals) # a copy is made so no changes propagate after function call
| {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_locals(self):\n self._locals = dict()",
"def __body__(cls):\n return locals()",
"def init_locals(self):\n pass",
"def variables(self):\n if save_context.in_save_context():\n return [self._vars[0]]\n return self._vars",
"def variables(self):\n return self._.v... | [
"0.6877947",
"0.68744916",
"0.68468225",
"0.66331345",
"0.6561542",
"0.65314925",
"0.6527621",
"0.65117097",
"0.6501746",
"0.64978904",
"0.64862746",
"0.64292955",
"0.6360151",
"0.6355349",
"0.6337556",
"0.63040286",
"0.62848973",
"0.6276612",
"0.62608",
"0.6234804",
"0.62323... | 0.8474401 | 0 |
Sets the depth of the meta optimization | def set_depth(self, d):
self.depth = d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_depth(node, depth):\n setattr(node[0], \"depth\", depth)",
"def set_depth(self, depth):\n self._depth = depth\n if self._scaled_image_coordinates is None:\n self._initialise()\n else:\n self._update_depth()",
"def setDepth(self, *args):\n return _Com... | [
"0.6856102",
"0.68161947",
"0.663544",
"0.6445991",
"0.6442644",
"0.620512",
"0.6200456",
"0.6039289",
"0.60049015",
"0.59819305",
"0.59119964",
"0.5897186",
"0.5789943",
"0.57407606",
"0.57189655",
"0.57090366",
"0.5706975",
"0.5686296",
"0.5670248",
"0.5658983",
"0.5600678"... | 0.68477595 | 1 |
Sets the axes of the final optimization | def set_axes(self, a):
self.axes = a | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_axes(self):\n data_shape = self.data.shape\n if len(self.axes) < self.data.ndim + 1:\n self._axes.append(Axis())\n for index in range(self.data.ndim):\n if len(self.axes[index].values) != data_shape[index]:\n self.axes[index].values = np.arange(... | [
"0.6624351",
"0.6607387",
"0.65469986",
"0.64689714",
"0.6465021",
"0.63839453",
"0.63570523",
"0.633108",
"0.62871677",
"0.6181594",
"0.6172089",
"0.61637175",
"0.6149092",
"0.6110123",
"0.6089712",
"0.6063385",
"0.6063385",
"0.6063385",
"0.6060724",
"0.6044115",
"0.5972315"... | 0.73003435 | 0 |
Function to create SDX pick metadata files. | def create_sdxmetadata(sdx_dir, output_dir):
#define list to store SDX information
instrument = []
picks = []
phases = []
#segment and store metadata
#define SDX files to be read
for root, dirs, files in os.walk(sdx_dir):
for idx, file in enumerate(files):
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_metadata_files(self):\n\n data_folder = self.get_data_folder(mode='absolute')\n\n parents = (data_folder / '_').parents\n\n for mfile in self.mdata:\n for regex, level in METADATA_LEVEL_BY_NAME.items():\n if re.compile(regex).match(mfile.name):\n ... | [
"0.56762755",
"0.56330436",
"0.5571166",
"0.5526829",
"0.54282945",
"0.53991246",
"0.5392514",
"0.5382981",
"0.52756345",
"0.524292",
"0.5220071",
"0.5204072",
"0.5186867",
"0.516208",
"0.51598644",
"0.5144246",
"0.50878596",
"0.5087506",
"0.50685555",
"0.5067621",
"0.5066993... | 0.66435 | 0 |
Create a valid protocol message, with length field | def create_msg(data):
length = str(len(str(data))).zfill(LENGTH_FIELD_SIZE)
return length + data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_msg(data):\n length = str(len(str(data))).zfill(LENGTH_FIELD_SIZE)\n return length + str(data)",
"def _pack_length(buffer: bytes) -> bytes:\n length = len(buffer)\n length_bytes = struct.pack('!Q', length)\n return length_bytes",
"def getLength(msg):\n return len(msg)",
"def encode_len... | [
"0.749747",
"0.67009306",
"0.6461154",
"0.61778706",
"0.6078046",
"0.6064738",
"0.6033815",
"0.5979925",
"0.597804",
"0.59384704",
"0.59168154",
"0.5863091",
"0.5849191",
"0.5846936",
"0.5832208",
"0.581549",
"0.5800198",
"0.5790691",
"0.5787721",
"0.5785481",
"0.57715964",
... | 0.74868876 | 1 |
This is the main function that sniff packets and transfers them to the hash function | def sniffing():
sniff(store=False, prn=lambda p: threading.Thread(target=sendHash, args=(p,)).start(), iface=IFACE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_packet(hash_str, size, s, d, count_dict, count_dict1, mark_dict, \n threshold, mark_group, seeds, polys, min_len, \n flow_paths, cflow_dict, app_link_dict, app_link_flow_dict, switch_nodes, table, select_dict, drop_id=0, r_threshold=0.0, black_hole='sh41', test_hop='',\n add_byte_dict... | [
"0.6474424",
"0.6359119",
"0.62538487",
"0.6235134",
"0.59752506",
"0.5920086",
"0.5838938",
"0.5832938",
"0.57783926",
"0.57677263",
"0.5712464",
"0.5671513",
"0.56459",
"0.56209433",
"0.5620818",
"0.56199867",
"0.5615371",
"0.56076825",
"0.5603673",
"0.55900735",
"0.5585948... | 0.75437576 | 0 |
Creates a wrapper for a renamed function or class. Prints a warning the first time a function or class is called with the old name. | def new_name_wrapper(
old_name: str, new_name: str, function_or_class: Callable
) -> Callable:
return deprecation_wrapper(
f"{old_name} is deprecated! Use {new_name} instead.", function_or_class
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_func_naming(func, name):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n warnings.warn(\n f\"Mixed case function naming is deprecated for '{name}'. \"\n f\"Please use '{func.__name__}' instead.\",\n DeprecationWarning\n )\n return func(*args, ... | [
"0.6507759",
"0.6414057",
"0.62374413",
"0.61508393",
"0.60380816",
"0.60260385",
"0.60256696",
"0.60150594",
"0.60078204",
"0.6007601",
"0.5990988",
"0.59894556",
"0.5980194",
"0.5934418",
"0.5912185",
"0.59046227",
"0.5889946",
"0.5888073",
"0.58767617",
"0.5855475",
"0.585... | 0.7470738 | 0 |
TODO(dwadden) Write documentation. The trigger embeddings are just the contextualized token embeddings, and the trigger mask is the text mask. For the arguments, we consider all the spans. | def forward(self, # type: ignore
trigger_mask,
trigger_embeddings,
spans,
span_mask,
span_embeddings, # TODO(dwadden) add type.
cls_embeddings,
sentence_lengths,
output_ner, # Needed if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_trigger_scores(self, trigger_embeddings, cls_projected, trigger_mask):\n cls_repeat = cls_projected.unsqueeze(dim=1).repeat(1, trigger_embeddings.size(1), 1)\n trigger_embeddings = torch.cat([trigger_embeddings, cls_repeat], dim=-1)\n if self._trigger_attention_context:\n ... | [
"0.5379738",
"0.5068709",
"0.5044443",
"0.4986414",
"0.49602845",
"0.48483908",
"0.48194224",
"0.48042494",
"0.4755274",
"0.47548753",
"0.47402453",
"0.47113836",
"0.47113836",
"0.47074533",
"0.46984977",
"0.46959755",
"0.46864945",
"0.46850377",
"0.467997",
"0.46317896",
"0.... | 0.6356573 | 0 |
Compute trigger scores for all tokens. | def _compute_trigger_scores(self, trigger_embeddings, cls_projected, trigger_mask):
cls_repeat = cls_projected.unsqueeze(dim=1).repeat(1, trigger_embeddings.size(1), 1)
trigger_embeddings = torch.cat([trigger_embeddings, cls_repeat], dim=-1)
if self._trigger_attention_context:
contex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze(self, tokens):\n score = 0\n recognized = 0\n \n if isinstance(tokens, list):\n tokens = Counter(tokens)\n\n for token, count in tokens.iteritems():\n if self.tokens.get(token):\n recognized += count\n score += count... | [
"0.5932834",
"0.57554513",
"0.5711732",
"0.56320643",
"0.555392",
"0.5513107",
"0.5503072",
"0.54894024",
"0.5481041",
"0.5473058",
"0.54386693",
"0.5396136",
"0.53766304",
"0.536205",
"0.53598356",
"0.5353856",
"0.535341",
"0.5315351",
"0.53079814",
"0.5300649",
"0.5289317",... | 0.6910087 | 0 |
Copy a payload file to a target DUT. This constructs a `RemoteDevice`, and calls its `CopyToDevice()` method to copy a payload file to the target device. A payload file is either the `stateful.tgz` tarball, or a Chrome OS AU payload (typically a full payload). | def CopyPayload(request_data):
log_handler = None
log_file = request_data.kwargs.get('log_stdout_to_file')
if log_file:
log_handler = logging.FileHandler(log_file)
log_handler.setFormatter(LOG_FORMATTER)
logging.getLogger().addHandler(log_handler)
try:
device = remote_access.RemoteDevice(request... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_os_release_file(dut, fname=default_os_release_file):\n # src = os.path.join(os.path.sep, 'shared', os_release_files_dir, fname)\n dst = os.path.join(os.path.sep, 'etc', 'os-release')\n dut(\"/bin/cp /tmp/files/os_releases/\" + fname + \" \" + dst, shell=\"bash\")",
"def ExportPayload(self, bund... | [
"0.52353776",
"0.51343566",
"0.4853628",
"0.48450089",
"0.4818834",
"0.4775596",
"0.4772644",
"0.4769703",
"0.4729799",
"0.47202316",
"0.47200903",
"0.47027627",
"0.4688308",
"0.4659099",
"0.46321183",
"0.46221995",
"0.45900363",
"0.4582369",
"0.45655885",
"0.45549017",
"0.45... | 0.6377265 | 0 |
Set method this WebEngine request is using. | def set_method(
self, method: MethodStr | QtWebEngineCore.QWebEngineHttpRequest.Method
):
self.setMethod(METHODS.get_enum_value(method)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMethod(self, method):\n\t\tself.method = method",
"def set_method(self, method):\n self.method = method",
"def setMethod(self, method):\n self.__set('method', method)",
"def Method(self, method):\n if not self.PostData:\n self._method = \"GET\"\n return\n ... | [
"0.7414499",
"0.726228",
"0.702355",
"0.665484",
"0.6639448",
"0.63432384",
"0.62657696",
"0.62472636",
"0.61951697",
"0.6175338",
"0.61433625",
"0.6134554",
"0.6128594",
"0.60774136",
"0.598188",
"0.5975263",
"0.59571177",
"0.59421414",
"0.5902525",
"0.5867244",
"0.58657044"... | 0.7805747 | 0 |
Entry point for resolving JSON pointers doc_uri is the URI of the JSON document in obj. obj can either be a dict or list object (possibly of a sub class) raises RefResolutionError on problems with the resolution | def resolve(self, doc_uri, obj):
self.cache = {doc_uri: obj}
return self._resolve(doc_uri, obj, obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resolve_dict_entry(self, doc_uri, main_doc, obj):\n # Interpret '$ref' key if present in obj\n if '$ref' in obj:\n result = self._load_ref(doc_uri, main_doc, obj['$ref'])\n else:\n result = self.dict_class()\n # Merge values from obj with result\n for k... | [
"0.7121993",
"0.7074867",
"0.6293771",
"0.59772015",
"0.5967495",
"0.5828319",
"0.58193433",
"0.5738192",
"0.5537941",
"0.55091614",
"0.5432009",
"0.52734804",
"0.52333444",
"0.52217376",
"0.52020717",
"0.51889354",
"0.51600057",
"0.51302445",
"0.5129704",
"0.5105317",
"0.510... | 0.7165876 | 0 |
To load the data from csv file and convert into dataframe as chunks and return generator object value. | def file_reader(self, filename):
for chunk in pd.read_csv(filename, chunksize = Reader.chunksize,delimiter='_'):
yield chunk | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_generators_from_csv(csv_file):\n with open(csv_file, mode='r', encoding='utf-8',\n errors='ignore') as source_data:\n source_data.readline() # skip header\n\n for line in source_data.readlines():\n try:\n line = line.rstrip().split(',')\n ... | [
"0.66778314",
"0.6532994",
"0.6500204",
"0.64397454",
"0.6374561",
"0.6271646",
"0.62676483",
"0.62417704",
"0.6231412",
"0.617245",
"0.6171647",
"0.61612386",
"0.615612",
"0.61506104",
"0.6114675",
"0.6108078",
"0.6093978",
"0.60078865",
"0.6007418",
"0.5958537",
"0.5955557"... | 0.69318163 | 0 |
Reader interface for a single Parquet file | def parquet_reader(filename):
return ParquetFile(source = filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_parquet(self, filename):\n if filename is None:\n raise ValueError(\"File name is None\")\n self.logger.info(\"# Reading a Parquet file \" + filename)\n sqlContext = SQLContext(self.spark)\n return sqlContext.read.parquet(filename)",
"def parquet(path, *args, **kwa... | [
"0.7603535",
"0.6967719",
"0.62087405",
"0.59183514",
"0.5898814",
"0.588586",
"0.5810062",
"0.57482684",
"0.57369685",
"0.57202274",
"0.57102007",
"0.5706327",
"0.56826794",
"0.56745964",
"0.5628247",
"0.56280136",
"0.56039065",
"0.5585544",
"0.5568789",
"0.5532862",
"0.5532... | 0.80133814 | 0 |
Convert parquet file object into dataframe and returns the generator object value | def get_parquet_data(parquet_data):
rows = parquet_data.num_row_groups
cols = ['fname', 'lname', 'email', 'cid']
for row in range(0, rows):
row_df = parquet_data.read_row_group(row)
res = row_df.to_pandas()[cols];
res.rename(columns = {'fname': 'te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pq2df(data_file):\n df = pd.read_parquet(data_file)\n return df",
"def translate_parquet_file_to_entities(self, file_like: IO, is_azure: bool = False, ref_only: bool = False) -> Iterator[Entity]:\n pq_table: pyarrow.Table\n if (is_azure):\n # We need to read and wrap t... | [
"0.67903274",
"0.6390485",
"0.6236925",
"0.61115915",
"0.5997497",
"0.59226865",
"0.5921605",
"0.5862621",
"0.58598256",
"0.57292855",
"0.571301",
"0.5683631",
"0.5665652",
"0.56199265",
"0.55904233",
"0.5587211",
"0.55499166",
"0.54838043",
"0.5480939",
"0.5471937",
"0.54550... | 0.64610976 | 1 |
Add dayHour to the updateRange which spans it | def addDayHour(self, dayHour):
for i, uRange in enumerate(self.__data['updateRange']):
if (Predictor.inURange(dayHour, uRange)):
self.addDayHourToURange(dayHour, i)
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDayHourToURange(self, dayHour, index):\n ur_hist_len = len(self.__data['updateRange'][index]['updateHistory']) - Predictor.rangeHistorySize\n if (ur_hist_len > 0):\n for i in range(ur_hist_len):\n self.__data['updateRange'][index]['updateHistory'].pop(0)\n self... | [
"0.76309925",
"0.67829174",
"0.6522682",
"0.6372817",
"0.58361083",
"0.56998515",
"0.56808156",
"0.5676554",
"0.5533775",
"0.5493878",
"0.54683",
"0.54240775",
"0.53958285",
"0.5395814",
"0.5260185",
"0.5241055",
"0.5191635",
"0.51754874",
"0.512196",
"0.5119061",
"0.5086528"... | 0.7823925 | 0 |
Add dayHour to the updateRange with the given index | def addDayHourToURange(self, dayHour, index):
ur_hist_len = len(self.__data['updateRange'][index]['updateHistory']) - Predictor.rangeHistorySize
if (ur_hist_len > 0):
for i in range(ur_hist_len):
self.__data['updateRange'][index]['updateHistory'].pop(0)
self.__data['u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDayHour(self, dayHour):\n for i, uRange in enumerate(self.__data['updateRange']):\n if (Predictor.inURange(dayHour, uRange)): \n self.addDayHourToURange(dayHour, i)\n return True\n return False",
"def incDayHour(self, dayHour, step):\n ... | [
"0.71282375",
"0.6279129",
"0.5524727",
"0.55059975",
"0.548313",
"0.542705",
"0.5268755",
"0.5264982",
"0.5242444",
"0.5150805",
"0.5098766",
"0.50898",
"0.50814986",
"0.5067921",
"0.5022453",
"0.50196314",
"0.49816942",
"0.4916486",
"0.49032694",
"0.4885665",
"0.48825178",
... | 0.800328 | 0 |
Checks whether or not dayHour is in updateRange | def inURange(dayHour, updateRange):
urm = updateRange['position'][0] * 24 + updateRange['position'][1]
urw = updateRange['width']
dh = (dayHour[0] * 24 + dayHour[1])%(7*24)
if (urm - urw <= 0 or urm + urw >= 7*24):
if ((urm - urw)%(7*24) <= dh or dh <= (urm + urw)%(7*24)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDayHour(self, dayHour):\n for i, uRange in enumerate(self.__data['updateRange']):\n if (Predictor.inURange(dayHour, uRange)): \n self.addDayHourToURange(dayHour, i)\n return True\n return False",
"def _check_hours(self):\n for re... | [
"0.75381076",
"0.60400754",
"0.60147965",
"0.59535074",
"0.59197867",
"0.5840171",
"0.5696204",
"0.5661697",
"0.56581056",
"0.5634459",
"0.5603134",
"0.558836",
"0.55719894",
"0.5525653",
"0.55132926",
"0.5499577",
"0.5442594",
"0.5428611",
"0.53889716",
"0.53774375",
"0.5357... | 0.784995 | 0 |
Generate blank updateRange with position dayHour | def blankUpdateRange(dayHour):
return { 'position': dayHour, 'updateHistory': [dayHour], 'width': Predictor.rangeWidth } | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDayHourToURange(self, dayHour, index):\n ur_hist_len = len(self.__data['updateRange'][index]['updateHistory']) - Predictor.rangeHistorySize\n if (ur_hist_len > 0):\n for i in range(ur_hist_len):\n self.__data['updateRange'][index]['updateHistory'].pop(0)\n self... | [
"0.6475007",
"0.5978527",
"0.5923652",
"0.5910789",
"0.58184034",
"0.5633496",
"0.55249983",
"0.5449982",
"0.5367907",
"0.52879053",
"0.5257693",
"0.5211784",
"0.52044344",
"0.51849717",
"0.51629126",
"0.50914294",
"0.50548",
"0.50495267",
"0.5037931",
"0.5035663",
"0.5035602... | 0.8097031 | 0 |
Convert from dayHour to hours | def dayHourToHours(dayHour):
return dayHour[0] * 24 + dayHour[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hoursToDayHour(hours):\n day = hours%(7*24)/24\n hour = hours%(7*24) - day*24\n return (day, hour)",
"def date_hour(date):\n return date.hour",
"def calculate_hours(time):\n return int(time / 3600)",
"def hours(input=None):\n return get(input).hours",
"def hours_to_24h_tim... | [
"0.7937075",
"0.72407734",
"0.6999563",
"0.6841289",
"0.6720024",
"0.6616497",
"0.6584598",
"0.6558432",
"0.65180236",
"0.64602065",
"0.64420825",
"0.6441045",
"0.64111125",
"0.64073116",
"0.63957",
"0.63636094",
"0.63547444",
"0.63547444",
"0.63547444",
"0.63547444",
"0.6290... | 0.8912514 | 0 |
Convert from hours to dayHour | def hoursToDayHour(hours):
day = hours%(7*24)/24
hour = hours%(7*24) - day*24
return (day, hour) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dayHourToHours(dayHour):\n return dayHour[0] * 24 + dayHour[1]",
"def date_hour(date):\n return date.hour",
"def hours_to_24h_time(hours: float) -> str:\n return (\n dt.datetime(2001, 1, 2) + dt.timedelta(hours=hours)\n ).time().isoformat()",
"def AstroDecHours2DecDay(decimalHo... | [
"0.8397278",
"0.6978807",
"0.69219255",
"0.6762243",
"0.66276217",
"0.65281284",
"0.65052354",
"0.64798987",
"0.6394315",
"0.638083",
"0.63314813",
"0.63003474",
"0.62778425",
"0.6271165",
"0.62147826",
"0.62147826",
"0.62147826",
"0.62147826",
"0.61698496",
"0.61328834",
"0.... | 0.8153483 | 1 |
Increment a dayHour by step | def incDayHour(self, dayHour, step):
hours = dayHour[0] * 24 + dayHour[1]
hours += step
return self.hoursToDayHour(hours) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_datetime(self):\n self.current_datetime += timedelta(seconds=self.step_size)",
"def addDayHour(self, dayHour):\n for i, uRange in enumerate(self.__data['updateRange']):\n if (Predictor.inURange(dayHour, uRange)): \n self.addDayHourToURange(dayH... | [
"0.62811697",
"0.6127225",
"0.6104047",
"0.60934705",
"0.5961879",
"0.5930467",
"0.5860924",
"0.58290106",
"0.5821868",
"0.5807655",
"0.5760683",
"0.5700757",
"0.56584424",
"0.5657079",
"0.5637752",
"0.5637628",
"0.5577834",
"0.5568806",
"0.5565447",
"0.55430585",
"0.554291",... | 0.86820614 | 0 |
Calculates average position of each updateRange from the updateHistory of the updateRange | def calculateURPositions(self, updateRanges):
ranges = []
prevRange = updateRanges[-1]
positions = []
for uRange in updateRanges:
hend = len(uRange['updateHistory'])
hstart = 0 if hend - self.rangeHistN < 0 else hend - self.rangeHistN
hPos = [0, 0, 0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_average_position():\n pass",
"def moving_average(position, step_size, avg_quantity):\n print(\"1\")\n avg_disp = int(math.floor(avg_quantity / 2))\n start_frame = step_size + avg_disp + 1\n end_frame = len(position) - avg_disp\n moving_avg = []\n for i in range(start_frame, end_fram... | [
"0.6643734",
"0.63453114",
"0.6180187",
"0.6059734",
"0.600848",
"0.5924276",
"0.5853471",
"0.5784035",
"0.572262",
"0.56950855",
"0.56444675",
"0.56442374",
"0.5603589",
"0.5591555",
"0.5587686",
"0.5578391",
"0.5568578",
"0.55374336",
"0.5531237",
"0.5504843",
"0.5494146",
... | 0.69121206 | 0 |
Calculates schedule from updateRanges | def calculateScheduleUR(self, updateRanges):
schedule = self.blankSchedule()
for uRange in updateRanges:
urMin = (uRange['position'][0] * 24 + uRange['position'][1] - uRange['width'])
urMax = (uRange['position'][0] * 24 + uRange['position'][1] + uRange['width'])
for i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_schedule(self, bounds):\n\n for i in self.stnu.nodes():\n if i not in self.contingent_timepoints:\n time = (bounds[(i, '-')].varValue + bounds[(i, '+')].varValue)/2\n self.stnu.update_edge_weight(0, i, time)\n self.stnu.update_edge_weight(i, 0,... | [
"0.6017435",
"0.5902199",
"0.5901805",
"0.57950115",
"0.5767664",
"0.5642639",
"0.55756396",
"0.5565357",
"0.555581",
"0.5545145",
"0.55218035",
"0.54661196",
"0.5464509",
"0.5460465",
"0.54522854",
"0.5439892",
"0.5409701",
"0.53629196",
"0.5356413",
"0.53264403",
"0.5309195... | 0.80853695 | 0 |
Calculate schedule from list of dayHours | def calculateScheduleDHL(self, dayHourList):
schedule = self.blankSchedule()
for dayHour in dayHourList:
schedule[dayHour[0]][dayHour[1]] = 1
return schedule | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def working_hours_by_day(self, day):\r\n availabilities = self.sorted_availabilities(day)\r\n options = []\r\n if not availabilities:\r\n return 0\r\n for availability in availabilities:\r\n count = 0\r\n while True:\r\n new = time(availab... | [
"0.6276786",
"0.6147449",
"0.6124674",
"0.6086472",
"0.6072305",
"0.6012469",
"0.5917698",
"0.58413386",
"0.5818381",
"0.58115643",
"0.5793096",
"0.5736743",
"0.5710367",
"0.5703349",
"0.56957567",
"0.5695591",
"0.5694364",
"0.56821144",
"0.5644465",
"0.5640465",
"0.5596298",... | 0.7642294 | 0 |
Stores default predictorData in 'Predictor.directory/predictorData.txt' | def generatePredictorDataTemplate(self):
self.__pdir = Predictor.directory
self.__predictorData = PredictorData(None)
self.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generatePredictorDataForComic(self, comicId):\n self.__pdir = Predictor.directory\n self.__predictorData = PredictorData(None)\n self.saveComic(comicId)",
"def _build_predictor(self):\n try: \n predict_fn = tf.contrib.predictor.from_saved_model(self.saved_path)\n ... | [
"0.6413398",
"0.6171626",
"0.61356676",
"0.6009358",
"0.596724",
"0.5911867",
"0.5838672",
"0.5826528",
"0.5737411",
"0.57363456",
"0.5727851",
"0.57256705",
"0.57163084",
"0.5696878",
"0.569231",
"0.56718373",
"0.5671094",
"0.5649376",
"0.5641301",
"0.56394625",
"0.56283516"... | 0.73713255 | 0 |
Stores default predictorData in 'Predictor.directory/comicId/predictorData.txt' | def generatePredictorDataForComic(self, comicId):
self.__pdir = Predictor.directory
self.__predictorData = PredictorData(None)
self.saveComic(comicId) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generatePredictorDataTemplate(self):\n self.__pdir = Predictor.directory\n self.__predictorData = PredictorData(None)\n self.save()",
"def _build_predictor(self):\n try: \n predict_fn = tf.contrib.predictor.from_saved_model(self.saved_path)\n except OSError as er... | [
"0.71445125",
"0.5952589",
"0.5898923",
"0.58085763",
"0.5794283",
"0.5790105",
"0.5789867",
"0.5745097",
"0.5710976",
"0.5706512",
"0.56962454",
"0.5682189",
"0.5664117",
"0.5661544",
"0.5641438",
"0.56358993",
"0.55838597",
"0.5572036",
"0.556112",
"0.5553325",
"0.5553013",... | 0.7314635 | 0 |
Scales the current time to 1 day every 30 minutes. Uncomment the first line to remove the time scaling. | def scaledTime():
#return (time.gmtime().tm_wday, time.gmtime().tm_hour)
epoch = time.strptime("2013-02-21 11:30:00", "%Y-%m-%d %H:%M:%S")
timeInSec = time.mktime(time.gmtime()) - time.mktime(epoch)
hourSince = timeInSec / Predictor.hourScale
day = int(hourSince / 24 % 7)
hour = int(hourSince % ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _adapt_time(self):\n self.time = min(max(self.time, self.minimum), self.maximum)",
"def set_time_based_auto_scaling(InstanceId=None, AutoScalingSchedule=None):\n pass",
"def scale_time_to(recs, unit):\n\n for r in recs:\n if unit == 'd':\n r.t = [t / 3600 / 24 for... | [
"0.5542452",
"0.5539189",
"0.5457712",
"0.5428337",
"0.5390285",
"0.53377664",
"0.52822775",
"0.5267681",
"0.52511734",
"0.5230599",
"0.52094924",
"0.51564914",
"0.5129247",
"0.50988543",
"0.5076794",
"0.5047586",
"0.5040881",
"0.5027793",
"0.50240153",
"0.5001529",
"0.498712... | 0.58429563 | 0 |
Return the first instance of a named moment. | def get_moment(self, name):
for m in self._iterate(use_repetitions=False):
if m.name == name:
m.multiple = [0 for x in m.multiple]
return m
raise KeyError(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_moment(self, mass, z=None):\n return 1.0",
"def satellite_first_moment(self, mass):\n diff = mass - numpy.power(10, self.log_M_0)\n return numpy.where(diff > 0.0,\n self.central_first_moment(mass)*\n numpy.power(diff/(10**self.log... | [
"0.58233577",
"0.5462766",
"0.5432633",
"0.5259999",
"0.5248827",
"0.5226425",
"0.5206987",
"0.50807136",
"0.5073002",
"0.502185",
"0.5018119",
"0.50037163",
"0.49910417",
"0.49821737",
"0.49816677",
"0.49806774",
"0.49673876",
"0.49526986",
"0.4935819",
"0.49190086",
"0.4896... | 0.6266457 | 0 |
Load a sequence of play from an XML file. | def load_sequence_of_play(filename):
import xml.etree.ElementTree as ET
return SequenceOfPlay(ET.parse(filename).getroot()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_xml(path: str):\n sch = Schedule()\n sch.load(path)\n return sch",
"def load_xml(self, xml_tree):\n xml_score_part = next(iter(\n score_part\n for score_part in xml_tree.getroot().findall(\"part-list/score-part\")\n if self.get_xml_part_name(s... | [
"0.6332673",
"0.62477773",
"0.5687271",
"0.5677034",
"0.55630183",
"0.5519669",
"0.5500596",
"0.54984254",
"0.54901326",
"0.5470644",
"0.5442298",
"0.5379086",
"0.53767586",
"0.53752714",
"0.5325398",
"0.5314379",
"0.52788985",
"0.52784187",
"0.5274382",
"0.526676",
"0.525374... | 0.8386591 | 0 |
Playback the listed moves, one at a time | def playbackmoves(moves):
result = moves[GameTests.nextMove]
GameTests.nextMove += 1
if GameTests.nextMove >= len(moves):
GameTests.nextMove = 0
GameTests.repititions += 1
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_one_move(self):\n self.print(\"top of move\")\n # 1) grab three cups\n c1 = self.take_cup_after(self.current_cup_idx())\n c2 = self.take_cup_after(self.current_cup_idx())\n c3 = self.take_cup_after(self.current_cup_idx())\n print(f\"pick up: {c1}, {c2}, {c3}\")\n ... | [
"0.69663936",
"0.66232324",
"0.66130567",
"0.65732914",
"0.64069617",
"0.63927305",
"0.63119614",
"0.62719434",
"0.62553626",
"0.6216315",
"0.6172408",
"0.6160903",
"0.6144604",
"0.60976857",
"0.6092823",
"0.6088141",
"0.60734206",
"0.60595244",
"0.6046967",
"0.60461044",
"0.... | 0.6628196 | 1 |
if the file ext include in suffixList | def suffix(file_, suffix_list_):
array = map(file_.endswith, suffix_list_)
if True in array:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matching_file(suffixes, file_name):\n (root, ext) = os.path.splitext(file_name)\n\n if len(ext) > 1:\n return ext in suffixes\n else:\n return False",
"def is_suffix_right(file: Path, extension: str):\n ext = extension.lower()\n fext = file.suffix.lower()[1:]\n jpgs = {\"jpg\"... | [
"0.7285265",
"0.72546804",
"0.716655",
"0.71057785",
"0.7014613",
"0.69920236",
"0.6939772",
"0.69129694",
"0.6875441",
"0.681909",
"0.6750354",
"0.6732758",
"0.6678505",
"0.6616039",
"0.657233",
"0.6570268",
"0.6565933",
"0.655888",
"0.65397346",
"0.6522987",
"0.65096575",
... | 0.8070566 | 0 |
Clear the debug files from root_path_ path | def clear_debug_files(root_path_):
ext_file = [
".sdf",
".VC.db",
".idb",
".exp",
".aps",
".pdb",
".obj",
".res",
".log",
".tlog",
".manifest",
".lastbuildstate",
".pch",
".ipch",
".cache",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\r\n self._root_dir = None",
"def clear_files_paths(self):\n del self.__files_paths[:]",
"def clear(self, cacheDir):",
"def clean():\n clean_files()",
"def clear_path(self):\n self.write(CLEAR + END_COMMAND)",
"def clean(path=None):\n conf.load(path)\n logger.inf... | [
"0.6934086",
"0.68364465",
"0.64536047",
"0.6438713",
"0.6417111",
"0.64125305",
"0.63640696",
"0.6328197",
"0.63175905",
"0.6267668",
"0.6226687",
"0.6213684",
"0.62077236",
"0.61829823",
"0.6172031",
"0.61512446",
"0.61469346",
"0.6142483",
"0.6137917",
"0.61204976",
"0.611... | 0.82561356 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.