query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Runs num_iters steps of SC steepest descent on the dictionary elements The a comment on axis ordering and the padding necessary to deal with boundary affects, see the docstrings in analysis_transforms/convolutional
def run(images_padded, dictionary, codes, kernel_stride, padding_dims, stepsize=0.001, num_iters=1, normalize_dictionary=True): reconstruction_mask = create_mask(images_padded, padding_dims) codes_temp_transposed = codes.transpose(dim0=1, dim1=0) # TODO: Figure out if I can remove the double-transpose in ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_conv_code_unroll_batch_kern(d, unroll_bsize=1, unroll_ksize=1):\r\n assert unroll_bsize > 0 and unroll_ksize > 0\r\n if \"unroll_bsize\" in d or \"unroll_ksize\" in d or \"unroll_iter\" in d or \"unroll_biter\" in d or \"unroll_kiter\" in d:\r\n raise Exception(\"We can't use this dictionnary ...
[ "0.561682", "0.5455139", "0.54320246", "0.5400106", "0.53414565", "0.53230274", "0.52961946", "0.52878106", "0.52821034", "0.5278173", "0.52781266", "0.52665293", "0.52234095", "0.5221753", "0.5208205", "0.52052426", "0.5204347", "0.5190821", "0.5174756", "0.5170999", "0.5153...
0.6045369
0
Perform multiple consecutive attacks
def multiattack(self, sentence, attacks_with_severity): for i,(attack, severity) in enumerate(attacks_with_severity): if attack=="rand": attack = random.choice(self.methods) while attack=="intrude" and i!=len(attacks_with_severity)-1: attack = rand...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def attacking_logic(self):\n if len(self.units(UnitTypeId.ZERGLING)) >= 6:\n for zergling in self.units(UnitTypeId.ZERGLING):\n self.do(zergling.attack(self.enemy_start_locations[0]))", "def attack(self, robot):\n pass", "def attack(self):\n\n if not self.at...
[ "0.5993577", "0.5946337", "0.576245", "0.5705413", "0.56642854", "0.5558414", "0.55434275", "0.5485012", "0.54479545", "0.53891695", "0.537023", "0.53190684", "0.5313921", "0.53021246", "0.5299953", "0.5299419", "0.5256593", "0.5190473", "0.5189436", "0.51798266", "0.51435095...
0.6846764
0
Attack all sentences in document with a set of attacks
def multiattack_document(self, infile, outfile, attacks_with_severity): scores,first_sentences, second_sentences = read_labeled_data(infile,do_float=False) pert_first = [self.multiattack(sentence,attacks_with_severity) for sentence in tqdm(first_sentences)] pert_second = [self.multiattack(senten...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiattack(self, sentence, attacks_with_severity):\n for i,(attack, severity) in enumerate(attacks_with_severity):\n if attack==\"rand\":\n attack = random.choice(self.methods)\n while attack==\"intrude\" and i!=len(attacks_with_severity)-1:\n ...
[ "0.66755813", "0.5918671", "0.58177257", "0.56210095", "0.561726", "0.558743", "0.55699134", "0.556751", "0.5551098", "0.5545578", "0.5531936", "0.5516357", "0.55113065", "0.54990625", "0.5497921", "0.5471788", "0.5453732", "0.54429746", "0.5412646", "0.53980833", "0.53979903...
0.5592882
5
Generate a temporary location.
def create_base_temp_dir(cls): if cls._thread_local.state.temp_dirs: base_temp_dir = os.path.join(cls._thread_local.state.temp_dirs[-1], cls._TEMP_SUBDIR) else: raise ValueError( 'A tf.Transform function that required a temp dir was called but no ' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_fixture():\n return _create_location()", "def location():\n return _locate_or_create()", "def get_temp_path():\n return os.getcwd() + \"/temp/\"", "def mktemp(self):\n if self.dryrun:\n return os.path.expandvars(\"$TEMP/build\")\n\n return tempfile.mkdtemp()", ...
[ "0.64077693", "0.62422216", "0.62217087", "0.61807305", "0.6160167", "0.6148715", "0.6127639", "0.6066422", "0.60584307", "0.6011024", "0.59502506", "0.592658", "0.59185654", "0.5910147", "0.5893831", "0.5826466", "0.5786726", "0.5777028", "0.57585794", "0.57543325", "0.57349...
0.55394065
40
Runs the given graph to realize the output tensors (i.e. features). Runs the graph in a TF session for computing the output values of the tensors, given an input row of data (input tensors). Due to the recordby record nature of beam we are operating sess.run() on individual record tensors vs batched tensors.
def process(self, element, saved_model_dir): if self._graph_state is None: if (getattr(self._thread_local, 'graph_state', None) is None or self._thread_local.graph_state.saved_model_dir != saved_model_dir): start = datetime.datetime.now() self._thread_local.graph_state = self._GraphS...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self, input_graph, dataloader, postprocess=None,\n metric=None, measurer=None, iteration=-1,\n tensorboard=False, fp32_baseline=False):\n sess_options = ort.SessionOptions()\n if measurer:\n # https://github.com/microsoft/onnxruntime/issues/7347...
[ "0.6365999", "0.6352293", "0.6220024", "0.61351186", "0.61189103", "0.61167485", "0.6106582", "0.60465544", "0.60121274", "0.5962098", "0.59156436", "0.5904605", "0.5866814", "0.5846091", "0.5842682", "0.58306944", "0.58295", "0.58167785", "0.581451", "0.58137304", "0.58033",...
0.0
-1
Create path to a unique temp dir from given base temp dir.
def _make_unique_temp_dir(base_temp_dir): return os.path.join(base_temp_dir, uuid.uuid4().hex)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_base_temp_dir(cls):\n if cls._thread_local.state.temp_dirs:\n base_temp_dir = os.path.join(cls._thread_local.state.temp_dirs[-1],\n cls._TEMP_SUBDIR)\n else:\n raise ValueError(\n 'A tf.Transform function that required a temp dir was called but ...
[ "0.7639535", "0.75858647", "0.75725234", "0.7204607", "0.7200416", "0.71961796", "0.7147817", "0.71170455", "0.7116208", "0.71064216", "0.7062529", "0.6970509", "0.695506", "0.6905613", "0.689262", "0.68787223", "0.68727803", "0.681926", "0.6812259", "0.68059057", "0.6804259"...
0.885131
0
Converts a dict of statistics to a transform function.
def expand(self, analyzer_outputs_to_pcoll): # Create a transform_fn with unbound values. unbound_transform_fn_dir = _make_unique_temp_dir(base_temp_dir) input_columns_to_statistics = impl_helper.make_transform_fn_def( input_schema, self._input_columns, self._output_columns, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def map_values(function, dictionary):\n return {k: function(dictionary[k]) for k in dictionary}", "def map_values(fun, a_dict):\n return dict((k, fun(v)) for (k, v) in a_dict.items())", "def transform_fn(transforms, params, invert=False):\n if invert:\n transforms = {k: v.inv for k, v in transf...
[ "0.6108298", "0.60716486", "0.60059154", "0.5998334", "0.59223676", "0.5902528", "0.5645412", "0.55915976", "0.55356425", "0.54930705", "0.5493034", "0.54446834", "0.54181", "0.5416377", "0.53979397", "0.53423756", "0.5333607", "0.5317512", "0.5307221", "0.5295512", "0.525213...
0.48021248
90
Returns a list of lists, containing analyzers by level. We need to run analyzers in order so that when running the TF graph to get the inputs of an analyzer, we only rely on analyzers that have already been computed. This is acheived by running analyzers in order of their `level` where the level of an analyzer is defin...
def _analyzers_by_level(self, outputs): memoized_column_levels = {} analyzers_by_level = collections.defaultdict(list) def column_level(column): """Adds all analyzers above this column to analyzers_by_level. Visits all parents of this column or statistic in the `Column`/`Statistic` graph,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_analyzers(cls):\n for analyzer_name, analyzer_class in iter(cls._class_registry.items()):\n yield analyzer_name, analyzer_class", "def list_analyzers(args: argparse.Namespace):\n first = True\n queue = [tuple(c) + (\"lookout.\",) for c in pkgutil.iter_modules(lookout.__path__)]\n ...
[ "0.5864481", "0.53452533", "0.50972193", "0.5097106", "0.506351", "0.49360263", "0.49226353", "0.4915473", "0.48669732", "0.48573586", "0.475987", "0.47398412", "0.46899807", "0.46852565", "0.46842974", "0.4634878", "0.46315", "0.46094146", "0.4595435", "0.45916668", "0.45753...
0.7261228
0
Adds all analyzers above this column to analyzers_by_level. Visits all parents of this column or statistic in the `Column`/`Statistic` graph, and adds each _AnalyzerOutput to analyzers_by_level according to its level.
def column_level(column): if column in memoized_column_levels: return memoized_column_levels[column] # pylint: disable=protected-access if isinstance(column, api._AnalyzerOutput): level = max( [column_level(input_column) for input_column in column.inputs]) + 1 anal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _analyzers_by_level(self, outputs):\n memoized_column_levels = {}\n analyzers_by_level = collections.defaultdict(list)\n def column_level(column):\n \"\"\"Adds all analyzers above this column to analyzers_by_level.\n\n Visits all parents of this column or statistic in the `Column`/`Statistic...
[ "0.78771067", "0.48176712", "0.45828122", "0.44564846", "0.44539464", "0.4452111", "0.44325805", "0.43774885", "0.4376514", "0.42762798", "0.4257025", "0.42525667", "0.42483383", "0.42271966", "0.42109933", "0.42009965", "0.41943592", "0.41868788", "0.41585994", "0.41352066", ...
0.45502272
3
Transform the dataset by applying the preprocessing_fn.
def expand(self, dataset): # Expand is currently implemented by composing AnalyzeDataset and # TransformDataset. Future versions however could do somthing more optimal, # e.g. caching the values of expensive computations done in AnalyzeDataset. transform_fn = dataset | AnalyzeDataset(self._preprocessin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess_data(self):\n\n self._preprocess_train_data()\n self._preprocess_test_data()", "def _preprocess(self, data, normalize=False) -> np.ndarray:\n \n preprocessor = StandardScaler() if not normalize else Normalizer()\n\n data = preprocessor.fit_transform(data)\n ...
[ "0.73838943", "0.72549456", "0.7252309", "0.7228141", "0.71974176", "0.7074556", "0.7052995", "0.7013554", "0.69532084", "0.69424987", "0.6872287", "0.68646985", "0.6855033", "0.68126386", "0.6806819", "0.6798322", "0.67914605", "0.6788149", "0.67493486", "0.6716809", "0.6714...
0.0
-1
Transforms the dataset using the transform_fn.
def expand(self, dataset_and_transform_fn): (input_values, input_metadata), (transform_fn, output_metadata) = ( dataset_and_transform_fn) # If exclude_outputs is set, update the output metadata, which will also # cause _RunMetaGraphDoFn not to create the excluded outputs. if self._exclude_outpu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _transform(self, dataset):\n raise NotImplementedError()", "def transform(self, dataset: NumpyOrPandas) -> NumpyDataset:\n # checks here\n super().transform(dataset)\n # convert to accepted dtype and get attributes\n dataset = dataset.to_pandas()\n df = dataset.data\...
[ "0.80232185", "0.7545224", "0.7201159", "0.7166387", "0.7132256", "0.71175015", "0.70721376", "0.70721376", "0.70721376", "0.7071818", "0.703013", "0.70073336", "0.69790024", "0.6948974", "0.6937917", "0.6937917", "0.6937917", "0.6937917", "0.6937917", "0.6937917", "0.6937917...
0.0
-1
Replaces a wit b and b with a in my_str
def inverse_replacer(my_str:str, a:str, b:str) -> str: my_str = list(my_str) for i in range(len(my_str)): if my_str[i] == a: my_str[i] = b elif my_str[i] == b: my_str[i] = a return(''.join(my_str[::-1]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_substitutions_in_word(self):\n m = strutils.MultiReplace({r'cat': 'kedi', r'purple': 'mor', })\n self.assertEqual(m.sub('Thecatispurple'), 'Thekediismor')", "def myreplace(old, new, s):\n\n s = s.split()\n s = \" \".join(s)\n\n return new.join(s.split(old))", "def test_simple_su...
[ "0.6426957", "0.6371966", "0.62510085", "0.6172532", "0.605283", "0.60364926", "0.5999566", "0.591037", "0.5850798", "0.58500206", "0.58080274", "0.5771347", "0.57628804", "0.56756216", "0.56451476", "0.56305456", "0.56139046", "0.5609791", "0.5602158", "0.55999005", "0.55693...
0.7641272
0
Return a list of all audited data.
def _audited_log(self, request, pk=None, format=None, id=None): if not self.queryset: raise LookupError("You must override the queryset param!") model = self.queryset.model primary_key = pk if not primary_key: primary_key = id if not id: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def directory_audits(self):\n return self.properties.get('directoryAudits',\n EntityCollection(self.context, DirectoryAudit,\n ResourcePath(\"directoryAudits\", self.resource_path)))", "def audiences(self) -> pulumi.Outpu...
[ "0.6826847", "0.61051714", "0.60854363", "0.60486275", "0.6005237", "0.5997306", "0.5969678", "0.59662133", "0.59562707", "0.59453773", "0.59410286", "0.5906567", "0.59025174", "0.58759016", "0.58625376", "0.58387715", "0.5833064", "0.5813266", "0.58034986", "0.5798717", "0.5...
0.0
-1
Return an array of n logspaces values from min to max.
def rangeLog(min, max, n): logmin, logmax = log(min), log(max) return np.exp( np.arange( logmin, logmax, (logmax-logmin)/float(n) ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logspace(min, max, num, **kwargs):\n if isinstance(min, datetime.datetime):\n from matplotlib.dates import date2num, num2date\n ans = num2date(np.logspace(np.log10(date2num(min)), np.log10(date2num(max)), num, **kwargs))\n ans = spt.no_tzinfo(ans)\n return np.array(ans)\n else...
[ "0.70716333", "0.70391375", "0.67055446", "0.66992354", "0.6579034", "0.6477024", "0.64768785", "0.6472296", "0.64413065", "0.6438916", "0.64164", "0.6350058", "0.61967665", "0.6185765", "0.6154829", "0.6042712", "0.601705", "0.59243286", "0.5922405", "0.59168375", "0.5911305...
0.6757458
2
Return an array of n linearspaced values from min to max.
def rangeLin(min, max, n): return np.arange( min, max, (max-min)/n )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def linspace(start, stop, n, istart=True, istop=True):\r\n n = n-1\r\n arr = [start + ((stop-start)/n) * i for i in range(n+1)]\r\n return arr", "def create_array(n, bound):\n array = [np.random.randint(0, bound) for x in range(n)]\n return array", "def x_uniform1(xlim, n):\n return linspace...
[ "0.71289086", "0.7006669", "0.66802406", "0.65675193", "0.6554845", "0.6424489", "0.63840723", "0.6360398", "0.63580406", "0.6333735", "0.6289109", "0.6270997", "0.6265102", "0.6229819", "0.6141139", "0.6074155", "0.6066987", "0.6065085", "0.60578597", "0.6039758", "0.6018827...
0.7715625
0
Return X matrix Xij = [ exp(k_jt_i); Iw^(1/2) ] from arrays k and t.
def Xmatrix(k,t,w, standardizeData=True): K, N = len(k), len(t) X = np.zeros( (N+K,K) ) for i in range(N): for j in range(K): X[i,j] = np.exp(-1.0*k[j]*t[i]) for i in range(K): X[i+len(t),i] = w**0.5 Xmean = (X[0:N,:]).mean(axis=0) if standardizeData: for j in r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Xsubmatrix(k,t, standardizeData=True):\n\n K, N = len(k), len(t)\n X = np.zeros( (N,K) )\n for i in range(N):\n for j in range(K):\n X[i,j] = np.exp(-1.0*k[j]*t[i])\n\n Xmean = X.mean(axis=0)\n if standardizeData:\n for j in range(K):\n X[:,j] = X[:,j] - Xmean[j]\n\n r...
[ "0.654792", "0.62343216", "0.59998757", "0.59954584", "0.58997905", "0.5833076", "0.58315307", "0.5817481", "0.57968336", "0.57816815", "0.5695442", "0.56352943", "0.5633382", "0.55761397", "0.55315673", "0.5512695", "0.55079854", "0.5452388", "0.545135", "0.542148", "0.53979...
0.6576722
0
Return X matrix Xij = [ exp(k_jt_i)] from arrays k and t.
def Xsubmatrix(k,t, standardizeData=True): K, N = len(k), len(t) X = np.zeros( (N,K) ) for i in range(N): for j in range(K): X[i,j] = np.exp(-1.0*k[j]*t[i]) Xmean = X.mean(axis=0) if standardizeData: for j in range(K): X[:,j] = X[:,j] - Xmean[j] return X, Xmean
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Xmatrix(k,t,w, standardizeData=True):\n \n K, N = len(k), len(t)\n X = np.zeros( (N+K,K) )\n for i in range(N):\n for j in range(K):\n X[i,j] = np.exp(-1.0*k[j]*t[i])\n for i in range(K):\n X[i+len(t),i] = w**0.5\n\n Xmean = (X[0:N,:]).mean(axis=0) \n if standardizeData:\...
[ "0.64807385", "0.62325656", "0.6106175", "0.6067337", "0.5988209", "0.59643847", "0.58780324", "0.586434", "0.58161384", "0.5789269", "0.5753004", "0.57186216", "0.5696763", "0.56853116", "0.56414497", "0.5595421", "0.5574128", "0.55618346", "0.5512092", "0.5468021", "0.54500...
0.66882664
0
Return the sum of the exponential relaxations. If the data is standardized, an offset constant zero rate must be provided.
def SumSpectra(A, Rates, Times, offset=0.0): #print '*** in SumSpectra: ***' result = np.zeros( Times.shape ) for i in range(len(Rates)): #print '***', Rates[i] result += A[i]*np.exp( -1.0*Rates[i]*Times) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def energy(data):\n return sum(pow(data, 2))", "def epfromdata(data, krdel, kexp, fp):\n balance = compute_balance(data, krdel)\n return weighted_energy(balance, fp, kexp)", "def energy(data):\n\n return np.real(np.mean(np.abs(data)**2, axis=1))", "def sum_exp(self,time):\n sum = np.sum([s...
[ "0.591776", "0.56907016", "0.5573584", "0.550739", "0.54849076", "0.5483118", "0.5482724", "0.5391489", "0.5375844", "0.5359106", "0.53125805", "0.529915", "0.5268953", "0.5262514", "0.5254501", "0.523982", "0.52286243", "0.52204746", "0.5184274", "0.51719624", "0.5151444", ...
0.50822574
24
nTimes = 727 same number as W55F dataset taus = [1.0e6, 1.0e4, 5.0e3] timescales for a test data curve amps = [0.3, 0.3, 0.4] ampltudes of each relaxation sigma = 0.05 add artifical noise to the data
def testData(nTimes = 1000, taus = [1.0e-6, 1.0e-4, 5.0e-3], amps = [0.3, 0.3, 0.4], sigma = 0.05, linear=False): if linear: Times = rangeLin(1.0e-7, 1.0e-3, nTimes) # in seconds else: Times = rangeLog(1.0e-9, 1.0, nTimes) # in seconds Data = np.zeros( Times.shape ) for i in range(len(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_plt_mag_time():\n\n ta = WATA()\n wata_data = define_testdata()\n ta.source = ColumnDataSource(data=wata_data)\n ta.add_time_column()\n ta.setup_date_range()\n\n # create the arrays per filter and readout pattern\n nrsrapid_f140x, nrsrapid_f110w, nrsrapid_clear = [], [], []\n nrsra...
[ "0.6373813", "0.6351109", "0.6140943", "0.613694", "0.6108043", "0.6039261", "0.60305786", "0.596345", "0.59240603", "0.58829147", "0.5873695", "0.5839105", "0.58336765", "0.58019346", "0.5791312", "0.57601404", "0.57052803", "0.5704976", "0.569301", "0.5687342", "0.5664945",...
0.6944508
0
nTimes = 727 same number as W55F dataset beta = the stretching exponenent (should be between 0 and 1) sigma = 0.05 add artifical noise to the data
def testStretchedExpData(nTimes = 1000, beta = 0.5, sigma = 0.05, linear=False): if linear: Times = rangeLin(1.0e-3, 1.0e+3, nTimes) # in seconds else: Times = rangeLog(1.0e-3, 1.0e+3, nTimes) # in seconds Data = np.exp(-1.*(Times**beta)) Data += sigma*np.random.randn( len(Data) ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def noise_generator(n, mean, std, fractindex):\n if fractindex not in VALID_FRACT:\n raise ValueError(\"results: status must be one of %r.\" % VALID_FRACT)\n \n stdev = std\n \n b = 2*fractindex-1\n print('beta: ', b)\n \n bdis = np.zeros(n)\n\n bdis[0] = 1\n for i in range(1,n...
[ "0.64249635", "0.6127469", "0.59821934", "0.5905486", "0.5902299", "0.5896128", "0.5882188", "0.5829961", "0.58168125", "0.5813827", "0.5785464", "0.57696134", "0.5728573", "0.5718349", "0.57028085", "0.56930923", "0.56703866", "0.5651287", "0.5642848", "0.5610342", "0.559990...
0.623264
1
Using pseudoinverse, with Tikhonov regularization (w parameter) to solve the inverse lapace tranform. Returns coefficients A_k, residual sum of squares (rss), and number of degrees of freedom, for each relaxation rate.
def fitRateSpectrum(Times, Data, Rates, w, Lnorm='ridge', standardizeData=True, CalcNdof=False, rho=0.5): if Lnorm == 'lasso': # Use L1-norm Lasso regression try: from scikits.learn.linear_model import Lasso except: print 'Error: could NOT import Lasso from sci...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solver(u_init, eta_0, eta, eta_lin, T, H, L_lhs, L_rhs, alpha, gamma, B, D, C, ftol = 1e-3, max_iter = 5000, verbose = 0, nnls_max_iter=30):\n\n # Raise('NotImplementedError: only adjusted the arguments.')\n #Need to incorporate L_lhs into stacked and appropriate w_lin updates, u_update and eta_lin incre...
[ "0.5710855", "0.5675077", "0.5650308", "0.5553886", "0.5542864", "0.5486818", "0.54824346", "0.5439341", "0.5427962", "0.5392118", "0.5376725", "0.537398", "0.53675294", "0.5363947", "0.5357868", "0.5353982", "0.5346847", "0.53347623", "0.5315761", "0.53112704", "0.53029287",...
0.0
-1
Scale a numpy array of values so that (min, max) = (0,1).
def scaleValues(values): values = values - values.min() return values/values.max()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale01(arr):\r\n walk_arr_01 = numpy.interp(arr, (numpy.amin(arr), numpy.amax(arr)), (-1, +1)) # linear scaling\r\n return walk_arr_01 #return the scaled array\r", "def scale_1d(x):\n return (min(x), max(x), len(x))", "def _scale_array(arr, clip=True):\n if clip:\n scaled = np.c...
[ "0.77611136", "0.7545397", "0.74959666", "0.7466113", "0.7265087", "0.72355026", "0.7218419", "0.7183934", "0.71745336", "0.7156415", "0.70853466", "0.7025777", "0.6994783", "0.6936765", "0.69095606", "0.69059616", "0.6852354", "0.6841582", "0.6785465", "0.6775435", "0.675613...
0.72233146
6
Scale a numpy array of values so that (min, max) = (0,1).
def scaleValuesWithInfo(values): Shiftby = values.min() values = values - Shiftby Scaleby = values.max() return values/Scaleby, Scaleby, Shiftby
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale01(arr):\r\n walk_arr_01 = numpy.interp(arr, (numpy.amin(arr), numpy.amax(arr)), (-1, +1)) # linear scaling\r\n return walk_arr_01 #return the scaled array\r", "def scale_1d(x):\n return (min(x), max(x), len(x))", "def _scale_array(arr, clip=True):\n if clip:\n scaled = np.c...
[ "0.7762404", "0.75432307", "0.749825", "0.74669933", "0.72655994", "0.72361785", "0.72225434", "0.72195363", "0.7185347", "0.7177425", "0.71583474", "0.7086495", "0.7026466", "0.69962096", "0.69380826", "0.6910129", "0.69072604", "0.6853833", "0.68411666", "0.67867655", "0.67...
0.0
-1
Apply a passthrough filter to a cloud
def apply_passthrough_filter(cloud, axis, axis_min, axis_max): # Create a PassThrough filter object. passthrough = cloud.make_passthrough_filter() # Assign axis and range to the passthrough filter object. filter_axis = axis passthrough.set_filter_field_name(filter_axis) #axis_min = 0.6 #axi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_filter(self, image):\n pass", "def filter(self, *args, **kwargs):", "def apply(self, *args):\n return _ida_hexrays.udc_filter_t_apply(self, *args)", "def apply_filters(self, new_filters):\n\t\tself.filters = new_filters", "def apply(self, *args):\n return _ida_hexrays.microco...
[ "0.6539141", "0.60534006", "0.6045387", "0.593166", "0.5931561", "0.5887304", "0.58217114", "0.581077", "0.5772639", "0.57151353", "0.5696424", "0.5690819", "0.56490076", "0.563207", "0.5628303", "0.56268173", "0.561666", "0.5591821", "0.5530589", "0.5467814", "0.5466966", ...
0.74443835
0
Segments a cloud using a sac model
def ransac(cloud, sacmodel): # Create the segmentation object seg = cloud.make_segmenter() # Set the model you wish to fit seg.set_model_type(sacmodel) seg.set_method_type(pcl.SAC_RANSAC) # Max distance for a point to be considered fitting the model # Experiment with different values for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def segment(points, model=pclpy.pcl.sample_consensus.SACMODEL_LINE, method=pclpy.pcl.sample_consensus.SAC_RANSAC, miter=1000, distance=0.5, rlim=[0,0.5]):\n pointcloud = pclpy.pcl.PointCloud.PointXYZ(points)\n segmenter = pclpy.pcl.segmentation.SACSegmentation.PointXYZ()\n\n segmenter.setInputCloud(pointc...
[ "0.5972947", "0.57596177", "0.5705211", "0.55908954", "0.5576257", "0.55459577", "0.55090237", "0.54882836", "0.54302746", "0.53734714", "0.52986604", "0.528243", "0.5271106", "0.52643365", "0.5247393", "0.5247393", "0.5171636", "0.51356274", "0.51081306", "0.50940233", "0.50...
0.6150639
0
Generates training data in the CRF++ format for the ingredient tagging task
def run(self): with open(self.opts.data_path, encoding='utf-8') as data_file: data_reader = labelled_data.Reader(data_file) for row in data_reader: # Write the utf-8 encoded data directly to stdout instead of using print # because print() will output a byt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def easydatagen():\n\n # Reading in the training file\n data = pd.read_json('train.json')\n\n # The set of different cuisines\n cuisines = data.cuisine.unique()\n\n # To find the different ingredients, we need to clean them up a little.\n def clean(string) :\n s = string.replace('-',' ') #...
[ "0.71794796", "0.6370519", "0.63217074", "0.6288061", "0.6260432", "0.61992145", "0.61916214", "0.61623365", "0.6151186", "0.61314774", "0.6079185", "0.6071901", "0.60713", "0.6058677", "0.60482717", "0.6039198", "0.60251206", "0.60112286", "0.6009894", "0.60096776", "0.60037...
0.0
-1
Parse the commandline arguments into a dict.
def _parse_args(self, argv): opts = optparse.OptionParser() opts.add_option("--data-path", default="nyt-ingredients-snapshot-2015.csv", help="(%default)") (options, args) = opts.parse_args(argv) return options
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve_args_dict():\n process_args = sys.argv[1:]\n dictionary = dict()\n for process_arg in process_args:\n splitted = process_arg.split(\":\")\n if len(splitted) > 1:\n key = splitted[0]\n value = \"\".join(splitted[1:])\n dictionary[key] = value\n ...
[ "0.805954", "0.7853354", "0.748627", "0.7477624", "0.742788", "0.73723", "0.7298476", "0.7266872", "0.7208575", "0.7201047", "0.71894705", "0.71479756", "0.7123694", "0.7111748", "0.70769215", "0.70635056", "0.7010335", "0.7010014", "0.6994027", "0.6871115", "0.6870057", "0...
0.0
-1
Return the results of a data request based on the configuration UID, options include search, pagination and sorting
def fetch(): req_data= request.get_json() ## ddb uses text files, using this as to eat my own dogfoor and improve ## no service sql client. No daemon, low cpu. e=load_db() try: res=e.query(req_data['query']) serialized = jsonpickle.encode( res, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query(self,\n template: Union[list, str, pd.Series, pd.DataFrame, None] = None,\n title: Optional[str] = None,\n keyword: Union[str, list, None] = None,\n mongoquery: Union[str, dict, None] = None,\n page: Optional[int] = None,\n parse_dates: bool = True,\n...
[ "0.5923269", "0.5864445", "0.5786591", "0.57578933", "0.57529306", "0.57469153", "0.5704843", "0.5696772", "0.56865305", "0.5661509", "0.5644907", "0.56123847", "0.55941075", "0.5550665", "0.55397886", "0.55127746", "0.55086654", "0.5501796", "0.55009973", "0.54982543", "0.54...
0.0
-1
Returns an OptionParser object with all the default options.
def MakeOpts(): parser = ArgumentParser() parser.add_argument("-o", "--host", dest="host", default="hldbv02", help="The hostname for the MySQL database") parser.add_argument('-d', '--debug', action='store_true', default=False, help='debug mode, store results ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_default_options():\n parser = OptionParser()\n add_option_group(parser)\n options, args = parser.parse_args([])\n return options", "def initCmdLineParser():\n\n # Init parser and all general flags\n logging.debug(\"initiating command line option parser\")\n usage = \"usage: %prog [options...
[ "0.84064525", "0.7035872", "0.69315475", "0.6762891", "0.6612723", "0.65971667", "0.657549", "0.65095645", "0.65095645", "0.63397056", "0.6329244", "0.63176024", "0.6288814", "0.6283019", "0.6267587", "0.6220962", "0.6210075", "0.6204305", "0.6200668", "0.619317", "0.61901367...
0.0
-1
Make a terminal loader/spinner animation using the imports above. Takes seconds argument = time for the spinner to run. Does not return anything, only prints to stdout.
def spinner(seconds): timeout = time() for state in cycle(SPINNER_STATES): if time() - timeout > seconds: break else: print(state, end= '\r', flush= True) sleep(STATE_TRANSITION_TIME)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loading(delay):\r\n\r\n for i in range(3):\r\n\r\n print \".\",\r\n sys.stdout.flush()\r\n time.sleep(delay)\r\n\r\n print(\"\")", "def animate():\n for c in itertools.cycle(['|', '/', '-', '\\\\']):\n if done:\n break\n sys.stdout.wr...
[ "0.66631764", "0.65671074", "0.6313429", "0.62911284", "0.57967776", "0.57249594", "0.5722175", "0.5686955", "0.5641586", "0.56180584", "0.5608205", "0.5562148", "0.55549806", "0.5531149", "0.5498166", "0.5469922", "0.54436475", "0.54220825", "0.54170036", "0.5410249", "0.540...
0.68003017
0
Removes punctuation & excess whitespace, sets to lowercase, and stems tweets. Returns a list of stemmed tokens.
def tokenize(tweet): tweet = " ".join(re.split("[^a-zA-Z]*", tweet.lower())).strip() tokens = [stemmer.stem(t) for t in tweet.split()] return tokens
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stem_tokens(tokens, stemmer):\n stemmed = []\n # going through tokens stem where needed\n for token in tokens:\n stemmed.append(stemmer.stem(token))\n return stemmed", "def tokenizeAndStem(phrase, ignore = []):\n # Final list of stems\n stems = []\n # Loop through tokenized items\...
[ "0.7678134", "0.7551364", "0.75347817", "0.7524167", "0.750994", "0.750994", "0.750994", "0.750994", "0.750994", "0.7473676", "0.7467269", "0.7444527", "0.74240965", "0.7400697", "0.7393167", "0.7378211", "0.7346575", "0.7345031", "0.73118025", "0.7284678", "0.72558844", "0...
0.8219763
1
Same as tokenize but without the stemming
def basic_tokenize(tweet): tweet = " ".join(re.split("[^a-zA-Z.,!?]*", tweet.lower())).strip() return tweet.split()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_tokenize(sentence):\n sentence = sentence.lower()\n ll = word_tokenize(sentence)\n lls = [stemmer.stem(ii) for ii in ll if re.search(r'[a-z0-9]+', ii)]\n\n return lls", "def tokenize(tweet):\n tweet = \" \".join(re.split(\"[^a-zA-Z]*\", tweet.lower())).strip()\n tokens = [stemmer.stem(t)...
[ "0.7751562", "0.7710764", "0.7710764", "0.76984525", "0.76871353", "0.7683495", "0.7663285", "0.7655944", "0.7632767", "0.7604723", "0.7599857", "0.75302166", "0.75051105", "0.7499571", "0.7489158", "0.73736125", "0.7353079", "0.7338581", "0.7311257", "0.7308638", "0.7302826"...
0.69179165
60
Tally the statistics in the given HDF5
def tally_stats(hdf5_file): Stat = namedtuple('Stat', ['cr_count', 'img_count', 'total_exptime']) with h5py.File(hdf5_file,mode='r') as f: instr = list(f.keys())[0] print(instr) grp = f['/{}/sizes'.format(instr)] num_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summarize_hdf5(hdf5_file):\n # characterize the h5file in a mostly content-agnostic way\n summary = {\n 'sums': {},\n 'shapes': {}\n }\n\n def characterize_object(obj_name, obj_data):\n \"\"\"retain some properties of each dataset in an hdf5 file\"\"\"\n if isinstance(ob...
[ "0.65691614", "0.65687823", "0.647717", "0.61742824", "0.6162718", "0.5820011", "0.58141285", "0.5803666", "0.5748079", "0.57440376", "0.5700492", "0.5689688", "0.5675805", "0.5675805", "0.56419486", "0.56329083", "0.55740833", "0.55623597", "0.55504835", "0.5539534", "0.5532...
0.8037474
0
Parse all files in the results directory and tally the statistics
def compile_global_stats(results_dir='./../data/*/*cr_sizes*hdf5'): flist = glob.glob(results_dir) output = defaultdict(list) flist = [f for f in flist if 'nicmos' not in f] print(flist) flist.append('./../data/STIS/stis_cr_sizes.hdf5') results = [dask.delayed(tally_stats)(f) for f in flist] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analyze_files(self):\n for file in os.listdir(self.directory):\n if file[-3:] == (\".py\"):\n fopen = open(os.path.join(self.directory, file), \"r\")\n try:\n if not (py_file := fopen):\n raise FileNotFoundError\n\n ...
[ "0.7124748", "0.69089925", "0.68689764", "0.6803728", "0.67018825", "0.64793134", "0.6475737", "0.64586645", "0.6270642", "0.62664855", "0.6229735", "0.62132794", "0.61848545", "0.6163296", "0.61612755", "0.615097", "0.6112404", "0.60943806", "0.6093197", "0.60524863", "0.604...
0.594888
30
Queries a given endpoint on the Eskom loadshedding API with the specified payload
async def async_query_api(self, endpoint, payload=None): async with RetryClient() as client: # The Eskom API occasionally drops incoming connections, implement reies async with client.get( url=self.base_url + endpoint, headers=self.headers, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_call_api(url, payload, headers):\n return requests.request(\"GET\", url, headers=headers, data=payload)", "def _query(self, url, payload=None, action='GET'):\r\n full_url = self._base + url\r\n\r\n headers = {\r\n 'Content-Type': 'application/json'\r\n }\r\n\r\n ...
[ "0.6770775", "0.6607444", "0.6537534", "0.6452347", "0.6452142", "0.6295583", "0.61789805", "0.6112436", "0.6107325", "0.60884076", "0.59610105", "0.59126604", "0.5908381", "0.587297", "0.586031", "0.58270234", "0.5821195", "0.5821195", "0.5802803", "0.57767856", "0.57263523"...
0.7321024
0
Fetches the current loadshedding stage from the Eskom API
async def async_get_stage(self, attempts=50): # Query the API until a sensible (> 0) value is received, or the number of attempts is exceeded for attempt in range(attempts): res = await self.async_query_api("/GetStatus") # Return the current loadshedding stage by subtracting 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_stage():\n try:\n filename = os.path.join(get_var('SITE'), \".stage\")\n f = open(filename, \"r\")\n stage = f.readline().strip()\n f.close()\n logger.debug(\"get stage: %s\" % (stage))\n return stage\n except:\n return reset_stage()", "def get_stage...
[ "0.5896602", "0.55642724", "0.54953194", "0.54792047", "0.5462125", "0.54313517", "0.53262895", "0.53185606", "0.5314176", "0.5314081", "0.5314081", "0.5295862", "0.5229258", "0.5218341", "0.52007157", "0.5197444", "0.5197444", "0.5197444", "0.5137261", "0.512215", "0.5114277...
0.71549255
0
Fetches data from the loadshedding API
async def async_get_data(self): stage = await self.async_get_stage() data = { "data": {"stage": stage}, } return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fetch_data(self):\n pass", "def fetch_data(self):", "def _load_data(self):\n if self._api_response.status_code == 200:\n self._dataset = self._api_response.json()\n self._fill_day_dicts()", "def fetch_data():\n data.fetch_data()\n data.start_updating()", "def ...
[ "0.73392963", "0.72956276", "0.70448846", "0.6874289", "0.6612632", "0.65690875", "0.6422691", "0.6422691", "0.64019233", "0.6395586", "0.6293553", "0.62517023", "0.6210572", "0.61741084", "0.6149246", "0.6116018", "0.61003584", "0.6090419", "0.607891", "0.60308963", "0.60286...
0.0
-1
Check whether each file listed in the changes file is present. ```changes_file``` The changes file to parse for the orig.tar (note the dsc file referenced must exist)
def test_files_present(self, changes_file): for filename in changes_file.get_files(): log.debug('Looking whether %s was actually uploaded' % filename) if os.path.isfile(os.path.join(pylons.config['debexpo.upload.incoming'], filename)): log.debug('%s is present' % filename...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_native_package(self, changes_file):\n\n for file in changes_file['Files']:\n if file['name'].endswith('.diff.gz'):\n return False\n if file['name'].endswith(('.debian.tar.gz','.debian.tar.bz2','.debian.tar.xz')):\n return False\n return True"...
[ "0.6562452", "0.61490893", "0.5917509", "0.5785546", "0.5767901", "0.5733005", "0.5689596", "0.5616368", "0.5590855", "0.55259246", "0.54963535", "0.5468433", "0.5468134", "0.5463716", "0.5461302", "0.54606396", "0.5443999", "0.5441099", "0.542676", "0.53501844", "0.5344584",...
0.7056379
0
Check each file's md5sum and make sure the md5sum in the changes file is the same as the actual file's md5sum. ```changes_file``` The changes file to parse for the orig.tar (note the dsc file referenced must exist)
def test_md5sum(self, changes_file): for file in changes_file['Files']: log.debug('Checking md5sum of %s' % file['name']) filename = os.path.join(pylons.config['debexpo.upload.incoming'], file['name']) if not os.path.isfile(filename): raise OSError("Missing fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_sum(file_path, md5_sum):\n file_md5_sum = generate_sum(file_path)\n return (file_md5_sum == md5_sum)", "def svn_fs_file_md5_checksum(*args):\r\n return _fs.svn_fs_file_md5_checksum(*args)", "def test_source_package_checksum_changes(self):\n response = self.client.head(\n f'/...
[ "0.61215234", "0.6010805", "0.59985346", "0.59703654", "0.59538466", "0.5940276", "0.59365785", "0.5863028", "0.58563745", "0.5855248", "0.581167", "0.5796914", "0.5796634", "0.57454133", "0.57304496", "0.5703791", "0.5699861", "0.56995535", "0.5671011", "0.5628634", "0.56136...
0.8076951
0
Guess based on the changes file and files being uploaded, whether a package is considered native of not ```changes_file``` The changes file to parse for the orig.tar (note the dsc file referenced must exist)
def is_native_package(self, changes_file): for file in changes_file['Files']: if file['name'].endswith('.diff.gz'): return False if file['name'].endswith(('.debian.tar.gz','.debian.tar.bz2','.debian.tar.xz')): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_orig_tarball(self, changes_file):\n\n orig_name = None\n if not changes_file.get_dsc() or open(changes_file.get_dsc()) == None:\n return (orig_name, constants.ORIG_TARBALL_LOCATION_NOT_FOUND)\n\n dscfile = open(changes_file.get_dsc())\n dsc = deb822.Dsc(dscfile)\n ...
[ "0.7022202", "0.5861582", "0.5830605", "0.57546717", "0.5683719", "0.5522598", "0.55078954", "0.5425292", "0.5394608", "0.53885627", "0.537539", "0.5327455", "0.5298978", "0.52786845", "0.524849", "0.51662666", "0.5139674", "0.51386774", "0.5101697", "0.508725", "0.507584", ...
0.7332381
0
Look to see whether there is an orig tarball present, if the dsc refers to one. This method returns a triple (filename, file_found, location_hint), returning the (expected) name of the original tarball, and whether it was found in the local repository ```changes_file``` The changes file to parse for the orig.tar (note ...
def find_orig_tarball(self, changes_file): orig_name = None if not changes_file.get_dsc() or open(changes_file.get_dsc()) == None: return (orig_name, constants.ORIG_TARBALL_LOCATION_NOT_FOUND) dscfile = open(changes_file.get_dsc()) dsc = deb822.Dsc(dscfile) for file...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_applicable(result: Result, original_file_dict, file_diff_dict):\n\n if len(result.affected_code) == 0:\n return 'The result is not associated with any source code.'\n\n filenames = set(src.renamed_file(file_diff_dict)\n for src in result.affected_code)\n ...
[ "0.5856133", "0.5586155", "0.5303869", "0.52426755", "0.5206382", "0.5184854", "0.5141354", "0.5130958", "0.509906", "0.506888", "0.5050227", "0.50488764", "0.49886075", "0.49809384", "0.49780205", "0.49768654", "0.49239424", "0.4915758", "0.48938805", "0.48809808", "0.487459...
0.806148
0
Returns all unique paths for files associated with the supplied package version ```packageversion``` The package version to be scanned ```absolute_path``` if set to True, returns the absolute path instead of a path relative to the repository root
def find_files_for_packageversion(self, packageversion, absolute_path=False): package_files = [] for attr in ('binary_packages', 'source_packages'): if hasattr(packageversion, attr): for bp in getattr(packageversion, attr): for files in bp.package_files: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files_for_package(self, package, absolute_path=False):\n package_files = []\n for p in package.package_versions:\n package_files.extend(self.find_files_for_packageversion(p, absolute_path))\n return package_files", "def full_find(self, file, version):\n matches = [...
[ "0.6776081", "0.57738966", "0.57006", "0.5643437", "0.5551925", "0.5528448", "0.54549044", "0.5375594", "0.53727055", "0.5351883", "0.5307413", "0.5246328", "0.5221049", "0.51959926", "0.5160953", "0.51521415", "0.5149688", "0.51018757", "0.51011", "0.5095191", "0.5087868", ...
0.7598108
0
Returns all unique paths for files associated with the supplied packages ```package``` The package to be scanned ```absolute_path``` if set to True, returns the absolute path instead of a path relative to the repository root
def find_files_for_package(self, package, absolute_path=False): package_files = [] for p in package.package_versions: package_files.extend(self.find_files_for_packageversion(p, absolute_path)) return package_files
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files_for_packageversion(self, packageversion, absolute_path=False):\n package_files = []\n for attr in ('binary_packages', 'source_packages'):\n if hasattr(packageversion, attr):\n for bp in getattr(packageversion, attr):\n for files in bp.packag...
[ "0.65744954", "0.6538738", "0.6327214", "0.60860723", "0.6070535", "0.5906358", "0.5833705", "0.5832187", "0.58272886", "0.58078057", "0.5749993", "0.57397157", "0.57397157", "0.57397157", "0.5738294", "0.56959873", "0.565308", "0.563047", "0.56227636", "0.56075794", "0.55792...
0.7131917
0
Removes all files associated with the package version supplied ```packageversion``` PackageVersion object whose files are supposed to be removed
def delete_files_for_packageversion(self, packageversion): files = self.find_files_for_packageversion(packageversion, absolute_path=True) if not files: return path = os.path.dirname(files[0]) for file in files: if os.path.exists(file): log.debu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_files_for_package(self, package):\n files = self.find_files_for_package(package, absolute_path=True)\n if not files:\n return\n path = os.path.dirname(files[0])\n for file in files:\n if os.path.exists(file):\n log.debug(\"Removing fil...
[ "0.7006803", "0.6729492", "0.66909456", "0.62634903", "0.62541205", "0.6170387", "0.61650103", "0.6109658", "0.6072664", "0.6071761", "0.6042147", "0.600773", "0.60031897", "0.5883982", "0.58733577", "0.5864497", "0.58045745", "0.57851744", "0.57476383", "0.57243997", "0.5702...
0.8144159
0
Removes all files associated with the package supplied ```package``` package object whose files are supposed to be removed
def delete_files_for_package(self, package): files = self.find_files_for_package(package, absolute_path=True) if not files: return path = os.path.dirname(files[0]) for file in files: if os.path.exists(file): log.debug("Removing file '%s'" % (fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_packages(self, packages):", "def clean(self) -> None:\n # remove all *.py and *.pyi files in the folder\n for wc in [\"*.py\", \"*.pyi\", \"modules.json\"]:\n for f in (self.package_path).rglob(wc):\n f.unlink()", "def remove_module_files(self, base_dir):\n ...
[ "0.7546989", "0.73516136", "0.71049297", "0.70153433", "0.7001211", "0.6886907", "0.68704784", "0.6867759", "0.6712021", "0.66684604", "0.6525831", "0.6513985", "0.64653736", "0.6430455", "0.641628", "0.63933665", "0.6354628", "0.63250524", "0.63172334", "0.6308882", "0.62891...
0.7580052
0
Looks at a filename's extension and decides whether to accept it. We only want package files to be uploaded, after all. It returns a boolean of whether to accept the file or not. ``filename`` File to test.
def allowed_upload(self, filename): for suffix in ['.changes', '.dsc', '.tar.gz', '.diff.gz', '.deb', '.udeb', '.tar.bz2', ".tar.xz"]: if filename.endswith(suffix): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_file(filename):\n \n if not '.' in filename:\n return False\n \n ext = filename.rsplit('.', 1)[1]\n \n if ext.lower() in ALLOWED_FILE_EXTENSIONS:\n return True\n else:\n return False", "def allowed_file(filename: str) -> bool:\n if filename is None or file...
[ "0.82098633", "0.7922775", "0.790487", "0.787731", "0.7795147", "0.7711532", "0.7709475", "0.7709475", "0.77041215", "0.77041215", "0.76879025", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76774913", "0.76...
0.74530524
36
Sets the personal available time slot in calendar
def set_available_time_slot(): if request.content_type != 'application/json': error = json.dumps({'error': 'Invalid Content Type'}) return make_response(error, 400, InterviewCalendarApi.HEADERS) data = request.json # For Temporary purpose, stored in flat file database with open(InterviewCal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_time_available(self, new_value):\n\n self.available_at = new_value\n self.save()", "def time_slot(self):\n pass", "def timeslot(self, timeslot: List[TimeslotTimeslot]):\n\n self._timeslot = timeslot", "def choose_time_slot():\n req = request.json\n firebase_uid = req...
[ "0.6769007", "0.6269106", "0.6212529", "0.61314505", "0.6038733", "0.6016706", "0.59351456", "0.5850808", "0.580659", "0.5770316", "0.5760114", "0.57599235", "0.5728663", "0.5717891", "0.57096136", "0.5688027", "0.5682681", "0.56790507", "0.5677591", "0.56367344", "0.56291395...
0.78393424
0
Gets the ideal time slot to arrange interview between different parties.
def get_available_time_slot(): try: time_slot_set_list = list() # Read all time slot from database with open(InterviewCalendarApi.DB_FILE, "r") as fd: for line in fd: time_slot_list = list() (_,_,_, time_slots) = line.strip().split("|") for time_slot in time_s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_slot(self):\n min_time = self.introduction_time or 0\n current_time = self.agent.evaluation_context.get_current_time()\n assert isinstance(current_time, Number)\n if current_time < min_time:\n return None\n num = divmod(current_time - min_time, self.__period)[...
[ "0.63423276", "0.57650554", "0.571941", "0.5690644", "0.5626049", "0.55934006", "0.5564088", "0.55332726", "0.5426856", "0.542664", "0.5384493", "0.5384436", "0.5369141", "0.5359809", "0.53586596", "0.5353438", "0.5322902", "0.5312281", "0.5306348", "0.5242515", "0.52214307",...
0.5513882
8
Converts a timestamp into a human readable date format >>> convert_timestamp(1601104029)
def convert_timestamp(): ts = int(sys.argv[1]) human_readable_time = '%m/%d/%Y @ %I:%M %p (UTC)' print(datetime.utcfromtimestamp(ts).strftime(human_readable_time))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_timestamp(stamp):\n date = datetime.fromtimestamp(float(stamp))\n return date.strftime(\"%m/%d/%y %I:%M:%S %p\")", "def convert_timestamp_to_readable_date(timestamp: int) -> str:\n return datetime.utcfromtimestamp(timestamp).isoformat()", "def convert_epoch_to_timestamp(cls, timestamp, tsf...
[ "0.76768744", "0.7368898", "0.714151", "0.708612", "0.7062975", "0.6758006", "0.67139393", "0.6706629", "0.6660264", "0.6614045", "0.66062516", "0.65518653", "0.64964134", "0.6483565", "0.6470719", "0.6469389", "0.6456289", "0.6430389", "0.64229417", "0.63479745", "0.62924296...
0.71047884
3
update the current state based on action The working states, as oppose to 'idle' include that of 'pending', 'testing', 'countingDown', 'writing'
def update_state(self, act): # check the checkbox logic if act in ['follow', 'not_follow', 'locate', 'not_locate']: self.check_locate_follow_logic(act) # test/record logic print("update function not implemented")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take_action(self, state):", "def doAction(self,state,action):\n self.lastState = state\n self.lastAction = action", "def state_update(self, last_action, action):\n s_t = self._get_state(last_action)\n r= self._get_reward(last_action,action)\n self._move_user()\n s_t1 = sel...
[ "0.70931727", "0.70630455", "0.7048988", "0.6953234", "0.6851414", "0.68310285", "0.6781109", "0.6740664", "0.671901", "0.666701", "0.6620263", "0.66010344", "0.6586356", "0.6544292", "0.65192556", "0.6504407", "0.64934057", "0.6481681", "0.6471958", "0.6464481", "0.645273", ...
0.67353684
8
can only choose one
def check_locate_follow_logic(self, act): if act == 'freq_low': # if locate is chosen, remove it if 'freq_high' in self.state: self.state.remove('freq_high') self.state.append(act) elif act == 'not_freq_low': if 'freq_low' in self.state: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decide():", "def choose(self, choice):\n if self.available(choice):\n self.select(choice)", "def _choose_best_option(self):", "def choose(self, event):\n return self.can(event)[0]", "def select(self):\r\n pass", "def select(self):\n pass", "def select(self):\n...
[ "0.66341513", "0.6275091", "0.625221", "0.6161598", "0.61244404", "0.5988319", "0.5988319", "0.5933216", "0.5883137", "0.5878196", "0.5851665", "0.58068585", "0.5729175", "0.5729175", "0.5727388", "0.5708148", "0.5706344", "0.568923", "0.56353563", "0.5628979", "0.56164134", ...
0.0
-1
Parse a date string and convert to a naive ``datetime`` object in UTC
def parse(date_string: str): # parse the date string date = dateutil.parser.parse(date_string) # convert to UTC if containing time-zone information # then drop the timezone information to prevent unsupported errors if date.tzinfo: date = date.astimezone(dateutil.tz.UTC).replace(tzinfo=None) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_date(s):\n return parse(s).astimezone(pytz.utc)", "def parse_datetime(datestr):\r\n try:\r\n return dateutil.parser.parse(datestr).replace(tzinfo=utc)\r\n except ValueError:\r\n raise DashboardError(_(\"Unable to parse date: \") + datestr)", "def parse_datetime(date_string):\n...
[ "0.7907918", "0.7845481", "0.76971775", "0.7675037", "0.7473908", "0.7440517", "0.735506", "0.7350854", "0.72948474", "0.72435045", "0.7241617", "0.72313863", "0.7218996", "0.7172882", "0.71403486", "0.71389437", "0.71222574", "0.71187925", "0.71035874", "0.70936656", "0.7073...
0.8085187
1
Parse a date string of the form
def parse_date_string(date_string: str): # try parsing the original date string as a date try: epoch = parse(date_string) except ValueError: pass else: # return the epoch (as list) return (datetime_to_list(epoch), 0.0) # split the date string into units and epoch ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_parse(date_string) -> datetime:\n return datetime.strptime(date_string, DATE_FMT)", "def parse_date(str_date):\n return ciso8601.parse_datetime(str_date)", "def parse(self, str):\n values = self._exp.findall(str)\n if values is None or len(values) == 0:\n return None\n\n...
[ "0.7754825", "0.7681746", "0.7619202", "0.7595637", "0.7554202", "0.7522775", "0.7512194", "0.7293273", "0.7285541", "0.7257252", "0.7254006", "0.7244446", "0.7221628", "0.7219147", "0.72051275", "0.720416", "0.7189553", "0.71871907", "0.71790546", "0.71494836", "0.7117056", ...
0.6474711
81
Split a date string into units and epoch
def split_date_string(date_string: str): try: units,_,epoch = date_string.split(None, 2) except ValueError: raise ValueError(f'Invalid format: {date_string}') else: return (units.lower(), parse(epoch))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_date_string(date_string: str):\n # try parsing the original date string as a date\n try:\n epoch = parse(date_string)\n except ValueError:\n pass\n else:\n # return the epoch (as list)\n return (datetime_to_list(epoch), 0.0)\n # split the date string into units ...
[ "0.725681", "0.72525626", "0.6715245", "0.64701724", "0.6382786", "0.619452", "0.61797726", "0.6074394", "0.6071968", "0.60437346", "0.601686", "0.6001186", "0.59548134", "0.5884169", "0.5833305", "0.58276343", "0.5821117", "0.581139", "0.5810008", "0.5795588", "0.57780796", ...
0.7802953
1
Convert a ``datetime`` object into a list
def datetime_to_list(date): return [date.year, date.month, date.day, date.hour, date.minute, date.second]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_datetime_objs(list_of_dates):\n datetime_list = []\n for date in list_of_dates:\n date_obj = datetime.datetime.strptime(date, '%d.%m.%Y')\n datetime_list.append(date_obj)\n return datetime_list", "def deconstruct_datetime(self, date: datetime) -> List[int]:\n year, month...
[ "0.72293544", "0.7085231", "0.70122313", "0.64888054", "0.6427361", "0.6376207", "0.62667364", "0.6259938", "0.62293786", "0.61688745", "0.6106284", "0.6053032", "0.6039443", "0.6039443", "0.6039443", "0.6039443", "0.602236", "0.60170233", "0.601256", "0.5993775", "0.59911925...
0.8505954
1
Calculates the number of days per month for a given year
def calendar_days(year: int | float | np.ndarray) -> np.ndarray: # Rules in the Gregorian calendar for a year to be a leap year: # divisible by 4, but not by 100 unless divisible by 400 # True length of the year is about 365.2422 days # Adding a leap day every four years ==> average 365.25 # Subtrac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numDays(month, year):\n\tif month in [9, 4, 6, 11]:\n\t\treturn 30\n\telif month == 2 and year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):\n\t\treturn 29\n\telif month == 2:\n\t\treturn 28\n\telse:\n\t\treturn 31", "def dayInYear(month, day, year):\n current = 1\n numberOfDays = day\n while (...
[ "0.7755178", "0.77529544", "0.73326933", "0.7312692", "0.71782887", "0.71756566", "0.71731204", "0.7086364", "0.69122785", "0.6904365", "0.68112487", "0.67785037", "0.6743583", "0.6650364", "0.662489", "0.6611992", "0.6603074", "0.6593793", "0.65065837", "0.64749384", "0.6471...
0.7056173
9
Convert a ``numpy`` ``datetime`` array to seconds since ``epoch``
def convert_datetime( date: float | np.ndarray, epoch: str | tuple | list | np.datetime64 = _unix_epoch ): # convert epoch to datetime variables if isinstance(epoch, (tuple, list)): epoch = np.datetime64(datetime.datetime(*epoch)) elif isinstance(epoch, str): epoch = np.d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ts_to_epoch_seconds(t) -> float:\n return t.astype(int) / 1e9", "def epoch2datetime(t):\n return datetime.fromtimestamp(t/1000.0)", "def seconds_since_epoch(date_time, epoch=None):\n return microseconds_since_epoch(date_time) / 10.0**6", "def epoch_seconds(date):\n td = date - epoch\n retu...
[ "0.7119384", "0.70471823", "0.67733616", "0.6677283", "0.6677283", "0.66770333", "0.65791225", "0.6510859", "0.64249825", "0.62467736", "0.62348825", "0.62348825", "0.61904925", "0.6188793", "0.6172504", "0.5990658", "0.5972928", "0.5956192", "0.59386444", "0.59345615", "0.59...
0.72007585
1
Convert delta time from seconds since ``epoch1`` to time since ``epoch2``
def convert_delta_time( delta_time: np.ndarray, epoch1: str | tuple | list | np.datetime64 | None = None, epoch2: str | tuple | list | np.datetime64 | None = None, scale: float = 1.0 ): # convert epochs to datetime variables if isinstance(epoch1, (tuple, list)): epoch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def epoch2time(time):\n\tvalue = datetime.datetime.fromtimestamp(time)\n\tNormal = value.strftime('%Y-%m-%d %H:%M:%S')\n\tprint(normal)\n\treturn normal", "def pcr_delta_time_ms(pcr_t1, pcr_t2, offset = 0):\n return float(pcr_t2-pcr_t1)/90000.0 + offset", "def to_deltatime(self,\n epoch: str | tu...
[ "0.65060514", "0.6424808", "0.6152584", "0.60279953", "0.59376085", "0.5886172", "0.5869834", "0.58575207", "0.5820404", "0.58052814", "0.5757795", "0.57485944", "0.56638455", "0.56527215", "0.56485754", "0.56349045", "0.56349045", "0.5627923", "0.5625807", "0.5594252", "0.55...
0.7332065
1
Calculate the time in time units since ``epoch`` from calendar dates
def convert_calendar_dates( year: np.ndarray, month: np.ndarray, day: np.ndarray, hour: np.ndarray | float = 0.0, minute: np.ndarray | float = 0.0, second: np.ndarray | float = 0.0, epoch: tuple | list | np.datetime64 = _tide_epoch, scale: float = 1.0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def epoch_time(when):\n if not when: return 0\n epoch = datetime.utcfromtimestamp(0)\n delta = when - epoch\n return int(delta.total_seconds())", "def seconds_since_epoch(date_time, epoch=None):\n return microseconds_since_epoch(date_time) / 10.0**6", "def epoch_seconds(date):\r\n td = date -...
[ "0.65561664", "0.6340998", "0.63183016", "0.6301214", "0.6301214", "0.62795186", "0.6216668", "0.62102425", "0.61283773", "0.6122344", "0.61176836", "0.6072185", "0.6036625", "0.59966165", "0.59800243", "0.5976523", "0.59661543", "0.5852806", "0.57929045", "0.5781751", "0.577...
0.5230787
57
Converts from calendar date into decimal years taking into account leap years
def convert_calendar_decimal( year: np.ndarray, month: np.ndarray, day: np.ndarray, hour: np.ndarray | float | None = None, minute: np.ndarray | float | None = None, second: np.ndarray | float | None = None, DofY: np.ndarray | float | None = None, ) -> np.ndar...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def days_to_years(datum):\n return datum/DAYS_PER_YEAR", "def _days_before_year(year):\n y = year - 1\n return y * 365 + y // 4 - y // 100 + y // 400", "def year(self) -> int:\n if self.is_old_style:\n yy = int(self.split('/', 1)[1][0:2])\n else:\n yy = int(self[:2])...
[ "0.82051677", "0.7126889", "0.71093416", "0.71062267", "0.70007455", "0.695518", "0.68835115", "0.68746775", "0.6820882", "0.6783935", "0.6728416", "0.66622645", "0.66086173", "0.6600496", "0.65989643", "0.6592281", "0.65849185", "0.6562183", "0.65444785", "0.6497388", "0.649...
0.0
-1
Converts from Julian day to calendar date and time
def convert_julian(JD: np.ndarray, **kwargs): # set default keyword arguments kwargs.setdefault('astype', None) kwargs.setdefault('format', 'dict') # raise warnings for deprecated keyword arguments deprecated_keywords = dict(ASTYPE='astype', FORMAT='format') for old,new in deprecated_keywords.it...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def JulianDay(self):\n a = (14 - self._month) // 12\n y = self._year + 4800 - a\n m = self._month + (12 * a) - 3\n return (self._day + (153 * m + 2) // 5 + 365 * y +\n y // 4 - y // 100 + y // 400 - 32045)", "def _gregorian_to_julian_day(year, month, day):\n if month...
[ "0.6966466", "0.6876087", "0.6870243", "0.68287796", "0.67212313", "0.6684041", "0.6644245", "0.664008", "0.66230804", "0.65871185", "0.6576862", "0.6546014", "0.6470467", "0.645271", "0.645271", "0.64524555", "0.64404553", "0.6387761", "0.63858074", "0.62827337", "0.6244979"...
0.6714327
6
Counts the number of leap seconds between a given GPS time and UTC
def count_leap_seconds( GPS_Time: np.ndarray | float, truncate: bool = True ): # get the valid leap seconds leaps = get_leap_seconds(truncate=truncate) # number of leap seconds prior to GPS_Time n_leaps = np.zeros_like(GPS_Time,dtype=np.float64) for i,leap in enumerate(leaps): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def utctoweekseconds(utc, leapseconds=18):\n datetimeformat = \"%Y-%m-%d %H:%M:%S\"\n epoch = datetime.datetime.strptime(\"1980-01-06 00:00:00\", datetimeformat)\n tdiff = utc - epoch + datetime.timedelta(seconds=leapseconds)\n gpsweek = tdiff.days // 7\n gpsdays = tdiff.days - 7 * gpsweek\n gpss...
[ "0.652139", "0.58384943", "0.57290035", "0.56942356", "0.56746274", "0.5595739", "0.55098593", "0.5501737", "0.53909945", "0.5376595", "0.5324631", "0.5324156", "0.5290026", "0.5261761", "0.5184121", "0.5171609", "0.51585203", "0.5151989", "0.51178706", "0.5116599", "0.505507...
0.7145605
1
Gets a list of GPS times for when leap seconds occurred
def get_leap_seconds(truncate: bool = True): leap_secs = icesat2_toolkit.utilities.get_data_path(['data','leap-seconds.list']) # find line with file expiration as delta time with leap_secs.open(mode='r', encoding='utf8') as fid: secs, = [re.findall(r'\d+',i).pop() for i in fid.read().splitlines() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_leap_seconds(truncate: bool = True):\n leap_secs = pyTMD.utilities.get_data_path(['data','leap-seconds.list'])\n # find line with file expiration as delta time\n with leap_secs.open(mode='r', encoding='utf8') as fid:\n secs, = [re.findall(r'\\d+',i).pop() for i in fid.read().splitlines()\n ...
[ "0.6662289", "0.63633394", "0.6226151", "0.6171691", "0.61506224", "0.61460394", "0.6143277", "0.6093351", "0.5990384", "0.5958879", "0.5958879", "0.5958879", "0.5945612", "0.5896451", "0.5885215", "0.588292", "0.58812433", "0.5852047", "0.581152", "0.57902336", "0.5767987", ...
0.676572
0
Connects to servers to download leapseconds.list files from NIST servers
def update_leap_seconds( timeout: int | None = 20, verbose: bool = False, mode: oct = 0o775 ): # local version of file FILE = 'leap-seconds.list' LOCAL = icesat2_toolkit.utilities.get_data_path(['data',FILE]) HASH = icesat2_toolkit.utilities.get_hash(LOCAL) # try downloa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createFileListHTTP(self, server, directory):\r\n conn = httplib.HTTPConnection(server)\r\n conn.request(\"GET\",directory)\r\n r1 = conn.getresponse()\r\n '''if r1.status==200:\r\n print \"status200 received ok\"\r\n else:\r\n print \"oh no = status=%d %...
[ "0.630811", "0.5879872", "0.5738498", "0.5700458", "0.56712866", "0.5523393", "0.5522576", "0.54847145", "0.54457563", "0.54361594", "0.5377989", "0.5363726", "0.5337887", "0.5322642", "0.5293564", "0.52784735", "0.5269241", "0.52584785", "0.52491146", "0.5248196", "0.5207827...
0.572799
3
generate label vectors from collected images
def get_label_vectors(): print("Retrieving label vectors...") label_dict = {} # instantiate dict for labels:vectors categories = sorted([c for c in os.listdir('images/') if c[0] != '.']) # ignore hidden files x = np.zeros(len(categories)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_labels(pics):\r\n return []", "def extract_labels(filename, num_images, starting_id, context_factor):\n gt_imgs = []\n for i in range(starting_id, num_images+starting_id):\n imageid = \"satImage_%.3d\" % i\n image_filename = filename + imageid + \".png\"\n if os.path.is...
[ "0.7303702", "0.7006394", "0.68937486", "0.6873022", "0.68646514", "0.6803414", "0.6724581", "0.6620808", "0.66204023", "0.6591786", "0.6567913", "0.65644395", "0.65557486", "0.6555063", "0.6541309", "0.6527798", "0.65208435", "0.65085703", "0.6501463", "0.6480988", "0.646566...
0.78073823
0
load image data from collected categories
def load_image_data(): print("Loading image data...") label_dict = get_label_vectors() categories = [c for c in os.listdir('images/') if c[0] != '.'] # ignore labels = [] # instantiate list for image labels data = [] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prep_image_data(arg_dict):\n cat_df = pd.read_csv(arg_dict['category_file'],\n skiprows=1,\n sep='\\s+')\n bbox_df = pd.read_csv(arg_dict['bbox_file'],\n skiprows=1,\n sep='\\s+')\n img_dir = arg_dict['im...
[ "0.73744714", "0.70992035", "0.6866402", "0.6855467", "0.67352", "0.67105335", "0.6656234", "0.66058004", "0.65050745", "0.65049785", "0.6448114", "0.6420186", "0.6376639", "0.63688254", "0.6314507", "0.63099957", "0.6244066", "0.6235248", "0.62325114", "0.6227874", "0.621148...
0.75711864
0
main method of image_mgmt.py
def main(): labels, data = load_image_data() print(labels.shape, data.shape)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n images = Images()\n #print images.create_image_urls()\n print images.get_image_random()\n print images.get_image(12)", "def main():\n \n # for inserting other images, add tem to /input folder and list them here\n images = (\n 'image-0',\n 'image-1',\n 'image-2...
[ "0.7724663", "0.7417523", "0.72567064", "0.7056425", "0.6892278", "0.67639", "0.66935354", "0.6682261", "0.66802955", "0.66739655", "0.6670762", "0.6670762", "0.6670762", "0.6636167", "0.65970665", "0.6594695", "0.65808475", "0.657597", "0.6567467", "0.6554589", "0.6533119", ...
0.65013987
23
Detect posedge or negedge on input signal, default to posedge(mode=0)
def edge_detect( clk, rst_n, din, valid, mode=0 ): din_r = UBool(0) @always_ff(clk.posedge, reset=rst_n) def _latch(): din_r.next = din # TODO: conditional parameter on generate @always_comb def _valid(): if mode == 0: valid.next = not din and d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sensed(self):\n return not self.pin.read() if self.pinishigh else self.pin.read()", "async def handle_less(message: types.Message):\n await handle_change_threshold(message, 1 / 1.5)", "def nearest_test_pulse(self):", "def is_ringing(self) -> bool:", "def forward(self, input):\r\n retur...
[ "0.5264356", "0.5113618", "0.5000561", "0.49808434", "0.49234867", "0.49224997", "0.49052876", "0.4896278", "0.4894377", "0.4853233", "0.47944462", "0.47820812", "0.47796014", "0.47683772", "0.47345206", "0.47341648", "0.47143006", "0.4695682", "0.46904302", "0.4684524", "0.4...
0.0
-1
Binary to onehot conversion
def bin2ohot(din, dout): IN_W = len(din) OUT_W = 2**IN_W @always_comb def _conv(): for i in range(OUT_W): if din == i: dout[i] = 1 else: dout[i] = 0 return instances()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_to_one_hot(arr: np.ndarray) -> np.ndarray:\n res = np.zeros((arr.shape[0], 2))\n res[np.where(arr == 1)[0], 0] = 1\n res[np.where(arr == 0)[0], 1] = 1\n return res", "def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerat...
[ "0.8336464", "0.8243893", "0.8077957", "0.8006649", "0.792823", "0.79020256", "0.7887456", "0.7865496", "0.78533834", "0.7835221", "0.7825861", "0.7818072", "0.7791989", "0.7786955", "0.77542466", "0.77538735", "0.77049476", "0.7704875", "0.76757723", "0.76493716", "0.7637535...
0.0
-1
Generates a bot object
def __init__(self, order, timer): super().__init__(order) self.name = 'Bot' + str(order + 1) self.is_checked = False self.timer = timer # vpip, pfr and agg stored as integer% (/ 100) # TODO # Dictionary? # Translate to playable hand ratings self.vp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, bot=BNBot):\n self.bot = bot", "def __init__(self, bot):\n self.bot = bot", "def __init__(self, bot):\n self.bot = bot", "def bot_factory(url):\n from dallinger_experiment.experiment import Bot\n\n return Bot(url)", "def makebot(self, name, cfg=None):\n\n ...
[ "0.6956568", "0.6869598", "0.6869598", "0.6731655", "0.66259605", "0.6554135", "0.65377176", "0.65377176", "0.6139103", "0.60624367", "0.6005556", "0.58768237", "0.5853435", "0.58470196", "0.5823871", "0.57866377", "0.5736363", "0.5711528", "0.56844354", "0.5640654", "0.56065...
0.0
-1
Decides whether to bet or fold at this point in time
def bet_fold_algorithm(self, current_top_bid, pot_size, community_cards, position, number_of_players, is_first_cycle, total_value): # If pre-flop if len(community_cards) == 0: rank = self.hand.opening_hand_ranking() # Cut-off rank = 0.00 right now ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fold(self):\n self.active = False\n self.hand = None\n self.bet = 0\n return True", "def get_learn_after_each_decision(self):\r\n return 0", "def notFold(self):\n return not self._fold", "def rough_outcome(self) -> float:\n # HUYNH YOU PRICK WHY THE FUCK D...
[ "0.72265923", "0.6000676", "0.5944416", "0.56944317", "0.5582698", "0.5582698", "0.5582698", "0.55106276", "0.5448707", "0.54409707", "0.54199135", "0.5411135", "0.5394675", "0.5384363", "0.53631586", "0.536092", "0.5355963", "0.5352496", "0.5329533", "0.5312051", "0.530132",...
0.61763084
1
Decides amount to bet
def amount_algorithm(self, current_top_bid, pot_size, community_cards, position, number_of_players, is_first_cycle, total_value): # If pre-flop if len(community_cards) == 0: if is_first_cycle is False: return current_top_bid - self.current_bet ...
{ "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 get_bet(self) -> int:\n return int(input(f\"How much money would you like to place? \"\...
[ "0.80275404", "0.7679025", "0.7675108", "0.7609656", "0.74898267", "0.7448841", "0.733221", "0.7229419", "0.69224185", "0.69190437", "0.69124156", "0.6872131", "0.68597424", "0.67960364", "0.6715273", "0.66506547", "0.6604676", "0.6566986", "0.65195584", "0.65036714", "0.6471...
0.66638166
15
Used to remove any possible empty module params passed in from a task file.
def filter_empty_subparams(self, param_name): param = self.module.params.get(param_name) filtered = [] if isinstance(param, list): for subparam in param: if isinstance(subparam, dict): filtered.append( dict( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_parameters(self):\n self.parameters = []", "def purge(root=os.path.join(\"~\", \".daisykit\", \"assets\")):\n root = os.path.expanduser(root)\n files = os.listdir(root)\n for f in files:\n if f.endswith(\".params\"):\n os.remove(os.path.join(root, f))", "def buildWi...
[ "0.57616585", "0.5588865", "0.5586321", "0.5513312", "0.5493854", "0.5449779", "0.54313815", "0.5419195", "0.53861827", "0.53727466", "0.53104013", "0.53044254", "0.52886343", "0.5246557", "0.52453816", "0.52363384", "0.52314204", "0.51972383", "0.51937133", "0.5189336", "0.5...
0.5294682
12
Sets up other parameters for the api call that may not be specified in the modules from tasks file.
def api_params(self): params = dict( (key, self.module.params.get(key)) for key, value in RECORD_KEYS_MAP.items() if key != "answers" and self.module.params.get(key) is not None ) return params
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_params():\n global module \n global ora_inst\n global response_loc\n\n module_args=dict(\n ora_inst=dict(type='str', required=True),\n response_loc=dict(type='str', required=True)\n )\n\n module=AnsibleModule(\n argument_spec=module_args\n )\n\n ora_inst = modul...
[ "0.6986048", "0.64589137", "0.63455117", "0.62272775", "0.60726595", "0.6069171", "0.5985259", "0.5889219", "0.5888519", "0.5883398", "0.58747536", "0.58570075", "0.5845327", "0.5829871", "0.5793331", "0.5773644", "0.5773644", "0.57736164", "0.5762372", "0.5761211", "0.573227...
0.0
-1
Remove fields from the APIreturned record that we don't want to pass back, or consider when diffing.
def sanitize_record(self, record): def remove_ids(d): if isinstance(d, dict): if 'id' in d: del d['id'] for key, val in d.items(): if isinstance(val, (dict, list)): remove_ids(val) if isinstan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_unwanted_fields(self, data, many, **kwargs):\n unwanted_fields = [\"resource_type\"]\n for field in unwanted_fields:\n if field in data:\n data.pop(field)\n return data", "def prune(record: cfg.OpenAPI, outformat: cfg.Format = None) -> NoReturn:\n conte...
[ "0.6754392", "0.66556805", "0.62742776", "0.62539446", "0.6249638", "0.6215634", "0.6152936", "0.60918176", "0.60912836", "0.6078683", "0.602921", "0.59926665", "0.59876364", "0.59813493", "0.5973602", "0.5944134", "0.5934237", "0.5881215", "0.58473516", "0.5843913", "0.58421...
0.5617131
33
Used to get the zone associated with the record being worked on.
def get_zone(self): to_return = None try: to_return = self.ns1.loadZone(self.module.params.get('zone')) except ResourceException as re: if re.response.code == 404: if ( self.module.params.get('ignore_missing_zone') a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zone(self):\n return self._zone", "def get_zone(self):\n return self.project.get_flow().get_zone_of_object(self)", "def zone(self) -> str:\n return pulumi.get(self, \"zone\")", "def zone(self) -> str:\n return pulumi.get(self, \"zone\")", "def zone(self) -> str:\n ret...
[ "0.80801183", "0.80179244", "0.78354365", "0.78354365", "0.7710645", "0.7473004", "0.7473004", "0.7236832", "0.7219368", "0.7201566", "0.7194352", "0.71658826", "0.7155139", "0.7087766", "0.7087766", "0.7087766", "0.7087766", "0.7087766", "0.7074198", "0.70047337", "0.6966433...
0.710795
13
Used to look up the record name and type from the specified zone.
def get_record(self, zone): to_return = None try: to_return = zone.loadRecord(self.module.params.get('name'), self.module.params.get('type').upper()) except ResourceException as re: if re.response.code != 404: self.m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_r53_record_by_name ( route53_conn, dns_name, record_type = 'A' ) :\n dns_name = dns_name.lower( )\n zone_info = route53_conn.get_hosted_zone( route_53_hosted_zoneid )\n zone_name = zone_info[ 'GetHostedZoneResponse' ][ 'HostedZone' ][ 'Name' ]\n zone = route53_conn.get_zone( zone_name )\n return ...
[ "0.684966", "0.6636891", "0.6613396", "0.6532525", "0.64089847", "0.6375922", "0.6265335", "0.6205971", "0.61214995", "0.6064319", "0.6040061", "0.60173184", "0.60097045", "0.5822029", "0.5814325", "0.5788017", "0.5685655", "0.56776536", "0.56634295", "0.56493497", "0.5640705...
0.74746597
0
Used to handle records with values changing.
def update(self, record): # clean copy of record to preserve IDs for response if no update required record_data = self.sanitize_record(copy.deepcopy(record.data)) changed = False args = {} for key in RECORD_KEYS_MAP: input_data = self.filter_empty_subparams(key) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_record(self, record):\n raise NotImplementedError", "def process_record(self, record):\n raise NotImplementedError('Process record needs to be customized')", "def visit_record(self, syrecord):\n for other_key, other_value in syrecord.items():\n try:\n g...
[ "0.6425481", "0.60396576", "0.5966757", "0.5945433", "0.58991665", "0.58991665", "0.58991665", "0.5884155", "0.58602935", "0.58449084", "0.57962346", "0.57869387", "0.5782773", "0.57684565", "0.57654285", "0.5758463", "0.57228583", "0.57219404", "0.5706814", "0.5650283", "0.5...
0.54137516
40
Central exit point for the module.
def record_exit(self, after=None, before=None, changed=None, record=None): # convert dictionaries to yaml txt dump before_yaml = yaml.safe_dump(before, default_flow_style=False) after_yaml = yaml.safe_dump(after, default_flow_style=False) # build the final dict to pass into exit_json ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exit(self):\n pass", "def __exit(self, *args):\n sys.exit(0)", "def exit(self):\n super(Agent, self).exit()\n\n if self._module is not None:\n self._module.exit()", "def __exit__(self, *args):\n pass", "def exit(self):\n logger.debug(\"EXIT\")", "def...
[ "0.7896138", "0.78592885", "0.77071196", "0.7696922", "0.7685185", "0.756464", "0.7539602", "0.7297987", "0.7291299", "0.7278677", "0.7160537", "0.714784", "0.71462065", "0.7087686", "0.7087392", "0.70799416", "0.70055544", "0.69983804", "0.6993124", "0.6984299", "0.69821894"...
0.0
-1
Method called by main to handle record state logic handling.
def exec_module(self): state = self.module.params.get('state') zone = self.get_zone() if zone is None: self.module.fail_json(msg='zone "{}" not found'.format( self.module.params.get('zone') )) record = self.get_record(zone) # record found ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_record(self, record):\n raise NotImplementedError", "def process_record(self, record):\n raise NotImplementedError('Process record needs to be customized')", "def _post_init(self):\n self.set_new_record_state(False)", "def record(self, state):\r\n\r\n if state: # Start...
[ "0.6171262", "0.6028878", "0.5895539", "0.5820173", "0.57114506", "0.5640522", "0.56325686", "0.5569406", "0.55691856", "0.5568817", "0.555975", "0.5550883", "0.55424047", "0.5522525", "0.5502867", "0.54969925", "0.5492289", "0.5486894", "0.5483148", "0.54682165", "0.54612875...
0.51843923
45
write an NPZ file (Numpy binary files) containing only the preprocessed data needed for running Component Contribution estimations
def save_equilibrator_bin_data(self, npz_file_name): preprocess_dict = {'cids': self.params['cids']} for k, v in self.params.items(): if k.find('preprocess_') != -1: preprocess_dict[k.replace('preprocess_', '')] = v np.savez_compressed(npz_file_name, **preprocess_dict...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate(self):\n super().generate()\n records = random.random((self._dimension, self._dimension, self.num_samples))\n record_labels = [0] * self.num_samples\n prev_out_spec =\"\"\n count = 0\n for i in range(0, int(self.num_files)):\n if i % self.comm_size ...
[ "0.66370714", "0.65234995", "0.63456404", "0.6172922", "0.6125077", "0.60102993", "0.59520173", "0.5935673", "0.59053946", "0.58978695", "0.58922994", "0.5873275", "0.58675355", "0.58388406", "0.58206254", "0.5806083", "0.57888585", "0.57863545", "0.57822645", "0.5781454", "0...
0.70493346
0
Returns the chemical formation energy of the major MS at pH 7. If the compound is part of the training set, returns the value that was calculated during training. Otherwise, we use pure group contribution (if possible) on the groups of the major MS.
def get_major_ms_dG0_f(self, compound_id): if compound_id is None: raise ValueError('given compound ID is None') if self.params is None: self.train() if compound_id in self.cids: i = self.cids.index(compound_id) return self.params['dG0_cc'][i, 0] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_energy(self):\n return self.momentum*self.momentum/(2*self.mass)", "def get_hoomd_energy(key, hoomd_force_groups, calc_group):\n\n total_energy = 0\n total_energy = sum([a.get_energy(calc_group) \n for a in hoomd_force_groups[key]])\n return total_energy", "def co...
[ "0.620082", "0.5894757", "0.58618146", "0.5841101", "0.5817328", "0.578734", "0.5772486", "0.57676405", "0.5644884", "0.5638012", "0.56097746", "0.5535166", "0.5525179", "0.5514855", "0.5491314", "0.54726696", "0.5452643", "0.5449478", "0.54388803", "0.54244787", "0.54218894"...
0.591733
1
adds the componentcontribution estimation to the JSON
def to_dict(self, compound_id): if compound_id is None: raise ValueError('given compound ID is None') if self.params is None: self.train() comp = ccache.get_compound(compound_id) d = {'compound_id': compound_id, 'inchi_key': comp.inchi_key} gv = None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, contribution):\n self._contribution = contribution", "def add_comp(self, component, mole_fraction=np.nan):\n self['pore.mole_fraction.' + component.name] = mole_fraction", "def execute_contribution(self):\n contributions = [v for v in self.action_register if v['action'] ...
[ "0.5488856", "0.546339", "0.5305696", "0.524301", "0.5230317", "0.5165457", "0.51322114", "0.5111415", "0.50932914", "0.5080458", "0.50602216", "0.503721", "0.50131637", "0.4996776", "0.499471", "0.497496", "0.49216732", "0.4919991", "0.48574156", "0.48565018", "0.4780565", ...
0.46383762
30
Initialize G matrix, and then use the python script "inchi2gv.py" to decompose each of the compounds that has an InChI and save the decomposition as a row in the G matrix.
def create_group_incidence_matrix(self): gv_data = [] # decompose the compounds in the training_data and add to G for compound_id in self.cids: smiles = ccache.get_compound(compound_id).smiles try: gv_data.append( list(self.decompo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invcell2Gmat(invcell):\n G = fillgmat(invcell)\n g = nl.inv(G)\n return G, g", "def complete_disp(IBC, nodes, UG):\r\n nnodes = nodes.shape[0]\r\n UC = np.zeros([nnodes, 3], dtype=np.float)\r\n for row in range(nnodes):\r\n for col in range(3):\r\n cons = IBC[row, col]\r\n...
[ "0.59091425", "0.57651687", "0.5696586", "0.5588323", "0.5519537", "0.54216594", "0.54123414", "0.538351", "0.5372897", "0.5361422", "0.5356955", "0.5349356", "0.53209347", "0.53064805", "0.5252595", "0.5252", "0.5212284", "0.52063763", "0.51806784", "0.51663315", "0.5142872"...
0.5412369
6
Estimate standard Gibbs energies of formation
def train(S, G, b, w): assert type(S) == np.ndarray assert type(G) == np.ndarray assert type(b) == np.ndarray assert type(w) == np.ndarray m, n = S.shape assert G.shape[0] == m assert b.shape == (n,) assert w.shape == (n,) # Apply weighing ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bse_fe(self):\n p = self.model.exog.shape[1]\n return np.sqrt(np.diag(self.cov_params())[0:p])", "def gibbs_init(self, sigma2_s_param=None, sigma2_g_param=None):\n #Gibbs : Initialization step\n self.gibbs_init_step(self.nb_days, self.nb_particles, sigma2_s_param, sigma2_g_param)\...
[ "0.6456396", "0.6389554", "0.6329877", "0.62599355", "0.6148615", "0.60690296", "0.60667825", "0.60188264", "0.5966948", "0.59658873", "0.5957548", "0.595523", "0.5916523", "0.5912427", "0.58843017", "0.58783764", "0.58764386", "0.5825013", "0.5818016", "0.57995355", "0.57661...
0.0
-1
Test for correct instantiation given a set of players.
def test_init(players, clean): residents, hospitals = players game = HospitalResident(residents, hospitals, clean) for resident, game_resident in zip(residents, game.residents): assert resident.name == game_resident.name assert resident._pref_names == game_resident._pref_names for ho...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_players(self, players):\n\t\tself.players.clear()\n\t\tids = set([p.get_player_id() for p in players])\n\t\tfor p in self.state.get_players():\n\t\t\tif p not in ids:\n\t\t\t\traise PlayerException(p)\n\t\tfor p in players:\n\t\t\tself.players[p.get_player_id()] = p", "def test_valid_game_setup(self):\...
[ "0.68950206", "0.68166816", "0.6779744", "0.6726286", "0.6673796", "0.6636629", "0.65848154", "0.6571941", "0.6493531", "0.64693403", "0.6440882", "0.64096856", "0.6371468", "0.63653827", "0.6354527", "0.6353987", "0.6349084", "0.63259184", "0.6288197", "0.6285662", "0.626197...
0.7017496
0
Test for correct instantiation given a set of dictionaries.
def test_create_from_dictionaries(connections, clean): resident_prefs, hospital_prefs, capacities = connections game = HospitalResident.create_from_dictionaries( resident_prefs, hospital_prefs, capacities, clean ) for resident in game.residents: assert resident._pref_names == resident...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_from_dictionaries(\n student_names, project_names, supervisor_names, capacities, seed, clean\n):\n\n stud_prefs, sup_prefs, proj_sups, proj_caps, sup_caps = make_connections(\n student_names, project_names, supervisor_names, capacities, seed\n )\n\n game = StudentAllocation.creat...
[ "0.64251405", "0.61764544", "0.599205", "0.5967179", "0.5964097", "0.59410644", "0.57628375", "0.5736472", "0.57099533", "0.56787115", "0.56783843", "0.56684375", "0.56655174", "0.5664207", "0.5655415", "0.5654512", "0.5649937", "0.5634078", "0.5615306", "0.55827117", "0.5577...
0.6566189
0
Test that inputs to an instance of HR can be verified.
def test_check_inputs(game): with warnings.catch_warnings(): warnings.simplefilter("error") game.check_inputs() assert game.residents == game._all_residents assert game.hospitals == game._all_hospitals
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validParameters(self):\n # stupid/simple inputs\n h = Helix(\"thing\", \"Cu\", 0, 0, 1, 1, 1)\n self.assertEqual(h.getDimension(\"axialPitch\"), 1)\n\n # standard case / inputs ordered well\n h = Helix(\n \"what\",\n \"Cu\",\n Tinput=25.0...
[ "0.6665209", "0.6371906", "0.627438", "0.62270224", "0.6090711", "0.6064556", "0.6048889", "0.603993", "0.6019733", "0.5987716", "0.59819835", "0.5966513", "0.5957849", "0.5943022", "0.5917704", "0.5901547", "0.5900447", "0.5894026", "0.5893552", "0.58609515", "0.58448863", ...
0.62387663
3
Test each resident has only hospitals in its preference list. If not, check that a warning is caught and the resident's preferences are changed.
def test_check_inputs_resident_prefs_all_hospitals(game): resident = game.residents[0] resident.prefs = [Resident("foo")] with pytest.warns(PreferencesChangedWarning) as record: game._check_inputs_player_prefs_all_in_party("residents", "hospitals") assert len(record) == 1 message = str(r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_inputs_hospital_prefs_all_residents(game):\n\n hospital = game.hospitals[0]\n hospital.prefs = [Resident(\"foo\")]\n\n with pytest.warns(PreferencesChangedWarning) as record:\n game._check_inputs_player_prefs_all_in_party(\"hospitals\", \"residents\")\n\n assert len(record) == 1\n...
[ "0.76461375", "0.7579265", "0.75171703", "0.75103134", "0.7466917", "0.71831375", "0.70516497", "0.7038354", "0.64109606", "0.62843776", "0.6155221", "0.6151795", "0.608665", "0.6074421", "0.59615344", "0.5961042", "0.587259", "0.5870157", "0.5802495", "0.5735709", "0.5553829...
0.7821524
0
Test each hospital has only residents in its preference list. If not, check that a warning is caught and the hospitals's preferences are changed.
def test_check_inputs_hospital_prefs_all_residents(game): hospital = game.hospitals[0] hospital.prefs = [Resident("foo")] with pytest.warns(PreferencesChangedWarning) as record: game._check_inputs_player_prefs_all_in_party("hospitals", "residents") assert len(record) == 1 message = str(r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_hospital_prefs(self):\n\n errors = []\n for hospital in self.hospitals:\n residents_that_ranked = [\n res for res in self.residents if hospital in res.prefs\n ]\n if set(hospital.prefs) != set(residents_that_ranked):\n errors.a...
[ "0.7820969", "0.76278716", "0.75781184", "0.74795306", "0.73008245", "0.70282596", "0.69267523", "0.67586416", "0.6459601", "0.62566453", "0.6184107", "0.6075766", "0.6060278", "0.600085", "0.5896375", "0.5779385", "0.5753072", "0.5702106", "0.56878966", "0.5652447", "0.55289...
0.77083474
1
Test each hospital has ranked only residents that have ranked it. If not, check that a warning is caught and the hospital has forgotten any such residents.
def test_check_inputs_hospital_prefs_all_reciprocated(game): hospital = game.hospitals[0] resident = hospital.prefs[0] resident._forget(hospital) with pytest.warns(PreferencesChangedWarning) as record: game._check_inputs_player_prefs_all_reciprocated("hospitals") assert len(record) == 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_hospital_prefs(self):\n\n errors = []\n for hospital in self.hospitals:\n residents_that_ranked = [\n res for res in self.residents if hospital in res.prefs\n ]\n if set(hospital.prefs) != set(residents_that_ranked):\n errors.a...
[ "0.65927255", "0.62228805", "0.6033156", "0.5816217", "0.57702166", "0.5740605", "0.569085", "0.56001204", "0.552595", "0.5460149", "0.54297745", "0.53983676", "0.5360775", "0.5351841", "0.5335599", "0.5331168", "0.528455", "0.5271201", "0.52700424", "0.52670234", "0.5262435"...
0.5287138
16
Test each hospital has ranked all residents that have ranked it. If not, check that a warning is caught and any such resident has forgotten the hospital.
def test_check_inputs_hospital_reciprocated_all_prefs(game): hospital = game.hospitals[0] resident = hospital.prefs[0] hospital._forget(resident) with pytest.warns(PreferencesChangedWarning) as record: game._check_inputs_player_reciprocated_all_prefs( "hospitals", "residents" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_hospital_prefs(self):\n\n errors = []\n for hospital in self.hospitals:\n residents_that_ranked = [\n res for res in self.residents if hospital in res.prefs\n ]\n if set(hospital.prefs) != set(residents_that_ranked):\n errors.a...
[ "0.6707456", "0.6244367", "0.6030781", "0.5817202", "0.57967025", "0.56785023", "0.5596258", "0.554864", "0.5504701", "0.5493291", "0.54924923", "0.5488279", "0.5485713", "0.54585725", "0.5428704", "0.5420342", "0.5397366", "0.5381196", "0.53527856", "0.53451216", "0.53155655...
0.58555126
3
Test that each resident has a nonempty preference list. If not, check that a warning is caught and the resident has been removed from the game.
def test_check_inputs_resident_prefs_all_nonempty(game): resident = game.residents[0] resident.prefs = [] with pytest.warns(PlayerExcludedWarning) as record: game._check_inputs_player_prefs_nonempty("residents", "hospitals") assert len(record) == 1 assert resident.name in str(record[0].me...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_inputs_hospital_prefs_all_reciprocated(game):\n\n hospital = game.hospitals[0]\n resident = hospital.prefs[0]\n resident._forget(hospital)\n\n with pytest.warns(PreferencesChangedWarning) as record:\n game._check_inputs_player_prefs_all_reciprocated(\"hospitals\")\n\n assert le...
[ "0.7198795", "0.71749365", "0.71210027", "0.6954522", "0.6899493", "0.6747819", "0.6641792", "0.6345878", "0.61837107", "0.6050496", "0.5979725", "0.59595793", "0.5754744", "0.57290685", "0.5725816", "0.56024337", "0.5517876", "0.5488233", "0.54230016", "0.5410084", "0.539465...
0.7836128
0
Test that each hospital has a nonempty preference list. If not, check that a warning is caught and the player has been removed from the game.
def test_check_inputs_hospital_prefs_all_nonempty(game): hospital = game.hospitals[0] hospital.prefs = [] with pytest.warns(PlayerExcludedWarning) as record: game._check_inputs_player_prefs_nonempty("hospitals", "residents") assert len(record) == 1 assert hospital.name in str(record[0].me...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_inputs_hospital_prefs_all_reciprocated(game):\n\n hospital = game.hospitals[0]\n resident = hospital.prefs[0]\n resident._forget(hospital)\n\n with pytest.warns(PreferencesChangedWarning) as record:\n game._check_inputs_player_prefs_all_reciprocated(\"hospitals\")\n\n assert le...
[ "0.74706024", "0.7364109", "0.7355341", "0.7349609", "0.7254875", "0.6616572", "0.62527543", "0.6152463", "0.61230946", "0.60876256", "0.6085861", "0.6065636", "0.5856437", "0.58475614", "0.58438146", "0.58048016", "0.5630108", "0.56236094", "0.5622575", "0.5621679", "0.56021...
0.81164616
0
Test each hospital has a positive integer capacity. If not, raise an Exception detailing the hospital.
def test_check_inputs_hospital_capacity(game): hospital = game.hospitals[0] capacity = hospital.capacity hospital.capacity = 0 assert hospital._original_capacity == capacity with pytest.warns(PlayerExcludedWarning) as record: game._check_inputs_player_capacity("hospitals", "residents") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_hospital_capacity(self):\n\n errors = []\n for hospital in self.hospitals:\n if len(hospital.matching) > hospital.capacity:\n errors.append(\n ValueError(\n f\"{hospital} is matched to {hospital.matching} which \"\n ...
[ "0.7667984", "0.6397596", "0.62737614", "0.6177663", "0.60829747", "0.6006602", "0.59802", "0.5944431", "0.5858093", "0.58271384", "0.58146626", "0.5800991", "0.57918227", "0.5761161", "0.5714757", "0.5673754", "0.56648004", "0.5643236", "0.56302327", "0.56134015", "0.5581795...
0.73591745
1
Test for the correct solving of games.
def test_solve(game, optimal): matching = game.solve(optimal) assert isinstance(matching, MultipleMatching) hospitals = sorted(game.hospitals, key=lambda h: h.name) matching_keys = sorted(matching.keys(), key=lambda k: k.name) for game_hospital, hospital in zip(matching_keys, hospitals): a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_validity(game):\n\n game.solve()\n assert game.check_validity()", "def test_check_solved():\n game = Game()\n game.word = 'word'\n game.pattern = 'word'\n game.check_solved()\n assert game.solved is True", "def test_is_solved_when_puzzle_is_solved(self):\n self.assert...
[ "0.7135749", "0.711226", "0.70119655", "0.6942161", "0.69317514", "0.68992364", "0.68689203", "0.68571925", "0.68241847", "0.6820517", "0.6752076", "0.6728036", "0.6698164", "0.6654949", "0.6626608", "0.6581106", "0.65573555", "0.65466815", "0.6539139", "0.6468664", "0.642725...
0.68758893
6
Test for a valid matching when the game is solved.
def test_check_validity(game): game.solve() assert game.check_validity()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_match(self):\n self.assertEqual(solution( \"\"\"p=<-6,0,0>, v=< 3,0,0>, a=< 0,0,0>\np=<-4,0,0>, v=< 2,0,0>, a=< 0,0,0>\np=<-2,0,0>, v=< 1,0,0>, a=< 0,0,0>\np=< 3,0,0>, v=<-1,0,0>, a=< 0,0,0>\"\"\"), 1)", "def test_check_validity(resident_names, hospital_names, capacities, seed):\n\n _, _, matc...
[ "0.6855574", "0.6748413", "0.67361814", "0.66506636", "0.65528977", "0.6500697", "0.64891684", "0.64536655", "0.6449834", "0.6446524", "0.64406365", "0.6418722", "0.6375467", "0.6332083", "0.6327593", "0.6303921", "0.6292576", "0.6269725", "0.62239105", "0.62134755", "0.62047...
0.5917138
45
Test that matched residents have a preference of their match.
def test_check_for_unacceptable_matches_residents(game): resident = game.residents[0] hospital = Hospital(name="foo", capacity=1) resident.matching = hospital issues = game._check_for_unacceptable_matches("residents") assert len(issues) == 1 issue = issues[0] assert issue.startswith(resid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_reviewer_matching(resident_names, hospital_names, capacities, seed):\n\n _, _, match = _make_match(resident_names, hospital_names, capacities, seed)\n\n match.solve()\n match.reviewers[0].matching.append(Player(name=\"foo\", pref_names=[]))\n\n with pytest.raises(Exception):\n match._ch...
[ "0.6435155", "0.6338223", "0.63054293", "0.6247562", "0.6155224", "0.5968124", "0.5949417", "0.59368134", "0.5935081", "0.59329754", "0.5906463", "0.58899987", "0.58429325", "0.58374435", "0.5827494", "0.5767351", "0.575049", "0.5748831", "0.57429886", "0.56962484", "0.569148...
0.53893685
56
Test that each hospital has a preference of all its matches.
def test_check_for_unacceptable_matches_hospitals(game): hospital = game.hospitals[0] resident = Resident(name="foo") hospital.matching.append(resident) issues = game._check_for_unacceptable_matches("hospitals") assert len(issues) == 1 issue = issues[0] assert issue.startswith(hospital.na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hospital_optimal(resident_names, hospital_names, capacities, seed):\n\n np.random.seed(seed)\n residents = _make_residents(resident_names, hospital_names)\n hospitals = _make_hospitals(residents, capacities)\n matching = hospital_resident(residents, hospitals, optimal=\"hospital\")\n\n asse...
[ "0.6493731", "0.62789917", "0.625827", "0.6236417", "0.6157629", "0.61469007", "0.60858804", "0.6017746", "0.601711", "0.5959501", "0.59545827", "0.58850694", "0.58698004", "0.5841389", "0.5817565", "0.576249", "0.5716353", "0.5706714", "0.56535304", "0.5595088", "0.5543368",...
0.5400718
34
Test that no hospitals can be oversubscribed.
def test_check_for_oversubscribed_hospitals(game): hospital = game.hospitals[0] hospital.matching = range(hospital.capacity + 1) issues = game._check_for_oversubscribed_players("hospitals") assert len(issues) == 1 issue = issues[0] assert issue.startswith(hospital.name) assert issue.endsw...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nonsubscriber(self) -> None:\n # Create a stream for which Hamlet is the only subscriber.\n stream_name = \"Saxony\"\n self.common_subscribe_to_streams(self.user_profile, [stream_name])\n other_user = self.example_user(\"othello\")\n\n # Fetch the subscriber list as a no...
[ "0.707774", "0.66021943", "0.6580524", "0.6333144", "0.63258743", "0.62714976", "0.62273604", "0.62074196", "0.6164765", "0.61497414", "0.61130273", "0.6111483", "0.60828555", "0.60759217", "0.607235", "0.6040785", "0.60398805", "0.60398805", "0.6023948", "0.6017094", "0.5979...
0.7428499
0