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 |
|---|---|---|---|---|---|---|
Takes an id and queries storgae for a recipe with that id, if found creates a review with the info recieve in the body of the request | def post_review(recipe_id=None):
if not storage.get(Recipe, recipe_id):
abort(404)
data = request.get_json()
if not data:
abort(400, 'Not a JSON')
if 'user_id' not in data.keys():
abort(400, 'Missing user_id')
if not storage.get(User, data['user_id']):
abort(404)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_review(review_id=None):\n\n review = storage.get(Review, review_id)\n if not review:\n abort(404)\n data = request.get_json()\n if not data:\n abort(400, 'Not a JSON')\n keys_ignore = ['id', 'user_id', 'recipe_id', 'created_at', 'updated_at']\n for key in data.keys():\n ... | [
"0.7104539",
"0.68992984",
"0.68183094",
"0.6553969",
"0.6490217",
"0.64867735",
"0.6471957",
"0.6471404",
"0.6456918",
"0.6438148",
"0.64342123",
"0.643264",
"0.64140964",
"0.640353",
"0.6397071",
"0.63607436",
"0.6360191",
"0.6267148",
"0.6250765",
"0.6233157",
"0.6184229",... | 0.78581 | 0 |
Creates a new Point. | def __init__(self, measurement, tags, fields, time_stamp):
self.measurement = measurement
self.tags = tags
self.fields = fields
self.time = time_stamp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createFromPoint(cls, point, **kwargs):\n return cls(point.x, point.y, **kwargs)",
"def makePoint( nX, nY ):\n oPoint = createUnoStruct( \"com.sun.star.awt.Point\" )\n oPoint.X = nX\n oPoint.Y = nY\n return oPoint",
"def makePoint( nX, nY ):\n oPoint = createUnoStruct( \"com.sun.star.a... | [
"0.76999646",
"0.76265323",
"0.76265323",
"0.7439702",
"0.7264961",
"0.72064894",
"0.71525073",
"0.70361614",
"0.70158654",
"0.68029964",
"0.6796616",
"0.6775431",
"0.6693558",
"0.66233635",
"0.66092485",
"0.65570605",
"0.65377355",
"0.65286654",
"0.6472205",
"0.6437618",
"0.... | 0.0 | -1 |
This is an arbitrary cut of the whole Age feature range | def _build_age_range(row):
val = 0
if row.Age <= 10:
val = 0
elif 10 < row.Age <= 15:
val = 1
elif 15 < row.Age <= 25:
val = 2
elif 25 < row.Age <= 40:
val = 3
elif 40 < row.Age <= 60:
val = 4
elif 60 < row.Age <= 70:
val = 5
elif 70 < row.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def age_extents(self):\n age_df = self.dismod_file.age\n return age_df.age.min(), age_df.age.max()",
"def tachycardic_range(self):\n self.adjust_age()\n if self.age_units == \"day\":\n if self.age <= 2:\n return 159\n elif self.age <= 6:\n ... | [
"0.7009701",
"0.6644977",
"0.64925724",
"0.64132875",
"0.6301958",
"0.6268441",
"0.6253615",
"0.62327",
"0.62137556",
"0.6176642",
"0.61684674",
"0.6010145",
"0.6006865",
"0.59897786",
"0.594702",
"0.59454995",
"0.5927686",
"0.58634543",
"0.5848656",
"0.58344054",
"0.5815267"... | 0.6804948 | 1 |
Get the controller listener. | def get_ctrl_listener(name=None):
if name == None:
ctrl_listener = None
elif name == 'keyboard':
ctrl_listener = KeyListener()
else:
raise ValueError('Unrecognized controller listener type {}.'\
.format(name))
return ctrl_listener | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getController(self):\n return self.__controller",
"def controller(self):\n return self._controller",
"def _get_controller(self):\n return self.__controller",
"def controller( self ):\n\t\ttry:\n\t\t\treturn self._controller\n\t\texcept Exception as e:\n\t\t\tself.logToConsole( \"controll... | [
"0.7112546",
"0.69246894",
"0.68649477",
"0.65980697",
"0.6478356",
"0.6177869",
"0.5950903",
"0.58867276",
"0.58606994",
"0.5798346",
"0.5798346",
"0.5798346",
"0.5786203",
"0.5721135",
"0.5712241",
"0.5690139",
"0.56821615",
"0.565802",
"0.565802",
"0.5601729",
"0.5601729",... | 0.7545985 | 0 |
Calculate the steadystate entropy production of a row normalized stochastic transition matrix | def ss_ent(tmat):
ss = getss(tmat)
ent = 0.0
for (state, prob) in enumerate(ss):
ratio = (tmat[state,:]/tmat[:,state])
# account for non-connecting elements
ratio[isnan(ratio)] = 1.0
ent += prob*( tmat[state, :].dot( log(ratio) ) )
return ent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entropy_matrix(training):\n shape = training.shape[1]\n e = np.zeros((shape, shape))\n for i, j in product(*map(range, (shape, shape))):\n a = training[:, [i, j]]\n e[i, j] = pairwise_entropy(a)\n return e",
"def ensemble_entropy(self):\n return transition_matrices.entropy_me... | [
"0.61540824",
"0.59085083",
"0.5867261",
"0.58616656",
"0.58535415",
"0.58028114",
"0.5773103",
"0.5757553",
"0.5752487",
"0.57118",
"0.5695979",
"0.568907",
"0.56812966",
"0.5664729",
"0.5658963",
"0.563711",
"0.5630302",
"0.5626151",
"0.5606227",
"0.56060314",
"0.5588733",
... | 0.63712335 | 0 |
Return a list of list of indexes corresponding to context windows surrounding each word in the sentence | def contextwin(l, win):
assert (win % 2) == 1
assert win >= 1
l = list(l)
lpadded = win // 2 * [-1] + l + + win // 2 * [-1]
out = [lpadded[i:(i + win)] for i in range(len(l))]
assert len(out) == len(l)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_context(words, position, window_size=2):\n start = max(0, position - window_size)\n stop = min(position + window_size, len(words))\n context_words = words[start:position] + words[position + 1:stop + 1]\n\n return list(context_words)",
"def extract_context(words, mask_index, window):\n tota... | [
"0.69948196",
"0.6875678",
"0.6871552",
"0.6455821",
"0.63622624",
"0.6237589",
"0.61836",
"0.6174571",
"0.6174254",
"0.61661047",
"0.6155005",
"0.612393",
"0.606832",
"0.60450363",
"0.60336167",
"0.60253006",
"0.6023137",
"0.60178965",
"0.6011207",
"0.60107607",
"0.60081273"... | 0.5648834 | 48 |
Returns the desired the base path for current model. | def base_upload_to(self):
parent = getattr(self, (self.get_parent()))
remote = self._meta.get_field(self.get_parent()).remote_field.name
return '%s/%s' % (self.parent_base_upload_to(parent), remote) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_path(self):\n return self._base_path",
"def base_path(self):\n return self.setup.base_path",
"def get_base_path(self) -> str:\n raise NotImplementedError()",
"def base_dir():\n return os.path.join(TrainFile.base_dir(), 'model')",
"def base_path(self):\n return Pa... | [
"0.8196501",
"0.81495774",
"0.80238044",
"0.7781426",
"0.7762492",
"0.7529852",
"0.7433327",
"0.7298709",
"0.7170621",
"0.7158846",
"0.71554106",
"0.7079184",
"0.7060315",
"0.70507205",
"0.69751954",
"0.69701403",
"0.6937927",
"0.6904316",
"0.68710077",
"0.68371767",
"0.67874... | 0.0 | -1 |
Check subset_timesteps are within timesteps and return the matching indices. | def _get_subset_timesteps_idxs(timesteps, subset_timesteps, strict_match=True):
# Check timesteps format
subset_timesteps = _check_timesteps(subset_timesteps)
timesteps = _check_timesteps(timesteps)
# Ensure same time precision for comparison
subset_timesteps = subset_timesteps.astype(timesteps.dtyp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_trajectory_subset_indices():\n import MDAnalysis.coordinates\n from torch.utils.data import DataLoader\n\n # Load the test PDB file.\n pdb_file_path = os.path.join(os.path.dirname(__file__), 'data', 'chloro-fluoromethane.pdb')\n with MDAnalysis.coordinates.PDB.PDBReader(pdb_file_path) as tr... | [
"0.65873384",
"0.6348583",
"0.6150101",
"0.5920785",
"0.5851562",
"0.58184654",
"0.5783689",
"0.5779125",
"0.57199997",
"0.5710229",
"0.5670154",
"0.5607461",
"0.5595074",
"0.55182093",
"0.55174416",
"0.55094063",
"0.54846525",
"0.5484273",
"0.54372245",
"0.54266435",
"0.5406... | 0.82982326 | 0 |
Return the next available identifier/sequence for a job. | def get_sequence(self):
self.__sequence = self.__sequence + 1
return self.__sequence - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_next_sequence_number(self):\n cur = self._next_sequence_number\n self._next_sequence_number += 1\n return cur",
"def next_jid(self):\n return self._next_jid",
"def get_id(self):\n\n self.redis.setnx('job_id', '-1')\n return self.redis.incr('job_id')",
"def g... | [
"0.68406105",
"0.6782614",
"0.65857005",
"0.65596986",
"0.652274",
"0.643459",
"0.6384779",
"0.6378936",
"0.63675517",
"0.63397074",
"0.62978864",
"0.6288522",
"0.62754005",
"0.6256476",
"0.6253577",
"0.6224356",
"0.6215352",
"0.6205352",
"0.6194486",
"0.6172089",
"0.6170341"... | 0.5997307 | 27 |
Return the job's uuid. | def uuid(self):
return self.__uuid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_job_id(self):\n return uuid.uuid4().hex",
"def job_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"job_id\")",
"def _job_id(resource_uuid: str) -> str:\n return resource_uuid if \".\" in resource_uuid else f\"{resource_uuid}.0\"",
"def _get_job_id(self) -> str:\n retu... | [
"0.86546224",
"0.78402054",
"0.77013296",
"0.76090837",
"0.74697393",
"0.7312589",
"0.7276957",
"0.71953255",
"0.71432364",
"0.713256",
"0.713256",
"0.71263796",
"0.71238863",
"0.71216196",
"0.7107298",
"0.70966035",
"0.70952666",
"0.70894897",
"0.70843774",
"0.70843774",
"0.... | 0.7151712 | 9 |
Return whether the job is recoverable or not. | def is_recoverable(self):
return self.__is_recoverable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recover(self):\n eh = SimpleErrorHandler()\n\n self._client.execute('recover', eh=eh)\n\n return bool(eh)",
"def is_retryable(self) -> Optional[bool]:\n return pulumi.get(self, \"is_retryable\")",
"def ComputeERecoverable(self):\r\n pass",
"def can_failover(self):\n ... | [
"0.69704545",
"0.67285067",
"0.635075",
"0.6180352",
"0.60683817",
"0.6048156",
"0.6022064",
"0.60043204",
"0.5844405",
"0.57800615",
"0.574852",
"0.5740432",
"0.5737682",
"0.569681",
"0.5680629",
"0.56616783",
"0.56609786",
"0.5644535",
"0.5628481",
"0.5617091",
"0.56136096"... | 0.7188076 | 0 |
Return a reference to the current job. | def current_job(self):
assert(ExecutorThread.executor_object is not None)
return self.__job | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job(self):\n return self.batch[self.job_id]",
"def get_job(self) -> Job:\n return self.jobs_list[self.sel_idx]",
"def reference(self) -> pulumi.Output['outputs.JobReference']:\n return pulumi.get(self, \"reference\")",
"def job(self) -> str:\n return self._job",
"def job(sel... | [
"0.79037386",
"0.75921166",
"0.75559855",
"0.7450324",
"0.7450324",
"0.7389321",
"0.7362385",
"0.7249424",
"0.7177245",
"0.71029806",
"0.70070744",
"0.69591767",
"0.6869568",
"0.6856284",
"0.6851716",
"0.67642903",
"0.674771",
"0.673208",
"0.67094916",
"0.67041266",
"0.666569... | 0.8657935 | 0 |
Calculates number of workdays between two given dates, subtracting weekends. | def netto_workdays(self, start_date, end_date, holidays=[], weekend_days=[5,6]):
delta_days = (end_date - start_date).days + 1
full_weeks, extra_days = divmod(delta_days, 7)
# num_workdays = how many days/week you work * total number of weeks
num_workdays = (full_weeks + 1) * (7 - len(we... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_workdays(start, end):\n # Subtracts the total number of holidays from the total number of weekdays\n return compute_weekdays(start, end) - compute_holidays(start, end)[\"total holidays:\"]",
"def compute_weekdays(start, end):\n # Subtracts the total number of weekend days from the total numb... | [
"0.82260215",
"0.76884717",
"0.7357405",
"0.73224247",
"0.7148693",
"0.71188164",
"0.69908917",
"0.69651407",
"0.6855857",
"0.67219967",
"0.6661408",
"0.66076756",
"0.6565678",
"0.6479123",
"0.6442236",
"0.6421704",
"0.64207226",
"0.63230395",
"0.63177633",
"0.62915725",
"0.6... | 0.78390884 | 1 |
Load JSON file, return content. | def load_json_file(self, file, default_content=None):
if os.path.isfile(file) and os.path.getsize(file):
with open(file, "r", encoding="utf-8") as f:
return json.load(f)
return default_content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json_file(json_path):\n with open(json_path, 'r') as json_file:\n contents = load(json_file)\n\n return contents",
"def read_json(json_file):\n with open(json_file) as f:\n content = json.load(f)\n return(content)",
"def load(self, path):\n with open(path, \"rt\") as o... | [
"0.82497865",
"0.79960185",
"0.7876934",
"0.78544617",
"0.7830257",
"0.78212225",
"0.7788578",
"0.7781436",
"0.77589846",
"0.7758597",
"0.7723787",
"0.7681781",
"0.76791245",
"0.76791245",
"0.7672178",
"0.7659784",
"0.76580524",
"0.7657986",
"0.7617429",
"0.7595525",
"0.75920... | 0.76328456 | 18 |
Compute the pairwise Euclidean similarity between x and y. This function computes the following similarity value between each pair of x_i | def pairwise_euclidean_similarity(x, y):
s = 2 * torch.mm(x, torch.transpose(y, 1, 0))
diag_x = torch.sum(x * x, dim=-1)
diag_x = torch.unsqueeze(diag_x, 0)
diag_y = torch.reshape(torch.sum(y * y, dim=-1), (1, -1))
return s - diag_x - diag_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pairwise_euclidean_distance(x, y):\n x_norm = (x ** 2).sum(1).view(-1, 1)\n if y is not None:\n y_t = torch.transpose(y, 0, 1)\n y_norm = (y ** 2).sum(1).view(1, -1)\n else:\n y_t = torch.transpose(x, 0, 1)\n y_norm = x_norm.view(1, -1)\n\n dist = x_norm + y_norm - 2.0 *... | [
"0.738357",
"0.7380053",
"0.73787063",
"0.73718506",
"0.7349075",
"0.73226875",
"0.72762585",
"0.72503066",
"0.7161958",
"0.7151918",
"0.7014116",
"0.6968597",
"0.6913705",
"0.6870345",
"0.6869797",
"0.6763049",
"0.67404854",
"0.6728395",
"0.6713584",
"0.67111254",
"0.6706049... | 0.82490224 | 0 |
Compute the dot product similarity between x and y. This function computes the following similarity value between each pair of x_i | def pairwise_dot_product_similarity(x, y):
return torch.mm(x, torch.transpose(y, 1, 0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y))",
"def dotproduct(x, y):\n return sum(imap(operator.mul, x, y))",
"def dot(x,y):\n\treturn sum([xi*yi for (xi,yi) in zip(x,y)])",
"def pairwise_euclidean_similarity(x, y):\n s = 2 * torch.mm(x, torch.transpose(y, 1, 0))\n diag_x = torch... | [
"0.7166723",
"0.7099518",
"0.7010887",
"0.69136864",
"0.6815375",
"0.67372715",
"0.6728668",
"0.669478",
"0.6512557",
"0.64949995",
"0.6462717",
"0.6383443",
"0.6357349",
"0.6354375",
"0.634099",
"0.63111836",
"0.63083726",
"0.6292651",
"0.6290416",
"0.6290416",
"0.6277317",
... | 0.8126946 | 0 |
Getter for this policy's minimum TLS version. | def mode(self):
return self._data.get('mode', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_tls_version(self):\n return self._data.get('min-tls-version', None)",
"def tls_min_version(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"tls_min_version\")",
"def tls_min_version(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"tls_min_version\"... | [
"0.88268405",
"0.83500886",
"0.83500886",
"0.8272157",
"0.77342093",
"0.77342093",
"0.7507708",
"0.74329704",
"0.72299093",
"0.68167055",
"0.6603571",
"0.63064027",
"0.62191206",
"0.61907357",
"0.6169785",
"0.61624134",
"0.6144028",
"0.6090609",
"0.6068551",
"0.60074264",
"0.... | 0.0 | -1 |
Getter for this policy's minimum TLS version. | def min_tls_version(self):
return self._data.get('min-tls-version', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tls_min_version(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"tls_min_version\")",
"def tls_min_version(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"tls_min_version\")",
"def tls_min_version(self) -> pulumi.Output[str]:\n return pulumi.get(self,... | [
"0.83500886",
"0.83500886",
"0.8272157",
"0.77342093",
"0.77342093",
"0.7507708",
"0.74329704",
"0.72299093",
"0.68167055",
"0.6603571",
"0.63064027",
"0.62191206",
"0.61907357",
"0.6169785",
"0.61624134",
"0.6144028",
"0.6090609",
"0.6068551",
"0.60074264",
"0.5996794",
"0.5... | 0.88268405 | 0 |
Setter for the mx hosts that this domain's certs can be valid for. | def mxs(self, value):
self._set_attr('mxs', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hosts(self, hosts):\n self._hosts = hosts",
"def set_hosts(self, host_list: t.List[str]) -> None:\n if isinstance(host_list, str):\n host_list = [host_list.strip()]\n if not isinstance(host_list, list):\n raise TypeError(\"host_list argument must be a list of string... | [
"0.66594523",
"0.62303126",
"0.61410034",
"0.60394865",
"0.5943786",
"0.5919907",
"0.5905216",
"0.58935386",
"0.5861023",
"0.5801098",
"0.57297915",
"0.56756735",
"0.56741655",
"0.5644177",
"0.56378186",
"0.56277186",
"0.5555581",
"0.5550633",
"0.5550633",
"0.5545153",
"0.554... | 0.0 | -1 |
Flushes configuration to a file as JSONified string. If a new filename is not given, uses `filename` property. | def flush(self, filename=None):
if filename is None:
filename = self.filename
with open(filename, 'w') as f:
f.write(self.dump()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_json(config: dict, filename: str):\n\n with open(filename, 'w', encoding='utf-8') as f:\n mmengine.dump(config, f, file_format='json')",
"def save_config_to_json(config, filename):\n with open(filename, 'w+') as f:\n json.dump(vars(config), f)",
"def save_config(self, filename:... | [
"0.7051634",
"0.6968615",
"0.6865831",
"0.67977846",
"0.65548044",
"0.65458256",
"0.6461248",
"0.6459402",
"0.64368117",
"0.64325255",
"0.63536674",
"0.6334606",
"0.63211185",
"0.62924033",
"0.6287353",
"0.62850744",
"0.62815297",
"0.6277847",
"0.6236087",
"0.61888987",
"0.61... | 0.0 | -1 |
Getter for TLS policies in this configuration file. | def policies(self):
return self._data.get('policies') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_rules(self) -> Sequence[Any]:\n return pulumi.get(self, \"policy_rules\")",
"def policies(self):\n return self._policies",
"def get_policies():\r\n policy = policies.values()\r\n return policy",
"def GetPolicies(self):\n policy = {}\n if json is None:\n logging.error... | [
"0.62467045",
"0.60867196",
"0.6082778",
"0.6034959",
"0.59870845",
"0.59870845",
"0.59201676",
"0.5845755",
"0.5785512",
"0.5633026",
"0.56324357",
"0.5614157",
"0.5575458",
"0.55583334",
"0.5530851",
"0.5530851",
"0.552006",
"0.5461094",
"0.5461094",
"0.54478496",
"0.542930... | 0.6233299 | 1 |
Find maximum of LCurve curvature. | def curvature_criterion(self, tau_space, lx, ly):
rho = np.log(lx)
xi = np.log(ly)
drho = np.gradient(rho)
ddrho = np.gradient(drho)
dxi = np.gradient(xi)
ddxi = np.gradient(dxi)
curv = 2 * (drho * ddxi - ddrho * dxi) / (drho**2 + dxi**2)**(3/2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def curvature_max(self):\n return 1.0 / self.radius_min",
"def max_curvature(self, uv):\n max_curv = GeomLProp_SLProps(\n self.surface(), uv[0], uv[1], 2, 1e-9\n ).MaxCurvature()\n if self.reversed():\n max_curv *= -1\n return max_curv",
"def get_Curvatu... | [
"0.8062958",
"0.75860894",
"0.6589427",
"0.6373266",
"0.6339498",
"0.6208771",
"0.6165077",
"0.600116",
"0.6000239",
"0.59949034",
"0.59914637",
"0.5955797",
"0.59465796",
"0.589547",
"0.58683926",
"0.58191746",
"0.57832944",
"0.5777425",
"0.57619905",
"0.57436806",
"0.572652... | 0.625251 | 5 |
normalize a vector to have norm = 1 | def normalize(v):
return v / np.linalg.norm(v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(vector):\n return vector / np.linalg.norm(vector)",
"def normalize(v):\n return np.array(v) / np.linalg.norm(v)",
"def normalise1D(*vector):\n\n vector = np.array(vector).flatten() # 1D vector\n\n norm = np.linalg.norm(vector) # vector norm\n if norm == 0: return vector #... | [
"0.8746538",
"0.84981257",
"0.8360617",
"0.8298223",
"0.8282614",
"0.8234107",
"0.8215352",
"0.81593287",
"0.81533724",
"0.81196946",
"0.8094739",
"0.8092246",
"0.80322766",
"0.8016517",
"0.800429",
"0.8003724",
"0.7972604",
"0.7943567",
"0.7935485",
"0.781471",
"0.7795828",
... | 0.8574032 | 1 |
find vector perpenticular with given vector | def find_perpendicular_vector(vt):
x, y = vt
return np.array([y, -x]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perp_vector(p, q, r):\n v = cross(q - r, q - p)\n return v / mod(v) + q",
"def perp_2d_vec(vec):\n return normalized(np.dot(R90, vec))",
"def vector_perp(v):\n assert len(v) == 2\n x, y = v\n return Vector(-y, x)",
"def heterogen(vector):\n vector = [el for el in vector if el > 0]\n ... | [
"0.7070827",
"0.6774848",
"0.6715309",
"0.6387233",
"0.6200855",
"0.6109683",
"0.6108494",
"0.60990584",
"0.5985426",
"0.5945798",
"0.5942709",
"0.5935143",
"0.5935143",
"0.5935143",
"0.59223044",
"0.5867384",
"0.5867384",
"0.5867384",
"0.5867384",
"0.5867384",
"0.5867384",
... | 0.57323617 | 37 |
Randomizes the order of data samples and their corresponding labels | def randomize(x, y):
permutation = np.random.permutation(y.shape[0])
shuffled_x = x[permutation, :]
shuffled_y = y[permutation]
return shuffled_x, shuffled_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shuffle_labels(self):\n random.shuffle(self.y_train)\n random.shuffle(self.y_test)",
"def inlabel_shuffle(data):\n num_zero_data = np.sum(data[:,-1]==0)\n label_zero_data = data[:num_zero_data,:]\n label_one_data = data[num_zero_data:,:]\n np.random.shuffle(label_zero_data)\n np.random.shu... | [
"0.7610801",
"0.72624075",
"0.71498376",
"0.71094793",
"0.7101863",
"0.70504063",
"0.6969117",
"0.6969117",
"0.6969117",
"0.69373816",
"0.69088066",
"0.6856464",
"0.6789744",
"0.6737744",
"0.6674642",
"0.6634555",
"0.6630403",
"0.6464263",
"0.6435945",
"0.6421794",
"0.6305728... | 0.0 | -1 |
Simple path formatter. Adds "\\" to the path | def _formatPath(directoryPath, filePath):
return directoryPath + "\\" + filePath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escapeForPath(s):\n return s.replace(os.sep, \"\")",
"def format_path(path):\n if not path:\n return path\n\n path = re.sub(r'/+', '/', path)\n\n if path == '/':\n return (u\"\" if isinstance(path, unicode) else \"\")\n else:\n return '/' + path.strip('/')",
"def format_... | [
"0.7076021",
"0.69011325",
"0.6809344",
"0.67313296",
"0.6703751",
"0.66492784",
"0.6604016",
"0.65762943",
"0.65511465",
"0.65220314",
"0.6512196",
"0.64905304",
"0.6474801",
"0.6461339",
"0.6369531",
"0.6331675",
"0.6301687",
"0.62589455",
"0.6231303",
"0.6217088",
"0.62048... | 0.6674891 | 5 |
Fixture to remove the tmp/backups directory when complete. | def cleanup_backups():
try:
yield
finally:
shutil.rmtree("tmp/backups") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n self.tempdir.cleanup()",
"def tearDown(self):\n \tshutil.rmtree(self.tempdir)",
"def tearDown(self):\n if 'turbinia-test-tmp' in self.tmp_dir:\n shutil.rmtree(self.tmp_dir)",
"def tearDown(self):\n if os.path.exists(self.temp):\n shutil.rmtree(self.te... | [
"0.7652624",
"0.7603511",
"0.7543852",
"0.75340176",
"0.7451659",
"0.74468315",
"0.7431121",
"0.7373532",
"0.7364512",
"0.73501295",
"0.73501295",
"0.7349859",
"0.7301561",
"0.7287947",
"0.72825235",
"0.7265863",
"0.72474694",
"0.7246766",
"0.72339755",
"0.7223153",
"0.721172... | 0.767783 | 0 |
Check whether the enum is valid and return the values of the enum. | def _assert_enum_valid(cls, enum: Type):
if isinstance(enum, EnumMeta):
enum_values = [str(option.value) for option in enum]
elif isinstance(enum, Iterable):
enum_values = list(enum)
else:
msg = "enum must be a subclass of Enum or an iterable."
rai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def availableValues(self):\n return [x.name for x in self._field.enum_type.values]",
"def _assert_enum_valid(cls, enum):\n if isinstance(enum, EnumMeta):\n enum_values = [str(option.value) for option in enum]\n elif isinstance(enum, Iterable):\n enum_values = list(enum)... | [
"0.7362553",
"0.6854786",
"0.6562943",
"0.65465194",
"0.63105285",
"0.62630725",
"0.6243644",
"0.62355715",
"0.62194747",
"0.6213934",
"0.62135684",
"0.60678273",
"0.6064533",
"0.60520905",
"0.6037465",
"0.60322773",
"0.6014105",
"0.599411",
"0.59464246",
"0.5918026",
"0.5783... | 0.6797397 | 2 |
Test graphs with no edge weight data raises `KeyError` | def test_missing_edge_weight_data_raises_error(self):
g = nx.complete_graph(3).to_directed()
with pytest.raises(KeyError, match="does not contain weight data"):
loss_hamiltonian(g) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialization_of_graphs():\n g = UndirectedGraph([('A', 2), (2, 'B'), ('B', 'C')])\n h = UndirectedGraph([('A', 2), ('B', 'C'), (2, 'B')])\n assert g == h\n \n # Raises ValueError since there are too few weights\n with pytest.raises(ValueError):\n g = UndirectedGraph([('A', 2), (... | [
"0.72734416",
"0.6972526",
"0.6802868",
"0.67649627",
"0.66926366",
"0.66779673",
"0.65623194",
"0.6505124",
"0.6503687",
"0.6414738",
"0.6413256",
"0.6316475",
"0.6282279",
"0.62596464",
"0.6235064",
"0.6222054",
"0.6200128",
"0.61971813",
"0.6173143",
"0.61671",
"0.6159127"... | 0.82826227 | 0 |
Compare warpExposure to swarp for given warping kernel. Note that swarp only warps the image plane, so only test that plane. | def compareToSwarp(self, kernelName,
useWarpExposure=True, useSubregion=False, useDeepCopy=False,
interpLength=10, cacheSize=100000,
rtol=4e-05, atol=1e-2):
warpingControl = afwMath.WarpingControl(
kernelName,
"", # th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testMatchSwarpLanczos2Exposure(self):\n self.compareToSwarp(\"lanczos2\", useWarpExposure=True)",
"def testMatchSwarpNearestExposure(self):\n self.compareToSwarp(\"nearest\", useWarpExposure=True, atol=60)",
"def testMatchSwarpBilinearExposure(self):\n self.compareToSwarp(\"bilinear\",... | [
"0.64770603",
"0.6440578",
"0.64122427",
"0.6396634",
"0.6329896",
"0.587488",
"0.5531313",
"0.54937637",
"0.54928577",
"0.54863787",
"0.5368766",
"0.5365246",
"0.52809274",
"0.52763057",
"0.5259263",
"0.5255423",
"0.514235",
"0.5132371",
"0.5123436",
"0.5108016",
"0.5075532"... | 0.714955 | 0 |
Function for creating JWT for Authentication Purpose | def create_jwt(user_obj):
return jwt.encode(
user_serializer.GetUserInfoSerializer(user_obj).data,
settings.SECRET_KEY, algorithm='HS256').decode('utf-8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_jwt_token(self):\n payload = jwt_payload_handler(self)\n token = jwt_encode_handler(payload)\n return token",
"def _generate_jwt_token(self):\n import jwt\n from datetime import datetime, timedelta\n from django.conf import settings\n\n dt = datetime... | [
"0.78900695",
"0.78387576",
"0.76606333",
"0.76533544",
"0.7530544",
"0.74550074",
"0.7441873",
"0.7429062",
"0.7413366",
"0.7406035",
"0.73776555",
"0.7372965",
"0.73044765",
"0.71948004",
"0.71718085",
"0.71688247",
"0.7117753",
"0.7117288",
"0.71123064",
"0.7097365",
"0.70... | 0.7626761 | 4 |
Return a Flavor instance or raise ItemNotFound. | def get_flavor(flavor_id, include_deleted=False):
try:
flavor_id = int(flavor_id)
if include_deleted:
return Flavor.objects.get(id=flavor_id)
else:
return Flavor.objects.get(id=flavor_id, deleted=include_deleted)
except (ValueError, TypeError):
raise faul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flavor(name):\r\n return nova.flavors.find(name=name)",
"def flavor(self, name=None):\n return self.find(self.flavors(), name=name)",
"def find_flavor(self, name_or_id, ignore_missing=True):\n return self._find(\n _flavor.Flavor, name_or_id, ignore_missing=ignore_missing\n ... | [
"0.6734274",
"0.66894305",
"0.66251403",
"0.6595879",
"0.65231955",
"0.64819133",
"0.61645335",
"0.6058981",
"0.6058981",
"0.59495175",
"0.58669734",
"0.5849747",
"0.5845765",
"0.5731084",
"0.57228667",
"0.57207537",
"0.5711365",
"0.55633694",
"0.5540136",
"0.54709226",
"0.54... | 0.6445534 | 6 |
Extract the URL from a metadata object. Returns None if the URL is invalid or the metadata does not contain an URL. | def get_url_from_metadata(self, metadata):
if metadata != None:
url_object = metadata.lookup_value('xesam:url')
if url_object != None:
url = url_object.get_string()
if url != '':
return url
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def direct_url(self) -> Optional[DirectUrl]:\n try:\n content = self.read_text(DIRECT_URL_METADATA_NAME)\n except FileNotFoundError:\n return None\n try:\n return DirectUrl.from_json(content)\n except (\n UnicodeDecodeError,\n json.... | [
"0.70464224",
"0.6766931",
"0.61524594",
"0.6151016",
"0.61417866",
"0.6129782",
"0.6055454",
"0.60285854",
"0.59879005",
"0.58797365",
"0.5843219",
"0.5820332",
"0.58135706",
"0.5808752",
"0.5771527",
"0.56971586",
"0.56964463",
"0.568717",
"0.56862396",
"0.56862396",
"0.568... | 0.8732619 | 0 |
Resets the default fields values and creates the temporary directory. | def __init__(self, directory):
self.baseUrl = 'http://www.televideo.rai.it/televideo/pub/tt4web/Nazionale'
self.mapUrl = 'http://www.televideo.rai.it/televideo/pub/pagina.jsp?p=PAGE&s=PART&r=Nazionale&idmenumain=2&pagetocall=pagina.jsp'
self.directory = directory
self.default = director... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _use_temp_directory(self):\n if not self._is_temp_dir:\n self._orig_base_data_dir = self._base_data_dir\n self._orig_base_logs_dir = self._base_logs_dir\n temp_dir = Path(tempfile.mkdtemp())\n self._base_data_dir = temp_dir / \"data\"\n self._base_logs_dir = te... | [
"0.6702049",
"0.6620325",
"0.65989345",
"0.6576133",
"0.6560937",
"0.6450358",
"0.64152473",
"0.63893086",
"0.63178295",
"0.63178295",
"0.63107365",
"0.6245028",
"0.62278986",
"0.6205534",
"0.6180942",
"0.6150329",
"0.6143466",
"0.61324763",
"0.6119405",
"0.60965574",
"0.6063... | 0.0 | -1 |
Register and my custom Altair theme. | def use_my_theme():
# register and enable the theme
alt.themes.register("my_theme", my_theme)
alt.themes.enable("my_theme") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_theme(ctx, **defaults):\n from .quickstart import theme_quickstart\n\n project = ctx.get_project(silent=True)\n theme_quickstart(defaults, project=project)",
"def setup_theme():\n os.system('sudo apt install arc-theme')\n\n output = \"{padding}{mark} Installing theme...\"\n print(output... | [
"0.65362704",
"0.6533907",
"0.65302336",
"0.64712983",
"0.6326045",
"0.6273264",
"0.6266784",
"0.610829",
"0.59554917",
"0.59432256",
"0.5875423",
"0.5858105",
"0.5656011",
"0.56324315",
"0.5631634",
"0.54914767",
"0.5470845",
"0.5362045",
"0.53561074",
"0.53477967",
"0.52695... | 0.7663698 | 1 |
Returns True if the coefficients of the two polynomials have the following a. they are the same number b. they are close enough pointwise. | def close_enough(poly, target_poly, eps=0.01):
if type(target_poly) != type(poly):
target_poly = list(target_poly)
if len(poly) != len(target_poly):
raise Exception("Incorrect number of terms")
for term, target_term in zip(poly, target_poly):
if abs(term - target_term) > eps:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _poly_exactly_equal(a,b):\n for a_hole, b_hole in zip(a.holes, b.holes):\n if not np.array_equal(a_hole, b_hole):\n return False\n for a_part, b_part in zip(a.parts, b.parts):\n if not np.array_equal(a_part, b_part):\n return False\n return True",
"def _poly_exact... | [
"0.75495493",
"0.7335283",
"0.7044036",
"0.7025358",
"0.6952558",
"0.68725693",
"0.6750162",
"0.6706163",
"0.6680784",
"0.66692114",
"0.6664742",
"0.66516376",
"0.6607871",
"0.6606549",
"0.65600824",
"0.65223604",
"0.6481739",
"0.6467734",
"0.64365476",
"0.64043504",
"0.64041... | 0.5933131 | 57 |
Return a friendly HTTP greeting. | def hello():
return 'Hello World hahaha !!!!!!' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_greeting(name):\n\n greeting = (f\"Hello, {name.title()}. It's nice to meet you!\")\n return greeting",
"def welcome():\n return 'Welcome to Flask!'",
"def greeting_message(name):\n print('My name is ' + name)",
"def Welcome():\n return (\n f\"Welcome to the Surf's Up API!\... | [
"0.67860854",
"0.6719625",
"0.67095745",
"0.6680697",
"0.6663219",
"0.6638394",
"0.6633062",
"0.6628187",
"0.6556032",
"0.6536937",
"0.64776874",
"0.6477268",
"0.64715713",
"0.64644194",
"0.6443056",
"0.6435385",
"0.6400719",
"0.6400167",
"0.637615",
"0.637615",
"0.6367243",
... | 0.0 | -1 |
Return name of the worksheet. | def get_worksheet(self):
return self.worksheet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_workbook_name(self, workbook: Workbook) -> str:\n return workbook.title",
"def getActiveSheetName():\n document = Context.getDocument()\n activeSheet = document.getCurrentController().getActiveSheet()\n return activeSheet.getName()",
"def get_sheet_name(self):\n\n xl = pd.ExcelFi... | [
"0.7039318",
"0.6969674",
"0.68402946",
"0.6323195",
"0.62958205",
"0.6191118",
"0.6117964",
"0.6034934",
"0.5937051",
"0.5933627",
"0.5933627",
"0.5919367",
"0.59043777",
"0.59030783",
"0.5863491",
"0.58568406",
"0.5847715",
"0.5840714",
"0.5830654",
"0.5830654",
"0.5830654"... | 0.6774123 | 3 |
Return name of the workbook. | def get_workbook(self):
return self.workbook | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_workbook_name(self, workbook: Workbook) -> str:\n return workbook.title",
"def get_name(self):\n return self._file.name",
"def get_name(self) -> str:\n return os.path.split(os.getcwd())[-1]",
"def name(self):\n return self._filename",
"def get_sheet_name(filename):\n ... | [
"0.8340437",
"0.6342669",
"0.61625004",
"0.6157091",
"0.61231226",
"0.6090624",
"0.6081371",
"0.604609",
"0.59801394",
"0.5974948",
"0.5929345",
"0.59051883",
"0.5847362",
"0.5847362",
"0.5840521",
"0.5838494",
"0.58332425",
"0.5831625",
"0.5823304",
"0.58182245",
"0.5795293"... | 0.0 | -1 |
Return name of the document. | def get_document(self):
return self.document | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._document['name']",
"def name(self) -> str:\n return self.doc.get('name', self.identifier())",
"def name(self):\n\n if not hasattr(self, \"_name\"):\n name = Doc.get_text(self.doc.find(\"PreferredName\", \"\"))\n self._name = ... | [
"0.8442852",
"0.8306342",
"0.7380376",
"0.736301",
"0.72964364",
"0.7114619",
"0.7058983",
"0.7028049",
"0.7004435",
"0.7004435",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.69935924",
"0.697... | 0.0 | -1 |
Convert class labels from scalars to onehot vectors | def dense_to_one_hot(label_dense,num_classes=2): # scalars 标量 一个one-hot向量除了某一位的数字是1以外其余各维度数字都是0
num_labels = label_dense.shape[0]
index_offset = np.arange(num_labels)*num_classes # idnex_offset该下标表表示的是一维时候每个labels的对应下标 arange一个参数时,参数值为终点,起点取默认值0,步长取默认值1
labels_one_hot = np.zeros((num_labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(labels, classes=None):\n return K.utils.to_categorical(labels, classes)",
"def one_hot(labels, classes=None):\n\n one_hot_ = K.utils.to_categorical(labels, classes)\n return(one_hot_)",
"def To1hot(label,num_class):\n onehot = np.zeros(num_class)\n onehot[label] = 1\n return oneho... | [
"0.8369099",
"0.8184567",
"0.81024134",
"0.8077252",
"0.807633",
"0.8050328",
"0.80436194",
"0.80269533",
"0.80269533",
"0.79798156",
"0.79729146",
"0.79695207",
"0.79407936",
"0.79191554",
"0.79048985",
"0.7895879",
"0.7849574",
"0.7844943",
"0.7837363",
"0.78372246",
"0.783... | 0.7219783 | 92 |
Construct a DataSet. one_hot arg is used only if fake_data is true. `dtype` can be either `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into `[0, 1]`. | def __init__(self, images, labels, fake_data=False, one_hot=False,
dtype=tf.float32):
dtype = tf.as_dtype(dtype).base_dtype #返回该DType的基础DType,而非参考的数据类型(non-reference)
if dtype not in (tf.uint8, tf.float32):
raise TypeError('Invalid image dtype %r, expected uint8 or float32' %
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(x, num_classes, dtype=jnp.float32):\n return jax.nn.one_hot(x, num_classes).astype(dtype)",
"def labels_to_one_hot(\n labels: np.ndarray, categories: int, axis: int = 0,\n keepdims=False, dtype=bool\n):\n if keepdims:\n assert labels.shape[axis] == 1\n result_ndim = la... | [
"0.6929286",
"0.6369948",
"0.63244903",
"0.63239926",
"0.6284337",
"0.62314653",
"0.62222224",
"0.61985177",
"0.61884886",
"0.61752594",
"0.6170024",
"0.61685055",
"0.61614555",
"0.61585116",
"0.61585116",
"0.6153418",
"0.61488473",
"0.61419",
"0.61160076",
"0.61143345",
"0.6... | 0.0 | -1 |
Returns all topics from black mage. | def resolve_topics(self, info, **kwargs):
return Topic.objects.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_topics(self):\r\n return [x[0] for x in get_published_topics()]",
"def topics(self):\r\n return contents.Topics(self)",
"def topics(self):\r\n return topics.Topics(self)",
"def topics(self):\n return topics.Topics(self)",
"def get_topics(self):\n return self.clien... | [
"0.7876192",
"0.7469221",
"0.7463177",
"0.731952",
"0.7270489",
"0.7253152",
"0.7085382",
"0.7079373",
"0.7021672",
"0.70174825",
"0.6914631",
"0.6785149",
"0.6778883",
"0.67697227",
"0.67567474",
"0.6644736",
"0.6630566",
"0.66033",
"0.6587081",
"0.6583617",
"0.65086585",
... | 0.65285903 | 20 |
Return the same value within `seconds` time period | def get_ttl_hash(seconds=3600):
return round(time.time() / seconds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clock_helper(total_seconds):\n seconds_in_minute = total_seconds % 60",
"def roundSeconds(seconds):\n\n minutes = seconds / 60\n remainder = seconds % 60\n\n if(remainder >= 30):\n minutes += 1\n\n return minutes * 60",
"def get_millis(seconds):\n return seconds * 10 ** 3",
"def ... | [
"0.61171687",
"0.5976896",
"0.5888562",
"0.5886468",
"0.5863752",
"0.5855601",
"0.5782485",
"0.57756007",
"0.5713206",
"0.5713206",
"0.5676949",
"0.5647429",
"0.56461763",
"0.56433237",
"0.5612715",
"0.5611092",
"0.5597019",
"0.556223",
"0.5555322",
"0.5518646",
"0.5513411",
... | 0.0 | -1 |
Multiplies vector3 vec by unit quaternion quat and returns the resulting rotated vector | def vec_quat_mult(vec, quat):
vec_extended = np.concatenate((0, vec), axis=None)
quat_inverse = np.array([quat[0], -quat[1], -quat[2], -quat[3]])
final_prod = ham_product(ham_product(quat, vec_extended), quat_inverse)
return final_prod[1:4] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quatPassiveRot(q, v):\n\tv_q = np.zeros((4, 1))\n\tv_q[1:] = v\n\tv_qnew = quatLeftMat(q).T @ quatRightMat(q) @ v_q\n\treturn v_qnew[1:]",
"def test_rotate_vec(self):\n\n quat = Quat.from_axis_angle_deg(Vec3(-1, -1, -1), 180.)\n vec = Vec3(1, 0, 0)\n\n rotated_vec = quat.rotate_vec(vec)\... | [
"0.770387",
"0.7546813",
"0.7482931",
"0.7405268",
"0.73668677",
"0.7271283",
"0.72085196",
"0.7105764",
"0.70878017",
"0.7008738",
"0.69095737",
"0.6866999",
"0.68538564",
"0.68275446",
"0.68275446",
"0.67850894",
"0.67218274",
"0.66523397",
"0.6531478",
"0.64471996",
"0.643... | 0.76233983 | 1 |
Get the nearest neighbour words | def nn_words(table, wordvecs, query, k=10):
keys = table.keys()
qf = table[query]
scores = numpy.dot(qf, wordvecs.T).flatten()
sorted_args = numpy.argsort(scores)[::-1]
words = [keys[a] for a in sorted_args[:k]]
print ('QUERY: ' + query)
print ('NEAREST: ')
for i, w in enumerate(words):
print (w) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest_words(self, word, n):\n\n vector = self.get_vector(word)\n\n if vector is None:\n return None\n\n distances = [\n (w, torch.dist(vector, self.get_vector(w)).item())\n for w in self.glove.itos\n ]\n\n return [w for w, v in sorted(distan... | [
"0.7328914",
"0.71997714",
"0.7109158",
"0.70136714",
"0.6881527",
"0.6856135",
"0.6846056",
"0.67294353",
"0.67229235",
"0.67113394",
"0.663129",
"0.6483845",
"0.63731456",
"0.63354486",
"0.63354486",
"0.63354486",
"0.63039273",
"0.6289074",
"0.6258887",
"0.62265164",
"0.612... | 0.668223 | 10 |
Forward pass through GRU layer | def gru_layer(tparams, state_below, options, prefix='gru', mask=None, **kwargs):
nsteps = state_below.shape[0]
if state_below.ndim == 3:
n_samples = state_below.shape[1]
else:
n_samples = 1
dim = tparams[_p(prefix,'Ux')].shape[1]
if mask == None:
mask = tensor.alloc(1., state_below.shape[0], 1)
def _slic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GRU(previous_hidden_state, x):\n # R Gate\n r = tf.sigmoid(tf.matmul(x, Wr) + \\\n tf.matmul(previous_hidden_state, Ur) + br)\n # U Gate\n u = tf.sigmoid(tf.matmul(x, Wu) + \\\n tf.matmul(previous_hidden_state, Uu) + bu)\n # Final Memory cell\n ... | [
"0.69769704",
"0.69294876",
"0.6818954",
"0.679522",
"0.6615893",
"0.6545958",
"0.65410095",
"0.6538721",
"0.65336585",
"0.6498751",
"0.6459099",
"0.6454158",
"0.63321877",
"0.63270444",
"0.63208324",
"0.6287723",
"0.6279007",
"0.62770253",
"0.6275967",
"0.6260427",
"0.623505... | 0.71091443 | 0 |
Update or edit category | def updateCategory(request, category_id):
try:
category = Category.objects.get(id=category_id)
print("id", category)
except Category.DoesNotExist:
return Response({'message': "requested category does not exist"}, status=status.HTTP_404_NOT_FOUND)
if request.method == "GET":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, request, *args, **kwargs):\n response = super(CategoryViewSet).update(self, request, *args, *kwargs)\n response.data['message'] = \"Categoria ha sido editada\"",
"def editCategory(category_id):\n editedCategory = session.query(Category). \\\n filter_by(id=category_id).one... | [
"0.7671197",
"0.76485246",
"0.7480355",
"0.74739754",
"0.74328667",
"0.7319179",
"0.7312993",
"0.7269082",
"0.72075963",
"0.71546555",
"0.7112014",
"0.7063623",
"0.70480263",
"0.6980938",
"0.69538695",
"0.6924649",
"0.69143075",
"0.6906742",
"0.6785965",
"0.6713326",
"0.67053... | 0.7045605 | 13 |
Update or edit category | def deleteCategory(request, category_id):
try:
category = Category.objects.get(id=category_id)
print("id", category)
except Category.DoesNotExist:
return Response({'message': "requested category does not exist", "status": status.HTTP_404_NOT_FOUND})
if request.method == "GET":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, request, *args, **kwargs):\n response = super(CategoryViewSet).update(self, request, *args, *kwargs)\n response.data['message'] = \"Categoria ha sido editada\"",
"def editCategory(category_id):\n editedCategory = session.query(Category). \\\n filter_by(id=category_id).one... | [
"0.7671197",
"0.76485246",
"0.7480355",
"0.74739754",
"0.74328667",
"0.7319179",
"0.7312993",
"0.7269082",
"0.72075963",
"0.71546555",
"0.7112014",
"0.7063623",
"0.70480263",
"0.7045605",
"0.6980938",
"0.69538695",
"0.6924649",
"0.69143075",
"0.6906742",
"0.6785965",
"0.67133... | 0.0 | -1 |
Sets the job_flow_id of this JobFlow. | def job_flow_id(self, job_flow_id):
self._job_flow_id = job_flow_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job_id(self, job_id):\n\n self._job_id = job_id",
"def job_id(self, job_id):\n\n self._job_id = job_id",
"def job_id(self, job_id):\n\n self._job_id = job_id",
"def job_id(self, job_id: JobId):\r\n self._job_id = job_id",
"def setJobId(self, jobid):\n self._ShREEKConf... | [
"0.6441779",
"0.6441779",
"0.6441779",
"0.6380962",
"0.5943968",
"0.5826679",
"0.5772291",
"0.57185155",
"0.5481224",
"0.54755044",
"0.5443353",
"0.543557",
"0.5412495",
"0.54072183",
"0.54053146",
"0.5328769",
"0.5328769",
"0.53165245",
"0.529883",
"0.5298529",
"0.5259993",
... | 0.8996603 | 0 |
Sets the subscription_id of this JobFlow. | def subscription_id(self, subscription_id):
self._subscription_id = subscription_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscription(self, subscription):\n if subscription is None:\n raise ValueError(\"Invalid value for `subscription`, must not be `None`\")\n\n self._subscription = subscription",
"def subscription(self, subscription):\n\n self._subscription = subscription",
"def set_endpoint_... | [
"0.69916046",
"0.69174916",
"0.67454904",
"0.6105906",
"0.604121",
"0.5903538",
"0.58498675",
"0.58498675",
"0.58498675",
"0.5804755",
"0.57953686",
"0.5751992",
"0.5751992",
"0.57029617",
"0.5691048",
"0.56691235",
"0.5614546",
"0.5576805",
"0.54943603",
"0.54219455",
"0.536... | 0.8238573 | 2 |
Sets the name of this JobFlow. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self._name = name",
"def set_name(self, name: str):\n self._name = name",
"def set_name(self, _name):\n self.name = _name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, na... | [
"0.7690387",
"0.7690079",
"0.7669687",
"0.7637739",
"0.7637739",
"0.7637739",
"0.7637739",
"0.7637739",
"0.76286083",
"0.76286083",
"0.7604411",
"0.7604411",
"0.7576435",
"0.7565597",
"0.75361377",
"0.7484264",
"0.74761957",
"0.74760354",
"0.7465989",
"0.7465989",
"0.7465989"... | 0.0 | -1 |
Sets the action_flow of this JobFlow. | def action_flow(self, action_flow):
self._action_flow = action_flow | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flow(self, flow):\n\n self._flow = flow",
"def set_action(self, action):\n self._action = action\n return self",
"def set_action(self, action):\n self.action = action",
"def set_action(self, action):\n self.action = action",
"def setAction(self, action):\n self... | [
"0.6697477",
"0.6605106",
"0.6572391",
"0.6572391",
"0.65584624",
"0.65481216",
"0.65435165",
"0.6204514",
"0.6125053",
"0.61220413",
"0.60994005",
"0.60994005",
"0.60994005",
"0.60994005",
"0.60994005",
"0.60994005",
"0.6096965",
"0.6006232",
"0.5993321",
"0.59661347",
"0.58... | 0.8506048 | 0 |
Sets the job_flow_plans of this JobFlow. | def job_flow_plans(self, job_flow_plans):
self._job_flow_plans = job_flow_plans | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plans(self, plans):\n\n self._plans = plans",
"def supp_plans(self, supp_plans):\n\n self._supp_plans = supp_plans",
"def plan(self, plan):\n\n self._plan = plan",
"def job_flow_id(self, job_flow_id):\n\n self._job_flow_id = job_flow_id",
"def scheduled_plan(self, scheduled_... | [
"0.651165",
"0.59491223",
"0.57776326",
"0.56348467",
"0.54054314",
"0.5352163",
"0.53507125",
"0.5101109",
"0.5089099",
"0.47738126",
"0.47630695",
"0.47478443",
"0.46569446",
"0.46268952",
"0.46123677",
"0.46094048",
"0.4609186",
"0.46035862",
"0.45684758",
"0.45664078",
"0... | 0.86924565 | 0 |
Sets the creation_name of this JobFlow. | def creation_name(self, creation_name):
self._creation_name = creation_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, _name):\n self.name = _name",
"def set_name(self, _name):\n self.name = _name\n return self.name",
"def create_name (self):\n return self.create_topic().create_name('Name')",
"def job_name(self, job_name):\n\n self._job_name = job_name",
"def generate_w... | [
"0.6261876",
"0.6150714",
"0.6131463",
"0.6106729",
"0.6098038",
"0.60866755",
"0.608278",
"0.6082664",
"0.6082664",
"0.60284775",
"0.6012197",
"0.6012197",
"0.6012197",
"0.6012197",
"0.6012197",
"0.59981453",
"0.5983301",
"0.5983301",
"0.5977474",
"0.59725994",
"0.5952066",
... | 0.84072924 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, JobFlow):
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.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):
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 |
Returns the mean geometric chord of the wing (S/b). | def mean_geometric_chord(self) -> float:
return self.area() / self.span() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cf_mean(self):\n net_power = self['annual_gross_energy'] \\\n - self['annual_thermal_consumption'] # kW-hr\n # q_pb_des is in MW, convert to kW-hr\n name_plate = self['q_pb_design'] * 8760 * 1000\n\n return net_power / name_plate",
"def cf_mean(self):\n net_powe... | [
"0.6242437",
"0.60839003",
"0.6067497",
"0.6013805",
"0.5957862",
"0.5931541",
"0.58810556",
"0.58113635",
"0.57946396",
"0.5716967",
"0.567145",
"0.56415355",
"0.5621868",
"0.5609336",
"0.56035614",
"0.56033283",
"0.55870014",
"0.556996",
"0.55433065",
"0.5532752",
"0.552707... | 0.7377378 | 0 |
Returns whether or not the user can view this monitor. | def can_view(self, user):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkPermissionZopeManager(self):\n user = self.REQUEST.AUTHENTICATED_USER\n\n return bool(user.has_permission(view_management_screens, self))",
"def can_show(self):\n return self.can_show",
"def can_be_viewed_by(self,user):\n return True",
"def is_visible(cls, request):\n ... | [
"0.72141016",
"0.7082938",
"0.6964027",
"0.6945758",
"0.68961805",
"0.6861698",
"0.6835311",
"0.67899245",
"0.66705745",
"0.66488165",
"0.6610142",
"0.660011",
"0.660011",
"0.660011",
"0.6587095",
"0.65833217",
"0.6508811",
"0.64967203",
"0.64819425",
"0.64551294",
"0.6432972... | 0.7221826 | 0 |
Initialise the weights of the ESIM model. | def _init_esim_weights(module):
if isinstance(module, nn.Linear):
nn.init.xavier_uniform_(module.weight.data)
nn.init.constant_(module.bias.data, 0.0)
elif isinstance(module, nn.LSTM):
nn.init.xavier_uniform_(module.weight_ih_l0.data)
nn.init.orthogonal_(module.weight_hh_l0.data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n pass",
"def init_weights(model):\n ...",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def init_weights(self):\n # Initialize weights\n ... | [
"0.7948795",
"0.791889",
"0.7916553",
"0.79133403",
"0.7717142",
"0.76740867",
"0.7670459",
"0.7665397",
"0.7627345",
"0.7601293",
"0.75917876",
"0.730495",
"0.7301711",
"0.7301711",
"0.7301711",
"0.7273246",
"0.724169",
"0.7238179",
"0.7222038",
"0.7220882",
"0.7216713",
"... | 0.6846368 | 65 |
loads a numpy .npy array from file and transforms it into a symmetric array | def symLoad(loadFile='symsave.npy'):
loaded = np.load(loadFile)
n = -1/2.+np.sqrt(1/4.+2*loaded.size)
array = np.zeros([n,n])
indices = np.triu_indices(n)
array[indices]=loaded
return array+np.transpose(array)-np.diag(np.diag(array)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_npy_file(file_path):\n return np.load(file_path.decode()).astype(np.float32)",
"def load_data_from_npy(filename):\n return np.load(filename)",
"def read_npy_file(filename):\n np_arr = np.load(filename)\n return np_arr",
"def load(filename):\n return np.load(filename)",
"def rea... | [
"0.6977436",
"0.6900838",
"0.6504564",
"0.6435888",
"0.6384373",
"0.6379861",
"0.6334662",
"0.6327956",
"0.6262082",
"0.62526375",
"0.6193084",
"0.6189153",
"0.613422",
"0.6123099",
"0.6086385",
"0.6024466",
"0.601707",
"0.59880936",
"0.5978878",
"0.5957565",
"0.5915432",
"... | 0.6669528 | 2 |
Initialize a new ConsoleController self. | def __init__(self, number_of_cheeses, number_of_stools):
self.number_of_cheeses = number_of_cheeses
self.number_of_stools = number_of_stools | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, game):\n self.game = game\n ConsoleController.__init__(self, None)",
"def setUp(self):\n self.console = ConsoleWidget()\n self.text_edit = self.console._control",
"def start_console(self):\n return",
"def __init__(self, args):\n super().__init__()\... | [
"0.6878187",
"0.6425806",
"0.64223385",
"0.63462037",
"0.6332916",
"0.6221512",
"0.61765397",
"0.61424834",
"0.6123856",
"0.60340816",
"0.6028922",
"0.5927555",
"0.5853501",
"0.5844645",
"0.5807799",
"0.57861006",
"0.5784058",
"0.5724852",
"0.5724138",
"0.56988347",
"0.564804... | 0.0 | -1 |
Generate a new sitemap filename based on count. | def _newfile(counter):
name = '%s/sitemap-%s.xml.gz' % (settings.SITEMAPS_DIR,
counter)
fp = gzip.open(name, 'wb')
fp.write("""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n""")
return fp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _newurl(counter):\n return \"%s/sitemap-%s.xml.gz\" % (settings.SITEMAPS_BASE_URL, counter)",
"def write_sitemaps():\n sitemap_index = open('static/sitemaps/sitemap.xml', 'w')\n sitemap_index.write('<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/si... | [
"0.7264054",
"0.6227657",
"0.6097597",
"0.5960428",
"0.5937562",
"0.58240074",
"0.5783639",
"0.57822263",
"0.573668",
"0.57359517",
"0.5726482",
"0.5720662",
"0.56979996",
"0.56799036",
"0.565552",
"0.5585595",
"0.55738306",
"0.5567021",
"0.5521101",
"0.5515651",
"0.5514743",... | 0.6769124 | 1 |
Order queryset by annotation values. The format of the ordering field is annotations__field_id, possibly prefixed by a minus sign. The minus sign indicates descending order. | def order_queryset(self, queryset):
if ordering := self.request.query_params.get("ordering"):
order_by = []
regex = re.compile(r"-?annotations__(?P<field_id>\d+)")
fields = [field.strip() for field in ordering.split(",")]
for match in filter(None, map(regex.match,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_by(self, *fields):\n doc = []\n for field in fields:\n if field.startswith('-'):\n doc.append((field.strip('-'), pymongo.DESCENDING))\n else:\n doc.append((field, pymongo.ASCENDING))\n return self.sort(doc)",
"def order_by(self, f... | [
"0.6110459",
"0.60601103",
"0.58421963",
"0.57634676",
"0.56661314",
"0.5527909",
"0.5513533",
"0.55091345",
"0.5437888",
"0.540819",
"0.54006535",
"0.53413165",
"0.5323872",
"0.5321573",
"0.5297688",
"0.525465",
"0.5236016",
"0.52188337",
"0.5209658",
"0.51942223",
"0.516283... | 0.8023197 | 0 |
Move samples from source to destination collection. The request accepts argument 'handle_missing_annotations'.The possible values for it are 'ADD' and 'REMOVE'. When 'REMOVE' is set without arguments the 'confirm_annotations_delete' argument must be set to True. | def move_to_collection(self, request, *args, **kwargs):
ids = self.get_ids(request.data)
dst_collection_id = self.get_id(request.data, "destination_collection")
dst_collection = get_collection_for_user(dst_collection_id, request.user)
entity_qs = self._get_entities(request.user, ids)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_from_empty_source(self, mock_info):\n source_consumer_data = {\"allocations\": {}}\n source_rsp = mock.Mock()\n source_rsp.json.return_value = source_consumer_data\n self.mock_get.side_effect = [source_rsp, self.target_rsp]\n\n resp = self.client.move_allocations(\n... | [
"0.5602858",
"0.5356931",
"0.51003027",
"0.50642705",
"0.4770782",
"0.47355297",
"0.4683761",
"0.46703807",
"0.46632388",
"0.46476516",
"0.4641159",
"0.46215132",
"0.45906737",
"0.45707744",
"0.45690298",
"0.45258832",
"0.45139736",
"0.45118746",
"0.44913766",
"0.4481148",
"0... | 0.6794272 | 0 |
Get the annotations on this sample. | def get_annotations(self):
entity = self.get_object()
serializer = AnnotationValueSerializer(entity.annotations.all(), many=True)
return Response(serializer.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annotations(self):\n return self._annotations",
"def annotations(self):\n\n return self._annotations",
"def annotations(self) -> pulumi.Output[Mapping[str, Any]]:\n return pulumi.get(self, \"annotations\")",
"def annotations(self) -> Mapping[str, str]:\n return pulumi.get(self... | [
"0.82852864",
"0.82130015",
"0.7955252",
"0.7897015",
"0.7897015",
"0.7691412",
"0.74950594",
"0.7343457",
"0.7343457",
"0.7288582",
"0.7096112",
"0.7033083",
"0.6869257",
"0.67692256",
"0.66795343",
"0.66695225",
"0.6660288",
"0.6541105",
"0.6517347",
"0.6506238",
"0.6480126... | 0.73477864 | 7 |
Checks if the given image is of supported type. | def validate_image_type(filename: str) -> bool:
supported_extensions = ("png", "jpg", "jpeg")
return (filename not in (None, "")) and (get_extension(filename) in supported_extensions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_type(filename):\n try:\n im = Image.read(filename)\n except SanperaError:\n return False\n else:\n return im.original_format in [b'JPEG', b'PNG', b'GIF']",
"def _check_image_is_supported(self):\n\t\tSUPPORTED = {}\n\t\tSUPPORTED['RECORD_TYPE'] = 'FIXED_LENGTH',\n\t\tSUPPOR... | [
"0.7959575",
"0.77283853",
"0.7631249",
"0.71965295",
"0.7109659",
"0.7044094",
"0.6983421",
"0.6947739",
"0.6901157",
"0.68962884",
"0.6860417",
"0.6825139",
"0.6693099",
"0.6690817",
"0.6669964",
"0.65231454",
"0.6522318",
"0.6504293",
"0.6495985",
"0.64689946",
"0.6465042"... | 0.77737397 | 1 |
Wraps hidden states in new Tensors, to detach them from their history. | def repackage_hidden(h):
if isinstance(h, torch.Tensor):
return h.detach()
else:
return tuple(repackage_hidden(v) for v in h) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detach_hidden(hidden: Any) -> Any:\n return apply_to_tensor(hidden, Tensor.detach)",
"def reset_hidden(self, hidden, reset_flags):\n # detach it from history (pytorch mechanics)\n if self.rnn_type in ['lstm', 'mylstm']:\n h = Variable(hidden[0].data)\n c = Variable(hidd... | [
"0.6897401",
"0.656451",
"0.644081",
"0.6318728",
"0.6296365",
"0.6182935",
"0.61435914",
"0.6126952",
"0.6126952",
"0.61207926",
"0.6028801",
"0.60258055",
"0.60202205",
"0.59870327",
"0.5969085",
"0.5969085",
"0.59322524",
"0.59322524",
"0.5919225",
"0.5889256",
"0.58735996... | 0.5654297 | 27 |
Returns the instance of the PersistenceManager | def get_instance():
if PersistenceManager._instance is None:
PersistenceManager._instance = PersistenceManager()
return PersistenceManager._instance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Get(self):\n\n if not hasattr(self, \"_instance\"):\n self._instance = PersistenceManager()\n\n return self._instance",
"def getManager(self):\n return self._manager",
"def GetManager(self):\r\n\r\n return self.manager",
"def get_persistence(self):\n return s... | [
"0.8831981",
"0.70946217",
"0.70936316",
"0.70914304",
"0.6594804",
"0.65939456",
"0.6508369",
"0.6459507",
"0.64588106",
"0.6402856",
"0.6056207",
"0.60556406",
"0.6042333",
"0.6017835",
"0.60154915",
"0.5996921",
"0.59719694",
"0.59528816",
"0.59403986",
"0.58729494",
"0.58... | 0.9267288 | 0 |
This method sets the activation functions. | def set_activation(self, method, sig=None, d_sig=None, sig_0=None, d_sig_0=None):
method = method.lower()
if method == 'logistic':
self.sig = lambda z: twod(1 / (1 + np.exp(-z)))
self.d_sig = lambda z: twod(np.multiply(self.sig(z), (1 - self.sig(z))))
self.sig_0 = self.sig
self.d_sig_0 = self.d_sig
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialiseActivationFunctions(self):\n\n\t\t###uniform for output units\n\t\tif self._outputActivationFunctions == None or self._outputActivationDerivatives == None:\t\n\t\n\t\t\tself._outputActivationFunctions = []\n\t\t\tself._outputActivationDerivatives = []\n\n\t\t\tactFunc = lambda x : x\n\t\t\tdActFunc =... | [
"0.7149997",
"0.6836559",
"0.67072904",
"0.66936004",
"0.65057546",
"0.62645847",
"0.62319726",
"0.61494285",
"0.61046493",
"0.6033056",
"0.59909195",
"0.59692806",
"0.59556955",
"0.5932327",
"0.5928175",
"0.59252304",
"0.5907595",
"0.59056467",
"0.5880977",
"0.58801496",
"0.... | 0.64503163 | 5 |
Set weights of the classifier. | def set_weights(self, wts):
self.wts = wts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weights(self, weights):\r\n self.weights = weights",
"def setWeights(self, w):\n raise NotImplementedError",
"def set_weights(self, weights):\n self._weights = weights\n self.normalize_weights() ########################added\n #self.get_weights()",
"def set_weight... | [
"0.8336834",
"0.81745493",
"0.8036256",
"0.79957646",
"0.79326403",
"0.78144443",
"0.77861327",
"0.7707767",
"0.7583068",
"0.74949944",
"0.74890727",
"0.74890727",
"0.74572176",
"0.74309945",
"0.73803174",
"0.7362213",
"0.7277161",
"0.7219205",
"0.721557",
"0.71476513",
"0.71... | 0.7036269 | 24 |
Removes probabilities of the transition to the same state | def __prepareTransitions(self):
self.transition_matrix=self.markovModel._get_transmat()[:]
for i in range(len(self.transition_matrix)):
index=np.argmax(self.transition_matrix[i,:])
if index==i:
self.transition_matrix[i,index]=0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune_states(state: PushState) -> PushState:\n if state and not state[-1]:\n return PushGame.prune_states(state[:-1])\n else:\n return state",
"def change_state(self):\n transitions = self.transition_map[self.current_state]\n self.current_state = select_from_... | [
"0.6404007",
"0.619103",
"0.6151447",
"0.61319476",
"0.60930943",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.6027078",
"0.60149777",
"0.598207",
"0.58333635",
"0.5816282",
"0.5785089",
... | 0.5308184 | 81 |
Integration test with a default neo4j instance. Should be executed by Travis after setting up neo4j in docker. | def test_init(self):
# Default values are neo4j defaults, EXCEPT the password.
address = os.environ.get('NEO4J_ADDRESS', 'bolt://localhost:7687')
user = os.environ.get('NEO4J_USERNAME', 'neo4j')
passw = os.environ.get('NEO4J_PASSWORD', 'neo42j')
ontpath = "scientio/examples/exam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_db_connection():\n\n from cwf2neo.neo4j import Neo4j\n\n db = Neo4j()\n\n assert db.graph.database.name",
"def init_neo4j_db():\n try:\n app.neo4j_driver = GraphDatabase.driver(\n app.config[\"NEO4J_URI\"],\n auth=(app.config[\"NEO4J_USER\"], app.config[\"NEO4J_P... | [
"0.6870226",
"0.6318031",
"0.60555273",
"0.59611243",
"0.5933263",
"0.59210235",
"0.58759856",
"0.583238",
"0.5797669",
"0.5789919",
"0.5756901",
"0.57314175",
"0.57208085",
"0.5701184",
"0.56891775",
"0.56769663",
"0.5672596",
"0.56328666",
"0.56218374",
"0.56114644",
"0.560... | 0.6991862 | 0 |
A bullet fired at asteroids by the player's ship | def __init__(self, position, direction):
super().__init__() # initialize sprite parent class
self.position = list(position) # make a copy of the given position
# load own images, each is slightly different for animation
self.images = [
pygame.image.load('images/bullets/0.png'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fire_bullet(ai_settings, screen, ship, bullets):\n new_bullet = Bullet(ai_settings, screen, ship)\n bullets.add(new_bullet)",
"def fire_bullet(si_settings, screen,ship,bullets):\n if len(bullets) < si_settings.bullets_allowed:\n new_bullet = Bullet(si_settings, screen, ship)\n bullets.... | [
"0.7970675",
"0.7635095",
"0.75735414",
"0.7546383",
"0.7519869",
"0.7512564",
"0.72985286",
"0.7175615",
"0.7158266",
"0.7126401",
"0.7082839",
"0.7053322",
"0.6837131",
"0.68251425",
"0.6814673",
"0.6807269",
"0.67777765",
"0.67516774",
"0.67516774",
"0.6721613",
"0.6702805... | 0.0 | -1 |
Initialize a bullet in the correct place and direction | def shoot(self):
if self.direction == 'left':
self.__temp_bullet = Bullet(self.position, 60)
elif self.direction == 'forward':
self.__temp_bullet = Bullet(self.position, 90)
else:
self.__temp_bullet = Bullet(self.position, 120)
global game
game... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, start_x, start_y, dest_x, dest_y):\n\n # Call the parent class (Sprite) constructor\n super().__init__()\n\n # Set up the image for the bullet\n self.image = pygame.Surface([4, 10])\n self.image.fill(BLACK)\n\n self.rect = self.image.get_rect()\n\n ... | [
"0.7660517",
"0.7281839",
"0.7259123",
"0.7196976",
"0.70620996",
"0.6956014",
"0.6912989",
"0.68725806",
"0.6837206",
"0.6831253",
"0.67853045",
"0.67775095",
"0.6743614",
"0.67379355",
"0.6696253",
"0.6695931",
"0.66193455",
"0.6586116",
"0.652206",
"0.6477041",
"0.6439046"... | 0.64504766 | 20 |
Returns the Todo collection from the database name | def collection(cls, db):
return db[cls._collection_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_collection(db, name):\n\n if db.hasCollection(name) is False:\n return db.createCollection(name=name)\n\n return db[name]",
"def get_collection(self, db_name, collection_name):\n return self._client[db_name][collection_name]",
"def _get_collection(self):\n db = self._get_db()... | [
"0.75178367",
"0.7019389",
"0.6961613",
"0.6945066",
"0.69228756",
"0.68842953",
"0.68054384",
"0.6777322",
"0.6762051",
"0.6751696",
"0.6725501",
"0.6637227",
"0.6562498",
"0.63872415",
"0.6258051",
"0.6248418",
"0.6171125",
"0.61325145",
"0.6119849",
"0.6117652",
"0.6077261... | 0.749158 | 1 |
Returns all Todos from database | def index(cls, db):
return (Todo(**doc) for doc in cls.collection(db).find()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todos(self):\r\n return Todos(self)",
"def get_all_todos():\n with sql.connect(\"todos.db\") as con:\n cursor = con.cursor()\n cursor.execute(\"SELECT * from todos\")\n todos = cursor.fetchall()\n cursor.close()\n\n return jsonify(todos), 200",
"def todos(self):\n ... | [
"0.72763526",
"0.69864017",
"0.6939543",
"0.68065625",
"0.6759967",
"0.65298516",
"0.63737416",
"0.6324294",
"0.6228168",
"0.6147736",
"0.61296636",
"0.6114062",
"0.6081039",
"0.59922886",
"0.59572005",
"0.5927529",
"0.5897877",
"0.58868027",
"0.5858164",
"0.5852649",
"0.5760... | 0.63684165 | 7 |
This is used to compare 2 objects | def __eq__(self, other):
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare(obj_a, obj_b):\n\n return tuple_to_string(obj_a) == tuple_to_string(obj_b)",
"def cmp ( self, object1, object2 ):\n return cmp( self.get_raw_value( object1 ),\n self.get_raw_value( object2 ) )",
"def test_compare() -> None:\n\n obj = SpecificLocation()\n obj2 ... | [
"0.768704",
"0.75287986",
"0.7502687",
"0.74012315",
"0.73266083",
"0.7315071",
"0.730467",
"0.72950774",
"0.72916",
"0.7233773",
"0.7187291",
"0.71354896",
"0.71354896",
"0.7133146",
"0.71203434",
"0.7096868",
"0.7096868",
"0.7077981",
"0.7014047",
"0.7014047",
"0.7014047",
... | 0.733177 | 33 |
Write image (numpy array) to filename | def iwrite(im, filename, **kwargs):
# TODO check valid input
ret = cv.imwrite(filename, im, **kwargs)
if ret is False:
print('Warning: image failed to write to filename')
print('Image =', im)
print('Filename =', filename)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imwrite(image, path):\n\n if image.ndim == 3 and image.shape[2] == 1: # for gray image\n image = np.array(image, copy=True)\n image.shape = image.shape[0:2]\n\n imgarray=((image+1.0)*127.5).astype(np.uint8)\n img=Image.fromarray(imgarray)\n img.save(path)",
"def save_image(image, f... | [
"0.77573204",
"0.7610638",
"0.7599373",
"0.7531891",
"0.75274044",
"0.72986335",
"0.7259946",
"0.7180678",
"0.71756893",
"0.71720535",
"0.71709555",
"0.71597785",
"0.7157825",
"0.7141185",
"0.7140283",
"0.7125746",
"0.71178085",
"0.7110519",
"0.70775425",
"0.7075237",
"0.7014... | 0.72239596 | 7 |
Symmetric key used to produce signed cookies. If deploying on multiple replicas, this should be set to the same value across all replicas to ensure they all share the same secret. | def _server_cookie_secret() -> str:
return secrets.token_hex() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_symmetric_key():\n return Fernet.generate_key()",
"def generate_sharedsecret(self):\n return self._get_shared_secret(self.public_key)",
"def secret_key(self):\n return self._secret_key",
"def shared_secret(self):\n return self.__shared_secret",
"def get_symetric_key():\... | [
"0.6843532",
"0.66070616",
"0.6488235",
"0.64860755",
"0.64590937",
"0.6387863",
"0.63022816",
"0.6287843",
"0.6275759",
"0.6197298",
"0.61395967",
"0.61033815",
"0.6074002",
"0.603065",
"0.6004424",
"0.59876615",
"0.59875613",
"0.59667724",
"0.5964372",
"0.5942358",
"0.59301... | 0.6436826 | 5 |
update the bullet(per frame) | def update(self, game):
self.moving = self.moving + game.deltaT
if self.moving <= self.attack_range * 1000.0:
#calculate our next x/y coords
self.x_real += -(self.x_movement * game.deltaT / 1000.0)
self.y_real += -(self.y_movement * game.deltaT / 1000.0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n\t\t#update decimal position of bullet\n\t\tself.y -= self.speed_factor\n\t\t\n\t\t#update rect position\n\t\tself.rect.y = self.y",
"def _update_bullet(self):\n\n # update position of old bullets\n self.bullets.update()\n\n # Get rid of bullets that are off screen\n ... | [
"0.785518",
"0.77965",
"0.7735301",
"0.7699103",
"0.7499398",
"0.7491995",
"0.74260056",
"0.73959744",
"0.73681337",
"0.73681337",
"0.7340684",
"0.72539043",
"0.7239085",
"0.71356463",
"0.7132375",
"0.7132375",
"0.7132375",
"0.7108712",
"0.71061456",
"0.71061456",
"0.7082746"... | 0.0 | -1 |
Return the score of the last game. | def latest(scores):
return scores[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_score(self):\n return np.max(self._scores) if self._scores is not None else self._score_history[-1]",
"def latest_score(self):\r\n if not self.child_history:\r\n return None\r\n return self.score_for_attempt(-1)",
"def latest_score(self):\r\n if not self.child_his... | [
"0.79713035",
"0.77741975",
"0.77566767",
"0.72432387",
"0.7235617",
"0.71855366",
"0.7176506",
"0.71573997",
"0.71300536",
"0.7090592",
"0.7090592",
"0.7090592",
"0.70904565",
"0.7077915",
"0.70046514",
"0.70046514",
"0.70046514",
"0.69844407",
"0.6983077",
"0.69551617",
"0.... | 0.6763456 | 38 |
Add new vocaburary of list of word | def add_vocab_words(self, words):
for word in words:
word = word.strip()
if word:
self.add_vocab_word(word) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vocab_word(self, word):\n # If it's a special token, it'll be separatelly processed during saving file. Skip here.\n if word in special_tokens:\n return\n # Check each character in the word. We don't want none-character (control code) in the vocaburary.\n for char in ... | [
"0.7100722",
"0.7011703",
"0.6828554",
"0.67654085",
"0.66928184",
"0.6681542",
"0.6639657",
"0.6639657",
"0.6560879",
"0.65191865",
"0.65015227",
"0.6491513",
"0.6454286",
"0.64350694",
"0.64322484",
"0.6412685",
"0.6384731",
"0.63524365",
"0.63103646",
"0.62997055",
"0.6273... | 0.75470304 | 0 |
Add new vocaburary of single word. If the word contains nonecharctor code it won't be added. | def add_vocab_word(self, word):
# If it's a special token, it'll be separatelly processed during saving file. Skip here.
if word in special_tokens:
return
# Check each character in the word. We don't want none-character (control code) in the vocaburary.
for char in word:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addWord(self, word):\n if word:\n self.word_dict[len(word)].append(word)",
"def add_word(self, word):\r\n word = word.strip().lower()\r\n if word in self.builtin_words:\r\n return\r\n if word not in self.word_count:\r\n self.word_count[word] = 1\r\... | [
"0.7187799",
"0.7125923",
"0.7117727",
"0.70981",
"0.70694226",
"0.70515966",
"0.70297855",
"0.7028809",
"0.69383836",
"0.68906635",
"0.6798285",
"0.67736614",
"0.67667323",
"0.67629194",
"0.67540944",
"0.6750989",
"0.6707737",
"0.6701871",
"0.6694156",
"0.66806084",
"0.66607... | 0.8439421 | 0 |
Pad given arrays to make a matrix. | def pad_sequence(xs, length=None, padding=0):
return PadSequence(length, padding).apply((xs))[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(self, matrices, pad_value):\n shapes = [m.shape for m in matrices]\n M, N = sum([s[0] for s in shapes]), sum([s[1] for s in shapes])\n zeros = torch.FloatTensor(np.zeros((M, N))).to(device)\n pad_matrices = pad_value + zeros\n i, j = 0, 0\n for k, matrix in enumera... | [
"0.74011046",
"0.69070196",
"0.6891135",
"0.63259584",
"0.6299927",
"0.62858576",
"0.6252854",
"0.6237991",
"0.61054367",
"0.6063243",
"0.60472333",
"0.6041576",
"0.6038859",
"0.6027965",
"0.5972429",
"0.59311354",
"0.5871436",
"0.58661133",
"0.5832211",
"0.58308405",
"0.5828... | 0.5375745 | 70 |
Transform a paper dictionary to its string representation, following the ArnetMiner V8 format. | def to_v8_format(paper):
output_string = ''
if 'title' in paper:
output_string += '#*' + paper['title'] + '\n'
if 'authors' in paper:
output_string += '#@' + ', '.join(paper['authors']) + '\n'
if 'year' in paper:
output_string += '#t' + str(paper['year']) + '\n'
if 'venue'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_2_string(d):\n buff = io.StringIO()\n print_dictionary(d, output=buff)\n return buff.getvalue()",
"def _dict_to_string(self, dictionary):\n st = ''\n for i in range(len(dictionary)):\n st = st + dictionary[i]\n return st",
"def _to_string(self) -> str:\n\n ... | [
"0.5836646",
"0.5793684",
"0.572276",
"0.5594937",
"0.55521554",
"0.55323184",
"0.5516697",
"0.5492731",
"0.5472213",
"0.54526013",
"0.54526013",
"0.54512227",
"0.54493475",
"0.54230607",
"0.54210913",
"0.53997415",
"0.5375539",
"0.5375539",
"0.5375539",
"0.5375539",
"0.53755... | 0.71196246 | 0 |
A class based view for home page. | def callview(request):
return render(request, "calls/dial_screen.html", {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n\n return render_template('home_page.html')",
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)",
"def home():\n return render_template(\n 'home.ht... | [
"0.7957105",
"0.79327995",
"0.79057616",
"0.7861989",
"0.78191036",
"0.77962",
"0.77875817",
"0.77696264",
"0.7765028",
"0.77555066",
"0.7748772",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",
"0.7746853",... | 0.0 | -1 |
Returns a Twilio Client token. Create a TwilioCapability object with our Twilio API credentials. | def get_token(request):
capability = TwilioCapability(
settings.TWILIO_ACCOUNT_SID,
settings.TWILIO_AUTH_TOKEN)
"""Allow our users to make outgoing calls with Twilio Client"""
capability.allow_client_outgoing(settings.TWIML_APPLICATION_SID)
"""Allow our users to accept incoming calls fr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_token(request):\n # Create a TwilioCapability token with our Twilio API credentials\n capability = ClientCapabilityToken(\n settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN\n )\n\n capability.allow_client_outgoing(settings.TWILIO_ACCOUNT_SID)\n capability.allow_client_incoming(... | [
"0.7517461",
"0.55318433",
"0.5446775",
"0.5343524",
"0.53153723",
"0.5191174",
"0.51755804",
"0.51548344",
"0.5122021",
"0.5122021",
"0.5090577",
"0.5080828",
"0.5076209",
"0.5074888",
"0.5074888",
"0.5055256",
"0.50080496",
"0.5006763",
"0.49628928",
"0.49568442",
"0.495156... | 0.7282685 | 1 |
Density parameter of ultrarelativistic species at a given redshift. | def Omega_ur_z(self, z):
t15_p4 = 15./np.pi**4.
F = self.FermiDirac_integral(0.)
GU = self.Gamma_nu_inst**4
ourz = t15_p4*GU*self.Omega_gamma*F*(1+z)**4*(self.H0/self.H(z))**2*self.massless_nu
return ourz | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDensity(h, R_w, R_sun): # k is a fitting constant\n\n R = np.sqrt(R_w**2+h**2)\n r = R/R_sun # units need to be in solar radii \n a = 77.1\n b = 31.4\n c = 0.954\n d = 8.30\n e = 0.550\n f = 4.63\n\n return (a*r**(-b) + c*r**(-d) + e*r**(-f))*10**8 #[cm-3]",
"def density(x, k... | [
"0.62256503",
"0.61620927",
"0.5873424",
"0.5868262",
"0.5865576",
"0.5852844",
"0.5823442",
"0.57586694",
"0.57586694",
"0.57177067",
"0.570516",
"0.5657935",
"0.563403",
"0.5631013",
"0.5631013",
"0.5631013",
"0.56187314",
"0.5606973",
"0.5598327",
"0.5598045",
"0.5580763",... | 0.0 | -1 |
Photon density parameter at a given redshift. | def Omega_gamma_z(self, z):
return self.Omega_gamma*(1.+z)**4.*(self.H0/self.H(z))**2. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcPointDensity(number_NN, radius):\n \n D = (number_NN+1.0)/((4.0/3)*np.pi*pow(radius, 3))\n \n return D",
"def gc_prob_density(r):\n return np.exp(_interp_ln_dens(r))",
"def density_by_ideal_gas_law(\n p: tf.Tensor,\n r: tf.Tensor,\n t: tf.Tensor,\n ) -> tf.Tensor:\n re... | [
"0.57514596",
"0.56553835",
"0.5647372",
"0.5645357",
"0.562136",
"0.56183624",
"0.56013864",
"0.55564827",
"0.5485939",
"0.5448282",
"0.5427796",
"0.5409707",
"0.54076976",
"0.5388588",
"0.53784984",
"0.536299",
"0.534592",
"0.53130656",
"0.53130656",
"0.53130656",
"0.530578... | 0.0 | -1 |
Radiation (photons and ultrarelativistic species) density parameter at a given redshift. | def Omega_rad_z(self, z):
return self.Omega_gamma_z(z)+self.Omega_ur_z(z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(R, Rs, rho0, gamma_inner, gamma_outer):\n x = R/Rs\n outer_slope = (gamma_outer-gamma_inner)/2\n return rho0 / (x**gamma_inner * (1 + x ** 2) ** outer_slope)",
"def getDensity(h, R_w, R_sun): # k is a fitting constant\n\n R = np.sqrt(R_w**2+h**2)\n r = R/R_sun # units nee... | [
"0.6126698",
"0.60065585",
"0.5798869",
"0.5796106",
"0.5755804",
"0.56965536",
"0.5674885",
"0.56346494",
"0.5633367",
"0.55818737",
"0.5579029",
"0.5572337",
"0.55625594",
"0.5537787",
"0.5496676",
"0.5479252",
"0.5475977",
"0.54667497",
"0.5458098",
"0.5457645",
"0.5457493... | 0.0 | -1 |
Dark energy density evolution as function of redshift. | def X_DE(self, z):
return (1.+z)**(3.*(1.+self.w0+self.wa))*np.exp(-3.*self.wa*(z/(1.+z))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_energy(atom,layer1,layer2):\n global r,c,h\n return float('%.2E' % Decimal(str(r*((atom**2/layer1**2)-(atom**2/layer2**2)))))",
"def alpha_evol( redshift, richness):\n\treturn function_eq10( redshift, richness, alpha_z[0], alpha_z[1], alpha_z[2] )",
"def _redfield_old(nstates, rho0, c_ops, h0, ... | [
"0.604257",
"0.60318714",
"0.60257363",
"0.60132575",
"0.60025567",
"0.6002432",
"0.5927095",
"0.5845874",
"0.58156395",
"0.5813257",
"0.577581",
"0.5761021",
"0.57592326",
"0.57536393",
"0.5708376",
"0.56448245",
"0.56020665",
"0.5592319",
"0.5573531",
"0.5559011",
"0.555248... | 0.0 | -1 |
Thermal velocity in km/s of each neutrino species at a given redshift. | def neutrino_thermal_velocity(self, z):
fac = 5./3.*5.*ss.zeta(5.)/ss.zeta(3.)
vel = np.zeros(self.N_nu)
vel = fac**.5*(const.kB*self.T_nu/self.M_nu)*(1.+z)*const.c
return vel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thermal_velocity(charge, temperature, mass):\n return np.sqrt(2*abs(charge)*temperature/mass)",
"def velocity(self,level='cell'):\r\n\r\n # 每个section中总是储存t+1时刻的volume,t到t+1的flow,即一个仿真步长(step)过程中的流量和仿真步长结束时的元胞中车辆数\r\n # 但计算速度需要用到仿真步长开始时的元胞密度,因此要对应时刻的元胞中车辆数vol_t = Vol_t+1 + outflow_t - inflo... | [
"0.63195765",
"0.6299258",
"0.61607003",
"0.60907865",
"0.60434467",
"0.5991612",
"0.59753996",
"0.5974196",
"0.5960642",
"0.5942102",
"0.5926313",
"0.5916545",
"0.5840134",
"0.58151364",
"0.5805877",
"0.57542396",
"0.57530046",
"0.5742614",
"0.5738102",
"0.57253337",
"0.5710... | 0.64933246 | 0 |
Mass variance in spheres as a function of mass. | def mass_variance(self, logM, k = [], pk = [], var = 'cb', window = 'th', **kwargs):
return self.mass_variance_multipoles(logM = logM, k = k, pk = pk, var = var, window = window, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mass(self):\n\t\treturn self.volume*self.density",
"def particleMass(self):\n return self.params['particleMass']",
"def variance(self):\n return 1 / self.count() * sum((number-self.average())**2 for number in self.numbers)",
"def _compute_mass(box_size, evo_config):\n\n # ensure format\n... | [
"0.7020908",
"0.6720049",
"0.6626578",
"0.65401584",
"0.6525435",
"0.6516823",
"0.63889617",
"0.6373961",
"0.6329182",
"0.6318994",
"0.63164437",
"0.6301457",
"0.6293322",
"0.627911",
"0.62584674",
"0.62497646",
"0.62430245",
"0.6211593",
"0.6201464",
"0.61729527",
"0.6162649... | 0.6821766 | 1 |
It returns the nowiggle linear power spectrum in the Eisenstein & Hu approximation. | def EisensteinHu_nowiggle_Pk(self,
z = 0.,
k = np.logspace(-4., 2., 1001),
sigma_8 = 0.83):
om_m = self.omega_cdm+self.omega_b
om_b = self.omega_b
ns = self.ns
h = self.h
theta = self.T_cmb/2.7
#if self.w0 != -1. or self.wa != 0.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculate_strehl(self):\n\n self.strehl = np.exp(-1*((2*np.pi/self.science_wavelength)*self.high_order_wfe)**2)",
"def _spectrum(self, energy):\n return self.pref*energy**2*self.occupation_number(energy/self.kT)",
"def powerSpectrum(input, nfft):\n result = fft(input, nfft)\n result = ... | [
"0.6442251",
"0.63549614",
"0.61639607",
"0.6117033",
"0.6110234",
"0.6087136",
"0.60539514",
"0.60324204",
"0.5990941",
"0.59798294",
"0.5951483",
"0.5948886",
"0.59340197",
"0.5920154",
"0.59193414",
"0.5890483",
"0.58862925",
"0.5877945",
"0.5871378",
"0.58371544",
"0.5816... | 0.0 | -1 |
Get path where trader is running in. | def _get_KR_settings_dir(temp_name: str):
cwd = Path.cwd()
temp_path = cwd.joinpath(temp_name)
# If .vntrader folder exists in current working directory,
# then use it as trader running path.
if temp_path.exists():
return cwd, temp_path
# Otherwise use home path of system.
home_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_path() -> str:\n return os.path.dirname(os.path.realpath(__file__))",
"def current_trades_path(self):\n trades_dir = Path(\"espn/trades\")\n if not trades_dir.exists() or not trades_dir.is_dir():\n LOGGER.info(\"directory for trades does not exist, creating it now\")\n ... | [
"0.74595207",
"0.71973884",
"0.7193988",
"0.71872944",
"0.69951946",
"0.6970462",
"0.6934165",
"0.6924591",
"0.69177747",
"0.69177747",
"0.6914863",
"0.6837173",
"0.68297523",
"0.680496",
"0.6730785",
"0.67026556",
"0.6699885",
"0.66974795",
"0.66706717",
"0.66706717",
"0.666... | 0.0 | -1 |
Save data into json file in temp path. | def save_json_settings(filename: str, data: dict):
filepath = TEMP_DIR.joinpath(filename)
with open(filepath, mode='w+') as f:
json.dump(data, f, indent=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write(self, filename, data):\n fullpath = os.path.join(self._tempdir, filename)\n with open(fullpath, 'w') as ofile:\n json.dump(data, ofile)\n return fullpath",
"def save_json():\r\n with open(os.path.join(cwd, 'data.json'), 'w') as f:\r\n json.dump(data, f)",
"d... | [
"0.7984496",
"0.78909826",
"0.7799274",
"0.77699864",
"0.7734938",
"0.7716659",
"0.7681191",
"0.75846934",
"0.7529496",
"0.7481133",
"0.7467559",
"0.7459418",
"0.74591017",
"0.73854935",
"0.7375848",
"0.7343941",
"0.73193693",
"0.72733265",
"0.7148962",
"0.71251637",
"0.71242... | 0.7334746 | 16 |
Predict a label for each example in x. Find the get the cluster assignment for each x, then use self.cluster_label_map to map to the corresponding digit. | def supervised_predict(self, x):
z_ik = self.get_posterior(x)
em_label = np.argmax(z_ik, axis=1)
y_hat = [self.cluster_label_map[idx] for idx in em_label]
return np.array(y_hat) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, x):\n pred_labels = np.zeros((x.shape[0], 10))\n\n N = len(self.NET)\n for i in range(N):\n\n inputs = self.apply_dct_permutation(x.copy(), self.permutation[i])\n pred_labels += self.NET[i].model.predict(inputs)\n\n return pred_labels",
"def _pr... | [
"0.75602126",
"0.74025404",
"0.7111853",
"0.70548564",
"0.7051129",
"0.7027832",
"0.7020951",
"0.69805986",
"0.69508827",
"0.68679196",
"0.6822792",
"0.67326117",
"0.6685441",
"0.66654724",
"0.6665243",
"0.66498363",
"0.6642688",
"0.66195977",
"0.6619266",
"0.66072106",
"0.66... | 0.7022593 | 6 |
Return the first_name plus the last_name, with a space in between. | def get_full_name(self):
full_name = '%s %s' % (self.first_name, self.last_name)
return full_name.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name(first_name, last_name):\n return first_name + \" \" + last_name",
"def full_name(first_name, last_name):\n\t\n\treturn first_name + \" \" + last_name",
"def get_formated_name(first_name,last_name):\n\tfull_name = first_name + '' + last_name\n\treturn full_name.title()",
"def get_full_name(se... | [
"0.8342851",
"0.82280374",
"0.81001484",
"0.8068425",
"0.80536336",
"0.80451626",
"0.7994962",
"0.79940844",
"0.79940844",
"0.79940844",
"0.7979702",
"0.7963534",
"0.7957951",
"0.79411453",
"0.79378146",
"0.79343975",
"0.7917004",
"0.7902344",
"0.78937757",
"0.7870946",
"0.78... | 0.78360254 | 25 |
Reply to a Tweet using either it's ID or it's link. | async def reply_tweet(reply: str,
in_reply_to: str = Query(None, alias="link of tweet", regex="https://twitter.com/([\w_]+)/status/([\d]+)"),
status_id: int = Query(None, alias="id of tweet"),
user: User = Depends(get_current_user),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reply_to_tweet():\n\n print('retrieving and replying to tweets...')\n all_mentions = api.mentions_timeline()\n\n # The content of the reply that the bot will send.\n rap_message = ' yo yo yo yo'\n\n for mention in reversed(all_mentions):\n\n # print(str(mention.id) + '-' + mention.text)\n... | [
"0.67275465",
"0.6495334",
"0.6470644",
"0.62004757",
"0.61928546",
"0.61790854",
"0.6174662",
"0.61714834",
"0.6132037",
"0.612587",
"0.6120367",
"0.6113957",
"0.5969409",
"0.5957614",
"0.59038496",
"0.5896435",
"0.5894628",
"0.58797956",
"0.5860841",
"0.5847755",
"0.5806339... | 0.70360327 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.