query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Returns a fractional mask from a result array, where the fractional mask describes whether the evaluated value in the result array is within the ``Grid2DIterate``'s specified fractional accuracy. The fractional mask thus determines whether a pixel on the grid needs to be reevaluated at a higher level of subgridding to ... | def threshold_mask_via_grids_from(
self, grid_lower_sub_2d: Grid2D, grid_higher_sub_2d: Grid2D
) -> Mask2D:
threshold_mask = Mask2D.all_false(
shape_native=grid_lower_sub_2d.shape_native,
pixel_scales=grid_lower_sub_2d.pixel_scales,
invert=True,
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_evaluation(annotation_mask, result_mask, idx):\n\n true_positive = np.sum(np.logical_and(annotation_mask == 255, result_mask == 255)) \n false_positive = np.sum(np.logical_and(result_mask == 255, annotation_mask != result_mask))\n false_negative = np.sum(np.logical_and(annotation_mask == 255,... | [
"0.540261",
"0.5198657",
"0.5171135",
"0.5063427",
"0.5014532",
"0.48458305",
"0.4784179",
"0.4779883",
"0.46855587",
"0.46468997",
"0.46343517",
"0.4627272",
"0.46060577",
"0.4589445",
"0.45833278",
"0.45417356",
"0.45366517",
"0.45316955",
"0.44950017",
"0.4484353",
"0.4469... | 0.43678007 | 28 |
Returns a given vector in normalized form. | def normalize(vector):
return vector / np.linalg.norm(vector) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normalized_vector(vector):\n # WARN: Zero length may cause problems!\n vector_lenght = get_vector_length(vector)\n if vector_lenght != 0:\n return np.divide(vector, get_vector_length(vector))\n else:\n return [0, 0]",
"def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n ... | [
"0.8575221",
"0.83980185",
"0.8287421",
"0.8287125",
"0.82777345",
"0.82405454",
"0.81163174",
"0.81054735",
"0.8068462",
"0.80491674",
"0.79364955",
"0.78791",
"0.7850027",
"0.7793986",
"0.7793986",
"0.7793986",
"0.77850926",
"0.77850926",
"0.77850926",
"0.77850926",
"0.7785... | 0.8422281 | 1 |
Calculate the absorption coefficient alpha | def opacity_sobolev(nu, T, n_l, rv, velocity_gradient, delta_lambda, points, line='halpha'):
n_l_cgs = n_l * 1e-6
balmer_properties = {'wavelength': {'halpha': 6562.8e-10, 'hbeta': 4861.35e-10, 'hgamma': 4340.47e-10, 'hdelta': 4101.73e-10},
'f_osc': {'halpha': 6.407e-1, 'hbeta': 1.1938e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha(self):\n sinOmg = np.sin(self.omega())\n return self.a1()/c.c*sinOmg",
"def _alpha(self):\n return _handle_ab(self.solution, self.use_const)[0]",
"def alpha(self,k1,k2,c):\n if k1 == 0.:\n return 0.\n else:\n return 1. + k2*c/k1",
"def alpha(... | [
"0.75805193",
"0.7271462",
"0.7158083",
"0.71428406",
"0.71282536",
"0.7086047",
"0.7055735",
"0.6872783",
"0.67840075",
"0.67840075",
"0.67840075",
"0.6741391",
"0.66441727",
"0.66424114",
"0.6641569",
"0.6568208",
"0.654783",
"0.6543631",
"0.65415496",
"0.6518507",
"0.64807... | 0.0 | -1 |
Calculate the absorption coefficient alpha where the absorption profile is rectangular. | def opacity_rectangular(nu, T, n_l, lambda_binsize, Blu, rv, velocity_gradient,points, line='halpha'):
n_l_cgs = n_l * 1e-6
balmer_properties = {'wavelength': {'halpha': 6562.8e-10, 'hbeta': 4861.35e-10, 'hgamma': 4340.47e-10, 'hdelta': 4101.73e-10},
'f_osc': {'halpha': 6.407e-1, 'hbeta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_alpha(color, F, B):\n return np.dot(color - B, F - B) / np.dot(F - B, F - B)",
"def alpha(self) -> float:\n return self.intrinsic_matrix[0, 1]",
"def comp_alphas(self):\n Rbo = self.get_Rbo()\n\n # alpha_Tt is the angle of the tooth to have the correct top width\n alpha_Tt = 2 ... | [
"0.67454916",
"0.669358",
"0.64711595",
"0.6469706",
"0.630655",
"0.6296904",
"0.6265656",
"0.623285",
"0.62106323",
"0.6010228",
"0.60099864",
"0.5963514",
"0.59502864",
"0.5948576",
"0.5944377",
"0.592804",
"0.591576",
"0.591576",
"0.591576",
"0.59120184",
"0.58645076",
"... | 0.53438336 | 71 |
Calculate the absorption coefficient alpha | def opacity_both(nu, T, n_HI, n_e, n_l, delta_gridpoints, Blu, rv, velocity_gradient, points, line='halpha'):
n_l_cgs = n_l * 1e-6
balmer_properties = {'wavelength': {'halpha': 6562.8e-10, 'hbeta': 4861.35e-10, 'hgamma': 4340.47e-10, 'hdelta': 4101.73e-10},
'f_osc': {'halpha': 6.407e-1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha(self):\n sinOmg = np.sin(self.omega())\n return self.a1()/c.c*sinOmg",
"def _alpha(self):\n return _handle_ab(self.solution, self.use_const)[0]",
"def alpha(self,k1,k2,c):\n if k1 == 0.:\n return 0.\n else:\n return 1. + k2*c/k1",
"def alpha(... | [
"0.75805193",
"0.7271462",
"0.7158083",
"0.71428406",
"0.71282536",
"0.7086047",
"0.7055735",
"0.6872783",
"0.67840075",
"0.67840075",
"0.67840075",
"0.6741391",
"0.66441727",
"0.66424114",
"0.6641569",
"0.6568208",
"0.654783",
"0.6543631",
"0.65415496",
"0.6518507",
"0.64807... | 0.0 | -1 |
Calculate the absorption coefficient alpha | def opacity(nu, T, n_HI, n_e, n_l, rv, line='halpha'):
n_l_cgs = n_l * 1e-6
balmer_properties = {'wavelength': {'halpha': 6562.8e-10, 'hbeta': 4861.35e-10, 'hgamma': 4340.47e-10, 'hdelta': 4101.73e-10},
'f_osc': {'halpha': 6.407e-1, 'hbeta': 1.1938e-1, 'hgamma': 4.4694e-2, 'hdelta': 2.2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha(self):\n sinOmg = np.sin(self.omega())\n return self.a1()/c.c*sinOmg",
"def _alpha(self):\n return _handle_ab(self.solution, self.use_const)[0]",
"def alpha(self,k1,k2,c):\n if k1 == 0.:\n return 0.\n else:\n return 1. + k2*c/k1",
"def alpha(... | [
"0.75805193",
"0.7271462",
"0.7158083",
"0.71428406",
"0.71282536",
"0.7086047",
"0.7055735",
"0.6872783",
"0.67840075",
"0.67840075",
"0.67840075",
"0.6741391",
"0.66441727",
"0.66424114",
"0.6641569",
"0.6568208",
"0.654783",
"0.6543631",
"0.65415496",
"0.6518507",
"0.64807... | 0.0 | -1 |
Creates a PlatformParameterModel instance. | def create(
cls,
param_name: str,
rule_dicts: List[platform_parameter_domain.PlatformParameterRuleDict],
rule_schema_version: int,
default_value: platform_parameter_domain.PlatformDataTypes
) -> PlatformParameterModel:
return cls(
id=param_name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createParameter(self):\n return _libsbml.Model_createParameter(self)",
"def createParameter(self, name, value):\r\n parameter = Parameter(self)\r\n self.callRemote('createParameter', name, value).chainDeferred(parameter)\r\n return parameter",
"def remote_createParameter(self, n... | [
"0.6038443",
"0.5898745",
"0.57178617",
"0.54691094",
"0.5428996",
"0.52719665",
"0.52563184",
"0.5229282",
"0.5225646",
"0.5200385",
"0.5198576",
"0.5181845",
"0.5179588",
"0.517855",
"0.5129397",
"0.51045793",
"0.5091119",
"0.50768375",
"0.50669825",
"0.5065463",
"0.5036845... | 0.76449805 | 0 |
Routine for determining the index mu such that t_mu <= x < t_mu+1. If x is larger than t[1], then the last index is returned, for convenience sake. If x is smaller than t[0], then the first index is returned, for convenience sake. | def index(x, t):
if x < t[0]:
return 0
for i in range(len(t) - 1):
if t[i] <= x < t[i + 1]:
return i
return len(t) - 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_index(self, u):\n if u == self.grid[-1]: # check if u equals last knot\n# index = len(self.grid) - 2 # pick next to last index\n index = (self.grid < u).argmin() - 1\n else:\n index = (self.grid > u).argmax() - 1\n return index",
"def _get_indx(self... | [
"0.6467503",
"0.6289578",
"0.62218434",
"0.60289025",
"0.59865326",
"0.59564394",
"0.5892032",
"0.5744281",
"0.57170856",
"0.5653306",
"0.5653306",
"0.5596471",
"0.5575372",
"0.5501344",
"0.5484174",
"0.5461618",
"0.54523337",
"0.5445007",
"0.5395855",
"0.5392234",
"0.5381911... | 0.7450273 | 0 |
Get the directory the script is being run from | def getScriptDirectory():
return os.path.dirname(os.path.realpath(__file__)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_script_directory():\n return os.path.dirname(__file__)",
"def getScriptPath():\n\treturn os.path.dirname(os.path.realpath(sys.argv[0]))",
"def get_current_directory():\n\treturn os.path.dirname(os.path.abspath(__file__))",
"def _current_script_dir(self):\n if self._script_dir:\n ... | [
"0.9032008",
"0.85514134",
"0.84030205",
"0.8204221",
"0.8180877",
"0.79245794",
"0.79154485",
"0.7863617",
"0.78479075",
"0.7799003",
"0.77155125",
"0.77155006",
"0.7712691",
"0.7662973",
"0.76583695",
"0.7639003",
"0.7633195",
"0.7625982",
"0.7607391",
"0.7600444",
"0.75781... | 0.8963206 | 1 |
Computes photon wavelength in m E is photon energy in eV | def lam(E):
return (12398.4/E)*1e-10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wavelength(energy):\r\n return 2 * np.pi * PLANCK_CONSTANT * SPEED_OF_LIGHT / energy",
"def photon_energy_to_wavelength(photon_energy):\n return 1.23984197386209e-06 / photon_energy",
"def wavelength(energy):\n return 2 * PI * PLANCK_CONSTANT * SPEED_OF_LIGHT / energy",
"def wavelength_to_photon... | [
"0.7718985",
"0.7642262",
"0.7588794",
"0.73797166",
"0.7176949",
"0.69914687",
"0.6837897",
"0.67762446",
"0.67741716",
"0.67048854",
"0.6668647",
"0.6616758",
"0.65861285",
"0.6564983",
"0.64233637",
"0.64233637",
"0.6356801",
"0.6292961",
"0.62876594",
"0.62810636",
"0.627... | 0.5720966 | 73 |
Computes the photon wavelength in m f is the photon frequency in Hz | def f2lam(f):
l=c['c']/f
return l | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wavelength(self,freq):\n return self.phase_velocity()/freq",
"def mtof(p):\n return 440.0 * 2 ** ((p - 69) / 12.0)",
"def photon_energy_to_wavelength(photon_energy):\n return 1.23984197386209e-06 / photon_energy",
"def wavelength(energy):\r\n return 2 * np.pi * PLANCK_CONSTANT * SPEED_OF_... | [
"0.76552045",
"0.7354487",
"0.7335382",
"0.7217696",
"0.72035086",
"0.7099578",
"0.70643204",
"0.7044682",
"0.69830227",
"0.6874363",
"0.6851119",
"0.6847966",
"0.6847966",
"0.6812081",
"0.6808982",
"0.6786479",
"0.6760791",
"0.6733954",
"0.66572225",
"0.6639089",
"0.6603311"... | 0.0 | -1 |
Computes the photon in energy in eV f is the photon frequency in Hz | def f2E(f):
E=c['h']*f*u['eV']
return E | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_Photon(freq=1.0,energy=0.0):\n global r,c,h\n if freq ==0:\n print(\"enerji yok...\")\n return 0\n if energy != 0:\n energy =energy\n else:\n energy = h*freq\n getit =str(input(\"frekans bulmak istiyorsaniz f,yoksa bos gecin.\"))\n if getit ==\"f\":\n ... | [
"0.75582814",
"0.7010123",
"0.6980056",
"0.6860616",
"0.67464495",
"0.66993487",
"0.66138697",
"0.66058874",
"0.65789384",
"0.64807785",
"0.64652133",
"0.64642763",
"0.64283204",
"0.6425996",
"0.6407731",
"0.64068997",
"0.6403905",
"0.64035344",
"0.6370066",
"0.63126194",
"0.... | 0.5724887 | 93 |
Return the average atom weight in g/mol | def atomWeight(matID):
mat = goodID(matID)
compound = xl.CompoundParser(mat)
mass = 0.0
for i in range(compound['nElements']):
mass += xl.AtomicWeight(compound['Elements'][i]) * compound['massFractions'][i]
return mass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meanMolecularWeight(self):\n return _cantera.phase_meanmolwt(self._phase_id)",
"def molecular_weight(self):\n mw = 0.0\n for a in self.allAtoms:\n try:\n mw += self.atomic_weight[a.element]\n except KeyError as key:\n print(\"Unknown el... | [
"0.7428603",
"0.73206",
"0.68543315",
"0.6735723",
"0.65982187",
"0.65982187",
"0.65982187",
"0.6588203",
"0.6512015",
"0.64679813",
"0.6382028",
"0.6346343",
"0.6338674",
"0.6314785",
"0.6290057",
"0.6283606",
"0.6278108",
"0.6278108",
"0.6261621",
"0.62610686",
"0.62504274"... | 0.6954688 | 2 |
Return the molar mass as g/mol | def molarMass(matID):
mat = goodID(matID)
compound = xl.CompoundParser(mat)
return atomWeight(matID) * compound['nAtomsAll'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def molar_mass_amu():\n return Equivalency([(si.g / si.mol, misc.u)], \"molar_mass_amu\")",
"def molar_mass_dry_air():\n return 28.9647",
"def mu(self):\n return self.mass * G",
"def calculate_molar_mass(collector):\n avg_temp = collector.get_average_temperature()\n avg_acceleratio... | [
"0.74213403",
"0.73191154",
"0.7141935",
"0.7074142",
"0.69905573",
"0.69690686",
"0.6968213",
"0.6919618",
"0.68583095",
"0.67381555",
"0.6718499",
"0.66173255",
"0.6593325",
"0.6585546",
"0.65702826",
"0.65114176",
"0.65034044",
"0.65034044",
"0.65002054",
"0.649447",
"0.64... | 0.6663713 | 11 |
Calculate the mass attenuation coefficients (1/m) at given energies | def mu(matID, keV, density=None):
mat = goodID(matID)
if density == None:
density = defaultDensity(matID)
if np.isscalar(keV):
energies = np.array([keV], dtype=np.double)
else:
energies = np.array(keV, dtype=np.double)
_mu = np.array([xl.CS_Total_CP(mat, eng) * density * u['c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_attenuation_coefficient(self, lines):\n wl = lines.to(\"nm\", \"spectroscopy\").magnitude\n if isarray(wl):\n return [self.getExtinctionCoefficient(l) for l in wl]\n else:\n return self.getExtinctionCoefficient(wl)",
"def mass_energy():\n ... | [
"0.6252447",
"0.6237623",
"0.60793096",
"0.5906701",
"0.59001994",
"0.5900195",
"0.58920497",
"0.5859726",
"0.5857189",
"0.58342105",
"0.5829927",
"0.58216125",
"0.5804701",
"0.57791084",
"0.576311",
"0.567844",
"0.5677239",
"0.566387",
"0.5661748",
"0.56613755",
"0.5651772",... | 0.0 | -1 |
Calculate the attenuation length (m) at given energies E in keV (vectorized) density in g/cm3, None=default density | def attenuationLength(matID, keV, density=None):
return 1.0 / mu(matID, keV, density) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debye_length_m(electron_density, electron_temperature):\n return 0.069 * np.sqrt(electron_temperature / electron_density)",
"def energy(e: float) -> float:\n\n return (1/np.sqrt(2))*(gamma(-e/2+1/2)/(gamma(-e/2+3/4)))",
"def debye_length(eps_0, electron_temperature, electron_density, elementary_charg... | [
"0.69875747",
"0.683513",
"0.68281406",
"0.64340115",
"0.640952",
"0.6275915",
"0.6182579",
"0.6081061",
"0.60733867",
"0.59705806",
"0.59496653",
"0.59434277",
"0.59365296",
"0.590933",
"0.5900445",
"0.5885812",
"0.58835375",
"0.5881771",
"0.5863816",
"0.58308667",
"0.582880... | 0.6993646 | 0 |
Calculate the eV/atom at given energies | def eVatom(matID, keV, mJ, rms_mm, density=None):
if density == None:
density = defaultDensity(matID)
attL = attenuationLength(matID, keV, density)
EdensityJcm3 = mJ/1000 / (2 * np.pi * attL*u['cm'] * (rms_mm*0.1)**2)
atomVolcm3 = atomWeight(matID) / c['NA'] / density
return EdensityJcm3 * a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calc_energy( self, V_a, eos_d ):\n pass",
"def calcEVals(self):\n self.eVals,self.eVecs = np.linalg.eigh(self.rhoOp)",
"def energy(self):\n self.E = - np.sum(self.phi) + 0.5 * self.mass * np.sqrt((self.v_x ** 2 + self.v_y **2))",
"def energy(e: float) -> float:\n\n return (1/np.s... | [
"0.7508632",
"0.7372567",
"0.72677183",
"0.7163756",
"0.7136966",
"0.70494306",
"0.7042038",
"0.7004612",
"0.6839347",
"0.6825977",
"0.68114936",
"0.68095696",
"0.6808786",
"0.6807677",
"0.6786194",
"0.6767813",
"0.67579764",
"0.67347634",
"0.67287016",
"0.66870046",
"0.66575... | 0.59766996 | 95 |
Calculate the eV/atom at given energies with mu_en | def eVatom_en(matID, keV, mJ, rms_mm, density=None):
if density == None:
density = defaultDensity(matID)
attL = 1.0 / mu_en(matID, keV, density)
EdensityJcm3 = mJ/1000 / (2 * np.pi * attL*u['cm'] * (rms_mm*0.1)**2)
atomVolcm3 = atomWeight(matID) / c['NA'] / density
return EdensityJcm3 * atom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def V2E(V):\n# for v in m/s returns energy in meV\n return 5.227e-6*V*V",
"def _calc_energy( self, V_a, eos_d ):\n pass",
"def get_o_energies(mol):\n try:\n ev_to_hartree = 1./convertor(1,'hartree','eV')\n g=hack_parser.Gaussian(mol.calc.log, loglevel=50)\n d=g.parse()\n ... | [
"0.70589775",
"0.677859",
"0.6765921",
"0.67600095",
"0.6704203",
"0.6699837",
"0.6672238",
"0.664315",
"0.66347003",
"0.66338253",
"0.6538472",
"0.6527403",
"0.6355422",
"0.63233757",
"0.63145655",
"0.6307296",
"0.62996507",
"0.6297362",
"0.62903994",
"0.62738526",
"0.625709... | 0.68466586 | 1 |
Get integrated heat capacity in J/mol T1, T2 in K | def getIntCp(matID, T1_K, T2_K):
goodID(matID, 'Cp')
if matID in specificHeatParams:
A = specificHeatParams[matID]
return intCp2(T1_K, T2_K, A)
else:
raise Exception(f'Wrong material {matID}: Only support materials within specificHeatParams.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heatCapacity(self, Tk=None, Tc=None):\n Tk = getTk(Tc, Tk)\n self.checkPropertyTempRange(\"heat capacity\", Tk)\n return (\n sum(\n [\n +1.38642e-13 * Tk**4,\n -6.47481e-10 * Tk**3,\n +1.02345e-06 * Tk**2,\n... | [
"0.7052304",
"0.66729563",
"0.6499355",
"0.6234018",
"0.610847",
"0.61031497",
"0.60763925",
"0.6059473",
"0.59271187",
"0.5921819",
"0.5901262",
"0.5900872",
"0.58959717",
"0.58786666",
"0.58646834",
"0.5833922",
"0.5831791",
"0.5828057",
"0.579185",
"0.5747869",
"0.5731908"... | 0.0 | -1 |
Computes the d spacing (m) of the specified material and reflection | def dSpace(ID,hkl):
ID = goodID(ID)
h=hkl[0]
k=hkl[1]
l=hkl[2]
lp=latticeParameters[ID]
a=lp[0]/u['ang']
b=lp[1]/u['ang']
c=lp[2]/u['ang']
alpha=lp[3]
beta=lp[4]
gamma=lp[5]
ca=cosd(alpha)
cb=cosd(beta)
cg=cosd(gamma)
sa=sind(alpha)
sb=sind(beta)
sg=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Density(material):\n if material == \"mild\":\n return 7850.0\n else:\n if material == \"al\":\n return 2700.0\n else:\n raise ValueError(\"Invalid material `\"+material+\"'\")",
"def dndM(self,M,z):\n G = self.Growth(z)\n _,_,mf = self.mass_func... | [
"0.5791452",
"0.57363826",
"0.54793894",
"0.5472913",
"0.541863",
"0.5322831",
"0.5271524",
"0.5220121",
"0.5219725",
"0.5149651",
"0.5139184",
"0.50905675",
"0.50732553",
"0.50541776",
"0.503615",
"0.5034007",
"0.5033631",
"0.5013977",
"0.5012649",
"0.49741548",
"0.4968204",... | 0.0 | -1 |
Computes the delta E corresponding to the Darwin width for a specified crystal reflection (degrees) | def DarwinWidthE(ID, hkl, E, T=293):
E = eV(E)
return DeltaEoE(ID, hkl, E, T) * E
# ID = goodID(ID)
# E = eV(E)
# dw = DarwinWidth(ID,hkl,E,T)
# theta = BraggAngle(ID,hkl,E)
# DeltaEoE = 1/tand(theta) * dw * u['rad']
# DeltaE = DeltaEoE * E
# return DeltaE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDiameter(self):\n\n hdr = self.header\n if \"cd1_1\" in hdr:\n self.D = abs(hdr[\"cd1_1\"]) * hdr[\"naxis1\"]\n elif \"cdelt1\" in hdr:\n self.D = abs(hdr[\"cdelt1\"]) * hdr[\"naxis1\"]\n else:\n print(\"Warning: no coordinate information found i... | [
"0.6305159",
"0.628104",
"0.61090827",
"0.6099441",
"0.6003955",
"0.5969684",
"0.59541386",
"0.58690524",
"0.5837903",
"0.58183527",
"0.5788124",
"0.5761929",
"0.5751232",
"0.5731895",
"0.5719951",
"0.57171685",
"0.5686599",
"0.5649855",
"0.5640603",
"0.5612785",
"0.5608334",... | 0.62418085 | 2 |
Alteration to the offical SummaryWriter from PyTorch, which creates a new tensorboard event file with the hyperparameters and adds additional scalars to the scalartab with the registered metric value. This is unfortunate behavior, and the below merely adds the hyperparameters to the existing eventfile. | def add_hparams(self, hparam_dict, metric_dict):
torch._C._log_api_usage_once("tensorboard.logging.add_hparams")
if type(hparam_dict) is not dict or type(metric_dict) is not dict:
raise TypeError('hparam_dict and metric_dict should be dictionary.')
exp, ssi, sei = hparams(hparam_dict... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_tensorboard(base, metrics, training, step, writer):\n\n tag = \"{}/{}\".format(base, \"train\" if training else \"val\")\n\n writer.add_scalars(tag, metrics, step)",
"def _write_weight_histogram_to_tensorboard(\n self, name: str, weight: DLTypes.WeightType, step: int\n ):\n pa... | [
"0.61675715",
"0.6129573",
"0.61244494",
"0.60987085",
"0.59445614",
"0.5911755",
"0.59107924",
"0.5841179",
"0.58267045",
"0.5798979",
"0.5740645",
"0.5712491",
"0.56752306",
"0.5646024",
"0.5636965",
"0.56225586",
"0.55613816",
"0.55318564",
"0.55298287",
"0.55234826",
"0.5... | 0.6085192 | 4 |
Sends a 401 response that enables basic auth | def authenticate():
return Response(
'Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )",
"def authenticate():\n return Response(\n 'You have to login with pro... | [
"0.8093736",
"0.80926424",
"0.7958403",
"0.7852648",
"0.7843114",
"0.7824419",
"0.776624",
"0.7754693",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.771945",
"0.7667712",
"0.7664151",
"0.76493174",
"0.76140213",
"0.76131... | 0.7810746 | 25 |
Specifies that the class is a planning entity. Each planning entity must have at least 1 PlanningVariable property. The class MUST allow passing None to all of __init__ arguments, so it can be cloned. | def planning_entity(entity_class):
ensure_init()
out = JImplements('org.optaplanner.optapy.OpaquePythonReference')(entity_class)
out.__javaClass = _generate_planning_entity_class(entity_class)
_add_deep_copy_to_class(out)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, initial, goal=(3, 3, 0, 0, 0)):\n\n self.goal = goal\n Problem.__init__(self, initial, goal)",
"def __init__(self):\r\n \r\n # World params\r\n self.spawn_distance = 0\r\n\r\n # Nest planning\r\n self.done_init = False\r\n self.wall_set =... | [
"0.5589948",
"0.5581126",
"0.55328023",
"0.5435785",
"0.54008275",
"0.53800786",
"0.53735876",
"0.5358138",
"0.5339011",
"0.5339011",
"0.53295225",
"0.5272971",
"0.52545625",
"0.5220482",
"0.5209913",
"0.52015144",
"0.51990515",
"0.51923585",
"0.51741636",
"0.5168528",
"0.515... | 0.55008984 | 3 |
Sample initial states by taking random number of noops on reset. Noop is assumed to be action 0. | def __init__(self, env, noop_max=30):
super().__init__(env)
self.noop_max = noop_max
self.noop_action = 0
assert env.unwrapped.get_action_meanings()[0] == 'NOOP' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self, **kwargs):\n self.env.reset(**kwargs)\n noops = self.unwrapped.np_random.randint(1, self.noop_max + 1)\n obs = None\n for _ in range(noops):\n obs, _, done, _ = self.env.step(self.noop_action)\n if done:\n obs = self.env.reset(**kwarg... | [
"0.7220573",
"0.7218107",
"0.70735174",
"0.7022051",
"0.7017444",
"0.6946022",
"0.6893083",
"0.6888874",
"0.6792307",
"0.67864877",
"0.66359997",
"0.6548219",
"0.6544826",
"0.64771396",
"0.64689976",
"0.6465279",
"0.64268816",
"0.6426747",
"0.6426265",
"0.64195555",
"0.637647... | 0.0 | -1 |
Bin reward to {+1, 0, 1} by its sign. | def reward(self, reward):
return np.sign(reward) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reward(self, reward):\r\n return np.sign(reward)",
"def reward(self, reward):\n return float(np.sign(reward))",
"def sign(x):\n return(copysign(1, x))",
"def sign(self):\n return 1 - 2 * self._ltz()",
"def sign(self, inputs):\n pass",
"def sign(self, inputs):\n pass"... | [
"0.71697664",
"0.66509384",
"0.6515038",
"0.61945957",
"0.6051103",
"0.6051103",
"0.6046361",
"0.6012344",
"0.59601265",
"0.59504265",
"0.5904576",
"0.5820199",
"0.58148813",
"0.57996655",
"0.5713134",
"0.5707423",
"0.5689205",
"0.56575656",
"0.56444323",
"0.56282294",
"0.562... | 0.70802456 | 5 |
Tests updating aesthetic fields on Tenant | def test_tenant_update(sample_identity):
access_token, tenant, tenant_user, tc = sample_identity
tenant.name = "ilovebeansllc"
headers = {"Authorization": "Bearer " + access_token}
updated_tenant_request = id_schemas.TenantSchema().dump(tenant)
updated_tenant = tc.put(
f"api/v1/identity/tena... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tenant_user_aesthetic_update(sample_identity):\n access_token, tenant, tenant_user, tc = sample_identity\n headers = {\"Authorization\": \"Bearer \" + access_token}\n new_email = f\"{uuid.uuid4()}@c1.com\"\n new_first_name = str(uuid.uuid4())\n new_last_name = str(uuid.uuid4())\n updated... | [
"0.74706066",
"0.70539707",
"0.70173454",
"0.6784828",
"0.66443217",
"0.6637554",
"0.6588656",
"0.6583764",
"0.6583764",
"0.6583764",
"0.6574935",
"0.6535326",
"0.6534278",
"0.65183234",
"0.6483002",
"0.64679134",
"0.6450146",
"0.6431829",
"0.6415476",
"0.64035213",
"0.639738... | 0.7749024 | 0 |
Point with the given offset from the given point. | def offset_by(lon, lat, posang, distance):
# Calculations are done using the spherical trigonometry sine and cosine rules
# of the triangle A at North Pole, B at starting point, C at final point
# with angles A (change in lon), B (posang), C (not used, but negative reciprocal posang)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_at_offset(self, offset):\n if offset > self.length():\n raise ValueError(\"Offset ({0})is greater than segment length ({1})\".format(offset, self.length()))\n dx = self.b.x - self.a.x\n dy = self.b.y - self.a.y\n linelen = math.hypot(dx, dy)\n\n return Point(... | [
"0.7713544",
"0.7500018",
"0.7447083",
"0.74095315",
"0.65110433",
"0.6407543",
"0.6362605",
"0.62644905",
"0.6243919",
"0.6231472",
"0.6186376",
"0.6127296",
"0.5993346",
"0.5959296",
"0.5928464",
"0.59195495",
"0.5867954",
"0.585459",
"0.5849837",
"0.58097494",
"0.58071303"... | 0.0 | -1 |
Create an unresolved Entry for this builder. Calls `_CONTEXT.on_entry` to register/check dependencies etc. | def __call__(self, config):
entry = Entry(self.name, make_key(config), config, None, None, None)
if not hasattr(_CONTEXT, "on_entry"):
return entry
on_entry = _CONTEXT.on_entry
if on_entry:
on_entry(entry)
return entry | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_entry(entry):\n Entry.create(**entry)\n return entry",
"def get_entry(self):\n # Filter out any fields that are invalid for the type of a new entry.\n properties = {\n field: value\n for field, value in self.properties.items()\n if field in self.typ... | [
"0.62241614",
"0.57561404",
"0.57318985",
"0.5663275",
"0.56416744",
"0.55154335",
"0.53690875",
"0.5359811",
"0.53573525",
"0.52931273",
"0.5256571",
"0.52439976",
"0.5211755",
"0.52079546",
"0.51699185",
"0.5136273",
"0.5114029",
"0.50949085",
"0.5077293",
"0.50508136",
"0.... | 0.5899941 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, Alert):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8089139",
"0.8089139",
"0.8054507",
"0.79827213",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Creates a survival class label list from a list of survival days categories are 0 for under 10 month survival, 1 for 1015 months and 2 for 15+ months | def categorize(y):
y_out = []
for yi in y:
if int(yi)<(365*10.0)/12.0:
y_out.append(0)
elif int(yi)<(365*15.0)/12.0:
y_out.append(1)
else:
y_out.append(2)
return np.array(y_out) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cvpr2018_labels():\n\n return {\n 0: 'others',\n 33: 'car',\n 34: 'motorcycle',\n 35: 'bicycle',\n 36: 'pedestrian',\n 38: 'truck',\n 39: 'bus',\n 40: 'tricycle'\n }",
"def _labels_for_historical_data(days: int, lang: str) -> List[str]:\n label... | [
"0.58232903",
"0.54263556",
"0.5314535",
"0.5298069",
"0.52912474",
"0.52161705",
"0.52161705",
"0.5207141",
"0.51999825",
"0.5147364",
"0.51438856",
"0.5126135",
"0.511763",
"0.51065487",
"0.50985366",
"0.50954306",
"0.5069807",
"0.5069807",
"0.5069807",
"0.50318503",
"0.503... | 0.587338 | 0 |
Formats keyvalue pairs into a string. | def render_attr(key, value, attr_format='{key}="{value}"'):
if not key or ' ' in key:
raise InvalidAttribute('Invalid name "{}"'.format(key))
if value:
if type(value) is RawNode:
value = str(value)
else:
value = html.escape(str(value))
return attr_forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_dict(kv_list):\n return '\\n'.join(['{} - {}'.format(key, value) for\n key, value in kv_list])",
"def format_tag_key_value(key: str, value: Any, max_length: int = 50) -> str:\n key = trim_string(key, max_length=max_length)\n value_str = trim_string(format_tag_valu... | [
"0.7382339",
"0.70097125",
"0.69886804",
"0.69435406",
"0.6925893",
"0.68692976",
"0.68466157",
"0.6813373",
"0.68111455",
"0.6705478",
"0.66385466",
"0.66350627",
"0.6613811",
"0.6563796",
"0.65591246",
"0.64990306",
"0.6475155",
"0.64583576",
"0.6454809",
"0.6448298",
"0.64... | 0.0 | -1 |
Set new password for the user | def reset_password(self, user_id, reset_code, password):
if not password:
raise DoorstepError('New password can\'t be blank.')
try:
user = self.get(id=user_id)
if not user.reset_code or user.reset_code != reset_code or user.reset_code_expire < timezone.now():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpassword(self, pwd):\n pass",
"def set_password(self, new_password):\n super(Mafiasi, self).set_password(new_password)\n self.new_password = new_password",
"def change_password(self):\n self.test_user.set_password(self.create_user_data()['password1'])\n self.test_user.... | [
"0.85625076",
"0.84197134",
"0.84045476",
"0.8324854",
"0.8196439",
"0.8067187",
"0.8015951",
"0.7982908",
"0.79221594",
"0.7921293",
"0.79066974",
"0.7902557",
"0.78806853",
"0.7870783",
"0.7867309",
"0.7854127",
"0.78511465",
"0.78445166",
"0.78221756",
"0.78202033",
"0.781... | 0.0 | -1 |
Remove leading text on variable names. | def remove_leading_text(inst, target=None):
if target is None:
return
elif isinstance(target, str):
target = [target]
elif (not isinstance(target, list)) or (not isinstance(target[0], str)):
raise ValueError('target must be a string or list of strings')
for prepend_str in targe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_name(x: str) -> str:\n x = x.replace(\", var.\", \" var.\")\n if \"{\" in x:\n x = x[:x.find(\"{\")-1]\n return x",
"def safe_formal_name(name):\n return re.sub(r\"\\s+\", \" \", re.sub(r'[!/\\\\:<>\"\\?\\*\\|]', \"\", name)).strip()",
"def normalize(s):\n s = str(s.strip())... | [
"0.6638469",
"0.65389246",
"0.6395497",
"0.6389507",
"0.63287926",
"0.62626815",
"0.6244013",
"0.6228783",
"0.61929065",
"0.61640257",
"0.61412144",
"0.60851556",
"0.6054423",
"0.602227",
"0.595736",
"0.59389913",
"0.5916294",
"0.59032863",
"0.58989096",
"0.587039",
"0.586797... | 0.585807 | 22 |
Create filenames as needed to support use of generated pysat data sets. | def filename_creator(value, format_str=None, start_date=None, stop_date=None):
estr = ''.join(('This feature has not been implemented yet and is here ',
'to support experimentation by the pysat team. If you are ',
'here intentionally, please contact the pysat developers ',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_filename(self):\n file_pattern = os.path.join(self.path, \"TCGA-*\")\n for f in glob(file_pattern):\n organ = get_organ(f)\n for raw_f in glob(os.path.join(f, \"*.tif\")):\n gt_f = raw_f.replace(\".tif\", \".xml\")\n yield raw_f, gt_f, ... | [
"0.690355",
"0.6853771",
"0.6809362",
"0.673915",
"0.67020744",
"0.66942877",
"0.6658102",
"0.6500855",
"0.6470896",
"0.645403",
"0.64270043",
"0.6413755",
"0.64010847",
"0.6393033",
"0.6370594",
"0.63543373",
"0.6306602",
"0.6296167",
"0.6285599",
"0.62806803",
"0.62518775",... | 0.0 | -1 |
Test a situation where we don't have any room to fit a 10 hour long meeting, and make sure free correctly doesn't give us any options. | def test_nothing_fits():
freetimes, _ = free([], 9, 0, 17, 0, day_range, 600)
fmt_freetime = output_format(freetimes)
for i in fmt_freetime:
print(i)
assert fmt_freetime == [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_meeting_polls(self):\n pass",
"def test_check_args_working_hours(self):\n test_date = dt.datetime(2021, 6, 18, 7, 0, 0)\n with self.assertRaises(ValueError) as context:\n self.duedate.check_args(test_date, self.test_turn_time)\n self.assertTrue(\n \"You ... | [
"0.6461312",
"0.6427224",
"0.63982356",
"0.63208705",
"0.62497026",
"0.62348133",
"0.6175124",
"0.61536694",
"0.6140344",
"0.6110118",
"0.6105791",
"0.60931855",
"0.6075776",
"0.60656667",
"0.6051703",
"0.60466737",
"0.6025748",
"0.6015936",
"0.5952996",
"0.5946169",
"0.59436... | 0.0 | -1 |
Transform a point by a pose. | def test_transform(self):
pt = np.array([1.0, 2.0, 3.0])
tr = pose.Pose()
tr.position = onp.array([4.0, 5.0, 6.0])
pt2 = tr.transform(pt)
self.assertLess(np.linalg.norm(pt2 - np.array([5.0, 7.0, 9.0])), 1e-6) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_transform_point(transform: Transform, point: Point) -> Point:\n\n transform_mat = alloy.math.transformation_matrix_from_array(alloy.ros.transform_to_numpy(transform))\n point_np = alloy.ros.point_to_numpy(point)\n point_np = np.append(point_np, 1).reshape((4,1))\n trans_point = np.matmul(transfo... | [
"0.7689383",
"0.75313944",
"0.7491983",
"0.717364",
"0.6967495",
"0.6942316",
"0.68925005",
"0.68116057",
"0.6775886",
"0.674591",
"0.6688146",
"0.6662814",
"0.66449785",
"0.6541229",
"0.65059096",
"0.64215887",
"0.64020514",
"0.6357577",
"0.63394284",
"0.62678653",
"0.625153... | 0.6632149 | 13 |
Creates a random training array of x and y values from the previously generated random training indices. | def createtrainingarrays(dataSize, xVariables, yVariable, TrainIndices):
# For the desired training indices, add the values to the training arrays
xTrainValues = np.array([])
yTrainValues = np.array([])
indexCounter = 0
for q in range(0, dataSize):
if TrainIndices.__contains__(q):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_rand():\n n_cols = 5\n n_rows = 100\n n_class = 10\n trial_x = np.random.rand(n_rows, n_cols)\n trial_y = np.random.random_integers(1, n_class, size = (n_rows, 1))\n\n # Append response to data\n trial_data = np.append(trial_x, trial_y, 1)\n return trial_data, n_class, n_cols",... | [
"0.6570673",
"0.6503485",
"0.64883083",
"0.64699143",
"0.62543833",
"0.61690664",
"0.61252266",
"0.6068083",
"0.60674566",
"0.6065398",
"0.60245997",
"0.6022316",
"0.60218686",
"0.60069555",
"0.59726936",
"0.5962033",
"0.59572494",
"0.5953861",
"0.59299576",
"0.5908545",
"0.5... | 0.6240317 | 5 |
Load weights from snapshot file | def load_weights(net, optimizer, scheduler, snapshot_file, restore_optimizer_bool=False):
logging.info("Loading weights from model %s", snapshot_file)
net, optimizer, scheduler, epoch, mean_iu = restore_snapshot(net, optimizer, scheduler, snapshot_file,
restore_optimizer_bool)
return epoch, mean... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_weights(self, filepath):\n self.model.load_weights(filepath)",
"def _load_weights(self):\n self.npz_weights = np.load(self._weight_file)\n self._load_byte_embedding()\n self._load_cnn_weights()\n self._load_highway()\n self._load_projection()",
"def load_weigh... | [
"0.7100965",
"0.7099289",
"0.70770496",
"0.69538385",
"0.69538385",
"0.6940326",
"0.6940326",
"0.6904215",
"0.686968",
"0.68578506",
"0.68147826",
"0.6770877",
"0.6694163",
"0.6670967",
"0.66293234",
"0.6612041",
"0.6583617",
"0.6533964",
"0.65129817",
"0.6429854",
"0.6425971... | 0.7182239 | 0 |
Restore weights and optimizer (if needed ) for resuming job. | def restore_snapshot(net, optimizer, scheduler, snapshot, restore_optimizer_bool):
checkpoint = torch.load(snapshot, map_location=torch.device('cpu'))
logging.info("Checkpoint Load Compelete")
if optimizer is not None and 'optimizer' in checkpoint and restore_optimizer_bool:
optimizer.load_state_dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _restore(self, checkpoint):\n checkpoint_path = os.path.join(checkpoint, \"model_weights\")\n self.model.load_weights(checkpoint_path)",
"def restore(self):\n\n self.brain.restore_checkpoint()",
"def restore(self):\n # For multi-worker training, it should not restore a model in ... | [
"0.7119056",
"0.70205605",
"0.6907856",
"0.68798095",
"0.6837659",
"0.6772707",
"0.6730122",
"0.65198785",
"0.6509292",
"0.6508566",
"0.64382255",
"0.6432103",
"0.63515466",
"0.63054734",
"0.6265027",
"0.6233326",
"0.6201555",
"0.6145458",
"0.6145122",
"0.61347353",
"0.612845... | 0.0 | -1 |
Checks if claims user belongs to Tenant or has override permissions to edit other Tenants | def check_tenant_authorization(tenant_id, override_permission=None):
claims = get_jwt_claims()
if "id" in list(claims.keys()):
tenant_user = identity.TenantUser.query.filter_by(id=claims["id"]).first()
if (
tenant_user.tenant_id == tenant_id
or override_permission in tena... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, user):\n return user == request.user or request.user.is_superuser",
"def has_object_permission(self, request, view, obj):\n\n #check if method is get i.e user only want to view\n if request.method in permissions.SAFE_METHODS:\n return... | [
"0.6689976",
"0.66579235",
"0.6575025",
"0.6559304",
"0.65221727",
"0.64526767",
"0.64456385",
"0.64339375",
"0.64206105",
"0.64158726",
"0.63980037",
"0.6397329",
"0.63969445",
"0.6390685",
"0.6379953",
"0.6357644",
"0.6335498",
"0.63311714",
"0.6319886",
"0.6311173",
"0.630... | 0.7168181 | 0 |
Get current position in bounding box format `(top left x, top left y, width, height)`. Returns ndarray The bounding box. | def to_tlwh(self):
ret = self.mean[:4].copy()
ret[2] -= ret[0]
ret[3] -= ret[1]
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bbox(self):\n return np.array(\n [[self.position[0], self.position[1]], [self.position[0], self.position[1]]]\n )",
"def boundingBox(self):\n y_max = np.max(self.points[:,0])\n x_max = np.max(self.points[:,1])\n y_min = np.min(self.points[:,0])\n x_min = n... | [
"0.77596384",
"0.76277995",
"0.74914104",
"0.7463242",
"0.7340598",
"0.7291298",
"0.7291298",
"0.7284453",
"0.7281455",
"0.72684383",
"0.7253557",
"0.725342",
"0.72211915",
"0.72211915",
"0.71617776",
"0.70993555",
"0.70709103",
"0.7034543",
"0.7002361",
"0.6985949",
"0.69722... | 0.0 | -1 |
Returns True if this track is dead and should be deleted. | def is_deleted(self):
return self.state == TrackState.Deleted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dead(self):\n return self.hearts <= 0",
"def is_dead(self):\n return self.hp <= 0",
"def is_dead(self):\n if self.killer:\n if self.killer.stype == 'fire' and not (self.killer in self.pjs.fires):\n return True\n elif self.killer.stype == 'enemy' ... | [
"0.73522246",
"0.73043823",
"0.73029953",
"0.7253518",
"0.7196813",
"0.69974554",
"0.68229127",
"0.6763713",
"0.6648157",
"0.6643092",
"0.6627581",
"0.66072875",
"0.6537883",
"0.633626",
"0.6273279",
"0.6250151",
"0.6248301",
"0.62391317",
"0.62285733",
"0.62271005",
"0.62231... | 0.7310355 | 2 |
Computes IUO between two bboxes in the form [x1,y1,x2,y2] | def _iou(self, bb_test,bb_gt):
xx1 = np.maximum(bb_test[0], bb_gt[0])
yy1 = np.maximum(bb_test[1], bb_gt[1])
xx2 = np.minimum(bb_test[2], bb_gt[2])
yy2 = np.minimum(bb_test[3], bb_gt[3])
w = np.maximum(0., xx2 - xx1)
h = np.maximum(0., yy2 - yy1)
wh = w * h
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bboxes_iou(boxes1, boxes2):\n boxes1 = np.array(boxes1)\n boxes2 = np.array(boxes2)\n boxes1_area = (boxes1[..., 2] - boxes1[..., 0]) * (boxes1[..., 3] - boxes1[..., 1])\n boxes2_area = (boxes2[..., 2] - boxes2[..., 0]) * (boxes2[..., 3] - boxes2[..., 1])\n left_up = np.maxim... | [
"0.7835872",
"0.76479733",
"0.75411224",
"0.7489639",
"0.7474853",
"0.7459696",
"0.7459484",
"0.7459484",
"0.7443315",
"0.7419611",
"0.73922247",
"0.7391839",
"0.7327725",
"0.7315838",
"0.73052406",
"0.7246565",
"0.7230692",
"0.72218716",
"0.7210955",
"0.7180109",
"0.70957893... | 0.0 | -1 |
Returns a string representation of the version information of this project. | def get_version():
return ".".join([str(i) for i in config["version"]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getVersionInfo(cls):\n\n return __version__ + \"\\n\"",
"def __str__(self):\n return self.version",
"def __repr__(self) -> str:\n return f'Version({self.major}, {self.minor}, {self.patch})'",
"def getVersionString():\n return str(version_gen.major) + \".\" + str(version_gen.minor... | [
"0.8182292",
"0.7585876",
"0.75506777",
"0.7505532",
"0.74372286",
"0.7423208",
"0.741231",
"0.7308783",
"0.7293368",
"0.72486275",
"0.72482157",
"0.7205356",
"0.7182546",
"0.7182546",
"0.7182546",
"0.7182546",
"0.71682525",
"0.7156679",
"0.71290743",
"0.7123848",
"0.71083623... | 0.0 | -1 |
Get the normalization scale of the colormap. This will be hyper based on the input min / max normalization \ values. For a 'symmetric_log' colormap, linthesh and linscale also change the colormap. If norm_min / norm_max are not supplied, the minimum / maximum values of the array of data_type are used. | def norm_from_array(self, array):
if self.norm_min is None:
norm_min = array.min()
else:
norm_min = self.norm_min
if self.norm_max is None:
norm_max = array.max()
else:
norm_max = self.norm_max
if self.norm in "linear":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cmap_normalisation(self):\n\n # Non-normalisable data should return cmap = None\n if not self.normalisable:\n return\n\n # Get min/max based upon ZScale with contrast parameter\n contrast = self.options.get('contrast', 0.2)\n vmin, vmax = ZScaleInterval(contra... | [
"0.72524613",
"0.6972815",
"0.6618555",
"0.6486291",
"0.6427787",
"0.6354715",
"0.6299304",
"0.62872404",
"0.6286947",
"0.6258192",
"0.6249495",
"0.6228602",
"0.6161088",
"0.6160016",
"0.6148347",
"0.61341983",
"0.6132477",
"0.6123037",
"0.61163986",
"0.60827184",
"0.6079793"... | 0.6358464 | 5 |
Close the connection to the server. | def quit(self, server_alerted: bool):
#: Ensure the server know's that we're quitting.
if not server_alerted:
try:
self.send("/quit")
except:
#: If this fails then no
#: connection is possible, so continue
#: to clean up.
pass
#: Close down the threads and the connection.
self.joined... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_connection(self):\n\n self._connection.close()\n print(\"Closed connection....\")",
"def close_connection(self):\n self.nodesocket.close()",
"def closeConnection(self):\n print(\"closing connection...\")\n self.s.close()\n quit()",
"def close_connection(sel... | [
"0.8024756",
"0.78988117",
"0.78597456",
"0.78560853",
"0.7834141",
"0.7810334",
"0.7797453",
"0.77865463",
"0.7783736",
"0.7783736",
"0.778099",
"0.775742",
"0.77461404",
"0.77322274",
"0.77180624",
"0.7700556",
"0.76925087",
"0.7677453",
"0.7664896",
"0.7664896",
"0.7664896... | 0.0 | -1 |
Returns a path within the media folder. | def path_in_medialib(filename, medialib='samples', overwrite=False):
filedir = os.path.dirname(os.path.abspath(__file__))
basedir = os.path.join(filedir, f'{medialib}/')
filepath = os.path.join(basedir, filename)
if not overwrite and os.path.exists(filepath):
counter = 1
while not os.pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_path(self):\n return self._path",
"def get_media_directory():\n\treturn _paths[_MEDIA_DIRECTORY_KEY]",
"def path_media(self) -> Path:\n return self.path_supervisor / MEDIA_DATA",
"def get_media_dir(self):\n dir_path = _paths.concat(self._gnbase, _DIRNAME_GNMEDIA)\n if no... | [
"0.84203607",
"0.81858176",
"0.7804115",
"0.7541061",
"0.74994236",
"0.7355289",
"0.71313196",
"0.71061504",
"0.70629007",
"0.70172185",
"0.68971485",
"0.68737835",
"0.681157",
"0.68090796",
"0.67766106",
"0.6737827",
"0.6737827",
"0.6669923",
"0.666317",
"0.66453886",
"0.662... | 0.0 | -1 |
Determine whether a position is actually on the board. | def on_board(self, pos):
i, j = pos
return 0 <= i < COLS and 0 <= j < ROWS | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_if_position_on_board(coord: tuple, board_size: int):\n in_row = coord[0] in range(board_size)\n in_col = coord[1] in range(board_size)\n return in_row and in_col",
"def in_board(self,pos : np.ndarray) -> bool:\r\n if 0 > pos[0] or pos[0] >= BOARD_SIZE:\r\n return False\r\n ... | [
"0.80705214",
"0.7999629",
"0.78791714",
"0.7729873",
"0.7538765",
"0.748726",
"0.72529185",
"0.7232605",
"0.7207643",
"0.716349",
"0.71262467",
"0.71225506",
"0.71194375",
"0.70848924",
"0.70833313",
"0.7071761",
"0.70679206",
"0.7066438",
"0.7058514",
"0.7044103",
"0.703895... | 0.78372264 | 3 |
Drop (and lock) curr_piece as far as possible, granting points equal to the distance of the drop. | def drop_curr_piece(self):
if self.over: return
delta = (0, 0) # now make this as big as possible
while True:
new_delta = tuple_add(delta, (0, 1))
if self.can_move_curr_piece(new_delta):
delta = new_delta
else:
break
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_curr_piece(self, delta, point=False):\n if self.over: return\n elif self.can_move_curr_piece(delta):\n self.curr_piece.confirm_move(delta)\n if point: self.increment_score(1)\n elif delta == (0,1): # \"illegal\" down move\n self.lock_curr_piece()\n ... | [
"0.65945",
"0.64016134",
"0.59951985",
"0.5804648",
"0.57469374",
"0.57464397",
"0.573787",
"0.5701909",
"0.5693444",
"0.566303",
"0.5634835",
"0.5607702",
"0.5607433",
"0.5579537",
"0.5576645",
"0.5542439",
"0.55122036",
"0.54979587",
"0.54958576",
"0.548495",
"0.5484019",
... | 0.8361154 | 0 |
Set the pool of servers used by this client. | def set_servers(self, servers):
self.servers = []
self.buckets = []
for server_desc in servers:
if type(server_desc) == tuple:
server_addr, weight = server_desc
else:
server_addr, weight = server_desc, 1
server = _ServerConnection(server_addr, weight, self._debuglog)
self.servers.append(se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_pool(self, server_pool):\n\n self._server_pool = server_pool",
"def set_servers(self, servers):\r\n self.servers = [_Host(s, self.debug, dead_retry=self.dead_retry,\r\n socket_timeout=self.socket_timeout)\r\n for s in servers]\r\n ... | [
"0.7319679",
"0.680685",
"0.6783699",
"0.6467647",
"0.6271275",
"0.615868",
"0.60961",
"0.60128826",
"0.5960502",
"0.5913157",
"0.58820456",
"0.5873742",
"0.5798574",
"0.5772111",
"0.5718808",
"0.5644137",
"0.55850923",
"0.55629134",
"0.5554513",
"0.55439126",
"0.55362344",
... | 0.7087884 | 1 |
Check that getting, setting, and deleting an object work as expected. | def check_setget(self, key, value):
yield self.conn.set(key, value)
new_value = yield self.conn.get(key)
self.assertEqual(new_value, value)
self.assert_((yield self.conn.delete(key)))
new_value = yield self.conn.get(key)
self.assertEqual(new_value, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get(self):\n objects = self.populate()\n for obj in objects:\n found = models.storage.get(type(obj), obj.id)\n self.assertIs(found, obj)\n for obj in objects:\n obj.delete()\n found = models.storage.get(type(obj), obj.id)\n self.a... | [
"0.687135",
"0.6869194",
"0.6750511",
"0.6626253",
"0.65565836",
"0.65089536",
"0.64209646",
"0.6346014",
"0.63143724",
"0.6287739",
"0.6254716",
"0.6201643",
"0.61983925",
"0.6194034",
"0.6165206",
"0.61537707",
"0.61463225",
"0.6140138",
"0.61308867",
"0.6113164",
"0.607181... | 0.58403534 | 43 |
determines this (self's) thread id | def _get_my_tid(self):
if not self.isAlive():
raise threading.ThreadError("the thread is not active")
# do we have it cached?
if hasattr(self, "_thread_id"):
return self._thread_id
# no, look for it in the _active dict
for tid, tobj in threading._active.items():
if tobj is self:
self._thread_id =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thread_id(self):\n return self._thread_id",
"def get_id(self):\n if hasattr(self, \"_thread_id\"):\n return self._thread_id\n for id, thread in threading._active.items():\n if thread is self:\n return id",
"def get_id(self):\n if hasattr(self... | [
"0.87604755",
"0.855684",
"0.855684",
"0.84960526",
"0.8430593",
"0.79912037",
"0.7944841",
"0.76469076",
"0.7611317",
"0.7069843",
"0.70444417",
"0.6986155",
"0.6953767",
"0.68797904",
"0.68797904",
"0.68797904",
"0.68797904",
"0.6876224",
"0.6822325",
"0.6800639",
"0.678210... | 0.806207 | 5 |
This function will search the booking of specific user id and car id then tell whether it exists or not | def bookingExists(self, user_id, car_id):
data = db.session.query(Booking).filter_by(user_id = user_id, car_id = car_id).first()
if data is None:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_bookings(bookingid, username, car_id):\n\n # get booking object for bookingid\n booking = Booking.query.get(bookingid)\n print(\"Booking:::\")\n print(booking)\n\n user = booking.customer\n print(\"User:::\")\n print(user)\n \n print(\"Params:::\"+bookingid+\"--\"+username+\... | [
"0.6837736",
"0.6354792",
"0.61274904",
"0.6110173",
"0.58761245",
"0.58010334",
"0.5644561",
"0.5604423",
"0.5591727",
"0.5572659",
"0.5558989",
"0.5531499",
"0.54869264",
"0.5457973",
"0.53667784",
"0.5342457",
"0.53367656",
"0.5316068",
"0.52929175",
"0.5258301",
"0.519973... | 0.79800326 | 0 |
Return last computed learning rate by current scheduler. | def get_last_lr(self):
if not hasattr(self, '_last_lr'):
raise RuntimeError("Run scheduler.step() first!")
return self._last_lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_lr(self) -> Tensor:\n\n return self.lr_scheduler.get_last_lr()",
"def get_learning_rate(self):\n config = self.config\n cur_lr = Train_model_pipeline.adjust_learning_rate(\n self.optimizer,\n self.epoch,\n config[\"training\"][\"learning_rate\"],... | [
"0.7769273",
"0.76568526",
"0.7607422",
"0.7512783",
"0.7506537",
"0.7461149",
"0.7436141",
"0.7349785",
"0.72943014",
"0.72450364",
"0.7220264",
"0.7183671",
"0.71548855",
"0.7150979",
"0.70551515",
"0.7010108",
"0.69940394",
"0.69894886",
"0.6972164",
"0.6972164",
"0.696085... | 0.7179609 | 12 |
Find the smallest and largest values in planes perpendicular to dir | def hminmax(s,iv=0,dir=2,i4=0,all=False,verbose=0):
pp=_patches(s)
p=pp[0]
xx=[]
hmin=[]
hmax=[]
for p in pp:
if all:
rr=p.xyz[dir]
else:
rr=p.xyzi[dir]
if iv in p.all_keys:
data=p.var(iv,all=all,i4=i4)
for i in range(data.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_perpendicular(n: np.ndarray) -> np.ndarray:\n # find smallest component\n i = np.argmin(n)\n\n # get the other two indices\n a = (i + 1) % 3\n b = (i + 2) % 3\n\n result = np.zeros(3)\n result[i] = 0.0\n result[a] = n[b]\n result[b] = -n[a]\n return result",
"def distance_fr... | [
"0.633757",
"0.6325897",
"0.5999939",
"0.58215743",
"0.57994306",
"0.5789848",
"0.5757493",
"0.57447475",
"0.57252127",
"0.57239264",
"0.5712923",
"0.56859016",
"0.56755674",
"0.5621076",
"0.5601583",
"0.55960625",
"0.559558",
"0.559558",
"0.5585564",
"0.55588734",
"0.5537385... | 0.5150106 | 91 |
Private method that returns a xapian.Database for use. | def _database(folder, writable=False):
if writable:
if debug:
database = xapian.WritableDatabase(folder, xapian.DB_CREATE_OR_OVERWRITE)
else:
database = xapian.WritableDatabase(folder, xapian.DB_CREATE_OR_OPEN)
else:
try:
database = xapian.Database(fol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_db():\n db = getattr(g, '_database', None)\n if db is None:\n db = g._database = sqlite3.connect(DATABASE)\n db.row_factory = sqlite3.Row\n return db",
"def get_db():\n\n def dict_factory(cursor, row):\n \"\"\"\n Creates dict from row.\n\n Args:\n ... | [
"0.7158793",
"0.71182173",
"0.7106204",
"0.7060895",
"0.7055445",
"0.70455647",
"0.69805187",
"0.6973953",
"0.6967501",
"0.6942097",
"0.6927526",
"0.6875223",
"0.6837122",
"0.67774034",
"0.6758049",
"0.6755272",
"0.6755272",
"0.67471236",
"0.6720506",
"0.6716896",
"0.67080945... | 0.7108539 | 2 |
Returns True if user_obj has any permissions in the given app_label. | def has_module_perms(self, user_obj, app_label):
for perm in self.get_all_permissions(user_obj):
if perm[:perm.index('.')] == app_label:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_module_perms(self, user_obj, app_label):\n if not user_obj.is_active:\n return False\n for perm in self.get_all_permissions(user_obj):\n if perm.partition(':')[0] == app_label:\n return True\n return False",
"def has_module_perms(self, user_obj, a... | [
"0.8357425",
"0.83342564",
"0.8126118",
"0.76733184",
"0.76733184",
"0.76733184",
"0.72403187",
"0.72403187",
"0.72199196",
"0.72199196",
"0.72199196",
"0.71857953",
"0.71857953",
"0.7147616",
"0.71443725",
"0.7129924",
"0.71252114",
"0.69549006",
"0.6774404",
"0.6771552",
"0... | 0.83037674 | 2 |
Sample based on `mu` and `log_var` | def latent(self, p):
mu, log_var = p
return mu + K.random_normal(K.shape(mu)) * K.exp(log_var / 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latent_sample(self, mu, logvar):\n\n # the reparameterization trick\n std = logvar.mul(0.5).exp_()\n eps = torch.empty_like(std).normal_()\n return eps.mul(std).add_(mu)",
"def sampler(self, mean, log_var):\n eps = torch.randn_like(mean).to(self.device)\n z = torch.e... | [
"0.7935419",
"0.7432471",
"0.73386836",
"0.73230505",
"0.7202619",
"0.71607625",
"0.71607625",
"0.71123385",
"0.7073304",
"0.7045168",
"0.7020554",
"0.7008292",
"0.7008292",
"0.7008292",
"0.7008292",
"0.69778776",
"0.6942059",
"0.692614",
"0.692614",
"0.6885979",
"0.68749344"... | 0.5974755 | 76 |
Gets a color for a node from the color map | def get_color(node, color_map):
if node in color_map:
return color_map[node]
return "black" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color(self, node: Node) -> str:\n\n idx = hash(node.get_kind_name()) % len(self.colors_)\n return self.colors_[idx]",
"def get_color(key):\n if _with_colors:\n return _color_map.get(key, None)\n return None",
"def which_color(node):\n for i, com in enumerate(communitie... | [
"0.78032285",
"0.73727363",
"0.73418564",
"0.69549704",
"0.68655634",
"0.68655634",
"0.68655634",
"0.68655634",
"0.6771988",
"0.676185",
"0.6759449",
"0.6740052",
"0.66710526",
"0.6658527",
"0.6653712",
"0.66476274",
"0.6644814",
"0.66379815",
"0.6580679",
"0.6572436",
"0.655... | 0.87923455 | 0 |
Initialisation of weightedData Object. | def __init__(self,sentences):
self.data_set = sentences
self.sum1=0
for sentence in self.data_set:
sentence.weight = 1/len(self.data_set)
self.sum1 += sentence.weight
self.sum2=1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data):\n assert len(data) == 6\n for i in range(5):\n assert data[i].keys() == data[5].keys()\n if isinstance(data, tuple):\n self.weights = data\n else:\n self.weights = tuple(data)",
"def __init__(self, weights):\n self._wei... | [
"0.7701631",
"0.7212534",
"0.71965295",
"0.7181386",
"0.70081145",
"0.6957095",
"0.691188",
"0.6801828",
"0.6749866",
"0.67144823",
"0.6690283",
"0.6690283",
"0.6638673",
"0.6596818",
"0.6584895",
"0.65725946",
"0.6562942",
"0.6554225",
"0.65446484",
"0.64966923",
"0.6489691"... | 0.0 | -1 |
Compute an upper bound on monthlength. Even if we haven't identified all the fields needed for checking leapyears yet, we can still prune if value.d is bigger than the month can ever possibly be. | def valid_day_of_month(value):
if value.m == 2:
month_length = 29
if value.y is not None:
if (value.y % 4) != 0:
month_length = 28
elif value.y == 0 and value.C is not None and (value.C % 4) != 0:
month_length = 28
else:
# Odd-numbe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_days(self):\n month_lengths = [31, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29]\n days_years = 365.24 * (self.number // 12)\n days_months = np.sum(month_lengths[:self.number % 12])\n days_frac = days_years + days_months + self.days\n return int(np.ceil(days_frac))",
"def... | [
"0.5886275",
"0.5427668",
"0.5374245",
"0.5331599",
"0.53222615",
"0.53004485",
"0.52571625",
"0.5251135",
"0.5178014",
"0.51442075",
"0.5120376",
"0.51074386",
"0.51074386",
"0.5104363",
"0.5086965",
"0.5083028",
"0.5073267",
"0.50732094",
"0.50614166",
"0.5055513",
"0.50528... | 0.6487694 | 0 |
Upon enter, return the context manager object for future updates. | def __enter__(self):
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __enter__(self):\n self.__within_context = True\n if not self.__initialized:\n self.__initialization__()\n return self",
"def __enter__(self):\n self.manual_enter()\n return self",
"def __enter__(self):\n self._in_context_block = True\n # TODO: cr... | [
"0.7337823",
"0.7026329",
"0.67525506",
"0.6666832",
"0.6612766",
"0.6591439",
"0.65740186",
"0.6571943",
"0.65712506",
"0.65712506",
"0.6558865",
"0.6538163",
"0.6537708",
"0.6537708",
"0.6537708",
"0.6537708",
"0.6537708",
"0.6537708",
"0.6537708",
"0.6537708",
"0.6537708",... | 0.64300215 | 66 |
Sets the end_date of this MdHistoryRequestCO. | def end_date(self, end_date):
self._end_date = end_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_date(self, end_date):\n self._end_date = end_date",
"def end_date(self, end_date):\n if end_date is None:\n raise ValueError(\"Invalid value for `end_date`, must not be `None`\")\n\n self._end_date = end_date",
"def set_end_date(self, date):\n pass",
"def end_da... | [
"0.83238953",
"0.8126522",
"0.8002559",
"0.7889392",
"0.78851426",
"0.7573475",
"0.75492877",
"0.7515379",
"0.7478635",
"0.7474362",
"0.7399435",
"0.7218076",
"0.7218076",
"0.7070495",
"0.6962145",
"0.68157727",
"0.6796637",
"0.6745392",
"0.6677834",
"0.661335",
"0.66080457",... | 0.8393393 | 6 |
Sets the nucleus_security_id of this MdHistoryRequestCO. | def nucleus_security_id(self, nucleus_security_id):
self._nucleus_security_id = nucleus_security_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def security_user_id(self, security_user_id):\n\n self._security_user_id = security_user_id",
"def security_user_id(self, security_user_id):\n\n self._security_user_id = security_user_id",
"def security_identities(self, security_identities):\n\n self._security_identities = security_identit... | [
"0.6567464",
"0.6567464",
"0.52219766",
"0.51711905",
"0.5101832",
"0.5018672",
"0.5015538",
"0.4997469",
"0.49538937",
"0.49538937",
"0.4811074",
"0.4785215",
"0.4778403",
"0.4775735",
"0.47065136",
"0.47065136",
"0.46921664",
"0.46891037",
"0.46483314",
"0.45931828",
"0.458... | 0.7827064 | 0 |
Sets the product of this MdHistoryRequestCO. | def product(self, product):
self._product = product | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(self, product):\n self._product = product",
"def product(self, product):\n if product is None:\n raise ValueError(\"Invalid value for `product`, must not be `None`\") # noqa: E501\n\n self._product = product",
"def target_product(self, target_product):\n\n se... | [
"0.77516913",
"0.67729884",
"0.66385",
"0.6534956",
"0.6446105",
"0.6446105",
"0.6381497",
"0.62452966",
"0.61594176",
"0.61521363",
"0.6055195",
"0.6055195",
"0.60030913",
"0.5981995",
"0.59426045",
"0.58830494",
"0.5794708",
"0.5767965",
"0.57638776",
"0.57638776",
"0.57638... | 0.770328 | 2 |
Sets the start_date of this MdHistoryRequestCO. | def start_date(self, start_date):
self._start_date = start_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_date(self, start_date):\n \n self._start_date = start_date",
"def start_date(self, start_date):\n self._start_date = start_date",
"def start_date(self, start_date):\n if start_date is None:\n raise ValueError(\"Invalid value for `start_date`, must not be `None`\... | [
"0.8342914",
"0.8177962",
"0.8133697",
"0.80655676",
"0.79983824",
"0.796645",
"0.74692875",
"0.7460006",
"0.7337247",
"0.70807976",
"0.6902143",
"0.67647326",
"0.67647326",
"0.66732126",
"0.6660251",
"0.660973",
"0.660973",
"0.65859705",
"0.6535868",
"0.64128643",
"0.6406774... | 0.82583505 | 8 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, MdHistoryRequestCO):
return False
return self.to_dict() == other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, MdHistoryRequestCO):
return True
return self.to_dict() != other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
... | 0.0 | -1 |
Initialize name and type. | def __init__(self, restaurant_name, cuisine_type):
self.name = restaurant_name
self.type = cuisine_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name: str, python_type: type):\n self.name = name\n self.python_type = python_type",
"def __init__(self, name):\n self.type_cls = None\n\n self.name = name\n self.description = None\n self.updated = None\n self.notes = None\n self.propert... | [
"0.74871093",
"0.7481559",
"0.72628826",
"0.7130087",
"0.7100174",
"0.70130837",
"0.69421357",
"0.69421357",
"0.69414806",
"0.6937453",
"0.6937453",
"0.6899564",
"0.6891967",
"0.6891897",
"0.6887291",
"0.68361604",
"0.68099797",
"0.68018526",
"0.68018526",
"0.6785917",
"0.678... | 0.0 | -1 |
Returns the index of the bin that feature belongs in. bin_bounds contains the upper bound on each bin's value, sorted. | def get_bin_index(signal, bins):
# could do this binary search-like at least
index = 0
for v in bin_bounds:
if signal > v:
return index
index += 1
return index - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bin_index(self, xnorm):\n return _bin_index(xnorm, self.nbins, self.padding)",
"def getBinIndex(self, x):\n\t\tb = -1\n\t\tif x == self._max_val: # final bin is [low, high], where others are [low,high)\n\t\t\tb = len(self._bins)-1\n\t\telse:\n\t\t\tb = math.floor((x-self._min_val)/self._bin_width)\n\t... | [
"0.70552397",
"0.70514095",
"0.700788",
"0.6601049",
"0.6601049",
"0.658574",
"0.64486784",
"0.6374188",
"0.6364163",
"0.63276494",
"0.61857146",
"0.6172362",
"0.615024",
"0.6147497",
"0.61349773",
"0.60643",
"0.5958335",
"0.5958335",
"0.5933699",
"0.59336483",
"0.5922114",
... | 0.7421128 | 0 |
Calculate the log of the sum of exponentials of the vector elements. Use the shifting trick to minimize numerical precision errors. Argument is a listlike thing similar to np.logaddexp(x1, x2) but takes a 1d list. >>> log_sum_exp([log(0.5), log(0.5)]) 0.0 >>> approx(exp(log_sum_exp([log(0.001), log(0.009), log(0.3)])),... | def log_sum_exp(v):
m = max(v)
x = m * np.ones(np.size(v))
return m + np.log(sum(np.exp(v - x))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_sum_exp(x, axis=None):\n xmax = x.max(axis=axis, keepdims=True)\n xmax_ = x.max(axis=axis)\n return xmax_ + T.log(T.exp(x - xmax).sum(axis=axis))",
"def log_sum_exp(x):\n # TF ordering\n axis = len(x.shape) - 1\n m = paddle.max(x, axis=axis)\n m2 = paddle.max(x, axis=axis, keepdim=Tr... | [
"0.7660464",
"0.7532827",
"0.7499924",
"0.7420318",
"0.7420318",
"0.74202895",
"0.7321609",
"0.7310051",
"0.72782695",
"0.718757",
"0.7187217",
"0.7149047",
"0.71360093",
"0.7101125",
"0.6841345",
"0.68399256",
"0.6781454",
"0.6760717",
"0.6751314",
"0.67455536",
"0.67455536"... | 0.737557 | 6 |
Return the index of the largest value, randomly breaking ties. >>> argmax([0, 1]) 1 >>> argmax([1, 0]) 0 >>> a = argmax([0, 1, 1]) >>> a in (1, 2) True | def argmax(values):
values = np.array(values)
mx = np.max(values)
val = np.where(values==mx)[0]
return np.random.choice(val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_argmax(x: np.ndarray) -> int:\n indices = all_argmax(x)\n return np.random.choice(indices)",
"def __argmax(l: list, key):\n max = float('-inf')\n max_i = -1\n for i in range(len(l)):\n if key(l[i]) > max:\n max = key(l[i])\n max_i = i\n return max_i",
"... | [
"0.7526515",
"0.7374521",
"0.73375267",
"0.7292933",
"0.7292933",
"0.7292933",
"0.7266164",
"0.7108389",
"0.7082183",
"0.69236606",
"0.6903086",
"0.67438745",
"0.66566026",
"0.6644861",
"0.66012126",
"0.65932435",
"0.64963543",
"0.64745444",
"0.6468216",
"0.6466282",
"0.64662... | 0.77623355 | 0 |
Calculate the numerator such that at t=0, a/(decay+t)=alpha | def calc_alpha_init(alpha, decay):
if not decay or decay <= 0:
return alpha
else:
return float(alpha * decay) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_decay(x0, alpha, T, t):\n if t <= T:\n return x0 - (1 - alpha) * x0 * t / T\n else:\n return alpha * x0",
"def alpha0(self, t):\n return (self.alpha_0 * pow((self.Light(t) / self.I0), self.p));",
"def get_rate(self, t):\n return self.l_0 + \\\n self.alpha * s... | [
"0.69432795",
"0.6660636",
"0.6574897",
"0.63983226",
"0.6329011",
"0.62791234",
"0.6273906",
"0.6231108",
"0.6197118",
"0.61908907",
"0.6139079",
"0.6103482",
"0.60895485",
"0.6089476",
"0.6075572",
"0.6073953",
"0.6066894",
"0.6041462",
"0.6040465",
"0.6033664",
"0.59855026... | 0.6787552 | 1 |
Join a number to the end of a string in the standard way If width is provided will backfill >>> join_number('fred', 10) 'fred10' >>> join_number('fred', 10, 3) 'fred010' | def join_number(string, num, width=None):
num = str(num)
if width:
num = num.rjust(width, '0')
return string + '-' + str(num) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(number, width=0):\n return str(number).zfill(width)",
"def pad_number(number, length):\n\n string_number = str(number)\n number_of_zeros = length - len(string_number)\n if number_of_zeros >= 0:\n return \"0\" * number_of_zeros + string_number\n else:\n return string_number",
... | [
"0.7575873",
"0.6719598",
"0.6585075",
"0.6569616",
"0.6502219",
"0.6435242",
"0.6325695",
"0.63152623",
"0.63049746",
"0.6270025",
"0.6255137",
"0.62551343",
"0.6232007",
"0.6167308",
"0.61607224",
"0.61002517",
"0.60625637",
"0.59663886",
"0.5961309",
"0.59325504",
"0.59198... | 0.8679115 | 0 |
Return true if filepath ends in 'gz' extension | def is_zip(filepath):
return os.path.splitext(filepath)[1] == '.gz' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_archive_ext(filepath):\n file_extension = os.path.splitext(filepath)[1].lower()\n if file_extension in get_archive_extensions():\n return True\n else:\n return False",
"def chk_for_gz(filenm):\n import os\n from os.path import expanduser\n filenm = expanduser(filenm)\n\n ... | [
"0.73746085",
"0.73102397",
"0.728944",
"0.7181048",
"0.69474477",
"0.67704386",
"0.6675972",
"0.6661081",
"0.6557845",
"0.6541729",
"0.6535836",
"0.6522381",
"0.64815605",
"0.646029",
"0.6333025",
"0.6316177",
"0.62578523",
"0.6246907",
"0.6244113",
"0.6234546",
"0.6212786",... | 0.80162406 | 0 |
Get the next noncommented line of strings from a file, separated by whitespace >>> f = open('results/testing/pos/Large/rawdata.txt', 'r') >>> read_strings(f) ['a', 'b', 'c', 'd', 'e', 'f', 'step'] | def read_strings(filepointer):
line = '#'
try:
while line and line[0]=='#':
line = filepointer.readline()
except (IOError, ValueError):
return None
if line:
return line.split()
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_strings(src_file):\n res = []\n try:\n res = open(src_file,'r').readlines()\n res = [x.strip() for x in res]\n except:\n res = []\n return res",
"def get_next_hundered_lines(file):\n count = 0\n result = []\n while count < 100:\n count += 1\n next_l... | [
"0.6840863",
"0.6173089",
"0.612168",
"0.6075292",
"0.6003574",
"0.59796333",
"0.59180355",
"0.5904176",
"0.5896242",
"0.5887557",
"0.5884237",
"0.5814879",
"0.5809892",
"0.5803777",
"0.57963556",
"0.57625866",
"0.5758329",
"0.5758329",
"0.57532275",
"0.57433313",
"0.57394236... | 0.74165165 | 0 |
Return the number of nonstring lines in the file >>> num_data_lines('results/testing/pos/Large/rawdata.txt') 16 >>> num_data_lines('asdfasdfasdf') 1 | def num_data_lines(filepath):
if not file_exists(filepath):
return -1
count = 0
with open(filepath, 'r') as f:
while read_floats(f):
count += 1
f.close()
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_of_lines():\n number_of_lines = len(open(FILE_NAME).readlines())\n return number_of_lines",
"def number_of_lines(filename=\"\"):\n num_lines = 0\n with open(filename, encoding=\"utf-8\") as myFile:\n return myFile.read().count('\\n')",
"def number_of_lines(filename=\"\"):\n with op... | [
"0.7510078",
"0.73360777",
"0.72530895",
"0.7075935",
"0.69970053",
"0.69092995",
"0.6866046",
"0.6847447",
"0.6827048",
"0.68235576",
"0.6811298",
"0.68074536",
"0.6784149",
"0.6774877",
"0.6768876",
"0.6754857",
"0.67495346",
"0.67374307",
"0.6730054",
"0.67297864",
"0.6678... | 0.71209097 | 3 |
Take a numpy array and return a smaller one with the data binned | def bin_data(data, num_bins):
slices = np.linspace(0, 100, num_bins+1, True).astype(np.int)
counts = np.diff(slices)
mean = np.add.reduceat(data, slices[:-1]) / counts
return mean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binarize(X, *, threshold=..., copy=...):\n ...",
"def to_bins(arr):\n result = np.zeros(len(arr)+1)\n result[1:-1] = 0.5 * (arr[1:] + arr[:-1])\n result[0] = arr[0] - 0.5*(arr[1] - arr[0])\n result[-1] = arr[-1] + 0.5*(arr[-1] - arr[-2])\n return result",
"def rebin(array, dimensions=None... | [
"0.7234878",
"0.7003438",
"0.67663366",
"0.6766225",
"0.6748709",
"0.6748709",
"0.674814",
"0.67069626",
"0.667625",
"0.65963215",
"0.6585553",
"0.65487653",
"0.65111923",
"0.64794827",
"0.64375645",
"0.64106",
"0.64076483",
"0.6361542",
"0.6330075",
"0.6326089",
"0.6321682",... | 0.6088632 | 29 |
Indices, if provided, gives the column indices for the desired data. If not provided, will return all the data. | def get_formatted_data(line, indices=None):
file_data = str.strip(line).split(' ')
if indices is None:
data = list(range(len(file_data)))
else:
data = list(indices)
for i, file_column in enumerate(data):
if file_column is not None:
datum = file_data[file_column]
else:
datum = ' '
if '.' in datum:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_column_indices(indices, inputs, multiple):\n if multiple:\n res = OrderedDict()\n for p in indices:\n ov, onnx_i = get_column_index(p, inputs)\n if ov not in res:\n res[ov] = []\n res[ov].append(onnx_i)\n return res\n\n onnx_var = N... | [
"0.6887428",
"0.642437",
"0.6343533",
"0.63019794",
"0.62214637",
"0.6197078",
"0.61851895",
"0.61848205",
"0.6175898",
"0.6137029",
"0.6089346",
"0.6044207",
"0.6037134",
"0.60361594",
"0.6008707",
"0.5967875",
"0.5950757",
"0.59473854",
"0.5901781",
"0.58976066",
"0.5879143... | 0.0 | -1 |
For a dictionary of potential parameter values, return an iterator of dictionaries of all possible combinations | def get_all_combinations(param_opt):
if not param_opt:
return {}
return (dict(zip(param_opt.keys(), x)) for x in itertools.product(*param_opt.values())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterparams(params: Dict[str, List[Any]]) -> Dict[str, Any]:\n for set in product(*params.values()):\n yield dotdict(zip(params.keys(), set))",
"def ParameterCombinations(parameter_dict):\n d = parameter_dict\n return [dict(zip(d, v)) for v in itertools.product(*d.values())]",
"def _paramete... | [
"0.81666803",
"0.7774893",
"0.77061653",
"0.6907007",
"0.68637216",
"0.6832588",
"0.6737774",
"0.6448503",
"0.6446987",
"0.6430941",
"0.63854337",
"0.6368257",
"0.63657707",
"0.6308112",
"0.6308112",
"0.62593734",
"0.6208581",
"0.61728126",
"0.6133052",
"0.61206704",
"0.60831... | 0.71145046 | 3 |
For the given iterable of parameter dictionaries, return a list of the keys that do not appear in every parameter dictionary | def get_unique_keys(param_list):
if not param_list:
return
counts = {}
max_count = len(param_list)
for p in param_list:
for k in p:
counts[k] = 1 + counts.get(k, 0)
unique = []
# now find out which keys are not shared
for k in counts:
if counts[k] < max_count:
unique.append(k)
unique.sort()
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_missing(dicts):\n for d in dicts:\n for k, v in d.items():\n d[k] = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) - set(v)\n return dicts",
"def without_keys(keys):\n keys = frozenset(keys) # frozenset has efficient membership lookup\n return filter_keys_c(fnot(partial(operator.contains... | [
"0.6812278",
"0.6671408",
"0.62812865",
"0.6256023",
"0.6247341",
"0.6235568",
"0.62332124",
"0.62277204",
"0.62120247",
"0.6208719",
"0.6184913",
"0.6177239",
"0.60850805",
"0.6084818",
"0.6073516",
"0.6034428",
"0.5967064",
"0.59618556",
"0.59462625",
"0.59185004",
"0.58891... | 0.5885593 | 22 |
For the given list of parameter dictionaries, make a dictionary of the keys and values that are the same for every set in the list | def get_shared_values(param_list):
if not param_list:
return
keys = [p.keys() for p in param_list]
shared_keys = set(keys[0]).intersection(*keys)
shared = {k: param_list[0][k] for k in shared_keys}
for p in param_list:
for k in p:
if k in shared and shared[k] != p[k]:
shared.pop(k)
return shared | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permutation_dict(params):\n params_list = {key: value for (key, value) in params.items() if isinstance(value, list)}\n params_single = {key: value for (key, value) in params.items() if not isinstance(value, list)}\n keys, values = zip(*params_list.items())\n permutations = [dict(zip(keys, v), **par... | [
"0.653074",
"0.6364621",
"0.6317289",
"0.6270832",
"0.6233593",
"0.6211111",
"0.6143972",
"0.6098328",
"0.60746235",
"0.6021277",
"0.5985847",
"0.594793",
"0.5914551",
"0.59002",
"0.5881145",
"0.5872788",
"0.5848662",
"0.58468455",
"0.58299387",
"0.5814954",
"0.5791685",
"0... | 0.6330616 | 2 |
Opens a new database connection if there is none yet for the current application context. | def get_db():
if not hasattr(g, 'sqlite_db'):
g.sqlite_db = connect_db()
return g.sqlite_db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db",
"def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)",
"def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec... | [
"0.7737639",
"0.7582971",
"0.73180443",
"0.71693045",
"0.70220166",
"0.6966687",
"0.6954785",
"0.69486743",
"0.6897534",
"0.6842663",
"0.68292314",
"0.68191963",
"0.680592",
"0.67950195",
"0.67697805",
"0.6762173",
"0.6751266",
"0.6746273",
"0.67316663",
"0.670031",
"0.668866... | 0.640242 | 83 |
Validates aliasing works properly when the query contains both tags_key and tags_value. | def test_aliasing() -> None:
processed = parse_and_process(
{
"aggregations": [],
"groupby": [],
"selected_columns": ["tags_value"],
"conditions": [["tags_key", "IN", ["t1", "t2"]]],
}
)
sql = format_query(processed).get_sql()
transactions_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_generic_tag_match(key: str, value: str) -> Dict[str, Any]:\n query = {\n \"tags\": {\n \"$elemMatch\": {\n \"key\": key,\n \"$or\": [\n {\"vStr\": value},\n {\"vInt64\": value},\n ... | [
"0.57817465",
"0.570398",
"0.5615116",
"0.5476921",
"0.5441292",
"0.5437843",
"0.54195595",
"0.5388927",
"0.53832835",
"0.53694046",
"0.5329078",
"0.5325659",
"0.5304145",
"0.52602834",
"0.52379453",
"0.516322",
"0.5129891",
"0.50972956",
"0.5071068",
"0.50556076",
"0.5045664... | 0.6864035 | 0 |
Get the list of projects associated with this Community. | def get_projects(self, *criterion):
from wkcdd.models.helpers import get_project_list
return get_project_list([self.id], *criterion) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def projects(self):\n ret_val = []\n params = {\"fields\": Project.FIELDS}\n projects = self._request(\"get\", \"projects\", params=params)\n\n for project in projects:\n ret_val.append(Project(project))\n\n return ret_val",
"def getProjects(self):\n\n return ... | [
"0.7999997",
"0.79260135",
"0.7863379",
"0.7858218",
"0.7848352",
"0.78283966",
"0.7756608",
"0.77432966",
"0.7719255",
"0.7712745",
"0.76892686",
"0.7660413",
"0.75886464",
"0.75678885",
"0.74619716",
"0.74375945",
"0.73235",
"0.72587824",
"0.7201207",
"0.7165235",
"0.715986... | 0.7126879 | 21 |
test if square inherits from Rectangle class | def test_0_is_Rectangle_class(self):
self.assertTrue(issubclass(type(self.S0), Rectangle) and
type(self.S0) != Rectangle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_SquareinheritancefromRectangle(self):\n Square.reset_objects()\n self.assertEqual(issubclass(Square, Rectangle), True)",
"def test_inheritance(self):\n self.assertTrue(issubclass(Rectangle, Base))",
"def test_SquareinheritancefromBase(self):\n Square.reset_objects()\n ... | [
"0.8706331",
"0.84380364",
"0.7575495",
"0.7318062",
"0.72508115",
"0.6906887",
"0.68277794",
"0.6354814",
"0.63431084",
"0.6296655",
"0.62895024",
"0.6266489",
"0.6262198",
"0.6252961",
"0.61256933",
"0.60000396",
"0.59920377",
"0.5984847",
"0.59632903",
"0.5960873",
"0.5954... | 0.8131839 | 2 |
Read dict into a DataFrame. | def _listofdict_to_df(self, osw_dict=None):
if type(osw_dict) is not dict:
raise ValueError("The 'osw_dict' arg is invalid!")
frame = pd.DataFrame.from_dict(osw_dict, orient='columns')
return frame | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_to_DataFrame(data):\n return pd.DataFrame.from_dict(data)",
"def convert_measuerment_dict_to_DataFrame(measurement_dict):\n df = pd.DataFrame.from_dict(measurement_dict, orient='index')\n return(df)",
"def combine_dict_to_df(self, dict):\n\t\treturn pd.concat(dict.values(), axis=1)",
"def d... | [
"0.76458347",
"0.7417406",
"0.73200023",
"0.72285205",
"0.70975417",
"0.70477533",
"0.70334816",
"0.6873192",
"0.67515254",
"0.66828954",
"0.6593455",
"0.65235204",
"0.6477196",
"0.6186388",
"0.6157289",
"0.6113992",
"0.6113477",
"0.606115",
"0.60471964",
"0.6042822",
"0.6014... | 0.6676459 | 10 |
Read dict into a DataFrame. | def string_to_keypair(self, data):
return keypair_lst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_to_DataFrame(data):\n return pd.DataFrame.from_dict(data)",
"def convert_measuerment_dict_to_DataFrame(measurement_dict):\n df = pd.DataFrame.from_dict(measurement_dict, orient='index')\n return(df)",
"def combine_dict_to_df(self, dict):\n\t\treturn pd.concat(dict.values(), axis=1)",
"def d... | [
"0.7647582",
"0.74180055",
"0.7322513",
"0.72297966",
"0.70972997",
"0.704857",
"0.70342886",
"0.6873646",
"0.67528",
"0.6684072",
"0.66767454",
"0.65949196",
"0.65236676",
"0.6476429",
"0.6186509",
"0.6155475",
"0.6115515",
"0.6114628",
"0.60612005",
"0.604798",
"0.6041273",... | 0.0 | -1 |
Copies the image in the correct folder according to the label | def add_emotion(path, train_out_dir):
emotion_txt = os.open(path, os.O_RDONLY)
emotion = int(os.read(emotion_txt, 4))
if emotion == 1:
label = 'anger'
elif emotion == 2:
label = 'neutral'
elif emotion == 3:
label = 'disgust'
elif emotion == 4:
label = 'fear'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def img2folder(idir, img_lbl_df, label=\"breed\", img=\"img_name\"):\n lbls = set(img_lbl_df[label])\n\n for img, label in zip(img_lbl_df[img], img_lbl_df[label]):\n for folder in lbls:\n if label == folder:\n try:\n shutil.move(join(idir, img), join(idir, ... | [
"0.71940136",
"0.7184324",
"0.71660066",
"0.675361",
"0.675361",
"0.67486656",
"0.66388965",
"0.6494527",
"0.6413706",
"0.6357713",
"0.62656945",
"0.62399673",
"0.61743736",
"0.6170652",
"0.61690843",
"0.615815",
"0.61228734",
"0.61096156",
"0.6083451",
"0.60793895",
"0.60378... | 0.0 | -1 |
Send message to the user with notFound 404 status. | def page_not_found(e):
# Message to the user
message = {
"err":
{
"msg": "This route is currently not supported. Please refer API documentation."
}
}
# Making the message looks good
resp = jsonify(message)
# Sending OK response
resp.status_code... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send404(self):\n\t\tself.send_error(404, \"File not found\")",
"def _send_404(self):\n template_filename = self._get_config_template('404')\n text = read_template(\n template_filename,\n title='%s - 404' % SERVER_NAME,\n header='404 — Page not ... | [
"0.81251395",
"0.8037681",
"0.8027026",
"0.7466101",
"0.74292845",
"0.7336844",
"0.7312849",
"0.7261023",
"0.7249713",
"0.7249645",
"0.7249645",
"0.7244892",
"0.72413087",
"0.7238381",
"0.7221919",
"0.7220921",
"0.72206825",
"0.7216198",
"0.72136664",
"0.7207618",
"0.72071874... | 0.70322317 | 49 |
Check if user is allowed to do this. | def allowed(self):
may = self.request.user.may
return (not self.__class__.__name__ in self.request.cfg.actions_excluded and
may.write(self.pagename)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_allowed(self) -> bool:\n return self.effect == ALLOW_ACCESS",
"def checkIfAllowed(self, user):\n\n # Default case if mod access is not needed everyone has access\n if not self.modOnlyAccess:\n return True\n\n # Otherwise check the user's access level\n if user... | [
"0.7984081",
"0.7877894",
"0.7801698",
"0.77132416",
"0.7699536",
"0.76784873",
"0.7669489",
"0.7657942",
"0.76547027",
"0.7648808",
"0.7648808",
"0.7648808",
"0.7641889",
"0.7597246",
"0.75231224",
"0.7460616",
"0.7447043",
"0.7436796",
"0.74156576",
"0.7407053",
"0.73980033... | 0.7326418 | 23 |
Create a discrete control set that is shaped like a cosine function. | def gen_controls_cos(complex_controls, control_count, control_eval_count,
evolution_time, max_control_norms, periods=10.):
period = np.divide(control_eval_count, periods)
b = np.divide(2 * np.pi, period)
controls = np.zeros((control_eval_count, control_count))
# Create a wave f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def C(i, x):\n if i == 1:\n return np.array([[1., 0., 0.],\n [0., cos(x), sin(x)],\n [0., -sin(x), cos(x)]])\n elif i == 2:\n return np.array([[cos(x), 0., -sin(x)],\n [0., 1., 0.],\n ... | [
"0.62159336",
"0.5716321",
"0.5659428",
"0.543885",
"0.54238886",
"0.5407454",
"0.5336914",
"0.5282942",
"0.5246328",
"0.5203804",
"0.5200005",
"0.5176265",
"0.5172793",
"0.5138024",
"0.50859714",
"0.50710136",
"0.50569665",
"0.5047774",
"0.5034469",
"0.50343806",
"0.5020108"... | 0.5927754 | 1 |
Compute a TxN matrix of features of the given phase vector using Gaussian basis functions. Where T is the number of elements in the phase vector and N is the number of basis functions. | def compute_feature_matrix(phases, N, h):
T = len(phases)
# Uniformly distribute the centers of N basis functions in domain[-2h,2h+1].
centers = np.linspace(-2 * h, 1 + 2 * h, num=N)
# compute a TxN matrix with centers
C = np.repeat(centers.reshape(1, N), T, axis=0)
# compute a TxN matrix with p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TMM(x,N,n,trun_basis):\n Mat = np.zeros([len(trun_basis),len(trun_basis)])\n print('making TMM')\n perms = [int((x**n * iii)%N) for iii in trun_basis] # Modular multiplication\n for iii in range(len(trun_basis)):\n if trun_basis.__contains__(perms[iii]):\n Mat[iii,trun_basis.index... | [
"0.6072341",
"0.5897467",
"0.5807051",
"0.5731498",
"0.5680174",
"0.56800663",
"0.5603116",
"0.5543852",
"0.548797",
"0.5432222",
"0.5381884",
"0.53484786",
"0.5343271",
"0.5334068",
"0.53140724",
"0.5287831",
"0.5281735",
"0.527351",
"0.5270905",
"0.5261998",
"0.5241274",
... | 0.71907866 | 0 |
Before all tests, add sample city & users | def setUp(self):
Cafe.query.delete()
City.query.delete()
sf = City(**CITY_DATA)
db.session.add(sf)
cafe = Cafe(**CAFE_DATA)
db.session.add(cafe)
db.session.commit()
self.cafe = cafe | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpTestData(cls):\n # volunteer user\n common.initialize_empty_volunteer()",
"def setUp(self):\n self.new_users = User('Dennis', 'Kiplangat', 'kiplangat18')",
"def setUp(self):\n self.my_city = City()",
"def setUp(self):\n with connection.cursor() as cursor:\n ... | [
"0.71896327",
"0.7132645",
"0.7092744",
"0.7058307",
"0.7024194",
"0.6962954",
"0.6880135",
"0.68702155",
"0.68702155",
"0.6830722",
"0.6798843",
"0.6791531",
"0.6754927",
"0.6713461",
"0.67037135",
"0.66994065",
"0.668939",
"0.6669227",
"0.6663045",
"0.66554177",
"0.6648748"... | 0.0 | -1 |
Before all tests, add sample city & users | def setUp(self):
Cafe.query.delete()
City.query.delete()
sf = City(**CITY_DATA)
db.session.add(sf)
cafe = Cafe(**CAFE_DATA)
db.session.add(cafe)
db.session.commit()
self.cafe = cafe | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpTestData(cls):\n # volunteer user\n common.initialize_empty_volunteer()",
"def setUp(self):\n self.new_users = User('Dennis', 'Kiplangat', 'kiplangat18')",
"def setUp(self):\n self.my_city = City()",
"def setUp(self):\n with connection.cursor() as cursor:\n ... | [
"0.71896327",
"0.7132645",
"0.7092744",
"0.7058307",
"0.7024194",
"0.6962954",
"0.6880135",
"0.68702155",
"0.68702155",
"0.6830722",
"0.6798843",
"0.6791531",
"0.6754927",
"0.6713461",
"0.67037135",
"0.66994065",
"0.668939",
"0.6669227",
"0.6663045",
"0.66554177",
"0.6648748"... | 0.0 | -1 |
Before all tests, add sample city & users | def setUp(self):
Cafe.query.delete()
City.query.delete()
sf = City(**CITY_DATA)
db.session.add(sf)
cafe = Cafe(**CAFE_DATA)
db.session.add(cafe)
db.session.commit()
self.cafe_id = cafe.id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpTestData(cls):\n # volunteer user\n common.initialize_empty_volunteer()",
"def setUp(self):\n self.new_users = User('Dennis', 'Kiplangat', 'kiplangat18')",
"def setUp(self):\n self.my_city = City()",
"def setUp(self):\n with connection.cursor() as cursor:\n ... | [
"0.71896327",
"0.7132645",
"0.7092744",
"0.7058307",
"0.7024194",
"0.6962954",
"0.6880135",
"0.68702155",
"0.68702155",
"0.6830722",
"0.6798843",
"0.6791531",
"0.6754927",
"0.6713461",
"0.67037135",
"0.66994065",
"0.668939",
"0.6669227",
"0.6663045",
"0.66554177",
"0.6648748"... | 0.0 | -1 |
Delete a collection Deletes an existing collection. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. | def delete(self, collection_id, **kwargs):
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.delete_with_http_info(collection_id, **kwargs)
else:
(data) = self.delete_with_http_info(collection_id, **kwargs)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_collection(self, collection_name: str):\n return self.http.collections_api.update_collections(\n storage_operations=StorageOperationsAnyOf2(\n delete_collection=collection_name\n )\n )",
"def delete_collection(collection_id):\n if collection_dao.co... | [
"0.7492643",
"0.7383946",
"0.6933805",
"0.6725361",
"0.6679288",
"0.6656375",
"0.65549606",
"0.65480655",
"0.62788177",
"0.6267317",
"0.6216147",
"0.61422735",
"0.61316806",
"0.61219484",
"0.6106382",
"0.60968333",
"0.6066024",
"0.60241866",
"0.5959069",
"0.592581",
"0.589048... | 0.73280615 | 2 |
Delete a collection Deletes an existing collection. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. | def delete_with_http_info(self, collection_id, **kwargs):
all_params = ['collection_id']
all_params.append('callback')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_collection(self, collection_name: str):\n return self.http.collections_api.update_collections(\n storage_operations=StorageOperationsAnyOf2(\n delete_collection=collection_name\n )\n )",
"def delete_collection(collection_id):\n if collection_dao.co... | [
"0.7493432",
"0.7382503",
"0.7326914",
"0.69327015",
"0.67252374",
"0.6677552",
"0.6656314",
"0.6547391",
"0.62783366",
"0.6266493",
"0.6215074",
"0.61427295",
"0.61306936",
"0.6120033",
"0.61062884",
"0.6097403",
"0.6066358",
"0.6023609",
"0.595951",
"0.5926667",
"0.58899575... | 0.6553675 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.