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
Finds all nonnested open reading frames in the given DNA sequence on both strands.
def find_all_ORFs_both_strands(dna): return find_all_ORFs(dna) + find_all_ORFs(get_reverse_complement(dna))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_all_ORFs_oneframe(dna):", "def find_all_ORFs(dna):\n first_frame = find_all_ORFs_oneframe(dna[0:])\n second_frame = find_all_ORFs_oneframe(dna[1:])\n third_frame = find_all_ORFs_oneframe(dna[2:])\n list_of_frames = first_frame + second_frame + third_frame\n return list_of_frames", "def ...
[ "0.63436097", "0.6218921", "0.6172527", "0.60850155", "0.60356677", "0.59685004", "0.5943129", "0.5929876", "0.59213984", "0.592066", "0.59185624", "0.5876451", "0.5841582", "0.58351207", "0.5815624", "0.5804441", "0.5793256", "0.5780236", "0.5777369", "0.5773576", "0.5764555...
0.5699599
25
Unit tests for the find_all_ORFs_both_strands function
def find_all_ORFs_both_strands_unit_tests(): data_list = [ ["ATGCGAATGTAGCATCAAA", ["ATGCGAATG", "ATGCTACATTCGCAT"]], ["ATG", ["ATG"]], ["CAT", ["ATG"]], ["CATCAT", ["ATGATG"]], ["CATGGGCAT", ["ATGGGCAT", "ATGCCCATG"]], ["CATGCAGTGCACGGATGGCAT", ["ATGCAGTGCACGGATGGCAT...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_all_ORFs_both_strands_unit_tests():\n\n # YOUR IMPLEMENTATION HERE", "def find_all_ORFs_both_strands_unit_tests():\n print ''\n print 'Begin Unit test Find_all_ORFs both tests'\n input_a='ATGCGAGGGTAGATGGATTAG'\n expected_output='[ATGCGAGGG, ATGGAT]'\n actual_output=find_all_ORFs_both_...
[ "0.8720261", "0.8006601", "0.78446746", "0.7341566", "0.7335677", "0.71598625", "0.6980529", "0.695957", "0.6887582", "0.68275267", "0.68138146", "0.68044704", "0.6797018", "0.6769603", "0.67119783", "0.6693318", "0.6661346", "0.6647071", "0.6629509", "0.6596347", "0.65733176...
0.77680993
3
Finds the longest ORF on both strands of the specified DNA and returns it as a string
def longest_ORF(dna): l = find_all_ORFs_both_strands(dna) max_len = 0 r = "" # [???] what if there are ORFs with same length? # this function just get the first one. if len(l) == 0: return "" for o in l: if len(o) > max_len: r = o max_len = len(o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_ORF(dna):\n l = find_all_ORFs_both_strands(dna)\n longest=''\n if len(l)>=1:\n\t longest =max(l,key=len)\n return longest", "def longest_ORF(dna):\n both_strings=find_all_ORFs_both_strands(dna)\n L=max(both_strings,key=len)\n Q=len(L)\n return Q\n\n #save out put of ...
[ "0.87619084", "0.8655862", "0.86459744", "0.86390924", "0.86111736", "0.8554702", "0.8422834", "0.8375487", "0.83478934", "0.80594677", "0.8031292", "0.7990923", "0.7948157", "0.7885518", "0.76717263", "0.76625794", "0.7617656", "0.75137126", "0.75038695", "0.7478359", "0.742...
0.8745673
1
Unit tests for the longest_ORF function
def longest_ORF_unit_tests(): data_list = [ ["ATGCGAATGTAGCATCAAA", "ATGCTACATTCGCAT"], ["ATG", "ATG"], ["CAT", "ATG"], ["CATCAT", "ATGATG"], ["CATGGGCAT", "ATGCCCATG"], ["CATGCAGTGCACGGATGGCAT", "ATGCCATCCGTGCACTGCATG"], # CATGCAGTGCACGGATGGCAT # CAT GCA GTG CAC GGA ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_ORF_unit_tests():\n\n # YOUR IMPLEMENTATION HERE", "def longest_ORF_unit_tests():\n\n # YOUR IMPLEMENTATION HERE", "def longest_ORF_unit_tests():\n\n input_a=\"ATGCGAATGTAGCATCAAA\"\n expected_output=''\n actual_output=longest_ORF(input_a)\n print 'Expected Output is ' + expected_...
[ "0.87596375", "0.87596375", "0.87375337", "0.81525123", "0.80336714", "0.7930263", "0.78946465", "0.7806731", "0.774229", "0.77294636", "0.76995844", "0.7675174", "0.76290596", "0.76229846", "0.7548526", "0.74611413", "0.74381006", "0.74002784", "0.7334834", "0.73214704", "0....
0.85157883
3
Computes the maximum length of the longest ORF over num_trials shuffles of the specfied DNA sequence
def longest_ORF_noncoding(dna, num_trials): org = list(dna) max_len = 0 r = "" for i in range(num_trials): l = org shuffle(l) orf = longest_ORF(collapse(l)) if len(orf) > max_len: r = orf max_len = len(orf) return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_ORF_noncoding(dna, num_trials):\n i = 0\n longest_each_trial = []\n while i < num_trials:\n shuffled_dna = shuffle_string(dna)\n longest_each_trial.append(longest_ORF(shuffled_dna))\n i += 1\n\n longest_longest = max(longest_each_trial, key=len)\n return len(longest_...
[ "0.87796474", "0.87454444", "0.85417074", "0.8508988", "0.8500134", "0.84909016", "0.8478915", "0.8408802", "0.8328015", "0.8135475", "0.806552", "0.80442095", "0.74661", "0.7383516", "0.7355161", "0.7231103", "0.7160716", "0.7150049", "0.7064139", "0.70563704", "0.7049209", ...
0.8279816
9
Returns the amino acid sequences coded by all genes that have an ORF larger than the specified threshold.
def gene_finder(dna, threshold): l = find_all_ORFs_both_strands(dna) r = [] if len(l) > 0: for item in l: if len(item) > threshold: r.append(item) for i in range(len(r)): r[i] = coding_strand_to_AA(r[i]) return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gene_finder(dna, threshold):\n orfs = find_all_ORFs_both_strands(dna)\n orfs = [i for i in orfs if len(i)>threshold]\n orfs = [coding_strand_to_AA(i) for i in orfs]\n return orfs", "def gene_finder(dna):\n orfs = find_all_ORFs_both_strands(dna)\n print(orfs)\n threshold = longest_ORF_non...
[ "0.74298954", "0.71481067", "0.6994018", "0.68657947", "0.6788955", "0.67642456", "0.59709907", "0.58188194", "0.5695765", "0.557573", "0.55652696", "0.55194056", "0.5454421", "0.5452923", "0.54236233", "0.5409136", "0.53492814", "0.5158032", "0.5150435", "0.51174647", "0.506...
0.71809494
1
This is the helper function & rob a noncircular list of houses as House Robber I
def robSingle_2(self, nums, start, end): # print((start, end)) # print(nums[start: end + 1]) curMax = 0 preMax = 0 for num in nums[start:end + 1]: preMax, curMax = curMax, max(curMax, preMax + num) # print(curMax) # print("#############################...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_own_house(self, house): # Filling a list of houses are owned by Person\n self.own_home.append(house)", "def link_houses(self):\n # order the batteries for each house\n for house in list(self.houses.values()):\n dist = house.dist\n ord_dist = sorted(dist.items(...
[ "0.5806222", "0.5710233", "0.570435", "0.5521284", "0.551165", "0.550744", "0.5492642", "0.5478569", "0.5465875", "0.54462147", "0.54407626", "0.54252803", "0.54103124", "0.53790945", "0.53709656", "0.5357785", "0.53563446", "0.5340862", "0.53357506", "0.5317696", "0.53055185...
0.0
-1
This is the helper function & rob a noncircular list of houses as House Robber I
def robSingle(self, nums, start, end): # print((start, end)) # print(nums[start: end]) curMax = 0 preMax = 0 for num in nums[start:end]: preMax, curMax = curMax, max(curMax, preMax + num) # print(curMax) # print("####################################") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_own_house(self, house): # Filling a list of houses are owned by Person\n self.own_home.append(house)", "def link_houses(self):\n # order the batteries for each house\n for house in list(self.houses.values()):\n dist = house.dist\n ord_dist = sorted(dist.items(...
[ "0.58063686", "0.5711454", "0.57048863", "0.55215704", "0.5511004", "0.55080914", "0.5494405", "0.5479343", "0.5466541", "0.5447755", "0.54425746", "0.54249513", "0.5409817", "0.5380757", "0.537144", "0.53576016", "0.53571963", "0.53413516", "0.5336846", "0.53189075", "0.5307...
0.0
-1
r""" Initialize a collision with two wavefunctions, presumably a nucleus and a proton. One must implement the wilson line, though the order of the arguments does not matter. In the case that both wavefunctions implement the wilson line, the first (wavefunction1) will be used as such. In the case that neither implement ...
def __init__(self, wavefunction1: Wavefunction, wavefunction2: Wavefunction): # Make sure that at least one has a wilson line wilsonLineExists1 = callable(getattr(wavefunction1, "wilsonLine", None)) wilsonLineExists2 = callable(getattr(wavefunction2, "wilsonLine", None)) if not wilsonL...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_library_charges_to_two_waters(self):\n ff = ForceField(\n get_data_file_path(\"test_forcefields/test_forcefield.offxml\"),\n get_data_file_path(\"test_forcefields/tip3p.offxml\"),\n )\n mol = Molecule.from_file(\n get_data_file_path(os.path.join(\"syst...
[ "0.5363549", "0.53437185", "0.5282484", "0.4975989", "0.49336395", "0.49139965", "0.4913422", "0.4866941", "0.485196", "0.4840935", "0.4831913", "0.48300686", "0.48231012", "0.48094025", "0.47987574", "0.47694734", "0.47500825", "0.47249275", "0.47237548", "0.4697747", "0.467...
0.781818
0
r""" Calculate the field omega at each point on the lattice. If the field already exists, it is simply returned and no calculation is done.
def omega(self, forceCalculate=False, verbose=0): if self._omegaExists and not forceCalculate: return self._omega self.incidentWavefunction.gaugeField(verbose=verbose) self.targetWavefunction.adjointWilsonLine(verbose=verbose) if verbose > 0: print(f'Calculatin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculateOmegaOpt(N, gluonDOF, delta, incidentGaugeField, targetAdjointWilsonLine):\n\n # 2,2 is for the 2 dimensions, x and y\n omega = np.zeros((N, N, 2, 2, gluonDOF), dtype='complex') # 2 is for two dimensions, x and y\n\n derivs = [_x_deriv, _y_deriv]\n\n for i in range(N):\n for j in r...
[ "0.61966604", "0.61015", "0.6020752", "0.5965969", "0.5809604", "0.5785809", "0.5762362", "0.56903183", "0.5675721", "0.566216", "0.562489", "0.5606232", "0.5581973", "0.5539443", "0.5505453", "0.5466363", "0.5453032", "0.5429813", "0.5425745", "0.5405547", "0.53965545", "0...
0.6339087
0
r""" Compute the fourier transform of the field omega on the lattice. If the fft of the field already exists, it is simply returned and no calculation is done.
def omegaFFT(self, forceCalculate=False, verbose=0): if self._omegaFFTExists and not forceCalculate: return self._omegaFFT # Make sure omega exists self.omega(verbose=verbose) if verbose > 0: print(f'Calculating {type(self).__name__} omega fourier transform' + '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fourier_transform(hamiltonian, grid, spinless):\n return _fourier_transform_helper(hamiltonian=hamiltonian,\n grid=grid,\n spinless=spinless,\n phase_factor=+1,\n v...
[ "0.63342255", "0.63339674", "0.6287672", "0.62734646", "0.62432265", "0.61635166", "0.61274135", "0.60326177", "0.60305816", "0.5935891", "0.59015477", "0.5884128", "0.58474153", "0.58341295", "0.58334965", "0.57607025", "0.57455075", "0.5744383", "0.57404006", "0.5733641", "...
0.64539677
0
r""" Compute the range of momenta at which particles will be created based on the dimensions of the lattice.
def momentaBins(self, forceCalculate=False, verbose=0): if self._momentaBinsExists and not forceCalculate: return self._momentaBins if verbose > 0: print(f'Calculating {type(self).__name__} momentum bins' + '.'*10, end='') self._momentaBins = [i*self.binSize for i in r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bounds(self):\n return ([self.t_min] * self.dim,[self.t_max] * self.dim)", "def _calc_range(self) -> np.ndarray:\n if self._is_ct25k():\n range_resolution = 30\n n_gates = 256\n else:\n n_gates = int(self.metadata[\"number_of_gates\"])\n range_...
[ "0.62849957", "0.6180772", "0.6029936", "0.57914567", "0.5738106", "0.5718626", "0.57101995", "0.5694598", "0.5662082", "0.5660439", "0.56356585", "0.5627411", "0.56166595", "0.56106514", "0.5584325", "0.55651206", "0.55525315", "0.55234414", "0.55138046", "0.5500878", "0.548...
0.0
-1
r""" Compute the derivative of particles produced (\( \frac{d^2 N}{d^2 k} \)) at each point on the lattice If the calculation has already been done, the result is simply returned and is not repeated.
def particlesProducedDeriv(self, forceCalculate=False, verbose=0): if self._particlesProducedDerivExists and not forceCalculate: return self._particlesProducedDeriv # Make sure these quantities exist self.omegaFFT(verbose=verbose) self.momentaMagnitudeSquared(verbose=verbose...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_derivative(self, model, params, n):\n params1 = np.array(params)\n params2 = np.array(params)\n\n params1[n] += self.eps\n params2[n] -= self.eps\n\n res1 = model.run(params1)\n res2 = model.run(params2)\n\n d = (res1 - res2) / (2 * self.eps)\n\n return d.ravel()", "def nth_deriva...
[ "0.64778066", "0.64777637", "0.6454873", "0.6416733", "0.6385484", "0.6365195", "0.63649744", "0.6353335", "0.6346613", "0.63342845", "0.63319826", "0.6290726", "0.62458384", "0.61796194", "0.6177636", "0.6173804", "0.612152", "0.6115887", "0.6109102", "0.61023456", "0.608113...
0.5847744
40
r""" Compute the number of particles produced \(N(|k|)\) as a function of momentum. Note that this is technically the zeroth fourier harmonic, so this actually just calls the cgc.Collision.fourierHarmonic() function. The particles are binned according to cgc.Collision.momentaBins(). Most likely will be plotted against ...
def particlesProduced(self, forceCalculate=False, verbose=0): # This one is strictly real, so we should make sure that is updated self._fourierHarmonics[0] = np.real(self.fourierHarmonic(0, forceCalculate, verbose)) return self._fourierHarmonics[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cdf(self, k):\n\n if k < 0 or k > self.n:\n return 0\n\n k = int(k)\n ans = 0\n for i in range(0, k + 1):\n ans += self.pmf(i)\n return ans", "def frequency(self, mass: float) -> float:\n return self.omega(mass) / u.twopi", "def get_k(self, mo...
[ "0.6223754", "0.58447295", "0.5835107", "0.58238643", "0.5793296", "0.57711184", "0.57160884", "0.57103884", "0.57061857", "0.57055527", "0.56863546", "0.5672576", "0.5646059", "0.56414986", "0.5624835", "0.5577681", "0.5571035", "0.5556223", "0.55299175", "0.5514452", "0.549...
0.0
-1
Calculate the field omega at each point on the lattice. If the field already exists, it is simply returned and no calculation is done. Returns
def _calculateOmegaOpt(N, gluonDOF, delta, incidentGaugeField, targetAdjointWilsonLine): # 2,2 is for the 2 dimensions, x and y omega = np.zeros((N, N, 2, 2, gluonDOF), dtype='complex') # 2 is for two dimensions, x and y derivs = [_x_deriv, _y_deriv] for i in range(N): for j in range(N): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def omega(self, forceCalculate=False, verbose=0):\n\n if self._omegaExists and not forceCalculate:\n return self._omega\n\n self.incidentWavefunction.gaugeField(verbose=verbose)\n self.targetWavefunction.adjointWilsonLine(verbose=verbose)\n\n if verbose > 0:\n prin...
[ "0.65611875", "0.6319371", "0.5993952", "0.59877014", "0.5888921", "0.58748895", "0.58195966", "0.5772964", "0.5772052", "0.56714135", "0.56430805", "0.5615205", "0.5599253", "0.5576051", "0.5548847", "0.55219823", "0.55002594", "0.5486295", "0.5471869", "0.54689527", "0.5463...
0.62411505
2
Optimized (via numba) function to calculated the position (momentum) in Fourier space of each point
def _calculateMomentaOpt(N, delta): momentaComponents = np.zeros((N, N, 2)) theta = np.zeros((N, N)) for i in range(N): for j in range(N): # Note that these components are of the form: # k_x = 2/a sin(k_x' a / 2) # Though the argument of the sin is simplified a b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_to_Fourier(self):\n #TODO Try to do it with FFT \n U = self.alphas @ self.positions\n \n return U", "def PointMilieu(x,f):\n\tNx = f.shape[0]\n\tS=0.0\n\tfor i in range(0,Nx-1):\n\t\tS=S+f[i]*(x[i+1]-x[i]) \n\treturn S", "def f(x):\n return np.tan(x) - np.sin(x)...
[ "0.6262863", "0.58647877", "0.5800414", "0.57622546", "0.5669494", "0.566121", "0.56350255", "0.56235635", "0.56235635", "0.5615969", "0.5564165", "0.55272233", "0.55245006", "0.5508289", "0.54817075", "0.5475856", "0.5470814", "0.54582995", "0.54064107", "0.540339", "0.53952...
0.0
-1
Optimized (via numba) function to calculate dN/d^2k
def _calculateParticlesProducedDerivOpt(N, gluonDOF, momentaMagSquared, omegaFFT): # Where we will calculate dN/d^2k particleProduction = np.zeros((N,N)) # # 2D Levi-Cevita symbol LCS = np.array([[0,1],[-1,0]]) # # 2D Delta function KDF = np.array([[1,0],[0,1]]) # Note that unlike in the...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fn(k, i, j):\n if not (0 <= i < N and 0 <= j < N): return 0\n if k == 0: return 1 \n return 1/8*sum(fn(k-1, i+ii, j+jj) for ii, jj in ((-2, -1), (-2, 1), (-1, -2), (-1, 2), (1, -2), (1, 2), (2, -1), (2, 1)))", "def get_pij_numba(d, scale, i):\n \n d_scaled = -d/scale\n ...
[ "0.6455723", "0.6416024", "0.6281938", "0.622644", "0.60808295", "0.6065724", "0.6049456", "0.5998111", "0.5918952", "0.5913631", "0.5879115", "0.58402175", "0.58285564", "0.5814981", "0.5798404", "0.57793164", "0.57776886", "0.575968", "0.57358", "0.5716769", "0.5710634", ...
0.0
-1
Evaluate the systematic uncertainty of the fit model. Each signal shape in fitting.lambdac_mass.shapes_sig is fitted with each background shape in fitting.lambdac_mass.shapes_bkg. The systematic uncertainty is taken as the largest fractional deviation from the nominal yield, which is the yield obtained from the nominal...
def fit_systematics(mode, polarity, year): n = ntuples.get_ntuple(mode, polarity, year) sel_path = "{0}/selected-{1}.root".format(config.output_dir, n) sel_n = n.__class__("DecayTree", n.polarity, n.year) sel_n.add(sel_path) w_name = "{0}-{1}-{2}-workspace" # Nominal shapes # Nom nom nom ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_power_law_MMEN_per_system_observed_and_physical(sssp_per_sys, sssp, n_mult_min=2, max_core_mass=10., prescription='CL2013', n=10., a0=1., p0=1., p1=-1.5, scale_up=False):\n fit_per_sys_dict = {'n_pl_true':[], 'n_pl_obs':[], 'Mp_tot_true':[], 'Mp_tot_obs':[], 'sigma0_true':[], 'sigma0_obs':[], 'scale_fac...
[ "0.54107773", "0.53992355", "0.5390711", "0.5299261", "0.5136206", "0.5134165", "0.5129948", "0.5105046", "0.5085043", "0.5083824", "0.50725913", "0.5069007", "0.504954", "0.50494796", "0.50400126", "0.50268537", "0.49904805", "0.49638087", "0.49399418", "0.49384803", "0.4933...
0.54793423
0
We won't initialize values in the board in here. This allows us to set the board by various methods later.
def __init__(self): self.rows = None self.columns = None self.squares = None # max is useful as a way to track range for iteration, and also as a way # to track the maximum number in any spot. self.max = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initBoard(self):\n pass", "def set_board(board):", "def initialize_board(self):\n self.board = np.zeros(shape=(BOARD_SIZE, BOARD_SIZE), dtype=np.int) # another way of defining board: [[for x in range(cm.BOARD_SIZE)] for x in range(cm.BOARD_SIZE)]\n center = int(BOARD_SIZE / 2)\n ...
[ "0.84042627", "0.81255907", "0.7827382", "0.77757037", "0.76603794", "0.7593099", "0.7526167", "0.7517234", "0.7514194", "0.7464708", "0.74549705", "0.74544424", "0.7384845", "0.73820364", "0.73545396", "0.7345615", "0.732285", "0.7308128", "0.7305453", "0.73042303", "0.72986...
0.0
-1
Calculates the Euclidean distance of multivariate time series of the same length.
def ED(X,Y):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(x1: np.ndarray, x2: np.ndarray) -> float:\n return np.sqrt(np.square(x1 - x2).sum())", "def euclidean_distance(s1,s2): \n tmpsum = 0\n \n for index,value in enumerate(s1):\n tmpsum += (s1[index]-s2[index])**2\n \n return math.sqrt(tmpsum)", "def dist_euclidean...
[ "0.6681572", "0.65386665", "0.6445761", "0.6442041", "0.63351816", "0.6331959", "0.6330316", "0.6316178", "0.6282366", "0.62821025", "0.62731445", "0.62528145", "0.62418395", "0.62296194", "0.62112737", "0.61803675", "0.6160056", "0.6159171", "0.6150553", "0.61495095", "0.614...
0.0
-1
Get current date and time with the format= .
def getTime(form=Constants.record_name_format): # Get the date and time from the system now = datetime.now() # Format and return return now.strftime(form)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_now():\r\n now = dt.datetime.now()\r\n now_str = now.strftime(\"%d/%m %H:%M\")\r\n return now_str", "def get_current_datetime_string ( ) :\n return get_current_datetime( ).strftime( \"%Y%m%d-%H%M%S\" )", "def current_time():\n now = datetime.datetime.now()\n time = now.strftime(\"%Y-%m...
[ "0.8194152", "0.7987566", "0.7932862", "0.79326594", "0.79113275", "0.7893641", "0.78934723", "0.78358227", "0.7831609", "0.7829139", "0.7818449", "0.78158355", "0.7813814", "0.78097653", "0.775849", "0.77103084", "0.76516235", "0.764516", "0.76419735", "0.7633488", "0.762019...
0.7465342
35
Check if is number.
def isNumber(number): try: # Try to cast the string int(number) # The cast was successful return True # The cast was unsuccessful, the string is not a number except ValueError as err: # Write the exception in logging logging.exception(str(err)) return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_number(self) -> bool:\n return False", "def is_number(value):\n\n return isinstance(value, (int, long, float))", "def ISNUMBER(value):\n return isinstance(value, numbers.Number)", "def is_number(self,val):\n try:\n float(val)\n return True\n except ValueE...
[ "0.83748645", "0.8357549", "0.83331686", "0.8269055", "0.8266388", "0.8216462", "0.8212759", "0.81497115", "0.8141254", "0.8037783", "0.80337286", "0.80125856", "0.7990518", "0.7987615", "0.79799354", "0.7952793", "0.7945219", "0.7936261", "0.79353315", "0.7902707", "0.789953...
0.7382923
62
Check record name. The record name must be the same as getTime() function return.
def isRecordNameValid(record): # Split the string with the record separator ':' splitted = record.split(':') # There must be 5 values - year:month:day:hour:minute if len(splitted) != 5: # Not valid - more or less than 5 values return False # There are 5 values - check each one if is ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_record_name(self):\n zone = Zone('test.example.com')\n record = Record(zone, 'test-record', {'type': 'A', 'ttl': 300})\n self.assertEqual(record.name, 'test-record')", "def check_base_filename(self, record):\n time_tuple = time.localtime()\n\n if self.file_name_format:...
[ "0.71127087", "0.6416714", "0.62757695", "0.6255716", "0.5947194", "0.5886621", "0.58701205", "0.58524096", "0.5753524", "0.56767505", "0.56354964", "0.5626901", "0.5602901", "0.55897135", "0.55889857", "0.54834104", "0.547835", "0.54688334", "0.54676193", "0.54560345", "0.54...
0.64312017
1
Check if a record is older than value.
def olderThan(record, value=Constants.older_than): # Check first if the record is valid if isRecordNameValid(record): # Get the record values and split them - year:month:day:hour:minute splitted_record = record.split(':') # Get the current date and time from the system and split them ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def older(self, timestamp):\r\n return self._added < timestamp", "def match_Older(self, object, options) :\n\t\tif options.has_key(\"older\") :\n\t\t\tobjolder = self.toObject(self.__context, options[\"older\"])\n\t\t\tif objolder is not None :\n\t\t\t\tif object.bobobase_modification_time() >= objolder.b...
[ "0.71754", "0.6400666", "0.6392453", "0.6271246", "0.62259823", "0.6223402", "0.6223402", "0.62114763", "0.6195353", "0.61886394", "0.5976829", "0.5961276", "0.5923364", "0.59210014", "0.59175354", "0.5868831", "0.58493334", "0.5846879", "0.5807692", "0.5804501", "0.5777203",...
0.79310864
0
Take the dictionary from database and return it as two lists of and . The will be a list of lists. Each region in list will have a list of records in list.
def getDataBaseLists(data, db): # The list of regions - ex: "46 60 26 23" for region of coordinates 46.60 26.23 regions = [] # The list of lists of records - each region can have multiple records records = [] try: # Loop through all data in database dictionary for reg, rec in data: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def common_blocks_records(self):\n if self.records is None:\n raise ValueError(\"\")\n records = []\n for block_name, data in self.common_blocks.items():\n cst, (start, end, strand) = data[\"locations\"][0]\n record = self.records[cst][start:end]\n i...
[ "0.5845994", "0.5654632", "0.55073863", "0.5502603", "0.5475942", "0.54431844", "0.54248035", "0.5393792", "0.53916633", "0.52849215", "0.52630603", "0.52412134", "0.5224337", "0.5203017", "0.51666725", "0.5165008", "0.5107521", "0.50934386", "0.506704", "0.5066681", "0.50605...
0.70710075
0
Get the average weather condition from all records of a region. A region is a string (its name) representing the coordinates of it.
def calculateWeatherForEachRegion(regions, records): if not bool(regions) or not bool(records): return None, None try: weather_list = [] danger_list = [] for index in range(len(regions)): weather, mean_weather_code = Machine_learning.getWeatherForRegion(records[index]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def region_stats(ds, mask, region_name):\n agg = ds.where(mask == arctic_mask_region[region_name]).mean(dim=['x','y'])\n if 'latitude' in agg:\n agg = agg.drop('latitude')\n if 'longitude' in agg:\n agg = agg.drop('longitude')\n return agg", "def avg_based_on_forecast(city):\n wparam...
[ "0.6348331", "0.6154541", "0.6068361", "0.59449464", "0.5889889", "0.5856748", "0.5781751", "0.5741478", "0.56861424", "0.5669117", "0.56116873", "0.55883586", "0.55631655", "0.5545508", "0.53814787", "0.5365397", "0.5356737", "0.5309372", "0.5306273", "0.5302752", "0.5234683...
0.618818
1
Get the index of the weather using the weather code. Weather code can be from 100 to 499.
def getWeatherIndex(code, return_if_none=Constants.return_value_index_of_weather_not_found): # Start the index with 0 index = 0 for i in [100, 200, 300, 400]: for j in [0, 33, 66]: if inWeatherCodeRange(code, i + j, i + j + 33): return index index += 1 ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_index(weather_data: dict, date: datetime) -> int:\n weather_list = weather_data['list']\n for index, weather in enumerate(weather_list):\n if weather['dt_txt'] == date.strftime('%Y-%m-%d %H:%M:%S'):\n return index\n return 0", "def get_index(identify):\n\n ...
[ "0.66678154", "0.62248325", "0.61293477", "0.59989315", "0.5930833", "0.58119816", "0.57981074", "0.57821745", "0.5711183", "0.5681351", "0.5678698", "0.5635346", "0.56227213", "0.5618192", "0.561285", "0.5601398", "0.55593145", "0.5548384", "0.55290467", "0.55117786", "0.550...
0.8678492
0
Check if the code is in range.
def inWeatherCodeRange(code, _min, _max): # Example: code = 120 # _min = 0 _max = 133 # return 0 <= 120 <= 133 => true return _min <= code <= _max
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def icd9_in_code_range(val, code_ranges):\n return any(val <= code_range[1] and val >= code_range[0] for code_range in code_ranges)", "def isRangeValid(self) -> bool:\n ...", "def IsInRange(self, id, start, isStartInclusive, end, isEndInclusive):\r\n if isStartInclusive == False:\r\n ...
[ "0.7484409", "0.7367147", "0.7140791", "0.70511144", "0.70411056", "0.6920733", "0.68506825", "0.6842587", "0.6837561", "0.68176687", "0.6816321", "0.68019915", "0.676852", "0.6762765", "0.6742773", "0.6739405", "0.67343843", "0.66643924", "0.6628126", "0.6624612", "0.6607039...
0.7409259
1
Called every to check the database data. Remove invalid data. Write the calculated data. Update new data.
def checkDataBaseData(db, records, regions, data): # Loop through all list of list of records - every region has a list of records # The <records> list has list for each region (list of lists) for i in range(len(regions)): # Get the current region object from loop region = regions.__getitem_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(self):\n\t\tif self.update_check() or self.force_update:\n\t\t\tself.district_check() #pull all local data and regions\n\t\t\tself.fix() #fix data anomalies - e.g add in Bucks.\n\t\t\tself.save_all() #store a copy of the data\n\t\t\tself.ingest() #add data to models\n\t\t\tself.update_totals() #calcula...
[ "0.69099915", "0.647808", "0.6443949", "0.63570875", "0.6231783", "0.6180875", "0.6078408", "0.60474265", "0.6018188", "0.60085803", "0.5980333", "0.59342647", "0.59322685", "0.5918742", "0.59032136", "0.58859277", "0.5876542", "0.58433986", "0.58387524", "0.58320487", "0.583...
0.55986655
44
Write the new records in the main dataframe (from Machine_learning file). The records with the same values that exists in dataframe will be ignored (no duplications).
def writeRecordsInDataframe(records): # The list is not defined -- something was wrong if records is None: return # Loop through the main list, containing the list of Record objects for region_recs in records: # Loop through all Record objects of each list for record in region_re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_model_output(self):\n warnings.warn(\"Please ensure that the column names of the new file accurately corresponds to the relevant column names in the exisitng file\")\n column_names_new = self.new_data.head()\n column_names_old = self.existing_data.head()\n for column_name in ...
[ "0.6713008", "0.6275531", "0.6157596", "0.5832331", "0.5825501", "0.58015543", "0.5790889", "0.57429373", "0.5720146", "0.56158197", "0.56148225", "0.56103545", "0.55689096", "0.55660117", "0.5495955", "0.5441212", "0.5425738", "0.5421349", "0.5405427", "0.54010093", "0.53962...
0.61618674
2
Get the seconds of the string.
def getSecondsFromStringDateTime(date_time): split_date_time = date_time.split(Constants.record_name_sep) if len(split_date_time) == 5: for value in split_date_time: if not isNumber(value): return Constants.return_value_invalid_datetime_value result = int(split_date_t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSeconds(self, s):\n duration = 0\n \n for i in s.split('-'):\n if 'h' in i: duration = duration + int(i.split('h')[0])*3600\n if 'm' in i: duration = duration + int(i.split('m')[0])*60\n if 's' in i: duration = duration + int(i.split('s')[0])\n ...
[ "0.7766101", "0.7115368", "0.71104825", "0.7041365", "0.70393634", "0.70393634", "0.6951356", "0.69008636", "0.6872411", "0.6872411", "0.68332404", "0.68117046", "0.66860545", "0.6683153", "0.6572782", "0.65385103", "0.65095", "0.65092576", "0.6505078", "0.6484745", "0.642686...
0.58662844
53
Returns the weather string (name) from the file using the index of the weather. The weather titles are wrote in a dictionary, where the keys are the index.
def getWeatherString(index): return Texts.weather_titles[index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_index(index_file):\n index_dict = {}\n with open(index_file) as f:\n for line in f:\n title, path = line.strip().split()\n index_dict[title] = path\n return index_dict", "def read_weatherstationnames(path_to_data):\n\n nr, name = np.loadtxt(os.path.join(path_to_d...
[ "0.58560216", "0.57427657", "0.5587316", "0.54862076", "0.5465274", "0.53827", "0.53461164", "0.53260946", "0.5280319", "0.5268441", "0.5262383", "0.5219673", "0.521099", "0.51767963", "0.51703185", "0.51631576", "0.5161624", "0.51347274", "0.5134441", "0.5131381", "0.5129603...
0.7401113
0
Convert a dictionary to a list.
def convertToList(data): try: # Try to create a list from dictionary result = list(data.items()) # Successfully created # Return the list return result except Exception as err: # Couldn't convert the dictionary to a list print(err) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dictToLst(dictionary):\n keys = []\n values = []\n for key, value in dictionary.iteritems():\n keys.append(key)\n values.append(value)\n return [keys, values]", "def dict_to_list(dict: Dict, name_key: str = \"name\", value_key: str = \"value\"):\n ...
[ "0.82195216", "0.80905014", "0.80083996", "0.7971248", "0.7794634", "0.7763368", "0.7755257", "0.7734761", "0.741443", "0.741443", "0.73810256", "0.73580605", "0.71780914", "0.7127262", "0.71178746", "0.7070168", "0.70463735", "0.7015465", "0.6966923", "0.6900855", "0.6895519...
0.7301802
12
Randomly crops image and then scales to target size.
def _decode_and_random_crop(image_buffer, bbox, image_size): with tf.name_scope('distorted_bounding_box_crop', values=[image_buffer, bbox]): sample_distorted_bounding_box = tf.image.sample_distorted_bounding_box( tf.image.extract_jpeg_shape(image_buffer), bounding_boxes=bbox, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def img_agu_crop(img_):\n\tscale_ = 5\n\txmin = max(0, random.randint(0, scale_))\n\tymin = max(0, random.randint(0, scale_))\n\txmax = min(img_.shape[1]-1, img_.shape[1]-random.randint(0, scale_))\n\tymax = min(img_.shape[0]-1, img_.shape[0]-random.randint(0, scale_))\n\treturn img_[ymin : ymax, xmin : xmax , : ]...
[ "0.69238734", "0.688668", "0.67406136", "0.6653446", "0.6611991", "0.65635043", "0.65129", "0.64813966", "0.6446414", "0.6439087", "0.6420242", "0.64065105", "0.6373644", "0.63549376", "0.6237832", "0.6220096", "0.61792403", "0.61725205", "0.6107943", "0.6069131", "0.6034094"...
0.5382218
87
Crops to center of image with padding then scales to target size.
def _decode_and_center_crop(image_buffer, image_size): shape = tf.image.extract_jpeg_shape(image_buffer) image_height = shape[0] image_width = shape[1] padded_center_crop_size = tf.cast( 0.875 * tf.cast(tf.minimum(image_height, image_width), tf.float32), tf.int32) offset_height = ((image_height ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def center_crop(image, source=(218, 178, 3), target=128):\n height, width, channel = source\n\n off_h = np.ceil((height - target) / 2).astype(int)\n off_w = np.ceil((width - target) / 2).astype(int)\n return image[off_h: off_h+target, off_w: off_w+target, :]", "def _crop_image_and_paste(self, image, ...
[ "0.7128099", "0.70488757", "0.68803775", "0.6781932", "0.6731713", "0.67305714", "0.6663504", "0.664844", "0.6613311", "0.6602656", "0.6566218", "0.65391105", "0.65155274", "0.64812684", "0.6468684", "0.6438739", "0.6353911", "0.632617", "0.6314719", "0.6305832", "0.63000154"...
0.58932555
50
Rescale image to [1, 1] range.
def _normalize(image): return tf.multiply(tf.subtract(image, 0.5), 2.0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rescale_image_01(image):\n # scale image to from [0, 255] to [0.0, 1.0]\n image = image.astype(np.float32)\n return image / 255", "def rescale(self, img):\n\n if self.scale != 1:\n return imutils.resize(img, width=int(img.shape[1] * self.scale))\n else:\n return i...
[ "0.78326875", "0.76999515", "0.7549549", "0.7467479", "0.74480367", "0.7409863", "0.7364775", "0.7286831", "0.7183715", "0.71511316", "0.70305556", "0.7026632", "0.6979429", "0.6891725", "0.6880963", "0.6845083", "0.6800742", "0.67787117", "0.6744161", "0.67401654", "0.669306...
0.0
-1
Does image decoding and preprocessing.
def image_preprocessing(image_buffer, bbox, image_size, is_training): if is_training: image = _decode_and_random_crop(image_buffer, bbox, image_size) image = _normalize(image) image = tf.image.random_flip_left_right(image) else: image = _decode_and_center_crop(image_buffer, image_size) image = _...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_image(self):\n pass", "def process(self, image):", "def compute_img(self):\r\n self.load_img()\r\n self.check_shape()\r\n self.convert_img()\r\n self.img_computed = True", "def process(image):\n pass", "def process_images(self):\n self.processed_cont...
[ "0.7315352", "0.7302317", "0.7068986", "0.6870666", "0.6806362", "0.6737336", "0.66996175", "0.6657503", "0.65969765", "0.65701276", "0.65510494", "0.65479803", "0.6521088", "0.65128094", "0.64939", "0.6452522", "0.64515615", "0.6416641", "0.6404622", "0.6380717", "0.63793856...
0.0
-1
Parse an ImageNet record from a serialized string Tensor.
def imagenet_parser(value, image_size, is_training): keys_to_features = { 'image/encoded': tf.FixedLenFeature((), tf.string, ''), 'image/format': tf.FixedLenFeature((), tf.string, 'jpeg'), 'image/class/label': tf.FixedLenFeature([], tf.int64, -1), 'image/class/tex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_record(raw_record, is_training):\n keys_to_features = {\n 'image/encoded':\n tf.FixedLenFeature((), tf.string, default_value=''),\n 'image/format':\n tf.FixedLenFeature((), tf.string, default_value='jpeg'),\n 'image/class/label':\n tf.FixedLenFeatu...
[ "0.7003186", "0.69466406", "0.6868156", "0.6796544", "0.67705315", "0.6690875", "0.6612416", "0.652146", "0.64584464", "0.64071184", "0.6387107", "0.6385398", "0.6299073", "0.6298604", "0.62885815", "0.6247955", "0.61994916", "0.6195895", "0.6139263", "0.6138774", "0.6130966"...
0.6313274
12
Statically set the batch_size dimension.
def set_shapes(images, labels): images.set_shape(images.get_shape().merge_with( tf.TensorShape([batch_size, None, None, None]))) labels.set_shape(labels.get_shape().merge_with( tf.TensorShape([batch_size]))) return images, labels
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_batch_size(self, batch_size):\n self.batch_size = batch_size\n self.n_batch = math.ceil(self.n_samples / batch_size)", "def set_batch_size(self, batch_size):\n final_sz = self.full_dataset_size % batch_size\n if not self.final_batch:\n self.dataset_size = self.full_dataset_size -...
[ "0.79235494", "0.7797408", "0.77408826", "0.7675693", "0.73949724", "0.7355096", "0.72564864", "0.69373244", "0.6932983", "0.6832364", "0.6790107", "0.67524546", "0.6734956", "0.67191464", "0.66851157", "0.66851157", "0.66851157", "0.66851157", "0.66447586", "0.66447586", "0....
0.0
-1
Returns the number of examples in the data set.
def num_examples_per_epoch(split): if split.lower().startswith('train'): return 1281167 elif split.lower().startswith('validation'): return 50000 else: raise ValueError('Invalid split: %s' % split)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNumExamples(self):\n return self.__numExamples", "def num_examples(self):\r\n raise NotImplementedError", "def getSampleCount(self):\r\n return len(self._data)", "def count_elements_in_dataset(dataset):\n return dataset.count()", "def _number_of_samples(self):\n return len...
[ "0.7674337", "0.7648816", "0.75274837", "0.7515767", "0.7486572", "0.7340652", "0.7263475", "0.72145987", "0.7210284", "0.71721756", "0.7159244", "0.71544725", "0.714173", "0.7136569", "0.7095468", "0.70904535", "0.70807683", "0.706733", "0.704017", "0.703757", "0.703757", ...
0.0
-1
Get box regression transformation deltas (dx, dy, dw, dh) that can be used to transform the `src_boxes` into the `target_boxes`. That is, the relation ``target_boxes == self.apply_deltas(deltas, src_boxes)`` is true (unless any delta is too large and is clamped).
def get_deltas(self, src_boxes, target_boxes): assert isinstance(src_boxes, torch.Tensor), type(src_boxes) assert isinstance(target_boxes, torch.Tensor), type(target_boxes) TO_REMOVE = 1 # TODO remove src_widths = src_boxes[:, 2] - src_boxes[:, 0] + TO_REMOVE src_heights ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_deltas(self, deltas, boxes):\r\n assert torch.isfinite(deltas).all().item(), \"Box regression deltas become infinite or NaN!\"\r\n boxes = boxes.to(deltas.dtype)\r\n\r\n TO_REMOVE = 1 # TODO remove\r\n widths = boxes[:, 2] - boxes[:, 0] + TO_REMOVE\r\n heights = boxes[...
[ "0.699108", "0.6511962", "0.645136", "0.6319423", "0.6214895", "0.6214895", "0.61235464", "0.60987717", "0.56899726", "0.55584025", "0.55373454", "0.54795", "0.54542905", "0.54477835", "0.5432317", "0.54260546", "0.537766", "0.5244466", "0.523219", "0.5218577", "0.51628095", ...
0.84701025
0
Apply transformation `deltas` (dx, dy, dw, dh) to `boxes`.
def apply_deltas(self, deltas, boxes): assert torch.isfinite(deltas).all().item(), "Box regression deltas become infinite or NaN!" boxes = boxes.to(deltas.dtype) TO_REMOVE = 1 # TODO remove widths = boxes[:, 2] - boxes[:, 0] + TO_REMOVE heights = boxes[:, 3] - boxes[:, 1]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_box_deltas(boxes, deltas):\n boxes = boxes.astype(np.float32)\n # Convert to y, x, h, w\n height = boxes[:, 2] - boxes[:, 0]\n width = boxes[:, 3] - boxes[:, 1]\n center_y = boxes[:, 0] + 0.5 * height\n center_x = boxes[:, 1] + 0.5 * width\n # Apply deltas\n center_y += deltas[:, ...
[ "0.7690878", "0.7311821", "0.7311821", "0.6538352", "0.6171323", "0.59190184", "0.5770745", "0.5738584", "0.57102823", "0.5680742", "0.56772006", "0.56652987", "0.56527686", "0.562585", "0.5600068", "0.5577344", "0.5559888", "0.5343118", "0.52774864", "0.5238505", "0.5183296"...
0.6933272
3
Convert a JSON stream to a tabseparated "CSV" of concepttoconcept associations.
def convert_to_assoc(input_filename, output_filename): out_stream = codecs.open(output_filename, 'w', encoding='utf-8') for info in read_json_stream(input_filename): startc = reduce_concept(info['start']) endc = reduce_concept(info['end']) rel = info['rel'] weight = info['we...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def people_json_to_csv(self, outfilename, fname):\n subkeys = set()\n with open(fname, 'rb') as r:\n with open(outfilename, 'wb') as w:\n # Get all properties (will use this to create the header)\n for line in r:\n try:\n ...
[ "0.6206316", "0.6075651", "0.5827159", "0.57352823", "0.56285065", "0.55078745", "0.54613775", "0.5433535", "0.5431025", "0.5420267", "0.53780305", "0.5356324", "0.5320781", "0.5217893", "0.5152822", "0.5130858", "0.51101536", "0.5109959", "0.505014", "0.5041207", "0.5038131"...
0.5013517
21
Create model hyperparameters. Parse nondefault from given string.
def create_hparams(hparams_string=None, verbose=False): hparams = tf.contrib.training.HParams( ################################ # Experiment Parameters # ################################ epochs=1000, iters_per_checkpoint=1000, iters_per_validation=1000, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_hyper_parameters(self, hp_string):\n\n hp_dict = {}\n for params in hp_string.split(','):\n hp_name = params.split(':')[0]\n hp_value =params.split(':')[1]\n try: hp_value = int(hp_value)\n except ValueError: hp_value = float(hp_value)\n ...
[ "0.62610024", "0.597264", "0.5869631", "0.55946445", "0.5581092", "0.5527914", "0.5526985", "0.53285867", "0.53260046", "0.5311576", "0.52976143", "0.52973396", "0.52916193", "0.5237482", "0.5237394", "0.52253926", "0.51872045", "0.5182307", "0.51735324", "0.51575536", "0.514...
0.49683392
41
Load all test cases and return a unittest.TestSuite object.
def load_tests(loader, filter): suite = unittest.TestSuite() for r, d, f in os.walk(test_path): module_path = os.path.relpath(r, os.path.dirname(test_path)).replace(os.path.sep, ".") for file in f: filename, ext = os.path.splitext(file) if ext == ".py" and not file.starts...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suite():\n\tts = unittest.TestSuite()\n\tfor test_module in __all__:\n\t\tm = importlib.import_module(\"pyroclast.test.\" + test_module)\n\t\tfor n in dir(m):\n\t\t\tc = getattr(m, n)\n\t\t\tif is_test_case(c):\n\t\t\t\ts = unittest.TestLoader().loadTestsFromTestCase(c)\n\t\t\t\tts.addTests(s)\n\treturn ts", ...
[ "0.8478419", "0.8108045", "0.80656457", "0.80470455", "0.8037982", "0.8037982", "0.79625636", "0.7948463", "0.7787993", "0.774353", "0.77031124", "0.768088", "0.7679084", "0.76632", "0.7583168", "0.75241446", "0.7513062", "0.75110626", "0.7492876", "0.7442735", "0.7425314", ...
0.6891633
56
Convert value and error to string in LateX.
def val2str(s, serr): vals = [] for v, verr in zip(s, serr): if np.isnan(v) or np.isnan(verr): vals.append(r"--") elif np.log10(verr) < 1: sigfig = -int(np.floor(np.log10(verr))) newerr = np.around(verr, sigfig) if newerr == np.power(10., -sigfig)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_string(value: float, error: float, units: str = None, normalise: bool = True):#TODO: sort normalisation for value\n if normalise:#TODO: this dosn't normalise the value it just does the error\n error = sig_fig(error, 1)\n\n if units is None:\n return \"{} \\u00B1 {}\".format(value, flo...
[ "0.7160076", "0.70478255", "0.6800622", "0.6579564", "0.65621626", "0.64962274", "0.6461397", "0.6456456", "0.64154863", "0.6332837", "0.6320989", "0.6313117", "0.63117963", "0.63026834", "0.6295734", "0.6252095", "0.6219286", "0.61679935", "0.61673594", "0.61670315", "0.6156...
0.588954
60
return parsed xml tag
def listup_all_programs(self): with urllib.request.urlopen(self._request) as response: XmlData = response.read() root = ET.fromstring(XmlData) for child in root: for title in child.iter("title"): yield title.text.replace("\u3000","") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tag_name(self, xml):\r\n tag = etree.fromstring(xml).tag\r\n return tag", "def parsexml(self):\n raise NotImplementedError", "def parse(k):\r\n return xml_object.xpath(k)[0]", "def parse(k):\r\n return xml_object.xpath(k)[0]", "def parseXML(self, xml):\n ...
[ "0.68485546", "0.6773583", "0.67726684", "0.67726684", "0.6668718", "0.66462964", "0.6591409", "0.6402723", "0.63820267", "0.63488346", "0.63284", "0.6302398", "0.6082791", "0.6082791", "0.60371417", "0.6022387", "0.60149926", "0.5995002", "0.59925175", "0.59566605", "0.59175...
0.0
-1
Reconstruct file sequence of objects from index, sorted by absolute position
def inspect(filename): bfile = open(filename, 'rb') bdata = bfile.read() bfile.close() doc = loads(bdata) file_seq = [] second = None for ver, snapshot in enumerate(doc.index): nb_obj = len(snapshot) cache = nb_obj * [None] mini_index = nb_obj * [None] for i i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def indexed(filename):\n\n with tempfile.NamedTemporaryFile() as tmp:\n with gzip.open(filename, \"r\") as raw:\n SeqIO.write(corrected_records(raw), tmp, \"fasta\")\n\n tmp.flush()\n yield SeqIO.index(tmp.name, \"fasta\")", "def sort_index(self):\n def s(t):\n ...
[ "0.5764997", "0.572877", "0.56066453", "0.5589324", "0.55742806", "0.54208404", "0.54207265", "0.5403319", "0.53931236", "0.5381334", "0.5358659", "0.53422064", "0.5331138", "0.5320528", "0.528979", "0.52894425", "0.52819306", "0.5266695", "0.5228879", "0.5205095", "0.5189061...
0.60294557
0
Given a list of items with name, value and weight. Return the optimal value with total weight <= allowed weight and list of picked items.
def knapsack(W, items): n = len(items) k = [[0 for x in range(W+1)] for x in range(n+1)] for i in range(n+1): for w in range(W+1): if i == 0 or w == 0: k[i][w] = 0 elif items[i-1][2] <= w: k[i][w] = max(items[i-1][1] + k[i-1][w-items[i-1][2]]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weighted_choice(items):\n weight_total = sum((item[1] for item in items))\n n = random.uniform(0, weight_total)\n for item, weight in items:\n if n < weight:\n return item\n n = n - weight\n return item", "def weighted_choice(items: List[Tuple[str, float]]) -> str:\r\n total_weight = sum(it...
[ "0.7539636", "0.7514603", "0.74942696", "0.7100174", "0.7095652", "0.70954", "0.6999063", "0.69927824", "0.6953054", "0.6947716", "0.69220656", "0.6871103", "0.68582654", "0.68159413", "0.68074834", "0.67640036", "0.67107743", "0.6702032", "0.6597879", "0.6596981", "0.6595855...
0.6240748
36
Add element e to the back of the queue
def enqueue(self,e):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push_back(self, e):\n if(self.size_ >= self.capacity_):#If our Deque is full we need to resize it first\n self.resize_back()\n self.back_+=1\n self.data_[self.back_]= e\n self.size_+=1\n #print(\"case 1\")\n elif (self.front_ == -1 and self.s...
[ "0.78046787", "0.7583146", "0.7390687", "0.72610795", "0.7176424", "0.7175298", "0.7008927", "0.69792056", "0.68699765", "0.68680924", "0.68505114", "0.68476194", "0.6812599", "0.6803687", "0.6799105", "0.6699544", "0.66798687", "0.6613747", "0.6572156", "0.65694535", "0.6523...
0.7152605
6
Remove and return the element at the end of the queue Raise Empty exception if the queue is empty
def dequeue(self):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pop(self):\n if self._size > 0:\n elem = self.first.data\n self.first = self.first.next\n self._size = self._size - 1\n return elem\n \n raise IndexError('The queue is empty! ')", "def remove(self) -> T:\n if not self.is_empty():\n ...
[ "0.8022507", "0.7990784", "0.79863566", "0.7874401", "0.78543675", "0.7854198", "0.7853462", "0.7846237", "0.7837136", "0.78317785", "0.78260535", "0.78231287", "0.779543", "0.77750546", "0.7771193", "0.77538985", "0.7703734", "0.76770043", "0.76745313", "0.7670734", "0.76650...
0.0
-1
Return(but do not remove) the first element of the queue Raise Empty exception if the queue is empty
def first(self):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first(self):\r\n if self.is_empty():\r\n raise Empty(\"Queue is empty\")\r\n return self._head._element", "def first(self):\n\t\tif self.is_empty():\n\t\t\traise Empty('Queue is empty')\n\t\treturn self._head._element", "def first(self):\n if self.is_empty():\n ra...
[ "0.81999797", "0.81825745", "0.79937387", "0.7902844", "0.790266", "0.7881833", "0.7812879", "0.77918804", "0.7773757", "0.7751808", "0.75177455", "0.75161946", "0.7513576", "0.75060105", "0.7501084", "0.74900395", "0.748522", "0.74548346", "0.7403902", "0.73623663", "0.73067...
0.0
-1
Return the total number of elements in the stack.
def __len__(self):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size(self): #returns the size or number of items in the stack\n if self.is_empty():\n return 0\n else:\n return self.num_items", "def size(self):\n return self.N # Number of items in the stack", "def size(self):\n return len(self.stack)", "...
[ "0.8385018", "0.8324536", "0.82126945", "0.81617856", "0.8129431", "0.8096499", "0.8096499", "0.77489895", "0.7717348", "0.7416412", "0.74085087", "0.72057086", "0.70385385", "0.69653875", "0.6932348", "0.6904429", "0.68893206", "0.68893206", "0.6885125", "0.68705064", "0.686...
0.0
-1
Return True if the tree is empty.
def is_empty(self): return len(self) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_empty(self):\n if self.root == None:\n return True\n return False", "def empty(self) -> bool:\n return True if self.root is None else False", "def is_empty(self):\n return self.__root == None", "def is_empty(self):\n return self.root is None", "def is_em...
[ "0.8936684", "0.87890667", "0.8788178", "0.8782837", "0.8782837", "0.83093023", "0.82048905", "0.8137257", "0.81060463", "0.7952423", "0.7952423", "0.7916874", "0.7916541", "0.7911159", "0.79048574", "0.79016674", "0.78991055", "0.7893206", "0.7882776", "0.7882776", "0.787793...
0.77148354
94
Makes PyTorch DataLoaders for extraction.
def get_extract_dataloaders(data_path, image_shape=None, batch_size=1, num_workers=0): if image_shape is None and batch_size != 1: import warnings batch_size = 1 warnings.warn('Since you wish to use variable image sizes, setting batch_size=1.' '\nDealing with variable inputs is not trivial.', RuntimeWarni...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_dataloader(self) -> torch.utils.data.DataLoader: \n return torch.utils.data.DataLoader(self.dataset_train, **self.dl_kwargs)", "def dataloaders():\n # train data path\n data_train = '../dataset/train/'\n # set transformations\n train_transforms = transforms.Compose([\n ...
[ "0.7184117", "0.7172089", "0.7103049", "0.70585805", "0.7023571", "0.69776785", "0.6923268", "0.6862011", "0.6858555", "0.6841408", "0.6834583", "0.68124217", "0.6796105", "0.6769847", "0.6736129", "0.6662132", "0.664149", "0.6600465", "0.65924054", "0.65893775", "0.65822655"...
0.0
-1
The images go through this pipeline before extraction.
def get_transform(image_shape=None): from torchvision import transforms normalization = {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]} transform = [transforms.ToTensor(), transforms.Normalize(**normalization)] if image_shape is not None: if isinstance(image_shape, int): image_shape = (image_shape,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def extractimages(self, ctx):\n if self.extract_images_running:\n await ctx.send(inline('Extract images already running'))\n return\n\n event_loop = asyncio.get_event_loop()\n running_load = event_loop.run_in_executor(self.executor, self.do_extract_images)\n\n ...
[ "0.7110638", "0.6889193", "0.67962146", "0.67683077", "0.6659005", "0.6605889", "0.65992206", "0.64040875", "0.63980496", "0.6391139", "0.6390637", "0.6346538", "0.62487423", "0.6236488", "0.62193924", "0.6202339", "0.619318", "0.6191987", "0.61843616", "0.6183965", "0.614803...
0.0
-1
Makes PyTorch DataLoaders for training.
def get_training_dataloaders(data_path, caption_idx, shuffle): return {mode: _get_training_dataloader(data_path / mode, caption_idx, shuffle) for mode in ('train', 'val')}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_dataloader(self) -> torch.utils.data.DataLoader: \n return torch.utils.data.DataLoader(self.dataset_train, **self.dl_kwargs)", "def _init_train_loader(self):\n # Choose the right dataset type\n if self.config_args[\"num_members\"] > 1:\n class_dataset_wrapper = d...
[ "0.7816402", "0.76506495", "0.7545887", "0.7512149", "0.7501321", "0.7258058", "0.7178917", "0.7167783", "0.71297485", "0.71099246", "0.7090041", "0.7088098", "0.70586234", "0.70514125", "0.7021508", "0.70021164", "0.698864", "0.6976145", "0.696673", "0.69660807", "0.6953139"...
0.0
-1
The COCO Dataset that has the extracted features and the corresponding captions. The fundamental difference between this and the CocoCaptions class in torchvision.datasets
def __init__(self, root, annFile, feature_file, caption_idx): import torch super().__init__(root, annFile) self.features = torch.load(feature_file, map_location='cpu') self.caption_idx = caption_idx
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_coco_dataset():\n ds = AttrDict()\n classes = [\n '__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',\n 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant',\n 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse',\n 'sheep', ...
[ "0.7193297", "0.684184", "0.62688726", "0.62399566", "0.62046766", "0.6088953", "0.5980426", "0.597014", "0.5891977", "0.58210665", "0.5746802", "0.5740212", "0.57296383", "0.56720185", "0.56706953", "0.5666726", "0.562342", "0.55948806", "0.5585627", "0.5570578", "0.55512846...
0.0
-1
Set up babybuddy select entities for feeding and diaper change.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: async_add_entities([BabyBuddySelect(entity) for entity in SELECTOR_TYPES])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pick_up(self):", "def __init__(self, entity_description: BabyBuddySelectDescription) -> None:\n self._attr_unique_id = entity_description.key\n self._attr_options = entity_description.options\n self.entity_description = entity_description\n self._attr_current_option = None", "de...
[ "0.5553327", "0.5431278", "0.533167", "0.532243", "0.5231893", "0.51908284", "0.51467603", "0.5063082", "0.5009682", "0.49979505", "0.49765864", "0.49712533", "0.49513426", "0.49345365", "0.49092245", "0.48547655", "0.48247764", "0.48069692", "0.47705767", "0.47544596", "0.47...
0.65842026
0
Initialize the Babybuddy select entity.
def __init__(self, entity_description: BabyBuddySelectDescription) -> None: self._attr_unique_id = entity_description.key self._attr_options = entity_description.options self.entity_description = entity_description self._attr_current_option = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, *args, **kwargs):\n super(ChoiceFieldType, self).__init__(*args, **kwargs)\n\n self.choices = self.get_field_info_key('choices')", "def init(self):\n # IMPORTANT: create a new gob database model entry for this object\n self.gobify()", "def initialize(self):\n\n ...
[ "0.6092637", "0.60616356", "0.58840305", "0.5762157", "0.57082224", "0.56701213", "0.5660541", "0.5595342", "0.55679876", "0.55628157", "0.5492031", "0.54903996", "0.54903996", "0.54903996", "0.54903996", "0.54903996", "0.54903996", "0.54903996", "0.54903996", "0.54722273", "...
0.7361549
0
Restore last state when added.
async def async_added_to_hass(self) -> None: last_state = await self.async_get_last_state() if last_state: self._attr_current_option = last_state.state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore(self):\n raise NotImplementedError", "def restore_last_undo_point(self):\n self.unload()", "def restore(self):\n self.igate.restore()\n self.fgate.restore()\n self.ogate.restore()\n super(LSTM, self).restore()", "def revert_state(self):\n if self.p...
[ "0.7342478", "0.7273116", "0.70957226", "0.7068361", "0.7049309", "0.69999045", "0.69320804", "0.6918523", "0.6859195", "0.6853133", "0.6844502", "0.68230796", "0.67886513", "0.67182875", "0.67166734", "0.6713994", "0.6663462", "0.6641381", "0.6621431", "0.65914077", "0.65838...
0.0
-1
Update the current selected option.
async def async_select_option(self, option: str) -> None: if option not in self.options: raise ValueError(f"Invalid option for {self.entity_id}: {option}") self._attr_current_option = option self.async_write_ha_state()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_selection(self):\n raise NotImplementedError", "def update_view(self, selected):\n pass", "def changeCurrentValue(self):\n if(self.dropDown.currentIndex() >= 0):\n self.__currentValue = self.dropDown.currentIndex()\n\n if(self.__functionToInvoke != None):\n...
[ "0.72777873", "0.6968837", "0.66772693", "0.6658478", "0.6596658", "0.6303981", "0.62901753", "0.6194861", "0.61828315", "0.6148036", "0.6134859", "0.6079361", "0.6030761", "0.602593", "0.601563", "0.60150194", "0.60019153", "0.5996462", "0.5994246", "0.5967078", "0.59609795"...
0.0
-1
You do not need to change this method, but you're welcome to. getAction chooses among the best options according to the evaluation function. Just like in the previous project, getAction takes a GameState and returns some Directions.X for some X in the set {North, South, West, East, Stop}
def getAction(self, gameState): # Collect legal moves and successor states legalMoves = gameState.getLegalActions() # Choose one of the best actions scores = [self.evaluationFunction(gameState, action) for action in legalMoves] bestScore = max(scores) bestIndices = [index for index in range(len...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState):\n \"*** YOUR CODE HERE ***\"\n \n # The best_move is basically a pair with the evaluation value and action name\n best_move = self.minimax(gameState, 0 , 0)\n \n # Returning best action move\n return best_move[1]\n \n # ...
[ "0.73985434", "0.73298985", "0.73247117", "0.7301311", "0.72974575", "0.7279284", "0.7243445", "0.72334325", "0.722034", "0.72193974", "0.7208082", "0.7161462", "0.716105", "0.71267086", "0.71228415", "0.7121531", "0.7100198", "0.7100198", "0.7088234", "0.7043927", "0.7043721...
0.7037261
25
Design a better evaluation function here. The evaluation function takes in the current and proposed successor GameStates (pacman.py) and returns a number, where higher numbers are better. The code below extracts some useful information from the state, like the remaining food (newFood) and Pacman position after moving (...
def evaluationFunction(self, currentGameState, action): # Useful information you can extract from a GameState (pacman.py) successorGameState = currentGameState.generatePacmanSuccessor(action) newPos = successorGameState.getPacmanPosition() newFood = successorGameState.getFood() newGhostStates = succ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluationFunction(self, currentGameState, action):\n # Useful information you can extract from a GameState (pacman.py)\n successorGameState = currentGameState.generatePacmanSuccessor(action)\n newPos = successorGameState.getPacmanPosition()\n oldFood = currentGameState.getFood()\n newGhostState...
[ "0.85765415", "0.8431476", "0.837736", "0.8358476", "0.83099616", "0.83093965", "0.8276818", "0.82762575", "0.82379407", "0.82248855", "0.81835407", "0.81680053", "0.81561214", "0.8144599", "0.8134267", "0.8133093", "0.813167", "0.8119687", "0.8119089", "0.8108717", "0.809037...
0.8116712
19
This default evaluation function just returns the score of the state. The score is the same one displayed in the Pacman GUI. This evaluation function is meant for use with adversarial search agents (not reflex agents).
def scoreEvaluationFunction(currentGameState): return currentGameState.getScore()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scoreEvaluationFunction(gameState):\n return gameState.getScore()", "def scoreEvaluationFunction(currentGameState):\r\n return currentGameState.getScore()", "def scoreEvaluationFunction(currentGameState):\n return currentGameState.getScore()", "def scoreEvaluationFunction(currentGameState):\n ...
[ "0.8054703", "0.75815105", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", "0.7554428", ...
0.7593981
5
Returns the minimax action from the current gameState using self.depth and self.evaluationFunction. Here are some method calls that might be useful when implementing minimax.
def getAction(self, gameState): "*** YOUR CODE HERE ***" legalActions = gameState.getLegalActions(0) legalActions.remove('Stop') besctaction = Directions.STOP score = float("-inf") for action in legalActions: child = gameState.generateSuccessor(0, action) newscore = max(score, m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o...
[ "0.7805281", "0.7533675", "0.75330496", "0.75187063", "0.74377435", "0.74094397", "0.740521", "0.7399833", "0.7341552", "0.7264349", "0.7261286", "0.7251706", "0.71673775", "0.71428883", "0.70934355", "0.70878756", "0.70714605", "0.70707184", "0.7041809", "0.70143723", "0.699...
0.6830117
39
Returns the minimax action using self.depth and self.evaluationFunction
def getAction(self, gameState): "*** YOUR CODE HERE ***" legalActions = gameState.getLegalActions(0) legalActions.remove('Stop') alpha = float("-inf") beta = float("inf") besctaction = Directions.STOP score = float("-inf") for action in legalActions: child = gameState.generate...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o...
[ "0.7482665", "0.7383559", "0.71806973", "0.7110041", "0.70884514", "0.70694935", "0.70683014", "0.7048308", "0.70055133", "0.69651455", "0.69642085", "0.69604385", "0.6945924", "0.68998593", "0.6895832", "0.688605", "0.6826282", "0.6767276", "0.6758028", "0.6751636", "0.67054...
0.0
-1
Returns the expectimax action using self.depth and self.evaluationFunction All ghosts should be modeled as choosing uniformly at random from their legal moves.
def getAction(self, gameState): "*** YOUR CODE HERE ***" legalActions = gameState.getLegalActions(0) legalActions.remove('Stop') besctaction = Directions.STOP score = float("-inf") for action in legalActions: child = gameState.generateSuccessor(0, action) newscore = max(score, e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState):\n def Minimaxer(sucGameState, depth, curAgent, numGhosts):\n if sucGameState.isWin() or sucGameState.isLose():\n return self.evaluationFunction(sucGameState)\n if depth == 0:\n return self.evaluationFunction(sucGameState)\n ...
[ "0.7490743", "0.7464548", "0.7464233", "0.74424946", "0.74306947", "0.74106455", "0.7387545", "0.73767996", "0.73012114", "0.7255859", "0.72178525", "0.7213856", "0.72098166", "0.7205306", "0.7187404", "0.7172729", "0.716867", "0.7158275", "0.7151114", "0.7147327", "0.7108024...
0.6561642
83
Your extreme ghosthunting, pelletnabbing, foodgobbling, unstoppable evaluation function (question 5).
def betterEvaluationFunction(currentGameState): "*** YOUR CODE HERE ***" pos = currentGameState.getPacmanPosition() score1 = currentGameState.getScore() Food = currentGameState.getFood() foodlist = list(Food.asList()) dist = [] score2 = 0 if len(foodlist) != 0: for food in foodlist: dist.a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def betterEvaluationFunction(currentGameState):\n \"*** YOUR CODE HERE ***\"\n next_pacman_position = currentGameState.getPacmanPosition()\n next_food = [food for food in currentGameState.getFood().asList() if food]\n next_ghosts_states = currentGameState.getGhostStates()\n next_ghosts_scared_timers...
[ "0.73445916", "0.7206647", "0.7201176", "0.7178031", "0.71601456", "0.71585554", "0.7139828", "0.71391654", "0.71090144", "0.7050158", "0.70279783", "0.7020684", "0.70147085", "0.69905776", "0.69860834", "0.6977059", "0.6974314", "0.69628817", "0.6937865", "0.6931714", "0.692...
0.72288746
1
Returns an action. You can use any method you want and search to any depth you want. Just remember that the minicontest is timed, so you have to trade off speed and computation. Ghosts don't behave randomly anymore, but they aren't perfect either they'll usually just make a beeline straight towards Pacman (or away from...
def getAction(self, gameState): "*** YOUR CODE HERE ***" util.raiseNotDefined()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState):\n return self.minimax(gameState, self.depth, 0)", "def getAction(self, gameState):\n \"*** YOUR CODE HERE ***\"\n def minMaxHelper(gameState, deepness, agent):\n if agent >= gameState.getNumAgents():\n agent = 0\n deepness ...
[ "0.6819004", "0.6791531", "0.67102724", "0.6693187", "0.6638914", "0.6618938", "0.6614788", "0.66092956", "0.6582351", "0.6573214", "0.6567215", "0.65612036", "0.65345424", "0.6523664", "0.65080947", "0.6482032", "0.64712214", "0.64578146", "0.64441186", "0.6432857", "0.64244...
0.0
-1
Returns the timezone as an hour/minute offset in the form "+HHMM" or "HHMM".
def _format_timezone_offset(converted_time): # Windows treats %z in the format string as %Z, so we compute the hour/minute offset # manually. if converted_time.tm_isdst == 1 and time.daylight: utc_offset_secs = time.altzone else: utc_offset_secs = time.timezone ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_timezone_offset():\n timezone = get_localzone()\n offset_minutes = timezone.utcoffset(datetime.datetime.now()).total_seconds() // SECONDS_IN_MINUTE\n return parse_int(offset_minutes)", "def get_fixed_timezone(offset):\n if isinstance(offset, timedelta):\n offset = offset.total_seconds(...
[ "0.7235955", "0.67034847", "0.6700693", "0.66685057", "0.6638393", "0.66248596", "0.6586953", "0.6572008", "0.65655357", "0.64952195", "0.64378357", "0.6383715", "0.6347221", "0.63229084", "0.6319341", "0.62767327", "0.62652457", "0.6222787", "0.62033075", "0.61946964", "0.61...
0.71226084
1
Returns the executable path of a py_binary. This returns the executable path of a py_binary that is in another Bazel target's data dependencies. On Linux/macOS, the path and __file__ has the same root directory. On Windows, bazel builds an .exe file and we need to use the MANIFEST file the location the actual binary.
def get_executable_path(py_binary_name): if os.name == 'nt': py_binary_name += '.exe' manifest_file = os.path.join(FLAGS.test_srcdir, 'MANIFEST') workspace_name = os.environ['TEST_WORKSPACE'] manifest_entry = '{}/{}'.format(workspace_name, py_binary_name) with open(manifest_file, 'r') as manifest...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_exec_path(self):\n bin_name = 'test_hint_time'\n # Look for in place build\n script_dir = os.path.dirname(os.path.realpath(__file__))\n bin_path = os.path.join(script_dir, '.libs', bin_name)\n if not os.path.exists(bin_path):\n # Look for out of place build fro...
[ "0.70611286", "0.69784385", "0.67366946", "0.6704762", "0.6694283", "0.6644212", "0.66146284", "0.65615684", "0.6532665", "0.6474591", "0.6446678", "0.6406514", "0.6392812", "0.6340146", "0.632116", "0.6318753", "0.6304325", "0.6299277", "0.62937576", "0.62814784", "0.628113"...
0.80735695
0
Enumerates videos from the original dataset.
def get_seq(data_dir, dname): # Get list of video files data_dir = os.path.join(data_dir, 'softmotion30_44k', dname) filenames = gfile.Glob(os.path.join(data_dir, '*')) if not filenames: raise RuntimeError('No data files found.') # Enumerates videos (filename, index of file, list of images) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ordinarilyGenerateFrames(self):\n for name, video in self._videos.items():\n print(f'Reading:{name}...')\n success, frame = video.read()\n while self.alive and success:\n yield frame\n success, frame = video.read()\n print('Reading Co...
[ "0.62048256", "0.6199403", "0.6159387", "0.6045818", "0.60281456", "0.600516", "0.5924626", "0.59033257", "0.5884817", "0.587601", "0.5873562", "0.5806949", "0.57932585", "0.57638246", "0.57544434", "0.57515126", "0.5748793", "0.5737944", "0.57259256", "0.5701706", "0.5696077...
0.57019675
19
Preprocesses videos from the BAIR dataset in the input directory. Processed videos are saved in separate directories; each video frame is extracted in a .png file.
def convert_data(data_dir, dname): # Get videos from the original dataset seq_generator = get_seq(data_dir, dname) # Process videos for n, (f, k, seq) in enumerate(seq_generator): # Create a directory for the video f = os.path.splitext(os.path.basename(f))[0] dirname = os.path.jo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precompute_numpy_video_files(self):\n videos = self.get_videos(self.not_collisions, 1) \\\n | chain_with(self.get_videos(self.collisions, 0)) \\\n | where(lambda f: not isfile(self.get_numpy_filename(f[1])))\n\n for v in videos:\n path = self.get_numpy...
[ "0.69390935", "0.6890178", "0.66392815", "0.66133606", "0.66133606", "0.65581614", "0.6554764", "0.651356", "0.64366", "0.6430591", "0.6429932", "0.6412027", "0.6364831", "0.63648057", "0.6340141", "0.63109636", "0.6306809", "0.62747556", "0.62535834", "0.6226402", "0.6222001...
0.6655314
2
start threads and idle handler (update_ui) for callback dispatching
def start_thread(): global gIt, gOt, gRunning gRunning = True gIt = Thread(target = input_thread) gIt.start() gOt = Thread(target = output_thread) gOt.start()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polling( self, ):\r\n \"\"\"\r\n queue protocol, data = ( action, function, function_args )\r\n action = a string\r\n function = a function\r\n function_args = arguments to function which will be called function( function_args ) This should be a tuple...
[ "0.64265764", "0.64098173", "0.6402181", "0.6346647", "0.6325017", "0.62540954", "0.6195212", "0.6173926", "0.61703956", "0.6163969", "0.6110663", "0.6080352", "0.6075288", "0.6012084", "0.6007064", "0.6005521", "0.5975944", "0.59583676", "0.5932319", "0.59218866", "0.5921886...
0.0
-1
output thread function for getting inference results from Movidius NCS running graph specific post processing of inference result queuing the results for main thread callbacks
def output_thread(): global gRunning try: while gRunning: try: inference_result, user_data = gGraph.GetResult() print (postprocess(inference_result)) #print(user_data) # gUpdateq.put((postprocess(inference_result), user_data)) except KeyError: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inference(self):\n for i in range(len(self.nodes)):\n for j in range(len(self.nodes[i])):\n self.pipes[i][j].send(\"inference\")\n \n ## wait for the finalization to be completed\n for i in range(len(self.nodes)):\n for j in range(len(sel...
[ "0.7058547", "0.6675076", "0.63437945", "0.61934835", "0.60070735", "0.59801656", "0.59527904", "0.59318507", "0.59288776", "0.5920665", "0.5890297", "0.5875667", "0.58533645", "0.58358604", "0.5832103", "0.5815753", "0.58027357", "0.5774473", "0.5759439", "0.57552284", "0.57...
0.75303006
0
get a preprocessed frame to be pushed to the graph
def get_sample(): global counter counter = counter + 1 # capture frames from the camera; frame=picamera.array.PiRGBArray(camera) camera.capture(frame, 'bgr', use_video_port=True) # grab the raw NumPy array representing the image, then initialize the timestamp # and occupied/unoccupied tex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_frame(self, frame):\n\t\treturn frame", "def preprocess_frame(self, frame):\n state = torch.Tensor(frame)\n return gpuify(state, self.gpu_id)", "def frame_pre_process(self, frame):\n assert len(frame.shape) == 3, \\\n \"Expected input frame in (H, W, C) format propos...
[ "0.7119568", "0.6751297", "0.67064327", "0.6306198", "0.6134869", "0.6000026", "0.5978636", "0.59715766", "0.59634686", "0.5920147", "0.5843046", "0.58087265", "0.57635844", "0.5748316", "0.5747666", "0.57154405", "0.5696114", "0.56948686", "0.5672049", "0.56586546", "0.56557...
0.5511134
29
preprocess a video frame input in the format specified by rawinputformat() method output in the format required by the graph
def preprocess(img): dim=(227,227) resize_width = 224 resize_height = 224 img=cv2.resize(img,dim) #img=cv2.normalize(img,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX,dtype=cv2.CV_32F) img = img.astype(numpy.float32) #Preprocess image changing the RGB pixel values to the value...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_video(input_file, output_file):\n # video = VideoFileClip(input_file).subclip(40,44) # from 38s to 46s\n video = VideoFileClip(input_file)\n annotated_video = video.fl_image(process_pipeline)\n annotated_video.write_videofile(output_file, audio=False)", "def process_video(input_file, outp...
[ "0.660406", "0.660406", "0.6251925", "0.62162185", "0.61449426", "0.6016263", "0.59658784", "0.59191173", "0.5898252", "0.58571494", "0.58359957", "0.58204484", "0.5807554", "0.57724744", "0.5767315", "0.57514405", "0.5736507", "0.57330585", "0.5650401", "0.5630842", "0.56126...
0.5234842
60
postprocess an inference result input in the format produced by the graph output in a human readable format
def postprocess(output): text='' order = output.argsort()[::-1][:6] # print('\n------- predictions --------') for i in range(1): # print ('prediction ' + str(i) + ' (probability ' + str(output[order[i]]*100) + '%) is ' + gNetworkCategories[order[i]] + ' label index is: ' + str(order[i]) ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def postprocess(self, inference_output):\n logger.info(inference_output)\n return inference_output", "def inference():\n if request.method == \"POST\":\n data = request.json #\n src_img = np.array(data[\"src\"]).astype(np.uint8) # Pars...
[ "0.74513173", "0.63642395", "0.63103646", "0.6209664", "0.6149981", "0.61384505", "0.61171323", "0.6045562", "0.6036395", "0.59836096", "0.5979635", "0.58721167", "0.5831833", "0.58255285", "0.5821647", "0.58004344", "0.5789193", "0.5777875", "0.5736013", "0.572711", "0.57234...
0.6112819
7
Newton's Method. f(y) = y2 x = 0 f(y1) = f(y0) + dy f'(y0) = y0 y0 x + (y1 y0) 2 y0 = 0 y1 = (y0 + x / y0) / 2
def mySqrt(self, x: int) -> int: if x == 0: return 0 d = 0.1 y = x / 2 z = (y + x/y) / 2 e = abs(z-y) while e > d: y = z z = (y + x/y) / 2 e = abs(z - y) return int(z)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newton(f, x0, Df, tol=1e-5, maxiter=15, alpha=1.):\n raise NotImplementedError(\"Problem 1 Incomplete\")", "def test_newton():\n\n f = lambda x: x**2 + np.sin(5*x)\n df = lambda x: 2*x + 5*np.cos(5*x)\n ddf = lambda x: 2 + 0,-25*np.sin(5*x)\n\n\n print newtonsMethod(f,df,ddf, 0, niter = 100)",...
[ "0.7441877", "0.7211542", "0.71977335", "0.719035", "0.7187115", "0.71342146", "0.71297497", "0.7069365", "0.7065893", "0.70429343", "0.69355184", "0.68557405", "0.6837517", "0.68288064", "0.68169826", "0.6779649", "0.6760478", "0.6721544", "0.6686242", "0.6662009", "0.666122...
0.0
-1
Return the pending number of messages in the queue by doing a passive Queue declare.
def __len__(self): response = self._rpc(self._declare(True)) return response.message_count
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_pending(status=\"pending\", username=\"garrett.wilson\"):\n cmd = [\n \"squeue\",\n \"-u\", username,\n \"-t\", status,\n \"-h\"\n ]\n\n output = subprocess.check_output(cmd)\n output = output.decode(\"utf-8\").strip()\n\n if output == \"\":\n return 0\n\n ...
[ "0.6994661", "0.69166964", "0.6806728", "0.6793772", "0.674106", "0.653735", "0.65129846", "0.64847827", "0.64818645", "0.6461492", "0.63980144", "0.63980144", "0.6334779", "0.6294051", "0.62864494", "0.6266857", "0.6237147", "0.620611", "0.6205403", "0.6193056", "0.6183044",...
0.56386495
53
Bind the queue to the specified exchange or routing key.
def bind(self, source, routing_key=None, arguments=None): if hasattr(source, 'name'): source = source.name frame = specification.Queue.Bind(queue=self.name, exchange=source, routing_key=routing_key or '', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bind_queue_to_exchange(self, channel, exchange, queue_name, routing_key):\n logger.info('Binding %s to %s with %s',\n exchange, queue_name, routing_key)\n channel.queue_bind(queue=queue_name,\n exchange=exchange,\n routing_key=routing_key)", "async def b...
[ "0.8586502", "0.84070414", "0.8285592", "0.6888623", "0.6881881", "0.65968955", "0.63757175", "0.63733155", "0.6050453", "0.59048396", "0.5763697", "0.57079154", "0.57029057", "0.56764746", "0.5662288", "0.5568562", "0.5544528", "0.5477283", "0.54671043", "0.5458153", "0.5446...
0.73164797
3
Consumer message context manager, returns a consumer message generator.
def consumer(self, no_ack=False, prefetch=100, priority=None): if prefetch is not None: self.channel.prefetch_count(prefetch) self.channel._consume(self, no_ack, priority) self.consuming = True yield Consumer(self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n # Trigger the consumer procs to start off.\n # We will iterate till there are no more messages available\n self.size.value = 0\n self.pause.set()\n\n while True:\n self.start.set()\n try:\n # We will block for a small whi...
[ "0.6520486", "0.64304805", "0.6348474", "0.6260189", "0.6066062", "0.59972835", "0.5906607", "0.5790026", "0.57867485", "0.57645184", "0.5661963", "0.5636426", "0.5610837", "0.5610837", "0.56106585", "0.55232435", "0.5515625", "0.54985094", "0.5481432", "0.5471095", "0.546918...
0.60765916
4
Declare the queue on the RabbitMQ channel passed into the constructor, returning the current message count for the queue and its consumer count as a tuple.
def declare(self, passive=False): response = self._rpc(self._declare(passive)) return response.message_count, response.consumer_count
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_queue_msg_count1(self):\n self.queue.direct_declare(TEST_QUEUE)\n self.queue.publish(TEST_QUEUE, 'this is a test msg')\n\n msg_count = self.queue.get_queue_msg_count(TEST_QUEUE)\n assert isinstance(msg_count, int)", "def get_pending_messages():\n global logger\n try...
[ "0.6695004", "0.65361464", "0.6433904", "0.6380009", "0.63566524", "0.6303155", "0.6188639", "0.6182734", "0.61554193", "0.6077462", "0.6067161", "0.60579026", "0.60351235", "0.6034361", "0.60192823", "0.5917088", "0.58340645", "0.58212996", "0.5819722", "0.58159286", "0.5790...
0.6078519
9
Request a single message from RabbitMQ using the Basic.Get AMQP command.
def get(self, acknowledge=True): self._write_frame(specification.Basic.Get(queue=self.name, no_ack=not acknowledge)) return self.channel._get_message()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, msg):\n\n # print(\"get\")\n self.q.put(msg)", "def rabbit_request(self, path):\n uri = self._base_uri + path\n response = requests.get(uri, auth=self._auth)\n\n if response.status_code != 200:\n raise Exception(self.error_message(response))\n re...
[ "0.6866893", "0.68570006", "0.63802916", "0.6348834", "0.6341484", "0.61993957", "0.61341304", "0.6129399", "0.61021316", "0.5994536", "0.5983703", "0.59462357", "0.5938115", "0.59198", "0.59198", "0.59195334", "0.59125274", "0.5909593", "0.5882313", "0.58796036", "0.5872847"...
0.6481924
2
Declare a the queue as highly available, passing in a list of nodes the queue should live on. If no nodes are passed, the queue will be declared across all nodes in the cluster.
def ha_declare(self, nodes=None): if nodes: self._arguments['x-ha-policy'] = 'nodes' self._arguments['x-ha-nodes'] = nodes else: self._arguments['x-ha-policy'] = 'all' if 'x-ha-nodes' in self._arguments: del self._arguments['x-ha-nodes'] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def declare_queue(self):\n\n self._channel.queue_declare(queue=self._queue_name, durable=True)\n print(\"Queue declared....\")", "def _create_queue(self):\n # Instantiate\n queue = pbs.queue(verbose=not self.quiet)\n\n if self.q == 'ember':\n # Submitting to Utah emb...
[ "0.62286747", "0.60477805", "0.58977777", "0.5751411", "0.5699497", "0.5601299", "0.5536529", "0.5517704", "0.55171967", "0.54711384", "0.54707986", "0.5445398", "0.5411856", "0.54114914", "0.5409894", "0.53511775", "0.5346529", "0.5311034", "0.52988267", "0.5228136", "0.5223...
0.57938516
3
Purge the queue of all of its messages.
def purge(self): self._rpc(specification.Queue.Purge())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clearQueueAll():", "def clear_queue(self):\n while not self.queue.empty():\n self.queue.get()", "def clear_queue(self):\n\t\t\tself.message_queue.clear()\n\t\t\treturn self.message_queue", "def clear_messages(self):\n self.redis_client.delete(self.message_list)", "def flush_msg...
[ "0.7505619", "0.72489685", "0.7197505", "0.7081021", "0.70500505", "0.7026544", "0.6947277", "0.692343", "0.69218075", "0.68953866", "0.6863806", "0.6734934", "0.66792786", "0.66656256", "0.6581635", "0.6553705", "0.65511155", "0.6539296", "0.65362954", "0.65359545", "0.65193...
0.8184247
0
Unbind queue from the specified exchange where it is bound the routing key. If routing key is None, use the queue name.
def unbind(self, source, routing_key=None): if hasattr(source, 'name'): source = source.name self._rpc(specification.Queue.Bind(queue=self.name, exchange=source, routing_key=routing_key or ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def bind(\n self,\n exchange: ExchangeParamType,\n routing_key: Optional[str] = None,\n *,\n arguments: Arguments = None,\n timeout: TimeoutType = None,\n ) -> aiormq.spec.Queue.BindOk:\n\n if routing_key is None:\n routing_key = self.name\n\n ...
[ "0.5841196", "0.5779545", "0.5448614", "0.5320331", "0.52993155", "0.5290274", "0.51541996", "0.51409155", "0.5094225", "0.4963937", "0.49457547", "0.4868611", "0.48207507", "0.48195007", "0.48154044", "0.48097736", "0.4786163", "0.47184947", "0.47171628", "0.47167245", "0.46...
0.77533823
0
Return a specification.Queue.Declare class precomposed for the rpc method since this can be called multiple times.
def _declare(self, passive=False): arguments = dict(self._arguments) if self._expires: arguments['x-expires'] = self._expires if self._message_ttl: arguments['x-message-ttl'] = self._message_ttl if self._max_length: arguments['x-max-length'] = self._ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def declare(self) -> 'Queue':\n # we are relying to this in other functions\n self._channel = await self._backend.channel()\n self.log.debug(\"Channel acquired CHANNEL%i\",\n self._channel.channel_number)\n\n if self.exchange:\n await self.declare_...
[ "0.67236507", "0.66197556", "0.64929247", "0.6260047", "0.6201118", "0.5973525", "0.59200746", "0.5897509", "0.5897299", "0.5760605", "0.5723684", "0.57159436", "0.57159436", "0.57159436", "0.57159436", "0.57159436", "0.57159436", "0.57159436", "0.57159436", "0.57159436", "0....
0.6956101
0
Called when exiting the consumer iterator
def __exit__(self, exc_type, exc_val, exc_tb): self.queue.channel.rpc(self._basic_cancel) self.queue.consuming = False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end_iter(self):\n raise NotImplementedError", "def __exit__(self, *_) -> None:\n self.__cursor.top.pop()", "def end(self) -> None:", "def end(self):\n ...", "def _finish(self):\n if self.consumer:\n self.consumer.unregisterProducer()\n self.consumer = N...
[ "0.71276844", "0.64325505", "0.6416023", "0.63907677", "0.6312287", "0.6300143", "0.6271744", "0.6212424", "0.6212424", "0.6212424", "0.6162212", "0.61339283", "0.6100264", "0.6042454", "0.6037785", "0.6007991", "0.6005878", "0.6001117", "0.5998288", "0.59981495", "0.5981218"...
0.6188529
10
Retrieve the nest message from the queue as an iterator, blocking until the next message is available.
def next_message(self): while self.queue.consuming: yield self.queue.channel._consume_message()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next(self): # wait for 5 minutes after sending message\n if self.queue:\n messages = self.queue.get_messages(1,visibility_timeout=self.visibility_timeout)\n if messages:\n for m in messages:\n return m\n raise StopIteration", "def read(sel...
[ "0.7556442", "0.7009815", "0.6816463", "0.674572", "0.6724379", "0.66346157", "0.660066", "0.64881974", "0.63246495", "0.63130015", "0.62896055", "0.6209126", "0.6189926", "0.61867803", "0.60752857", "0.60651827", "0.6057777", "0.6036472", "0.5981971", "0.59722316", "0.596316...
0.7156374
1
This is initialization method of the algorithm's class.
def __init__(self, filename='', limit=0.80, members=3, delimiter=','): self.count = 0 # counter for correct predictions self.results = self.load_data(filename=filename, limit=limit, delim=delimiter) # load data and receive response self.test_data = self.results[1] self.training_data = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_algorithm(self):\n pass", "def initialize(self):\n\t\tpass", "def init(self) -> None:", "def initialize(self):\r\n pass", "def initialize(self):\r\n pass", "def initialize(self):\n pass", "def initialize(self):\n pass", "def initialize(self):\n pass"...
[ "0.8788583", "0.78260493", "0.7767065", "0.77532625", "0.77532625", "0.77265584", "0.77265584", "0.77265584", "0.77265584", "0.77265584", "0.7675273", "0.7675273", "0.7675273", "0.7675273", "0.7675273", "0.7675273", "0.7675273", "0.7675273", "0.7666846", "0.7661625", "0.76616...
0.0
-1
This method loads data from the file. A ny number of columns is accepted but provided the labels are on the last columns to the right.
def load_data(self, filename='', limit=0.75, delim=','): with open(filename) as data: reader = csv.reader(data, delimiter=delim) f = list(reader) for x in range(len(f)): for y in range(len(f[0]) - 1): f[x][y] = float(f[x][y]) # convert elements of eac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_column_labels(self):\n\n # read the label line (should be at row 15 of the file at this point)\n label_list = self._stream_handle.readline().strip().split()\n self.num_columns = len(label_list)\n self._header_dict['labels'] = label_list\n\n # the m_present_time label is...
[ "0.74831015", "0.7439754", "0.69201815", "0.68371534", "0.68163675", "0.6701311", "0.665933", "0.65913653", "0.65871", "0.6568758", "0.6536346", "0.653422", "0.65012157", "0.648894", "0.6411348", "0.63984174", "0.63932616", "0.63891995", "0.63853955", "0.63792837", "0.6369172...
0.0
-1
This method receives the whole training data set, the data instance being predicted and the cluster member size.
def get_neighbours(self, training_data=(), instance=(), k=3): data = [] neighbours = [] # calculate the query distance for x in range(len(training_data)): distance = self.query_distance(instance1=training_data[x][:-1], instance2=instance[:-1]) data.append([trainin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_train_instances(self):\n raise NotImplementedError()", "def predict(self, test_data):\n if self.centroids_.shape[0]==0:\n raise ValueError(\"No centroids present. Run KMeans.fit first.\")\n\n print test_data.shape\n part_of_cluster=np.zeros(test_data.shape[0])\n ...
[ "0.64410335", "0.6329403", "0.6253084", "0.6185533", "0.6177989", "0.61298734", "0.6108489", "0.61044306", "0.61016464", "0.606673", "0.6049881", "0.6038121", "0.60097194", "0.60030633", "0.59279317", "0.59199035", "0.5886591", "0.5773972", "0.5772074", "0.57601804", "0.57601...
0.0
-1
This method calculates the query distance between the current data in the training set and the test data in question
def query_distance(self, instance1=(), instance2=()): distance = sum([pow((a - b), 2) for a, b in zip(instance1, instance2)]) return distance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getDistanceM(self, test, train):\n p = 2 # TUNE currently euclidian distance\n distanceM = pd.DataFrame(index=test.index.values, columns=train.index.values)\n for testrow, testing in test.iterrows():\n for trainrow, training in train.iterrows():\n tot = 0\n ...
[ "0.7019203", "0.6988815", "0.68354094", "0.66117215", "0.64914435", "0.6445621", "0.6380863", "0.6360921", "0.6360921", "0.6267546", "0.619195", "0.6135691", "0.60662866", "0.6063706", "0.60594213", "0.60494125", "0.5988632", "0.5947215", "0.59445816", "0.594229", "0.5941032"...
0.56466407
48
This method receives the neighbours of the test data and takes a tally of the votes and makes a decision. The decision is based on the label with the highest count.
def count_votes(self, neighbours=()): labels = [] data = neighbours # create the list made up of labels. for x in range(len(data)): labels.append(data[x][-1]) # count the appearance of labels. count = [[x, labels.count(x)] for x in set(labels)] # Sort...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _vote(self, neighbor_labels):\n counts= torch.bincount(neighbor_labels.int())\n return torch.argmax(counts)", "def _tally_votes(self, labels, distances):\n votes = collections.defaultdict(int)\n for i, index in enumerate(distances.order(ascending=True).index):\n if i < ...
[ "0.7076513", "0.6492986", "0.63586086", "0.6339451", "0.62436193", "0.61596376", "0.6038543", "0.598995", "0.59895474", "0.5984259", "0.5975959", "0.5975312", "0.5897305", "0.58957624", "0.58957624", "0.58913827", "0.5873205", "0.5868879", "0.5822922", "0.5816393", "0.5770653...
0.7605235
0
Secure XMLRPC server. It it very similar to SimpleXMLRPCServer but it uses HTTPS for transporting XML data.
def __init__(self, server_address, HandlerClass, logRequests=True): self.logRequests = logRequests try: SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self) except TypeError: # An exception is raised in Python 2.5 as the prototype of the __init__ # metho...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ServerApp(stream, certfile, keyfile):\n\n def secured():\n print 'server secured!'\n wait()\n\n def read(line):\n line = line.strip()\n print 'client said: %r.' % line\n\n if line == 'QUIT':\n write('GOODBYE')\n elif line == 'STARTTLS':\n st...
[ "0.5892171", "0.5800856", "0.57675576", "0.55861664", "0.557848", "0.5535654", "0.5511048", "0.54085445", "0.5328043", "0.52619624", "0.52469873", "0.5210757", "0.5188847", "0.5187752", "0.51839226", "0.51787466", "0.51674885", "0.5163018", "0.5136565", "0.51175344", "0.51103...
0.5573137
5
Handles the HTTPS POST request. It was copied out from SimpleXMLRPCServer.py and modified to shutdown the socket cleanly.
def do_POST(self): try: # get arguments data = self.rfile.read(int(self.headers["content-length"])) # In previous versions of SimpleXMLRPCServer, _dispatch # could be overridden in this class, instead of in # SimpleXMLRPCDispatcher. To maintain backw...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_POST(self):\r\n SimpleXMLRPCRequestHandler.do_POST(self)\r\n try:\r\n # shut down the connection\r\n self.connection.shutdown()\r\n except:\r\n pass", "def do_POST(self):\n\n try:\n # get arguments\n data = self.rfile.read(...
[ "0.7406314", "0.67461973", "0.64566195", "0.63029206", "0.6072018", "0.6066601", "0.6046328", "0.5997497", "0.59290093", "0.58769035", "0.58373576", "0.57971627", "0.573956", "0.57225776", "0.5698153", "0.5666174", "0.563702", "0.56157655", "0.5584676", "0.55648243", "0.55317...
0.72129786
1
Return object data in easily serializeable format
def serialize(self): return { 'id' : self.id, 'name': self.name, 'address1' : self.address1, 'address2': self.address2, 'phone' : self.phone, 'lat': self.lat, 'lng' : self.lng, 'cost': self.cost, 'menu_type' :...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(self, obj):\n return obj", "def GetDataAsObject(self):", "def serialize(self, obj):\n pass", "def serialize(self, data):\n return data", "def SerializeObject(self, data):\n\n if isinstance(data,dict):\n serializad_data = json.dumps(data)\n else:\n...
[ "0.777154", "0.7626386", "0.7566185", "0.7525398", "0.74336725", "0.7321529", "0.7315361", "0.7281728", "0.7163479", "0.7155347", "0.7148642", "0.7124317", "0.7099167", "0.70400804", "0.70074207", "0.6971844", "0.6960608", "0.6955735", "0.6948549", "0.69371045", "0.69215906",...
0.67694086
45
u {l1} and r {l} new should be of equal sizes to be concatenated
def __init__(self, in_channels_r, out_channels_r, in_channels_u, out_channels, kernel_size_in, kernel_size_out, up_stride_in, stride_out, up_padding_in, padding_out, output_padding=0, activation_in='lrelu', activation_out='lrelu',...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concatenate_data():", "def rejoin(l0,l1=None):\r\n while len(l0) != 0:\r\n if l1 is None:\r\n l1 = []\r\n if l0[0] == '<':\r\n if len(l0) >= 3:\r\n if l0[2] == '>':\r\n l1 += [l0.pop(0) + l0.pop(0) + l0.pop(0)]\r\n else:\r\n ...
[ "0.6007597", "0.5953543", "0.58370024", "0.57667744", "0.56314075", "0.5579645", "0.5569091", "0.5529879", "0.55260503", "0.5507611", "0.5504095", "0.5491118", "0.5489259", "0.5442784", "0.5399009", "0.5395347", "0.5387921", "0.5385343", "0.5382747", "0.5379792", "0.5364914",...
0.0
-1